Commit 6eb045fc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Prevent Project.all & User.all in selectboxes

parent af297bd09b2c
......@@ -10,6 +10,10 @@
.ajax-users-select {
width: 400px;
&.input-large {
width: 210px;
}
}
.user-result {
......
......@@ -2,8 +2,10 @@ class Admin::ProjectsController < Admin::ApplicationController
before_filter :project, only: [:edit, :show, :update, :destroy, :team_update]
def index
@projects = Project.scoped
@projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
owner_id = params[:owner_id]
user = User.find_by_id(owner_id)
@projects = user ? user.owned_projects : Project.scoped
@projects = @projects.where(public: true) if params[:public_only].present?
@projects = @projects.with_push if params[:with_push].present?
@projects = @projects.abandoned if params[:abandoned].present?
......
......@@ -192,9 +192,12 @@ def image_url(source)
alias_method :url_to_image, :image_url
def users_select_tag(id, opts = {})
css_class = "ajax-users-select"
css_class << " multiselect" if opts[:multiple]
hidden_field_tag(id, '', class: css_class)
css_class = "ajax-users-select "
css_class << "multiselect " if opts[:multiple]
css_class << opts[:class] || ''
value = opts[:selected] || ''
hidden_field_tag(id, value, class: css_class)
end
def body_data_page
......
module NamespacesHelper
def namespaces_options(selected = :current_user, scope = :default)
if current_user.admin
groups = Group.all
users = Namespace.root
else
groups = current_user.owned_groups.select {|n| n.type == 'Group'}
users = current_user.namespaces.reject {|n| n.type == 'Group'}
end
groups = current_user.owned_groups.select {|n| n.type == 'Group'}
users = current_user.namespaces.reject {|n| n.type == 'Group'}
global_opts = ["Global", [['/', Namespace.global_id]] ]
group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [g.human_name, g.id]} ]
......
......@@ -14,9 +14,9 @@
= text_field_tag :name, params[:name], class: "span2"
.control-group
= label_tag :namespace_id, 'Namespace:', class: 'control-label'
= label_tag :owner_id, 'Owner:', class: 'control-label'
.controls
= select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen span2", prompt: "Any"
= users_select_tag :owner_id, selected: params[:owner_id], class: 'input-large'
.control-group
= label_tag :public_only, 'Public Only', class: 'control-label'
.controls
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment