From 682de1ba81229922dd546cbb381345ed8098e0db Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 7 Nov 2014 01:24:33 +0300 Subject: [PATCH] #369: updated UI for Groups#edit --- app/controllers/groups/profile_controller.rb | 2 +- app/models/group.rb | 4 +- app/views/groups/base/_submenu.html.slim | 23 ++++++++++++ app/views/groups/profile/_form.html.haml | 16 -------- app/views/groups/profile/_form.html.slim | 6 +++ app/views/groups/profile/edit.html.haml | 15 -------- app/views/groups/profile/edit.html.slim | 39 ++++++++++++++++++++ app/views/groups/profile/new.html.haml | 6 --- app/views/groups/profile/new.html.slim | 10 +++++ config/locales/models/group.en.yml | 25 +++++++++---- config/locales/models/group.ru.yml | 27 ++++++++++---- 11 files changed, 120 insertions(+), 53 deletions(-) create mode 100644 app/views/groups/base/_submenu.html.slim delete mode 100644 app/views/groups/profile/_form.html.haml create mode 100644 app/views/groups/profile/_form.html.slim delete mode 100644 app/views/groups/profile/edit.html.haml create mode 100644 app/views/groups/profile/edit.html.slim delete mode 100644 app/views/groups/profile/new.html.haml create mode 100644 app/views/groups/profile/new.html.slim diff --git a/app/controllers/groups/profile_controller.rb b/app/controllers/groups/profile_controller.rb index f1d89ed5d..42ca97708 100644 --- a/app/controllers/groups/profile_controller.rb +++ b/app/controllers/groups/profile_controller.rb @@ -1,6 +1,6 @@ class Groups::ProfileController < Groups::BaseController include AvatarHelper - layout 'bootstrap', only: [:index] + layout 'bootstrap' load_and_authorize_resource class: Group, instance_name: 'group' skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access'] diff --git a/app/models/group.rb b/app/models/group.rb index f507d8f7e..586887094 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -27,9 +27,11 @@ class Group < Avatar joins(:actors).where('relations.role' => ['admin', 'writer'], 'relations.actor_id' => actor.id, 'relations.actor_type' => 'User') } - attr_accessible :uname, :description + attr_accessible :uname, :description, :delete_avatar attr_readonly :uname + attr_accessor :delete_avatar + delegate :email, :user_appeal, to: :owner after_create :add_owner_to_members diff --git a/app/views/groups/base/_submenu.html.slim b/app/views/groups/base/_submenu.html.slim new file mode 100644 index 000000000..413d632b1 --- /dev/null +++ b/app/views/groups/base/_submenu.html.slim @@ -0,0 +1,23 @@ +- content_for :submenu do + - act = action_name.to_sym + - contr = controller_name.to_sym + nav.navbar.navbar-default role='navigation' + .container-fluid + / Brand and toggle get grouped for better mobile display + .navbar-header + button.navbar-toggle data-target='#submenu-navbar-collapse' data-toggle='collapse' type='button' + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + .navbar-brand + = link_to @group.uname, @group + / Collect the nav links, forms, and other content for toggling + #submenu-navbar-collapse.collapse.navbar-collapse + ul.nav.navbar-nav.left-border + - if can? :edit, @group + li class=('active' if act == :edit && contr == :profile) + = link_to t('layout.groups.edit'), edit_group_path(@group) + - if can? :manage_members, @group + li class=('active' if act == :index && contr == :members) + = link_to t('layout.groups.edit_members'), group_members_path(@group) diff --git a/app/views/groups/profile/_form.html.haml b/app/views/groups/profile/_form.html.haml deleted file mode 100644 index 7925ba609..000000000 --- a/app/views/groups/profile/_form.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- act = controller.action_name.to_sym -- if [:new, :create].include? act - .leftlist= f.label :uname, t("activerecord.attributes.group.uname"), class: :label - .rightlist.nomargin= f.text_field :uname - .both -%br -.leftlist= f.label :description, t("activerecord.attributes.group.description"), class: :label -.rightlist.nomargin= f.text_area :description -.both -%br -= render 'shared/avatar_form', subject: @group, f: f -%br -.leftlist - \  -.rightlist= submit_tag t('layout.save'), data: {'disable-with' => t('layout.saving')} -.both diff --git a/app/views/groups/profile/_form.html.slim b/app/views/groups/profile/_form.html.slim new file mode 100644 index 000000000..67cee0426 --- /dev/null +++ b/app/views/groups/profile/_form.html.slim @@ -0,0 +1,6 @@ +- act = controller.action_name.to_sym +- if [:new, :create].include? act + = f.input :uname += f.input :description, as: :text += render 'shared/avatar_form', subject: @group, f: f += f.button :submit, t('layout.save') \ No newline at end of file diff --git a/app/views/groups/profile/edit.html.haml b/app/views/groups/profile/edit.html.haml deleted file mode 100644 index f8aaa8c5e..000000000 --- a/app/views/groups/profile/edit.html.haml +++ /dev/null @@ -1,15 +0,0 @@ --set_meta_tags title: [title_object(@group), t('layout.groups.edit')] -= form_for @group, url: profile_group_path(@group) do |f| - = render "form", f: f - -.hr -.groups-profile= image_tag('code.png') -.groups-profile= link_to t("layout.groups.public_profile"), @group -.both -.hr -.leftside= t("layout.groups.delete_warning") -.rightside - = link_to t("layout.delete"), profile_group_path(@group), method: :delete, data: { confirm: t("layout.groups.confirm_delete") }, class: 'button' if can? :destroy, @group -.both - -- content_for :sidebar, render('sidebar') diff --git a/app/views/groups/profile/edit.html.slim b/app/views/groups/profile/edit.html.slim new file mode 100644 index 000000000..e7a836deb --- /dev/null +++ b/app/views/groups/profile/edit.html.slim @@ -0,0 +1,39 @@ +-set_meta_tags title: [title_object(@group), t('layout.groups.edit')] + += render 'groups/base/submenu' + +.container.col-md-offset-2.col-md-8 + .row + = simple_form_for @group, + url: profile_group_path(@group), + wrapper: :horizontal_form, + wrapper_mappings: { boolean: :horizontal_boolean } do |f| + + = render 'form', f: f + + - if can? :destroy, @group + .row + hr + .alert.alert-danger + = t('layout.groups.delete_warning') + = link_to t('layout.delete'), + profile_group_path(@group), + method: :delete, + data: { confirm: t("layout.groups.confirm_delete") }, + class: 'btn btn-danger' + + +/ = form_for @group, url: profile_group_path(@group) do |f| +/ = render "form", f: f + +/ .hr +/ .groups-profile= image_tag('code.png') +/ .groups-profile= link_to t("layout.groups.public_profile"), @group +/ .both +/ .hr +/ .leftside= t("layout.groups.delete_warning") +/ .rightside +/ = link_to t("layout.delete"), profile_group_path(@group), method: :delete, data: { confirm: t("layout.groups.confirm_delete") }, class: 'button' if can? :destroy, @group +/ .both + +/ - content_for :sidebar, render('sidebar') diff --git a/app/views/groups/profile/new.html.haml b/app/views/groups/profile/new.html.haml deleted file mode 100644 index a8fc47656..000000000 --- a/app/views/groups/profile/new.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -%h3.bpadding10= title t("layout.groups.new_header") -= form_for @group do |f| - = render "form", f: f - -:javascript - $('article .all').addClass('bigpadding'); diff --git a/app/views/groups/profile/new.html.slim b/app/views/groups/profile/new.html.slim new file mode 100644 index 000000000..9c7d6564b --- /dev/null +++ b/app/views/groups/profile/new.html.slim @@ -0,0 +1,10 @@ +.container.col-md-offset-2.col-md-8 + .row + h3 + = title t('layout.groups.new_header') + = simple_form_for @group, + wrapper: :horizontal_form, + wrapper_mappings: { boolean: :horizontal_boolean } do |f| + + = render 'form', f: f + diff --git a/config/locales/models/group.en.yml b/config/locales/models/group.en.yml index 4f1c443c5..27f2a0609 100644 --- a/config/locales/models/group.en.yml +++ b/config/locales/models/group.en.yml @@ -43,11 +43,22 @@ en: activerecord: models: group: Group - attributes: + + simple_form: + labels: group: - name: Name - uname: Nickname - owner: Owner - created_at: Created - updated_at: Updated - description: Description + uname: Name + owner: Owner + created_at: Created + updated_at: Updated + description: Description + avatar: Avatar + delete_avatar: Delete avatar + placeholders: + group: + uname: Enter the name here. + description: Enter the description here. + hints: + group: + description: Enter the description of group. + diff --git a/config/locales/models/group.ru.yml b/config/locales/models/group.ru.yml index 01c5aaf7a..6a460915d 100644 --- a/config/locales/models/group.ru.yml +++ b/config/locales/models/group.ru.yml @@ -43,11 +43,24 @@ ru: activerecord: models: group: Группа - attributes: + + simple_form: + labels: group: - name: Название - uname: Псевдоним - owner: Владелец - created_at: Создана - updated_at: Обновлена - description: Описание + uname: Название + owner: Владелец + created_at: Создана + updated_at: Обновлена + avatar: Аватар + delete_avatar: Удалить аватар + description: Описание + placeholders: + group: + uname: Введите название здесь. + description: Введите описание здесь. + hints: + group: + uname: Введите название группы. + description: Введите описание группы. + +