[refs #195] Add global fixes to projects and collaborators logic
This commit is contained in:
parent
fe46e53ad8
commit
c5d8041296
|
@ -1,4 +1,4 @@
|
|||
function deleteAdminMember() {
|
||||
/*function deleteAdminMember() {
|
||||
if (document.getElementById("niceCheckbox1-1").checked == true) {
|
||||
$("#admin-table-members-row1").fadeOut("slow");
|
||||
}
|
||||
|
@ -11,4 +11,16 @@ function deleteAdminMember() {
|
|||
if (document.getElementById("niceCheckbox4-1").checked == true) {
|
||||
$("#admin-table-members-row4").fadeOut("slow");
|
||||
}
|
||||
}*/
|
||||
|
||||
function saveAdminMember() {
|
||||
$('#_method').attr('value', 'post');
|
||||
$('form#members_form').submit();
|
||||
}
|
||||
|
||||
function deleteAdminMember() {
|
||||
$('#_method').attr('value', 'delete');
|
||||
var delete_url = $('form#members_form').attr('delete_url');
|
||||
$('form#members_form').attr('action', delete_url);
|
||||
$('form#members_form').submit();
|
||||
}
|
|
@ -30,48 +30,6 @@ class CollaboratorsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
#all_user_ids = []
|
||||
#all_groups_ids = []
|
||||
#Relation::ROLES.each { |r|
|
||||
# all_user_ids = all_user_ids | params['user'][r.to_sym].keys if params['user'] && params['user'][r.to_sym]
|
||||
# all_groups_ids = all_groups_ids | params['group'][r.to_sym].keys if params['group'] && params['group'][r.to_sym]
|
||||
#}
|
||||
|
||||
# Remove relations
|
||||
#users_for_removing = @project.collaborators.select do |u|
|
||||
# !all_user_ids.map{|k| k.to_i}.include? u.id and @project.owner != u
|
||||
#end
|
||||
#users_for_removing.each do |u|
|
||||
# Relation.by_object(u).by_target(@project).each {|r| r.destroy}
|
||||
#end
|
||||
#groups_for_removing = @project.groups.select do |u|
|
||||
# !all_groups_ids.map{|k| k.to_i}.include? u.id and @project.owner != u
|
||||
#end
|
||||
#groups_for_removing.each do |u|
|
||||
# Relation.by_object(u).by_target(@project).each {|r| r.destroy}
|
||||
#end
|
||||
|
||||
# Create relations
|
||||
#Relation::ROLES.each { |r|
|
||||
# #users_for_creating = users_for_creating params[:user].keys.map{|p| p.to_i} - @project.collaborators.map(&:id)
|
||||
# params['user'][r.to_sym].keys.each { |u|
|
||||
# if relation = @project.relations.find_by_object_id_and_object_type(u, 'User')
|
||||
# relation.update_attribute(:role, r)
|
||||
# else
|
||||
# relation = @project.relations.build(:object_id => u, :object_type => 'User', :role => r)
|
||||
# relation.save!
|
||||
# end
|
||||
# } if params['user'] && params['user'][r.to_sym]
|
||||
# params['group'][r.to_sym].keys.each { |u|
|
||||
# if relation = @project.relations.find_by_object_id_and_object_type(u, 'Group')
|
||||
# relation.update_attribute(:role, r)
|
||||
# else
|
||||
# relation = @project.relations.build(:object_id => u, :object_type => 'Group', :role => r)
|
||||
# relation.save!
|
||||
# end
|
||||
# } if params['group'] && params['group'][r.to_sym]
|
||||
#}
|
||||
|
||||
params['user'].keys.each { |user_id|
|
||||
role = params['user'][user_id]
|
||||
|
||||
|
@ -81,7 +39,7 @@ class CollaboratorsController < ApplicationController
|
|||
relation = @project.relations.build(:object_id => user_id, :object_type => 'User', :role => role)
|
||||
relation.save!
|
||||
end
|
||||
} if params['user']# && params['user'][r.to_sym]
|
||||
} if params['user']
|
||||
|
||||
params['group'].keys.each { |group_id|
|
||||
role = params['group'][group_id]
|
||||
|
@ -91,7 +49,7 @@ class CollaboratorsController < ApplicationController
|
|||
relation = @project.relations.build(:object_id => user_id, :object_type => 'Group', :role => role)
|
||||
relation.save!
|
||||
end
|
||||
} if params['group']# && params['group'][r.to_sym]
|
||||
} if params['group']
|
||||
|
||||
if @project.save
|
||||
flash[:notice] = t("flash.collaborators.successfully_changed")
|
||||
|
|
|
@ -35,6 +35,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def new
|
||||
@project = Project.new
|
||||
@who_owns = :me
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -44,6 +45,9 @@ class ProjectsController < ApplicationController
|
|||
@project = Project.new params[:project]
|
||||
#@project.owner = get_owner
|
||||
@project.owner = choose_owner
|
||||
puts "OWNER_TYPE: " + @project.owner_type
|
||||
@who_owns = (@project.owner_type == 'User' ? :me : :group)
|
||||
puts "WHO_OWNS: " + @who_owns.to_s
|
||||
|
||||
if @project.save
|
||||
flash[:notice] = t('flash.project.saved')
|
||||
|
|
|
@ -7,4 +7,12 @@ module ProjectsHelper
|
|||
"https://#{request.host_with_port}/#{name}.git"
|
||||
end
|
||||
end
|
||||
|
||||
def options_for_collaborators_roles_select
|
||||
options_for_select(
|
||||
Relation::ROLES.collect { |role|
|
||||
[t("layout.collaborators.role_names.#{ role }"), role]
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
= render :partial => 'projects/submenu'
|
||||
|
||||
= form_tag project_collaborators_path(@project), :id => 'members_form' do
|
||||
= 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"}
|
||||
%thead
|
||||
|
@ -8,16 +8,15 @@
|
|||
%th
|
||||
\
|
||||
%th
|
||||
Участники
|
||||
= t("layout.collaborators.members")
|
||||
%th{:colspan => "3"}
|
||||
Роли
|
||||
= t("layout.collaborators.roles")
|
||||
%tbody
|
||||
- @users.each do |user|
|
||||
%tr#admin-table-members-row1
|
||||
%td
|
||||
%span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)", :style => "background-position: 0px 0px; "}
|
||||
= check_box_tag "user_remove[#{user.id}][]"
|
||||
-#%input#niceCheckbox1-1{:name => "ch2", :type => "checkbox"}/
|
||||
%td
|
||||
.img
|
||||
= image_tag(gravatar_url(user.email))
|
||||
|
@ -29,16 +28,17 @@
|
|||
-# 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= role
|
||||
%a.button{:href => "#", :onclick => "deleteAdminMember();"} Удалить
|
||||
.forradio= t("layout.collaborators.role_names.#{ role }")
|
||||
= link_to_function t("layout.delete"), "deleteAdminMember();", :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_select(Relation::ROLES)
|
||||
= select_tag 'role', options_for_collaborators_roles_select
|
||||
.both
|
||||
-#.admin-search
|
||||
-# = label_tag "group_uname", t("layout.collaborators.input_groupname")
|
||||
|
@ -50,95 +50,6 @@
|
|||
|
||||
.hr.bottom
|
||||
.both
|
||||
=# submit_tag t("layout.save"), :class => 'button'
|
||||
%a.button{:href => "#", :onclick => "saveAdminMember();"}=t("layout.save")
|
||||
|
||||
:javascript
|
||||
function saveAdminMember() {
|
||||
$('#_method').attr('value', 'post');
|
||||
$('form#members_form').submit();
|
||||
}
|
||||
|
||||
function deleteAdminMember() {
|
||||
$('#_method').attr('value', 'delete');
|
||||
$('form#members_form').attr('action', '#{ remove_project_collaborators_path(@project) }');
|
||||
$('form#members_form').submit();
|
||||
}
|
||||
|
||||
-#= form_tag add_project_collaborators_path(@project) do
|
||||
-# .group
|
||||
-# .admin-search
|
||||
-# -#%input.gray{:onblur => "if(this.value==''){this.value='Найти участника...';this.className='gray';}", :onclick => "if(this.value=='Найти участника...'){this.value='';this.className='black';}", :type => "text", :value => "Найти участника..."}
|
||||
-# = autocomplete_field_tag 'group_id', params[:group_id], autocomplete_group_uname_groups_path, :id_element => '#group_id_field'
|
||||
-# .admin-add
|
||||
-# %a.button{:href => "#"} Добавить
|
||||
-# .both
|
||||
|
||||
|
||||
-#= form_tag add_project_collaborators_path(@project) do
|
||||
-# .group
|
||||
-# %h2.title= t("layout.collaborators.add")
|
||||
-# = label_tag "member_uname", t("layout.collaborators.input_username")
|
||||
-# = autocomplete_field_tag 'member_id', params[:member_id], autocomplete_user_uname_users_path, :id_element => '#member_id_field'
|
||||
-#
|
||||
-# = t('layout.or')
|
||||
-#
|
||||
-# = 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
|
||||
-# .group.navform.wat-cf
|
||||
-# %button.button{:type => "submit"}
|
||||
-# = image_tag("choose.png", :alt => t("layout.add"))
|
||||
-# = t("layout.add")
|
||||
|
||||
-#= form_tag project_collaborators_path(@project) do
|
||||
-# %h2.title= t("layout.users.list_header")
|
||||
-# %table.table
|
||||
-# %tr
|
||||
-# %th.first ID
|
||||
-# %th= t("activerecord.attributes.user.name")
|
||||
-# %th= t("activerecord.attributes.user.roles")
|
||||
-# %th= t("activerecord.attributes.user.uname")
|
||||
-# - #TODO: Replace this Chelyabinsk add/remove collaborators method by more human method
|
||||
-# - @users.each do |user|
|
||||
-# %tr{:class => cycle("odd", "even")}
|
||||
-# %td
|
||||
-# = user.id
|
||||
-# %td
|
||||
-# = link_to user.name, user_path(user)
|
||||
-# %td
|
||||
-# - Relation::ROLES.each do |role|
|
||||
-# = check_box_tag "user[#{ role }][#{user.id}]", '1', ((@project.relations.exists? :object_id => user.id, :object_type => 'User', :role => role) ? :checked : nil), {:class => "user_role_chbx"}
|
||||
-# = label_tag "user[#{ role }][#{user.id}]", t("layout.collaborators.roles.#{ role }")
|
||||
-# %td
|
||||
-# = user.uname
|
||||
-# %h2.title= t("layout.groups.list_header")
|
||||
-# %table.table
|
||||
-# %tr
|
||||
-# %th.first ID
|
||||
-# %th= t("activerecord.attributes.group.name")
|
||||
-# %th= t("activerecord.attributes.group.roles")
|
||||
-# %th= t("activerecord.attributes.group.uname")
|
||||
-# - @groups.each do |group|
|
||||
-# %tr{:class => cycle("odd", "even")}
|
||||
-# %td
|
||||
-# = group.id
|
||||
-# %td
|
||||
-# = link_to group.name, group_path(group)
|
||||
-# %td
|
||||
-# - Relation::ROLES.each do |role|
|
||||
-# = check_box_tag "group[#{role}][#{group.id}]", '1', ((@project.relations.exists? :object_id => group.id, :object_type => 'Group', :role => role) ? :checked : nil), {:class => "user_role_chbx"}
|
||||
-# = label_tag "group[#{role}][#{group.id}]", t("layout.collaborators.roles.#{role}")
|
||||
-# %td
|
||||
-# = group.uname
|
||||
-# .group.navform.wat-cf
|
||||
-# %button.button{:type => "submit"}
|
||||
-# = image_tag("choose.png", :alt => t("layout.save"))
|
||||
-# = t("layout.save")
|
||||
-# %span.text_button_padding= t("layout.or")
|
||||
-# = link_to t("layout.cancel"), project_path(@project), :class => "text_button_padding link_button"
|
||||
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button'
|
||||
|
||||
- content_for :sidebar, render('projects/sidebar')
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
= f.label :owner_id, t("activerecord.attributes.project.owner"), :class => :label
|
||||
.rightlist
|
||||
= label_tag t("activerecord.attributes.project.who_owns.me")
|
||||
= radio_button_tag :who_owns, 'me', :class => 'niceRadio'
|
||||
= radio_button_tag :who_owns, 'me'#, {}.merge( (@who_owns == :me ? {:checked => 'checked'} : {}) )
|
||||
= label_tag t("activerecord.attributes.project.who_owns.group")
|
||||
= radio_button_tag :who_owns, 'group', :class => 'niceRadio'
|
||||
= radio_button_tag :who_owns, 'group'#, {}.merge( (@who_owns == :group ? {:checked => 'checked'} : {}) )
|
||||
-# TODO: Make our own select_box helper with new design, blackjack and bitches!
|
||||
= select_tag :owner_id, options_for_select( Group.can_own_project(current_user) )
|
||||
.both
|
||||
|
@ -50,8 +50,6 @@
|
|||
\
|
||||
.rightlist
|
||||
.check
|
||||
-#%span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)"}
|
||||
-# %input{:name => "ch1", :type => "checkbox"}/
|
||||
%span#niceCheckbox1.niceCheck-main
|
||||
= f.check_box :is_rpm#, :class => 'niceCheckbox1'
|
||||
.forcheck
|
||||
|
@ -67,35 +65,5 @@
|
|||
.leftlist
|
||||
\
|
||||
.rightlist
|
||||
-#%a.button{:href => "#"} Сохранить
|
||||
= submit_tag t("layout.save"), :class => 'button'
|
||||
.both
|
||||
|
||||
-#.group
|
||||
-# = f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label
|
||||
-# = f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true
|
||||
-#.group
|
||||
-# = f.label :name, t("activerecord.attributes.project.name"), :class => :label
|
||||
-# = f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?)
|
||||
-#.group
|
||||
-# = f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label
|
||||
-# = f.select :visibility, Project::VISIBILITIES
|
||||
-#.group
|
||||
-# = f.label :description, t("activerecord.attributes.project.description"), :class => :label
|
||||
-# = f.text_area :description, :class => 'text_field', :cols => 80
|
||||
-#.group
|
||||
-# = f.label :has_issues, t("activerecord.attributes.project.has_issues"), :class => :label
|
||||
-# = f.check_box :has_issues
|
||||
-#.group
|
||||
-# = f.label :has_wiki, t("activerecord.attributes.project.has_wiki"), :class => :label
|
||||
-# = f.check_box :has_wiki
|
||||
-#.group
|
||||
-# = f.label :srpm, t("activerecord.attributes.project.srpm"), :class => :label
|
||||
-# = f.file_field :srpm, :class => 'file_field'
|
||||
-#
|
||||
-#.group.navform.wat-cf
|
||||
-# %button.button{:type => "submit"}
|
||||
-# = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
|
||||
-# = t("layout.save")
|
||||
-# %span.text_button_padding= t("layout.or")
|
||||
-# = link_to t("layout.cancel"), @projects_path, :class => "text_button_padding link_button"
|
||||
|
|
|
@ -26,5 +26,5 @@
|
|||
- content_for :sidebar, render('sidebar')
|
||||
|
||||
:javascript
|
||||
// TODO: Replace this temporary hack by somethins more true
|
||||
// TODO: Replace this temporary hack by something more true
|
||||
$('.right').addClass('bigpadding');
|
||||
|
|
|
@ -255,6 +255,12 @@ en:
|
|||
add_role: Add/Remove a role
|
||||
input_username: Enter an username
|
||||
input_groupname: Enter a groupname
|
||||
members: Members
|
||||
roles: Roles
|
||||
role_names:
|
||||
reader: Reader
|
||||
writer: Writer
|
||||
admin: Admin
|
||||
|
||||
members:
|
||||
back_to_group: Back to group
|
||||
|
|
|
@ -255,6 +255,12 @@ ru:
|
|||
add_role: Добавить/Удалить роль
|
||||
input_username: Введите псевдоним пользователя
|
||||
input_groupname: Введите псевдоним группы
|
||||
members: Участники
|
||||
roles: Роли
|
||||
role_names:
|
||||
reader: Читатель
|
||||
writer: Писатель
|
||||
admin: Админ
|
||||
|
||||
members:
|
||||
back_to_group: Вернуться к группе
|
||||
|
|
Loading…
Reference in New Issue