diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index a28e8ef..ee71268 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -282,8 +282,36 @@ def generate_welcome_page def setup_namespaces generate 'devise Admin name:string surname:string' + + copy_file 'app/controllers/hq/application_controller.rb', 'app/controllers/hq/application_controller.rb' + + copy_file 'app/controllers/hq/dashboard_controller.rb', 'app/controllers/hq/dashboard_controller.rb' template 'app/views/hq/dashboard/index.html.haml.erb', 'app/views/hq/dashboard/index.html.haml', force: true + + copy_file 'app/controllers/hq/passwords_controller.rb', 'app/controllers/hq/passwords_controller.rb' + directory 'app/views/hq/passwords', 'app/views/hq/passwords' + + copy_file 'app/controllers/hq/registrations_controller.rb', 'app/controllers/hq/registrations_controller.rb' + directory 'app/views/hq/registrations', 'app/views/hq/registrations' + + copy_file 'app/controllers/hq/sessions_controller.rb', 'app/controllers/hq/sessions_controller.rb' directory 'app/views/hq/sessions', 'app/views/hq/sessions' + + # User + copy_file 'app/controllers/user/user_application_controller.rb', 'app/controllers/user/user_application_controller.rb' + + copy_file 'app/controllers/user/dashboard_controller.rb', 'app/controllers/user/dashboard_controller.rb' + directory 'app/views/user/dashboard', 'app/views/user/dashboard' + + copy_file 'app/controllers/user/passwords_controller.rb', 'app/controllers/user/passwords_controller.rb' + directory 'app/views/user/passwords', 'app/views/user/passwords' + + copy_file 'app/controllers/user/registrations_controller.rb', 'app/controllers/user/registrations_controller.rb' + directory 'app/views/user/registrations', 'app/views/user/registrations' + + copy_file 'app/controllers/user/sessions_controller.rb', 'app/controllers/user/sessions_controller.rb' + directory 'app/views/user/sessions', 'app/views/user/sessions' + end def set_time_zone diff --git a/templates/app/controllers/hq/passwords_controller.rb b/templates/app/controllers/hq/passwords_controller.rb new file mode 100644 index 0000000..f7b93ed --- /dev/null +++ b/templates/app/controllers/hq/passwords_controller.rb @@ -0,0 +1,10 @@ +class Hq::PasswordsController < Devise::PasswordsController + layout 'hq/login' + + private + + def after_resetting_password_path_for(resource) + hq_root_path + end + +end diff --git a/templates/app/controllers/hq/registrations_controller.rb b/templates/app/controllers/hq/registrations_controller.rb new file mode 100644 index 0000000..c758377 --- /dev/null +++ b/templates/app/controllers/hq/registrations_controller.rb @@ -0,0 +1,20 @@ +class Hq::RegistrationsController < Devise::RegistrationsController + layout 'hq/application' + before_action :authenticate_admin! + before_action :redirect_admin, only: [:new, :create, :destroy] + add_breadcrumb I18n.t('activerecord.models.admin'), :hq_root_path + + def edit + end + + private + + def redirect_admin + redirect_to hq_root_path + end + + def after_update_path_for(resource) + hq_root_path + end + +end \ No newline at end of file diff --git a/templates/app/controllers/user/dashboard_controller.rb b/templates/app/controllers/user/dashboard_controller.rb new file mode 100644 index 0000000..1b7c7c7 --- /dev/null +++ b/templates/app/controllers/user/dashboard_controller.rb @@ -0,0 +1,8 @@ +class User::DashboardController < User::UserApplicationController + + add_breadcrumb I18n.t('dock.dashboard'), :user_dashboard_index_path + + def index + end + +end \ No newline at end of file diff --git a/templates/app/controllers/user/passwords_controller.rb b/templates/app/controllers/user/passwords_controller.rb new file mode 100644 index 0000000..941b624 --- /dev/null +++ b/templates/app/controllers/user/passwords_controller.rb @@ -0,0 +1,10 @@ +class User::PasswordsController < Devise::PasswordsController + layout 'user/login' + + private + + def after_resetting_password_path_for(resource) + user_root_path + end + +end diff --git a/templates/app/controllers/user/profiles_controller.rb b/templates/app/controllers/user/profiles_controller.rb new file mode 100644 index 0000000..6bc007e --- /dev/null +++ b/templates/app/controllers/user/profiles_controller.rb @@ -0,0 +1,34 @@ +class User::ProfilesController < User::UserApplicationController + + before_action :set_profile, only: [:show, :edit, :update] + add_breadcrumb I18n.t('dock.profile'), :user_profile_path + + def show + add_breadcrumb @profile.full_name, user_profile_path + respond_with([:user, @profile]) + end + + def edit + add_breadcrumb t('tooltips.edit'), edit_user_profile_path + end + + def update + @profile.update(profile_params) + respond_with([:user, @profile], location: user_profile_path) + end + + private + + def set_profile + @profile = current_user + end + + def profile_params + params.require(:user) + .permit( + :name, + :surname, + :timezone + ) + end +end diff --git a/templates/app/controllers/user/registrations_controller.rb b/templates/app/controllers/user/registrations_controller.rb new file mode 100644 index 0000000..1f5dcdc --- /dev/null +++ b/templates/app/controllers/user/registrations_controller.rb @@ -0,0 +1,20 @@ +class User::RegistrationsController < Devise::RegistrationsController + layout 'user/application' + before_action :authenticate_user! + before_action :redirect_user, only: [:new, :create, :destroy] + add_breadcrumb I18n.t('activerecord.models.user'), :user_root_path + + def edit + end + + private + + def redirect_user + redirect_to user_root_path + end + + def after_update_path_for(resource) + user_root_path + end + +end \ No newline at end of file diff --git a/templates/app/controllers/user/sessions_controller.rb b/templates/app/controllers/user/sessions_controller.rb new file mode 100644 index 0000000..c046315 --- /dev/null +++ b/templates/app/controllers/user/sessions_controller.rb @@ -0,0 +1,16 @@ +class User::SessionsController < Devise::SessionsController + layout 'user/login' + + private + + # Overwriting the sign_out redirect path method + def after_sign_in_path_for(resource_or_scope) + user_root_path + end + + # Overwriting the sign_out redirect path method + def after_sign_out_path_for(resource_or_scope) + new_user_session_path + end + +end \ No newline at end of file diff --git a/templates/app/controllers/user/user_application_controller.rb b/templates/app/controllers/user/user_application_controller.rb new file mode 100644 index 0000000..9134f6e --- /dev/null +++ b/templates/app/controllers/user/user_application_controller.rb @@ -0,0 +1,8 @@ +require 'application_responder' + +class User::UserApplicationController < ActionController::Base + layout 'user/application' + before_action :authenticate_user! + self.responder = ApplicationResponder + respond_to :html, :json +end \ No newline at end of file diff --git a/templates/app/views/devise/confirmations/new.html.haml b/templates/app/views/devise/confirmations/new.html.haml index af24614..75479be 100644 --- a/templates/app/views/devise/confirmations/new.html.haml +++ b/templates/app/views/devise/confirmations/new.html.haml @@ -1,9 +1,10 @@ -%h2 Resend confirmation instructions -= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| +%h2 + = t('devise.confirmation.new.title') += simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| = f.error_notification = f.full_error :confirmation_token .form-inputs - = f.input :email, :required => true, :autofocus => true + = f.input :email, required: true, autofocus: true .form-actions - = f.button :submit, "Resend confirmation instructions" -= render "devise/shared/links" + = f.button :submit, t('devise.confirmation.btn.resend'), class: 'btn btn-primary' += render 'devise/shared/links' diff --git a/templates/app/views/devise/mailer/confirmation_instructions.html.haml b/templates/app/views/devise/mailer/confirmation_instructions.html.haml index eeab62b..5d77634 100644 --- a/templates/app/views/devise/mailer/confirmation_instructions.html.haml +++ b/templates/app/views/devise/mailer/confirmation_instructions.html.haml @@ -1,4 +1,6 @@ %p - Welcome #{@email}! -%p You can confirm your account email through the link below: -%p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) + = t( 'email.salut', user: @resource.email ) +%p + = "#{t( 'email.devise.confirmation_instruction.desc1')} :" +%p + = link_to t( 'email.devise.confirmation_instruction.btn_confirm'), confirmation_url(@resource, confirmation_token: @token) diff --git a/templates/app/views/devise/mailer/reset_password_instructions.html.haml b/templates/app/views/devise/mailer/reset_password_instructions.html.haml index 5d73427..e35ac0d 100644 --- a/templates/app/views/devise/mailer/reset_password_instructions.html.haml +++ b/templates/app/views/devise/mailer/reset_password_instructions.html.haml @@ -1,8 +1,8 @@ %p - = t( 'email.salut', email: @resource.email ) + = t( 'email.salut', user: @resource.email ) %p = t( 'email.devise.reset_password.desc1') -%p= link_to t( 'email.devise.reset_password.change'), edit_password_url(@resource, :reset_password_token => @token) +%p= link_to t( 'email.devise.reset_password.change'), edit_password_url(@resource, reset_password_token: @token) %p = t( 'email.devise.reset_password.desc2') %p diff --git a/templates/app/views/devise/passwords/edit.html.haml b/templates/app/views/devise/passwords/edit.html.haml index 8d7efa5..326e2e6 100644 --- a/templates/app/views/devise/passwords/edit.html.haml +++ b/templates/app/views/devise/passwords/edit.html.haml @@ -1,11 +1,11 @@ %h2= t('devise.password.edit.title') -= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| = f.error_notification - = f.input :reset_password_token, :as => :hidden + = f.input :reset_password_token, as: :hidden = f.full_error :reset_password_token .form-inputs = f.input :password, label: t('devise.password.edit.new_password'), required: true, autofocus: true = f.input :password_confirmation, label: t('devise.password.edit.confirmation'), required: true .form-actions = f.button :submit, t('devise.password.edit.button'), class: 'btn btn-primary' -= render "devise/shared/links" \ No newline at end of file += render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/devise/passwords/new.html.haml b/templates/app/views/devise/passwords/new.html.haml index a15a411..a6b3fe9 100644 --- a/templates/app/views/devise/passwords/new.html.haml +++ b/templates/app/views/devise/passwords/new.html.haml @@ -1,9 +1,9 @@ %h2= t('devise.password.reset.title') -= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| = f.error_notification .form-inputs - = f.input :email, :required => true, :autofocus => true + = f.input :email, required: true, autofocus: true .form-actions = f.button :submit, t('devise.password.reset.instructions'), class: 'btn btn-primary' %br -= render "devise/shared/links" \ No newline at end of file += render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/devise/registrations/edit.html.haml b/templates/app/views/devise/registrations/edit.html.haml index 0512a14..409014e 100644 --- a/templates/app/views/devise/registrations/edit.html.haml +++ b/templates/app/views/devise/registrations/edit.html.haml @@ -1,18 +1,12 @@ %h2 = t('devise.registration.title', model: resource.class.model_name.human ) -= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| += simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| = f.error_notification .form-inputs - = f.input :email, :required => true, :autofocus => true - - if devise_mapping.confirmable? && resource.pending_reconfirmation? - %p - Currently waiting confirmation for: #{resource.unconfirmed_email} - = f.input :password, :autocomplete => "off", hint: t('devise.registration.hint_password'), :required => false - = f.input :password_confirmation, :required => false - = f.input :current_password, hint: t('devise.registration.hint_current_password'), :required => true + = f.input :email, required: true, autofocus: true + = f.input :password, autocomplete: 'off', hint: t('devise.registration.hint_password'), required: false + = f.input :password_confirmation, required: false + = f.input :current_password, hint: t('devise.registration.hint_current_password'), required: true .form-actions = f.button :submit, t('btn.update'), class: 'btn btn-primary' -%h3 Cancel my account -%p - Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete} = link_to t('btn.back'), :back diff --git a/templates/app/views/devise/registrations/new.html.haml b/templates/app/views/devise/registrations/new.html.haml index 29504fe..89ef05e 100644 --- a/templates/app/views/devise/registrations/new.html.haml +++ b/templates/app/views/devise/registrations/new.html.haml @@ -1,12 +1,24 @@ %h2 = t('devise.registration.new.title', model: resource.class.model_name.human) -= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| +%hr/ +- if devise_mapping.omniauthable? + - resource_class.omniauth_providers.each do |provider| + = link_to omniauth_authorize_path(resource_name, provider), class: 'btn btn-lg btn-primary btn-block' do + %i.fa.fa-facebook + = t('devise.shared.links.signup_with', name: provider.to_s.titleize) + %hr/ + %h3.text-center + = t('view.or') + %hr/ += simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = f.error_notification .form-inputs - = f.input :name, :autofocus => true - = f.input :email, :required => true - = f.input :password, :required => true - = f.input :password_confirmation, :required => true + = f.input :email, required: true + = f.input :password, required: true + = f.input :password_confirmation, required: true + = f.input :name, required: true + = f.input :surname, required: true + = f.input :time_zone, input_html: { class: 'chosen-select'}, include_blank: t('view.select'), required: true .form-actions = f.button :submit, t('devise.registration.new.button'), class: 'btn btn-primary' -= render "devise/shared/links" += render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/devise/sessions/new.html.haml b/templates/app/views/devise/sessions/new.html.haml index 6b0e838..ce058de 100644 --- a/templates/app/views/devise/sessions/new.html.haml +++ b/templates/app/views/devise/sessions/new.html.haml @@ -7,4 +7,4 @@ = f.input :remember_me, label: t('devise.session.remember_me'), as: :boolean if devise_mapping.rememberable? .form-actions = f.button :submit, t('devise.session.button'), class: 'btn btn-primary' -= render "devise/shared/links" += render 'devise/shared/links' diff --git a/templates/app/views/devise/shared/_links.haml b/templates/app/views/devise/shared/_links.haml index d73f22b..c2aca8f 100644 --- a/templates/app/views/devise/shared/_links.haml +++ b/templates/app/views/devise/shared/_links.haml @@ -17,4 +17,6 @@ - if devise_mapping.omniauthable? - resource_class.omniauth_providers.each do |provider| = link_to t('devise.shared.links.signin_with', name: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) - %br/ \ No newline at end of file + %br/ += link_to t('navbar.home_page'), root_path +%br/ \ No newline at end of file diff --git a/templates/app/views/devise/unlocks/new.html.haml b/templates/app/views/devise/unlocks/new.html.haml index 98304e5..c4dd03f 100644 --- a/templates/app/views/devise/unlocks/new.html.haml +++ b/templates/app/views/devise/unlocks/new.html.haml @@ -1,9 +1,9 @@ %h2 Resend unlock instructions -= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| += simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| = f.error_notification = f.full_error :unlock_token .form-inputs - = f.input :email, :required => true, :autofocus => true + = f.input :email, required: true, autofocus: true .form-actions - = f.button :submit, "Resend unlock instructions" -= render "devise/shared/links" + = f.button :submit, 'Resend unlock instructions' += render 'devise/shared/links' diff --git a/templates/app/views/hq/admin_profiles/_form.html.haml b/templates/app/views/hq/admin_profiles/_form.html.haml deleted file mode 100644 index abbdfee..0000000 --- a/templates/app/views/hq/admin_profiles/_form.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -.panel.panel-default - .panel-heading - %i.icon-edit.icon-large - = yield :form_title - .panel-body - = simple_form_for([:hq, @admin_profile], url: hq_admin_profile_path) do |f| - = f.error_notification - - .form-inputs - = f.input :first_name - = f.input :last_name - = f.input :gsm - .form-actions - = f.button :submit, class: 'btn btn-default' - = link_to t('cancel'), hq_admin_profile_path, class: 'btn' diff --git a/templates/app/views/hq/admin_profiles/edit.html.haml b/templates/app/views/hq/admin_profiles/edit.html.haml deleted file mode 100644 index ef2c74c..0000000 --- a/templates/app/views/hq/admin_profiles/edit.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :form_title do - = t('tt.edit', resource_name: AdminProfile.model_name.human) -= render 'form' \ No newline at end of file diff --git a/templates/app/views/hq/admin_profiles/new.html.haml b/templates/app/views/hq/admin_profiles/new.html.haml deleted file mode 100644 index d4f791c..0000000 --- a/templates/app/views/hq/admin_profiles/new.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :form_title do - = t('tt.new', resource_name: AdminProfile.model_name.human) -= render 'form' \ No newline at end of file diff --git a/templates/app/views/hq/admin_profiles/show.html.haml b/templates/app/views/hq/admin_profiles/show.html.haml deleted file mode 100644 index a1f7477..0000000 --- a/templates/app/views/hq/admin_profiles/show.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- content_for :toolbar do - = link_to edit_hq_admin_profile_path, class: 'btn btn-default' do - %i.icon-pencil - = t('action_button.edit') -.panel.panel-default - .panel-heading - %i.icon-edit.icon-large - = t('tt.show', resource_name: AdminProfile.model_name.human) - .panel-body - = show_for @admin_profile do |s| - = s.attribute :first_name - = s.attribute :last_name - = s.attribute :gsm diff --git a/templates/app/views/hq/passwords/edit.html.haml b/templates/app/views/hq/passwords/edit.html.haml new file mode 100644 index 0000000..315d5d7 --- /dev/null +++ b/templates/app/views/hq/passwords/edit.html.haml @@ -0,0 +1,12 @@ +%h2= t('devise.password.edit.title') += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| + = f.error_notification + = f.input :reset_password_token, as: :hidden + = f.full_error :reset_password_token + .form-inputs + = f.input :password, required: true, autofocus: true + = f.input :password_confirmation, required: true + .form-actions + = f.button :submit, t('devise.password.edit.button') , class: 'btn btn-primary' + %hr + = render 'devise/shared/links' diff --git a/templates/app/views/hq/passwords/new.html.haml b/templates/app/views/hq/passwords/new.html.haml new file mode 100644 index 0000000..eb890d7 --- /dev/null +++ b/templates/app/views/hq/passwords/new.html.haml @@ -0,0 +1,10 @@ +%h2= t('devise.password.new.title') += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| + = f.error_notification + .form-inputs + = f.input :email, required: true, autofocus: true + .form-actions + = f.button :submit, t('devise.password.reset.instructions'), class: 'btn btn-primary' + + %hr + = render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/hq/registrations/edit.html.haml b/templates/app/views/hq/registrations/edit.html.haml new file mode 100644 index 0000000..0129a8a --- /dev/null +++ b/templates/app/views/hq/registrations/edit.html.haml @@ -0,0 +1,19 @@ +.panel.panel-default + .panel-heading + %i.icon-edit.icon-large + = t('devise.registration.edit.title', model: resource.class.model_name.human) + .panel-body + = simple_form_for(resource, as: resource_name, url: admin_registration_path, html: { method: :put }) do |f| + = f.error_notification + .form-inputs + = f.input :email, required: true, autofocus: true + - if devise_mapping.confirmable? && resource.pending_reconfirmation? + %p + = t('devise.registration.waiting_confirmation', email: resource.unconfirmed_email ) + %hr + = f.input :password, label: t('activerecord.attributes.admin.password'), autocomplete: 'off', hint: t('devise.registration.hint_password'), required: false + = f.input :password_confirmation, label: t('activerecord.attributes.admin.password_confirmation'), required: false + %hr + = f.input :current_password, label: t('activerecord.attributes.admin.current_password'), hint: t('devise.registration.hint_current_password'), required: true + .form-actions + = f.button :submit, t('btn.update'), class: 'btn btn-primary' \ No newline at end of file diff --git a/templates/app/views/hq/sessions/new.html.haml b/templates/app/views/hq/sessions/new.html.haml index 1f1df71..3a22254 100644 --- a/templates/app/views/hq/sessions/new.html.haml +++ b/templates/app/views/hq/sessions/new.html.haml @@ -1,9 +1,9 @@ %h2 = t('devise.session.title', model: resource.class.model_name.human ) -= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| += simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| .form-inputs - = f.input :email, :required => false, :autofocus => true - = f.input :password, :required => false - = f.input :remember_me, :as => :boolean,label: t('devise.session.remember_me') if devise_mapping.rememberable? + = f.input :email, required: false, autofocus: true + = f.input :password, required: false + = f.input :remember_me, as: :boolean,label: t('devise.session.remember_me') if devise_mapping.rememberable? .form-actions = f.button :submit, t('devise.session.button') \ No newline at end of file diff --git a/templates/app/views/user/dashboard/index.html.haml b/templates/app/views/user/dashboard/index.html.haml new file mode 100644 index 0000000..263c4e8 --- /dev/null +++ b/templates/app/views/user/dashboard/index.html.haml @@ -0,0 +1,8 @@ +.panel.panel-default + .panel-body + .row + .col-lg-12 + .alert.alert-info + = t('view.hello', email: current_user.email) + = link_to t('navbar.sign_out'), destroy_user_session_path, method: :delete, class: 'btn btn-danger' + = link_to t('navbar.edit_login_info'), edit_user_registration_path, class: 'btn btn-primary' \ No newline at end of file diff --git a/templates/app/views/user/passwords/edit.html.haml b/templates/app/views/user/passwords/edit.html.haml new file mode 100644 index 0000000..315d5d7 --- /dev/null +++ b/templates/app/views/user/passwords/edit.html.haml @@ -0,0 +1,12 @@ +%h2= t('devise.password.edit.title') += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| + = f.error_notification + = f.input :reset_password_token, as: :hidden + = f.full_error :reset_password_token + .form-inputs + = f.input :password, required: true, autofocus: true + = f.input :password_confirmation, required: true + .form-actions + = f.button :submit, t('devise.password.edit.button') , class: 'btn btn-primary' + %hr + = render 'devise/shared/links' diff --git a/templates/app/views/user/passwords/new.html.haml b/templates/app/views/user/passwords/new.html.haml new file mode 100644 index 0000000..eb890d7 --- /dev/null +++ b/templates/app/views/user/passwords/new.html.haml @@ -0,0 +1,10 @@ +%h2= t('devise.password.new.title') += simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| + = f.error_notification + .form-inputs + = f.input :email, required: true, autofocus: true + .form-actions + = f.button :submit, t('devise.password.reset.instructions'), class: 'btn btn-primary' + + %hr + = render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/user_profiles/_form.html.haml b/templates/app/views/user/profiles/_form.html.haml similarity index 53% rename from templates/app/views/user_profiles/_form.html.haml rename to templates/app/views/user/profiles/_form.html.haml index 17b9e50..4d7d6d0 100644 --- a/templates/app/views/user_profiles/_form.html.haml +++ b/templates/app/views/user/profiles/_form.html.haml @@ -3,14 +3,13 @@ %i.icon-edit.icon-large = yield :form_title .panel-body - = simple_form_for(@user_profile, url: user_profile_path) do |f| + = simple_form_for([:user, @profile], url: user_profile_path) do |f| = f.error_notification .form-inputs - = f.input :first_name - = f.input :last_name - = f.input :gsm + = f.input :name + = f.input :surname .form-actions - = f.button :submit, class: 'btn btn-default' + = f.button :submit, class: 'btn btn-primary' = link_to t('cancel'), user_profile_path, class: 'btn' diff --git a/templates/app/views/user/profiles/edit.html.haml b/templates/app/views/user/profiles/edit.html.haml new file mode 100644 index 0000000..01435bd --- /dev/null +++ b/templates/app/views/user/profiles/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :form_title do + = t('tt.edit', resource_name: user.model_name.human) += render 'form' \ No newline at end of file diff --git a/templates/app/views/user/profiles/show.html.haml b/templates/app/views/user/profiles/show.html.haml new file mode 100644 index 0000000..a809fb6 --- /dev/null +++ b/templates/app/views/user/profiles/show.html.haml @@ -0,0 +1,15 @@ +- content_for :toolbar do + = link_to edit_user_profile_path, class: 'btn btn-default' do + %i.icon-pencil + = t('action_button.edit') +.panel.panel-default + .panel-heading + %i.icon-edit.icon-large + = t('tt.show', resource_name: user.model_name.human) + .panel-body + = show_for @profile do |s| + = s.attribute :name + = s.attribute :surname + = s.attribute :email + = s.attribute :created_at + = s.attribute :updated_at \ No newline at end of file diff --git a/templates/app/views/user/registrations/edit.html.haml b/templates/app/views/user/registrations/edit.html.haml new file mode 100644 index 0000000..4360d71 --- /dev/null +++ b/templates/app/views/user/registrations/edit.html.haml @@ -0,0 +1,19 @@ +.panel.panel-default + .panel-heading + %i.icon-edit.icon-large + = t('devise.registration.edit.title', model: resource.class.model_name.human) + .panel-body + = simple_form_for(resource, as: resource_name, url: user_registration_path, html: { method: :put }) do |f| + = f.error_notification + .form-inputs + = f.input :email, required: true, autofocus: true + - if devise_mapping.confirmable? && resource.pending_reconfirmation? + %p + = t('devise.registration.waiting_confirmation', email: resource.unconfirmed_email ) + %hr + = f.input :password, label: t('activerecord.attributes.user.password'), autocomplete: 'off', hint: t('devise.registration.hint_password'), required: false + = f.input :password_confirmation, label: t('activerecord.attributes.user.password_confirmation'), required: false + %hr + = f.input :current_password, label: t('activerecord.attributes.user.current_password'), hint: t('devise.registration.hint_current_password'), required: true + .form-actions + = f.button :submit, t('btn.update'), class: 'btn btn-primary' \ No newline at end of file diff --git a/templates/app/views/user/sessions/new.html.haml b/templates/app/views/user/sessions/new.html.haml new file mode 100644 index 0000000..fa09f94 --- /dev/null +++ b/templates/app/views/user/sessions/new.html.haml @@ -0,0 +1,11 @@ +%h2 + = t('devise.session.title', model: resource.class.model_name.human ) += simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| + .form-inputs + = f.input :email, required: false, autofocus: true + = f.input :password, required: false + = f.input :remember_me, as: :boolean,label: t('devise.session.remember_me') if devise_mapping.rememberable? + .form-actions + = f.button :submit, t('devise.session.button'), class: 'btn btn-primary' +%hr + = render 'devise/shared/links' \ No newline at end of file diff --git a/templates/app/views/user_profiles/edit.html.haml b/templates/app/views/user_profiles/edit.html.haml deleted file mode 100644 index 2a073eb..0000000 --- a/templates/app/views/user_profiles/edit.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :form_title do - = t('tt.edit', resource_name: UserProfile.model_name.human) -= render 'form' \ No newline at end of file diff --git a/templates/app/views/user_profiles/new.html.haml b/templates/app/views/user_profiles/new.html.haml deleted file mode 100644 index 285184c..0000000 --- a/templates/app/views/user_profiles/new.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :form_title do - = t('tt.new', resource_name: UserProfile.model_name.human) -= render 'form' \ No newline at end of file diff --git a/templates/app/views/user_profiles/show.html.haml b/templates/app/views/user_profiles/show.html.haml deleted file mode 100644 index e92d0bb..0000000 --- a/templates/app/views/user_profiles/show.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- content_for :toolbar do - = link_to edit_user_profile_path, class: 'btn btn-default' do - %i.icon-pencil - = t('action_button.edit') -.panel.panel-default - .panel-heading - %i.icon-edit.icon-large - = t('tt.show', resource_name: UserProfile.model_name.human) - .panel-body - = show_for @user_profile do |s| - = s.attribute :first_name - = s.attribute :last_name - = s.attribute :gsm diff --git a/templates/app/views/welcome/index.html.haml.erb b/templates/app/views/welcome/index.html.haml.erb index ea2ef2f..e1a332c 100644 --- a/templates/app/views/welcome/index.html.haml.erb +++ b/templates/app/views/welcome/index.html.haml.erb @@ -9,7 +9,7 @@ %p %strong Email: = current_user.email - = link_to 'Edit Profile', edit_user_profile_path, class: 'btn btn-large' + = link_to 'Edit Profile', edit_user_registration_path, class: 'btn btn-large' - else = link_to 'Sign up today', new_user_registration_path, class: 'btn btn-large btn-success' = link_to 'Sign in', new_user_session_path, class: 'btn btn-large' \ No newline at end of file