From 96309eb8bacfa45134d9a0708dd5d6787c076cae Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 25 Apr 2020 15:16:45 +0200 Subject: [PATCH] Move all modals into shared views/modal directory --- app/controllers/ajax/group_controller.rb | 2 +- app/views/layouts/_header.html.haml | 2 +- .../_ask.html.haml} | 0 .../_ban.html.haml} | 0 .../_comment_smiles.html.haml | 0 .../_group.html.haml} | 2 +- app/views/modal/_password.html.haml | 13 +++++++++++++ app/views/modal/_privileges.html.haml | 19 +++++++++++++++++++ .../group/_item.html.haml} | 0 .../privileges/_item.html.haml} | 0 app/views/shared/_comments.html.haml | 2 +- app/views/user/_account.html.haml | 15 +-------------- app/views/user/_modal_privileges.html.haml | 19 ------------------- app/views/user/show.html.haml | 6 +++--- 14 files changed, 40 insertions(+), 40 deletions(-) rename app/views/{shared/_modal_ask_followers.html.haml => modal/_ask.html.haml} (100%) rename app/views/{user/_modal_ban.html.haml => modal/_ban.html.haml} (100%) rename app/views/{shared => modal}/_comment_smiles.html.haml (100%) rename app/views/{user/_modal_group_memberships.html.haml => modal/_group.html.haml} (95%) create mode 100644 app/views/modal/_password.html.haml create mode 100644 app/views/modal/_privileges.html.haml rename app/views/{user/_modal_group_item.html.haml => modal/group/_item.html.haml} (100%) rename app/views/{user/_modal_privileges_item.html.haml => modal/privileges/_item.html.haml} (100%) delete mode 100644 app/views/user/_modal_privileges.html.haml diff --git a/app/controllers/ajax/group_controller.rb b/app/controllers/ajax/group_controller.rb index 0c803c4f..b3102489 100644 --- a/app/controllers/ajax/group_controller.rb +++ b/app/controllers/ajax/group_controller.rb @@ -45,7 +45,7 @@ class Ajax::GroupController < ApplicationController @status = :okay @success = true @message = I18n.t('messages.group.create.okay') - @render = render_to_string(partial: 'user/modal_group_item', locals: { group: group, user: target_user }) + @render = render_to_string(partial: 'modal/group/item', locals: { group: group, user: target_user }) end def destroy diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 5a403c0c..07087947 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -29,6 +29,6 @@ = nav_entry t('views.sessions.new'), new_user_registration_path - if user_signed_in? - = render 'shared/modal_ask_followers' + = render 'modal/ask' %button.btn.btn-primary.btn-fab.d-block.d-sm-none{"data-target" => "#modal-ask-followers", "data-toggle" => "modal", :type => "button"} %i.fa.fa-pencil-square-o diff --git a/app/views/shared/_modal_ask_followers.html.haml b/app/views/modal/_ask.html.haml similarity index 100% rename from app/views/shared/_modal_ask_followers.html.haml rename to app/views/modal/_ask.html.haml diff --git a/app/views/user/_modal_ban.html.haml b/app/views/modal/_ban.html.haml similarity index 100% rename from app/views/user/_modal_ban.html.haml rename to app/views/modal/_ban.html.haml diff --git a/app/views/shared/_comment_smiles.html.haml b/app/views/modal/_comment_smiles.html.haml similarity index 100% rename from app/views/shared/_comment_smiles.html.haml rename to app/views/modal/_comment_smiles.html.haml diff --git a/app/views/user/_modal_group_memberships.html.haml b/app/views/modal/_group.html.haml similarity index 95% rename from app/views/user/_modal_group_memberships.html.haml rename to app/views/modal/_group.html.haml index e9b144be..2d735306 100644 --- a/app/views/user/_modal_group_memberships.html.haml +++ b/app/views/modal/_group.html.haml @@ -19,7 +19,7 @@ .tab-pane.active{role:"tabpanel", id: "grouplist"} %ul.list-group.groups--list - current_user.groups.each do |group| - = render 'user/modal_group_item', group: group, user: @user + = render 'modal/group/item', group: group, user: @user .tab-pane{role:"tabpanel", id: "create"} .modal-body %input#new-group-name.form-control{type: :text, placeholder: t('views.modal.group.name')} diff --git a/app/views/modal/_password.html.haml b/app/views/modal/_password.html.haml new file mode 100644 index 00000000..7d411fb8 --- /dev/null +++ b/app/views/modal/_password.html.haml @@ -0,0 +1,13 @@ +#modal-passwd.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-passwd-label", :role => "dialog", :tabindex => "-1"} + .modal-dialog + .modal-content + .modal-header + %h5#modal-passwd-label.modal-title= t 'views.settings.account.modal.title' + %button.close{"data-dismiss" => "modal", :type => "button"} + %span{"aria-hidden" => "true"} × + %span.sr-only= t 'views.actions.close' + .modal-body + = f.password_field :current_password, autocomplete: "off", label: t('views.settings.account.password_current'), help: t('views.settings.account.password_current_help') + .modal-footer + %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"}= t 'views.actions.cancel' + %button.btn.btn-primary{:type => "submit"}= t 'views.actions.save' \ No newline at end of file diff --git a/app/views/modal/_privileges.html.haml b/app/views/modal/_privileges.html.haml new file mode 100644 index 00000000..99d77ed9 --- /dev/null +++ b/app/views/modal/_privileges.html.haml @@ -0,0 +1,19 @@ +#modal-privileges.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-privileges-label", :role => "dialog", :tabindex => "-1"} + .modal-dialog + .modal-content + .modal-header + %h5#modal-privileges-label.modal-title + = raw t('views.actions.privilege', user: @user.screen_name) + %button.close{"data-dismiss" => "modal", :type => "button"} + %span{"aria-hidden" => "true"} × + %span.sr-only= t 'views.actions.close' + %ul.list-group.groups--list + = render :partial 'modal/privileges/item', privilege: 'blogger', description: t('views.modal.privilege.blogger'), user: @user + = render :partial 'modal/privileges/item', privilege: 'contributor', description: t('views.modal.privilege.contributor'), user: @user + = render :partial 'modal/privileges/item', privilege: 'translator', description: t('views.modal.privilege.translator'), user: @user + - if current_user.has_role?(:administrator) + = render :partial 'modal/privileges/item', privilege: 'supporter', description: t('views.modal.privilege.supporter'), user: @user + = render :partial 'modal/privileges/item', privilege: 'moderator', description: t('views.modal.privilege.moderator'),user: @user + = render :partial 'modal/privileges/item', privilege: 'admin', description: t('views.modal.privilege.admin'), user: @user + .modal-footer + %button.btn.btn-primary{name: 'checked-privileges', type: :button, data: { dismiss: :modal }}= t 'views.actions.done' diff --git a/app/views/user/_modal_group_item.html.haml b/app/views/modal/group/_item.html.haml similarity index 100% rename from app/views/user/_modal_group_item.html.haml rename to app/views/modal/group/_item.html.haml diff --git a/app/views/user/_modal_privileges_item.html.haml b/app/views/modal/privileges/_item.html.haml similarity index 100% rename from app/views/user/_modal_privileges_item.html.haml rename to app/views/modal/privileges/_item.html.haml diff --git a/app/views/shared/_comments.html.haml b/app/views/shared/_comments.html.haml index cf0c13c9..d51d096d 100644 --- a/app/views/shared/_comments.html.haml +++ b/app/views/shared/_comments.html.haml @@ -4,7 +4,7 @@ %ul.comments - a.comments.order(:created_at).each do |comment| %li{data: { comment_id: comment.id }} - %div{class: "ab-comment-smile-list", style: "height: 0; width: 0"}= render "shared/comment_smiles", comment: comment + %div{class: "ab-comment-smile-list", style: "height: 0; width: 0"}= render "modal/comment_smiles", comment: comment .media.comments--media .pull-left %img.img-rounded.answerbox--img{src: gravatar_url(comment.user)} diff --git a/app/views/user/_account.html.haml b/app/views/user/_account.html.haml index f4fd1b98..0f5ee2b0 100644 --- a/app/views/user/_account.html.haml +++ b/app/views/user/_account.html.haml @@ -7,20 +7,7 @@ .card .card-body = bootstrap_form_for(resource, as: resource_name, url: '/settings/account', html: { method: :put }) do |f| - / Password field modal - #modal-passwd.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-passwd-label", :role => "dialog", :tabindex => "-1"} - .modal-dialog - .modal-content - .modal-header - %h5#modal-passwd-label.modal-title= t 'views.settings.account.modal.title' - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × - %span.sr-only= t 'views.actions.close' - .modal-body - = f.password_field :current_password, autocomplete: "off", label: t('views.settings.account.password_current'), help: t('views.settings.account.password_current_help') - .modal-footer - %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"}= t 'views.actions.cancel' - %button.btn.btn-primary{:type => "submit"}= t 'views.actions.save' + = render 'modal/password', f: f = devise_error_messages! diff --git a/app/views/user/_modal_privileges.html.haml b/app/views/user/_modal_privileges.html.haml deleted file mode 100644 index 634a9cf5..00000000 --- a/app/views/user/_modal_privileges.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -#modal-privileges.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-privileges-label", :role => "dialog", :tabindex => "-1"} - .modal-dialog - .modal-content - .modal-header - %h5#modal-privileges-label.modal-title - = raw t('views.actions.privilege', user: @user.screen_name) - %button.close{"data-dismiss" => "modal", :type => "button"} - %span{"aria-hidden" => "true"} × - %span.sr-only= t 'views.actions.close' - %ul.list-group.groups--list - = render 'user/modal_privileges_item', privilege: 'blogger', description: t('views.modal.privilege.blogger'), user: @user - = render 'user/modal_privileges_item', privilege: 'contributor', description: t('views.modal.privilege.contributor'), user: @user - = render 'user/modal_privileges_item', privilege: 'translator', description: t('views.modal.privilege.translator'), user: @user - - if current_user.has_role?(:administrator) - = render 'user/modal_privileges_item', privilege: 'supporter', description: t('views.modal.privilege.supporter'), user: @user - = render 'user/modal_privileges_item', privilege: 'moderator', description: t('views.modal.privilege.moderator'),user: @user - = render 'user/modal_privileges_item', privilege: 'admin', description: t('views.modal.privilege.admin'), user: @user - .modal-footer - %button.btn.btn-primary{name: 'checked-privileges', type: :button, data: { dismiss: :modal }}= t 'views.actions.done' diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index 099f7d76..8eedcc97 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -22,7 +22,7 @@ = t 'views.actions.load' .visible-xs= render 'shared/links' - if user_signed_in? - = render 'user/modal_group_memberships' + = render 'modal/group' - if current_user.mod? and @user != current_user - = render 'user/modal_privileges' - = render 'user/modal_ban' + = render 'modal/privileges' + = render 'modal/ban'