[issue #195] Added groups support to project.
This commit is contained in:
parent
401e570dc7
commit
9e31ae75b1
|
@ -24,3 +24,15 @@ function deleteAdminMember() {
|
|||
$('form#members_form').attr('action', delete_url);
|
||||
$('form#members_form').submit();
|
||||
}
|
||||
|
||||
function saveAdminGroup() {
|
||||
$('#groups_method').attr('value', 'post');
|
||||
$('form#groups_form').submit();
|
||||
}
|
||||
|
||||
function deleteAdminGroup() {
|
||||
$('#groups_method').attr('value', 'delete');
|
||||
var delete_url = $('form#groups_form').attr('delete_url');
|
||||
$('form#groups_form').attr('action', delete_url);
|
||||
$('form#groups_form').submit();
|
||||
}
|
||||
|
|
|
@ -621,3 +621,12 @@ div.right.bigpadding div.command_select div.rightlist textarea {
|
|||
div.rightlist textarea.resizable {
|
||||
resize: both;
|
||||
}
|
||||
|
||||
div.admin-role {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
/* TODO think, how to do it more beautiful */
|
||||
ul.ui-autocomplete {
|
||||
z-index: 999 !important;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class CollaboratorsController < ApplicationController
|
|||
relation.update_attribute(:role, role)
|
||||
else
|
||||
relation = @project.relations.build(:object_id => user_id, :object_type => 'User', :role => role)
|
||||
relation.save!
|
||||
relation.save
|
||||
end
|
||||
} if params['user']
|
||||
|
||||
|
@ -47,7 +47,7 @@ class CollaboratorsController < ApplicationController
|
|||
relation.update_attribute(:role, role)
|
||||
else
|
||||
relation = @project.relations.build(:object_id => user_id, :object_type => 'Group', :role => role)
|
||||
relation.save!
|
||||
relation.save
|
||||
end
|
||||
} if params['group']
|
||||
|
||||
|
@ -62,7 +62,7 @@ class CollaboratorsController < ApplicationController
|
|||
|
||||
def remove
|
||||
all_user_ids = []
|
||||
all_groups_ids = []
|
||||
all_group_ids = []
|
||||
|
||||
params['user_remove'].keys.each { |user_id|
|
||||
all_user_ids << user_id if params['user_remove'][user_id] == ["1"]
|
||||
|
@ -75,12 +75,12 @@ class CollaboratorsController < ApplicationController
|
|||
u = User.find(user_id)
|
||||
Relation.by_object(u).by_target(@project).each {|r| r.destroy}
|
||||
end
|
||||
all_groups_ids.each do |group_id|
|
||||
all_group_ids.each do |group_id|
|
||||
g = Group.find(group_id)
|
||||
Relation.by_object(g).by_target(@project).each {|r| r.destroy}
|
||||
end
|
||||
|
||||
redirect_to edit_project_collaborators_path(@project)
|
||||
redirect_to edit_project_collaborators_path(@project) + "##{params['user_remove'].present? ? 'users' : 'groups'}"
|
||||
end
|
||||
|
||||
def add
|
||||
|
@ -114,7 +114,8 @@ class CollaboratorsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
redirect_to(edit_project_collaborators_path(@project))
|
||||
# if add an anchor, adding will be more pleasant, but flash message wouldn't be shown.
|
||||
redirect_to edit_project_collaborators_path(@project) # + "##{(params['member_id'].present?) ? 'users' : 'groups'}"
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -124,11 +125,11 @@ class CollaboratorsController < ApplicationController
|
|||
end
|
||||
|
||||
def find_users
|
||||
@users = @project.collaborators#User.all
|
||||
@users = @project.collaborators.order('uname')#User.all
|
||||
end
|
||||
|
||||
def find_groups
|
||||
@groups = @project.groups#Group.all
|
||||
@groups = @project.groups.order('uname')#Group.all
|
||||
end
|
||||
|
||||
def authorize_collaborators
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
= render :partial => 'projects/sidebar'
|
||||
= render :partial => 'projects/submenu'
|
||||
|
||||
%a{:name => 'users'}
|
||||
%h3= t("layout.users.list_header")
|
||||
|
||||
= form_tag add_project_collaborators_path(@project) do
|
||||
.admin-search
|
||||
= autocomplete_field_tag 'member_id', params[:member_id], autocomplete_user_uname_users_path, :id_element => '#member_id_field'
|
||||
.admin-role
|
||||
.lineForm
|
||||
= select_tag 'role', options_for_collaborators_roles_select
|
||||
= hidden_field_tag 'member_id', nil, :id => 'member_id_field'
|
||||
= submit_tag t("layout.add"), :class => 'button'
|
||||
.both
|
||||
|
||||
= form_tag project_collaborators_path(@project), :id => 'members_form', :delete_url => remove_project_collaborators_path(@project) do
|
||||
= hidden_field_tag "_method", "post"
|
||||
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
|
@ -12,8 +26,8 @@
|
|||
%th{:colspan => "3"}
|
||||
= t("layout.collaborators.roles")
|
||||
%tbody
|
||||
- @users.each do |user|
|
||||
%tr#admin-table-members-row1
|
||||
- @users.each_with_index do |user, num|
|
||||
%tr{:id => "admin-table-members-row#{num}"}
|
||||
%td
|
||||
%span#niceCheckbox1.niceCheck-main{ :style => "background-position: 0px 0px; "}
|
||||
= check_box_tag "user_remove[#{user.id}][]"
|
||||
|
@ -25,31 +39,57 @@
|
|||
%td
|
||||
.radio
|
||||
= radio_button_tag "user[#{user.id}]", role, ((@project.relations.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
-# f.radio_button "group[#{role}][#{group.id}]", '1', ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil)
|
||||
-#%span.niceRadio.radioChecked
|
||||
-# %input#myradio1{:checked => "checked", :name => "myradio", :tabindex => "1", :type => "radio", :value => "on"}/
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button'
|
||||
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button'
|
||||
.both
|
||||
.hr.top
|
||||
|
||||
= form_tag add_project_collaborators_path(@project) do
|
||||
.admin-search
|
||||
= autocomplete_field_tag 'member_id', params[:member_id], autocomplete_user_uname_users_path, :id_element => '#member_id_field'
|
||||
.admin-role
|
||||
.lineForm
|
||||
= select_tag 'role', options_for_collaborators_roles_select
|
||||
.both
|
||||
-#.admin-search
|
||||
-# = label_tag "group_uname", t("layout.collaborators.input_groupname")
|
||||
-# = autocomplete_field_tag 'group_id', params[:group_id], autocomplete_group_uname_groups_path, :id_element => '#group_id_field'
|
||||
= hidden_field_tag 'member_id', nil, :id => 'member_id_field'
|
||||
=# hidden_field_tag 'group_id', nil, :id => 'group_id_field'
|
||||
%br
|
||||
= submit_tag t("layout.add"), :class => 'button'
|
||||
%br
|
||||
|
||||
.hr.bottom
|
||||
.both
|
||||
|
||||
%a{:name => 'groups'}
|
||||
%h3= t("layout.groups.list_header")
|
||||
|
||||
= form_tag add_project_collaborators_path(@project) do
|
||||
.admin-search
|
||||
= autocomplete_field_tag 'group_id', params[:group_id], autocomplete_group_uname_groups_path, :id_element => '#group_id_field'
|
||||
.admin-role
|
||||
.lineForm
|
||||
= select_tag 'role', options_for_collaborators_roles_select, :id => 'group_role'
|
||||
= hidden_field_tag 'group_id', nil, :id => 'group_id_field'
|
||||
= submit_tag t("layout.add"), :class => 'button'
|
||||
.both
|
||||
|
||||
= form_tag project_collaborators_path(@project), :id => 'groups_form', :delete_url => remove_project_collaborators_path(@project) do
|
||||
= hidden_field_tag "_method", "post", :id => 'groups_method'
|
||||
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
%thead
|
||||
%tr
|
||||
%th
|
||||
\
|
||||
%th
|
||||
= t("layout.collaborators.members")
|
||||
%th{:colspan => "3"}
|
||||
= t("layout.collaborators.roles")
|
||||
%tbody
|
||||
- @groups.each_with_index do |group, num|
|
||||
%tr{:id => "admin-table-members-row#{num + @users.size + 1}"}
|
||||
%td
|
||||
%span#niceCheckbox1.niceCheck-main{ :style => "background-position: 0px 0px; "}
|
||||
= check_box_tag "group_remove[#{group.id}][]"
|
||||
%td
|
||||
.forimg= link_to "#{group.uname}", group_path(group)
|
||||
- Relation::ROLES.each_with_index do |role, i|
|
||||
%td
|
||||
.radio
|
||||
= radio_button_tag "group[#{group.id}]", role, ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil), :class => 'niceRadio'
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete"), "deleteAdminGroup();", :class => 'button'
|
||||
= link_to_function t("layout.save"), "saveAdminGroup();", :class => 'button'
|
||||
.both
|
||||
%br
|
||||
|
||||
.hr.bottom
|
||||
.both
|
||||
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button'
|
||||
|
||||
- content_for :sidebar, render('projects/sidebar')
|
||||
|
|
Loading…
Reference in New Issue