#369: updated UI for Groups#edit

This commit is contained in:
Vokhmin Alexey V 2014-11-07 01:24:33 +03:00
parent 6a78ab4993
commit 682de1ba81
11 changed files with 120 additions and 53 deletions

View File

@ -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']

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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');

View File

@ -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

View File

@ -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.

View File

@ -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: Введите описание группы.