Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement on UI #21

Merged
merged 5 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ gem "rails", "~> 7.1.3", ">= 7.1.3.2"

gem "bootsnap", require: false
gem "devise"
gem "devise-i18n"
gem "image_processing"
gem "importmap-rails"
gem "jbuilder"
gem "kaminari"
gem "packwerk"
gem "pg"
gem "puma"
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-i18n (1.12.0)
devise (>= 4.9.0)
drb (2.2.1)
erubi (1.12.0)
ffi (1.16.3)
Expand All @@ -143,6 +145,18 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.1)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
kaminari-activerecord (= 1.2.2)
kaminari-core (= 1.2.2)
kaminari-actionview (1.2.2)
actionview
kaminari-core (= 1.2.2)
kaminari-activerecord (1.2.2)
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -320,10 +334,12 @@ DEPENDENCIES
capybara
debug
devise
devise-i18n
foreman
image_processing
importmap-rails
jbuilder
kaminari
packwerk
pg
puma
Expand Down
Binary file added app/assets/images/hoy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions app/packages/accounts/views/accounts/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<h2 class="text-2xl mb-5">Forgot your password?</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }, html: { class: "max-w-sm mx-auto" }) do |f| %>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }, html: { class: "max-w-sm mx-auto mt-20" }) do |f| %>
<%= render "accounts/shared/error_messages", resource: resource %>

<div class="mb-5">
Expand All @@ -9,7 +7,7 @@
</div>

<div class="actions">
<%= f.submit "Send me reset password instructions", class: submit_classes %>
<%= f.submit I18n.t("devise.password.send_me_instructions"), class: submit_classes %>
</div>

<%= render "accounts/shared/links" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "max-w-sm mx-auto" }) do |f| %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "max-w-sm mx-auto mt-20" }) do |f| %>
<%= render "accounts/shared/error_messages", resource: resource %>

<div class="mb-5">
Expand All @@ -7,17 +7,17 @@
</div>

<div class="mb-5">
<%= f.label :password, class: label_classes %>
<%= f.label :password, I18n.t("devise.registrations.password"), class: label_classes %>
<%= f.password_field :password, autocomplete: "new-password", class: input_classes %>
</div>

<div class="mb-5">
<%= f.label :password_confirmation, class: label_classes %>
<%= f.label :password_confirmation, I18n.t("devise.registrations.password_confirmation"), class: label_classes %>
<%= f.password_field :password_confirmation, autocomplete: "new-password", class: input_classes %>
</div>

<div class="actions">
<%= f.submit "Sign up", class: submit_classes %>
<%= f.submit I18n.t("devise.registrations.signup"), class: submit_classes %>
</div>

<%= render "accounts/shared/links" %>
Expand Down
10 changes: 4 additions & 6 deletions app/packages/accounts/views/accounts/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "max-w-sm mx-auto" }) do |f| %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "max-w-sm mx-auto mt-20" }) do |f| %>
<div class="mb-5">
<%= f.label :email, class: label_classes %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: input_classes %>
</div>

<div class="mb-5">
<%= f.label :password, class: label_classes %>
<%= f.label :password, I18n.t("devise.sessions.password"), class: label_classes %>
<%= f.password_field :password, autocomplete: "current-password", class: input_classes %>
</div>

Expand All @@ -15,14 +15,12 @@
<%= f.check_box :remember_me, class: "w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3
focus:ring-blue-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-600
dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800" %>
<%= f.label :remember_me, class: "ms-2 text-sm font-medium text-gray-900 dark:text-gray-300" %>
<%= f.label :remember_me, I18n.t("devise.sessions.remember_me"), class: "ms-2 text-sm font-medium text-gray-900 dark:text-gray-300" %>
</div>
</div>
<% end %>

<div class="actions">
<%= f.submit "Log in", class: submit_classes %>
</div>
<%= f.submit I18n.t("devise.sessions.login"), class: submit_classes %>

<%= render "accounts/shared/links" %>
<% end %>
Expand Down
10 changes: 5 additions & 5 deletions app/packages/accounts/views/accounts/shared/_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

<p class="mt-5 text-sm text-gray-500 dark:text-gray-400">
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<%= link_to I18n.t("devise.shared.login"), new_session_path(resource_name) %><br />
<% end %>

<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<%= link_to I18n.t("devise.shared.signup"), new_registration_path(resource_name) %><br />
<% end %>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<%= link_to I18n.t("devise.shared.forgot_password?"), new_password_path(resource_name) %><br />
<% end %>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<%= link_to I18n.t("devise.shared.did_not_receive_confirmation?"), new_confirmation_path(resource_name) %><br />
<% end %>

<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<%= link_to I18n.t("devise.shared.did_not_receive_unlock_instrutions?"), new_unlock_path(resource_name) %><br />
<% end %>

<%- if devise_mapping.omniauthable? %>
Expand Down
28 changes: 28 additions & 0 deletions app/packages/planning/controllers/pictos_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

class PictosController < ApplicationController
before_action :authenticate_account!

def index
@pictos = Picto::FindAll
.call(
keyword: params[:q],
enabled: !params[:only_disabled].present?,
page: params[:page]
).value!
end

def enable
Picto::Enable
.call(picto_id: params[:id])

redirect_to pictos_path(q: params[:q], only_disabled: params[:only_disabled])
end

def disable
Picto::Disable
.call(picto_id: params[:id])

redirect_to pictos_path(q: params[:q], only_disabled: params[:only_disabled])
end
end
95 changes: 95 additions & 0 deletions app/packages/planning/controllers/plans/events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# frozen_string_literal: true

module Plans
class EventsController < ApplicationController
before_action :authenticate_account!
before_action :load_plan
before_action :load_event, only: %w(edit update destroy)

def index
@events = Event::FindAll
.call(plan_id: @plan.id)
.value!
end

def new
@event_form = Event::Create::Form.new
end

def create
response = Event::Create.call(
**input_data_for_create
)

if response.success?
flash[:notice] = "Nuevo evento creado!"
redirect_to plan_events_path(@plan.id)
else
flash.now[:alert] = "Algo ha ido mal!"
@event = response.value.data
render :new
end
end

def edit
@event_form = Event::Update::Form.new(
@event.attributes
.slice(:plan_id, :picto_id, :title, :day_of_the_week)
.merge(event_id: params[:id])
)
end

def update
response = Event::Update.call(
**input_data_for_update
)

if response.success?
flash[:notice] = "Evento editado!"
redirect_to plan_events_path(response.value.id)
else
flash.now[:alert] = "Algo ha ido mal!"
@event_form = response.value.data
render :edit
end
end

def destroy
Event::Remove.call(
plan_id: @plan.id,
event_id: params[:id]
)

redirect_to plan_events_path(@plan.id)
end

private

def load_event
@event = Event::Find.call(
plan_id: @plan.id,
event_id: params[:id]
).value!
end

def input_data_for_create
params
.require(:event_create_form)
.permit(:picto_id, :title, :day_of_the_week)
.merge(plan_id: @plan.id)
end

def input_data_for_update
params
.require(:event_update_form)
.permit(:picto_id, :title, :day_of_the_week)
.merge(plan_id: @plan.id, event_id: params[:id])
end

def load_plan
@plan = Plan::Find
.call(account_id: current_account.id, plan_id: params[:plan_id])
.value!
end
end
end
98 changes: 98 additions & 0 deletions app/packages/planning/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,105 @@

class PlansController < ApplicationController
before_action :authenticate_account!
before_action :load_plan, only: %w(edit update destroy)

def index
@plans = Plan::FindAll
.call(account_id: current_account.id)
.value!
end

def new
@plan_form = Plan::Create::Form.new
end

def create
response = Plan::Create.call(
**input_data_for_create
)

if response.success?
flash[:notice] = "Nueva planificación creada!"
redirect_to plan_events_path(response.value.id)
else
flash.now[:alert] = "Algo ha ido mal!"
@plan_form = response.value.data
render :new
end
end

def edit
@plan_form = Plan::Update::Form.new(
@plan.attributes
.slice(:account_id, :name)
.merge(plan_id: params[:id])
)
end

def update
response = Plan::Update.call(
**input_data_for_update
)

if response.success?
flash[:notice] = "Planificación editada!"
redirect_to plan_events_path(response.value.id)
else
flash.now[:alert] = "Algo ha ido mal!"
@plan = response.value.data
render :edit
end
end

def activate
response = Plan::Activate.call(
account_id: current_account.id, plan_id: params[:id]
)

if response.success?
flash[:notice] = "Nueva planificación creada!"
else
flash[:alert] = "Algo ha ido mal!"
end

redirect_to plans_path
end

def current
@plan = Plan::FindCurrent.call(
account_id: current_account.id
).value
end

def destroy
Plan::Remove.call(
account_id: current_account.id,
plan_id: @plan.id
)

redirect_to plans_path
end

private

def load_plan
@plan = Plan::Find.call(
account_id: current_account.id,
plan_id: params[:id]
).value!
end

def input_data_for_create
params
.require(:plan_create_form)
.permit(:name)
.merge(account_id: current_account.id)
end

def input_data_for_update
params
.require(:plan_update_form)
.permit(:name)
.merge(account_id: current_account.id, plan_id: params[:id])
end
end
Loading