#648: updated models, JS, controller according to comments and discussions
This commit is contained in:
parent
cee1ee6cb6
commit
9be978eb68
|
@ -6,12 +6,10 @@ $(document).ready(function() {
|
||||||
var bg = $("#"+flag).css("background-color");
|
var bg = $("#"+flag).css("background-color");
|
||||||
var checkbox = $(this).find(':checkbox');
|
var checkbox = $(this).find(':checkbox');
|
||||||
if ($(this).css("background-color") != bg) {
|
if ($(this).css("background-color") != bg) {
|
||||||
$(this).css("background-color",bg);
|
$(this).css("background-color",bg).css("color","#FFFFFF");
|
||||||
$(this).css("color","#FFFFFF");
|
|
||||||
checkbox.attr('checked', 'checked');
|
checkbox.attr('checked', 'checked');
|
||||||
} else {
|
} else {
|
||||||
$(this).css("background-color","rgb(247, 247, 247)");
|
$(this).css("background-color","rgb(247, 247, 247)").css("color","#565657");
|
||||||
$(this).css("color","#565657");
|
|
||||||
checkbox.removeAttr('checked');
|
checkbox.removeAttr('checked');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -698,48 +698,13 @@ div.toolbar a.button {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.toolbar div.legend {
|
div.toolbar, table.dataTable {
|
||||||
float: left;
|
> .group_owner, > .user_owner, > .group, > .user { margin-right: 15px; }
|
||||||
margin-left: 50px;
|
.group_owner, .user_owner, .group, .user { padding-left: 20px; }
|
||||||
padding: 4px 0 6px;
|
.user_owner { background: image-url('user16g.png') no-repeat 0 0 transparent; }
|
||||||
}
|
.group_owner { background: image-url('group16g.png') no-repeat 0 0 transparent; }
|
||||||
|
.user { background: image-url('user16.png') no-repeat 0 0 transparent; }
|
||||||
table.dataTable tr td.rights span.group,
|
.group { background: image-url('group16.png') no-repeat 0 0 transparent; }
|
||||||
div.toolbar div.legend.rights span.group {
|
|
||||||
background: image-url('group16.png') no-repeat 0 0 transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.dataTable tr td.rights span.user,
|
|
||||||
div.toolbar div.legend.rights span.user {
|
|
||||||
background: image-url('user16.png') no-repeat 0 0 transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.dataTable tr td.rights span.group_owner,
|
|
||||||
div.toolbar div.legend.rights span.group_owner {
|
|
||||||
background: image-url('group16g.png') no-repeat 0 0 transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.dataTable tr td.rights span.user_owner,
|
|
||||||
div.toolbar div.legend.rights span.user_owner {
|
|
||||||
background: image-url('user16g.png') no-repeat 0 0 transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.dataTable tr td.rights span.group_owner,
|
|
||||||
div.toolbar div.legend.rights span.group_owner,
|
|
||||||
table.dataTable tr td.rights span.user_owner,
|
|
||||||
div.toolbar div.legend.rights span.user_owner,
|
|
||||||
table.dataTable tr td.rights span.group,
|
|
||||||
div.toolbar div.legend.rights span.group,
|
|
||||||
table.dataTable tr td.rights span.user,
|
|
||||||
div.toolbar div.legend.rights span.user {
|
|
||||||
padding-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.toolbar div.legend.rights span.group_owner,
|
|
||||||
div.toolbar div.legend.rights span.user_owner,
|
|
||||||
div.toolbar div.legend.rights span.group,
|
|
||||||
div.toolbar div.legend.rights span.user {
|
|
||||||
margin: 0 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class Projects::ProjectsController < Projects::BaseController
|
class Projects::ProjectsController < Projects::BaseController
|
||||||
|
include ProjectsHelper
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
load_and_authorize_resource :id_param => :project_name # to force member actions load
|
load_and_authorize_resource :id_param => :project_name # to force member actions load
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@groups = params[:groups] || []
|
|
||||||
@user_owner = params[:user_owner] ? true : false
|
|
||||||
@projects = Project.accessible_by(current_ability, :membered)
|
@projects = Project.accessible_by(current_ability, :membered)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { @projects = @projects.recent.paginate(:page => params[:page], :per_page => 25) }
|
format.html {
|
||||||
format.json { @projects = prepare_list(@projects, @groups, @user_owner) }
|
@all_projects = @projects
|
||||||
|
@groups = current_user.groups
|
||||||
|
@owners = User.where(:id => @projects.select(:owner_id).where(:owner_type => 'User').group(:owner_id).map(&:owner_id))
|
||||||
|
@projects = @projects.recent.paginate(:page => params[:page], :per_page => 25)
|
||||||
|
}
|
||||||
|
format.json {
|
||||||
|
selected_groups = params[:groups] || []
|
||||||
|
selected_owners = params[:owners] || []
|
||||||
|
@projects = prepare_list(@projects, selected_groups, selected_owners)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -97,7 +105,7 @@ class Projects::ProjectsController < Projects::BaseController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def prepare_list(projects, groups, user_owner)
|
def prepare_list(projects, groups, owners)
|
||||||
res = {}
|
res = {}
|
||||||
|
|
||||||
colName = ['name']
|
colName = ['name']
|
||||||
|
@ -107,12 +115,8 @@ class Projects::ProjectsController < Projects::BaseController
|
||||||
|
|
||||||
res[:total_count] = projects.count
|
res[:total_count] = projects.count
|
||||||
|
|
||||||
if user_owner && groups.present?
|
if groups.present? || owners.present?
|
||||||
projects = projects.by_groups_or_owner(groups, current_user)
|
projects = projects.by_owners(groups, owners)
|
||||||
elsif groups.present?
|
|
||||||
projects = projects.where(:groups => {:id => groups}).joins(:groups)
|
|
||||||
elsif user_owner
|
|
||||||
projects = projects.where(:owner_id => current_user, :owner_type => 'User')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
projects = projects.search(params[:sSearch]).search_order if params[:sSearch].present?
|
projects = projects.search(params[:sSearch]).search_order if params[:sSearch].present?
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
module ProjectsHelper
|
module ProjectsHelper
|
||||||
|
def options_for_filters(all_projects, groups, owners)
|
||||||
|
(groups + owners).map do |o|
|
||||||
|
class_name = o.class.name
|
||||||
|
{
|
||||||
|
:id => "#{class_name.downcase}-#{o.id}",
|
||||||
|
:color => '464646',
|
||||||
|
:selected => false,
|
||||||
|
:check_box_name => class_name.downcase.pluralize,
|
||||||
|
:check_box_value => o.id,
|
||||||
|
:name => o.uname,
|
||||||
|
:count => all_projects.where(:owner_id => o, :owner_type => class_name).count
|
||||||
|
}
|
||||||
|
end.sort_by{ |f| f[:name] }
|
||||||
|
end
|
||||||
|
|
||||||
def git_repo_url(name)
|
def git_repo_url(name)
|
||||||
if current_user
|
if current_user
|
||||||
"#{request.protocol}#{current_user.uname}@#{request.host_with_port}/#{name}.git"
|
"#{request.protocol}#{current_user.uname}@#{request.host_with_port}/#{name}.git"
|
||||||
|
|
|
@ -49,9 +49,8 @@ class Project < ActiveRecord::Base
|
||||||
WHERE (ptr.repository_id = #{ repository_id })
|
WHERE (ptr.repository_id = #{ repository_id })
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
scope :by_groups_or_owner, lambda { |group_ids, owner_id|
|
scope :by_owners, lambda { |group_owner_ids, user_owner_ids|
|
||||||
where("(relations.actor_id IN (?) AND relations.actor_type = 'Group') OR (projects.owner_id = ? AND projects.owner_type = 'User')", group_ids, owner_id).
|
where("(projects.owner_id in (?) AND projects.owner_type = 'Group') OR (projects.owner_id in (?) AND projects.owner_type = 'User')", group_owner_ids, user_owner_ids)
|
||||||
joins(:relations)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,25 +3,9 @@
|
||||||
=form_tag projects_path, :id => 'filter_projects', :method => :get do
|
=form_tag projects_path, :id => 'filter_projects', :method => :get do
|
||||||
.bordered.bpadding20
|
.bordered.bpadding20
|
||||||
=tracker_search_field(:search, t('layout.find_project'))
|
=tracker_search_field(:search, t('layout.find_project'))
|
||||||
|
= link_to t('layout.projects.new'), new_project_path, :class => 'button' if can?(:create, Project)
|
||||||
|
|
||||||
.bordered.bpadding20
|
.bordered.bpadding20
|
||||||
=render 'projects/shared/filter_label',
|
%h3=t('layout.relations.filters')
|
||||||
:id => 'user-owner',
|
- options_for_filters(@all_projects, @groups, @owners).each do |options|
|
||||||
:selected => @user_owner,
|
=render 'projects/shared/filter_label', options
|
||||||
:color => '00a651',
|
|
||||||
:check_box_name => 'user_owner',
|
|
||||||
:check_box_value => 'true',
|
|
||||||
:name => t("layout.relations.my"),
|
|
||||||
:count => current_user.own_projects.count
|
|
||||||
|
|
||||||
.bordered.bpadding20
|
|
||||||
%h3=t('layout.groups.list_header')
|
|
||||||
- current_user.groups.each do |group|
|
|
||||||
=render 'projects/shared/filter_label',
|
|
||||||
:id => "group-#{group.id}",
|
|
||||||
:selected => @groups.include?(group.id.to_s),
|
|
||||||
:color => '00a651',
|
|
||||||
:check_box_name => 'groups',
|
|
||||||
:check_box_value => group.id,
|
|
||||||
:name => group.uname,
|
|
||||||
:count => group.projects.count
|
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
-set_meta_tags :title => t('layout.projects.list_header')
|
-set_meta_tags :title => t('layout.projects.list_header')
|
||||||
-render 'filters'
|
-render 'filters'
|
||||||
.toolbar
|
.toolbar
|
||||||
= link_to t('layout.projects.new'), new_project_path, :class => 'button' if can?(:create, Project)
|
|
||||||
|
|
||||||
.legend.rights
|
|
||||||
%div
|
|
||||||
%span.user_owner= t("layout.relations.user_owner")
|
%span.user_owner= t("layout.relations.user_owner")
|
||||||
%span.group_owner= t("layout.relations.group_owner")
|
%span.group_owner= t("layout.relations.group_owner")
|
||||||
%div
|
|
||||||
%span.user= t("layout.relations.user")
|
%span.user= t("layout.relations.user")
|
||||||
%span.group= t("layout.relations.group")
|
%span.group= t("layout.relations.group")
|
||||||
.both
|
.both
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
en:
|
en:
|
||||||
layout:
|
layout:
|
||||||
relations:
|
relations:
|
||||||
my: My
|
filters: Filters
|
||||||
user_owner: I'm owner
|
user_owner: I'm owner
|
||||||
group_owner: I'm member of owner group
|
group_owner: I'm member of owner group
|
||||||
user: I'm collaborator
|
user: I'm collaborator
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
ru:
|
ru:
|
||||||
layout:
|
layout:
|
||||||
relations:
|
relations:
|
||||||
my: Мои
|
filters: Фильтры
|
||||||
user_owner: Я - владелец
|
user_owner: Я - владелец
|
||||||
group_owner: Я состою в группе-владельцев
|
group_owner: Я состою в группе-владельце
|
||||||
user: Я - участник
|
user: Я - участник
|
||||||
group: Я состою в группе-участников
|
group: Я состою в группе-участнике
|
||||||
|
|
Loading…
Reference in New Issue