port to rails3

Conflicts:
	Gemfile.lock
pull/82/head
jwollert 12 years ago
parent a3e01cede1
commit 1c1a464f96
  1. 5
      app/assets/javascripts/members_select_boxes.js
  2. 2
      app/assets/stylesheets/default/application.css.erb
  3. 2
      app/assets/stylesheets/select2_customizing.css.erb
  4. 4
      app/controllers/members_controller.rb
  5. 4
      app/controllers/roles_controller.rb
  6. 3
      app/models/principal.rb
  7. 8
      app/models/role.rb
  8. 9
      app/views/members/_autocomplete_for_member.html.erb
  9. 2
      app/views/members/_member_form.html.erb
  10. 9
      app/views/members/_member_form_impaired.html.erb
  11. 7
      app/views/members/_member_form_non_impaired.html.erb
  12. 12
      app/views/members/autocomplete_for_member.json.erb
  13. 14
      app/views/roles/autocomplete_for_role.json.erb

@ -42,15 +42,14 @@ jQuery(document).ready(function($) {
minimumInputLength: 1,
ajax: {
url: $(fakeInput).attr("data-ajaxURL"),
dataType: 'json',
quietMillis: 500,
contentType: "application/json",
dataType: 'json',
data: function (term, page) {
return {
q: term, //search term
page_limit: 10, // page size
page: page, // current page number
id: fakeInput.attr("data-projectId") // current project id
project_id: fakeInput.attr("data-projectId") // current project id
};
},
results: function (data, page) {

@ -566,8 +566,6 @@ div#tab-content-members fieldset legend,
div#tab-content-memberships fieldset legend,
div#tab-content-users fieldset legend { font-weight: bold; }
div#tab-content-members .user.status_registered, div#tab-content-members label.status_registered { filter: alpha(opacity=80); -khtml-opacity: 0.8; opacity: 0.8; -moz-opacity: 0.8; }
div#tab-content-members .principals label,
div#tab-content-members .roles label { display: block; }
table.members td.group { padding-left: 20px; background: url(<%= asset_path 'group.png' %>) no-repeat 0% 50%; }

@ -33,7 +33,7 @@
}
/* Indirectly styling size of result list */
.select2-container.select2-select {
.select2-container {
position: static;
max-width: 350px;
width:100%;

@ -96,7 +96,7 @@ JS
if page
page = page.to_i
@principals = Principal.paginate_scope!(Principal.search_scope_without_project(@project, params[:q]).scope(:find),
@principals = Principal.paginate_scope!(Principal.search_scope_without_project(@project, params[:q]),
{ :page => page, :page_limit => size })
# we always get all the items on a page, so just check if we just got the last
@more = @principals.total_pages > page
@ -106,7 +106,7 @@ JS
end
respond_to do |format|
format.json { render :layout => false }
format.json
format.html {
if request.xhr?
partial = "members/autocomplete_for_member"

@ -97,13 +97,13 @@ class RolesController < ApplicationController
size = params[:page_limit].to_i
page = params[:page].to_i
@roles = Role.paginated_search(params[:q], page, { :page_limit => size })
@roles = Role.paginated_search(params[:q], { :page => page, :page_limit => size })
# we always get all the items on a page, so just check if we just got the last
@more = @roles.total_pages > page
@total = @roles.total_entries
respond_to do |format|
format.json { render :layout => false }
format.json
end
end

@ -50,8 +50,7 @@ class Principal < ActiveRecord::Base
def self.paginate_scope!(scope, options = {})
limit = options.fetch(:page_limit) || 10
page = options.fetch(:page) || 1
scope = (scope.respond_to?(:scope) ? scope.scope(:find) : scope)
paginate({ :per_page => limit, :page => page }.merge(scope))
scope.paginate({ :per_page => limit, :page => page })
end
def self.search_scope_without_project(project, query)

@ -20,7 +20,7 @@ class Role < ActiveRecord::Base
compare = 'not' if args.first == true
{ :conditions => "#{compare} builtin = 0" }
}
named_scope :like, lambda { |q|
scope :like, lambda { |q|
s = "%#{q.to_s.strip.downcase}%"
{:conditions => ["LOWER(name) LIKE :s", {:s => s}]
}
@ -151,10 +151,10 @@ class Role < ActiveRecord::Base
end
end
def self.paginated_search(search, page, options = {})
def self.paginated_search(search, options = {})
limit = options.fetch(:page_limit) || 10
registered_scope = givable.like(search).scope(:find)
paginate({ :per_page => limit, :page => page }.merge(registered_scope))
page = options.fetch(:page) || 1
givable.like(search).paginate({ :per_page => limit, :page => page })
end
private

@ -23,9 +23,12 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="roles splitcontentright">
<p><%= l(:label_role_plural) %>:
<% roles.each do |role| %>
<label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %></label>
<% end %></p>
<% roles.each do |role| %>
<div>
<label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %></label>
</div>
<% end %>
</p>
</div>
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>

@ -1,5 +1,3 @@
<%= javascript_include_tag "members_select_boxes.js" %>
<% if User.current.impaired? %>
<% partial = "members/member_form_impaired" %>
<% locals = { :members => @project.member_principals.find(:all, :include => [:roles, :principal, :member_roles]) }%>

@ -1,6 +1,9 @@
<% remote_form_for(:member, members, :url => {:controller => 'members', :action => 'new', :id => project}, :method => :post,
:loading => '$(\'member-add-submit\').disable();',
:complete => 'if($(\'member-add-submit\')) $(\'member-add-submit\').enable();') do |f| %>
<%= form_for(:member,
:url => {:controller => 'members', :action => 'create', :project_id => project},
:method => :post,
:remote => true,
:loading => '$(\'member-add-submit\').disable();',
:complete => 'if($(\'member-add-submit\')) $(\'member-add-submit\').enable();') do |f| %>
<fieldset>
<legend><%=l(:label_member_new)%></legend>
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>

@ -1,4 +1,9 @@
<% remote_form_for(:member, :url => {:controller => 'members', :action => 'new', :id => project}, :method => :post, :html => {:id => "members_add_form"}) do |f| %>
<%= javascript_include_tag "members_select_boxes.js" %>
<%= form_for(:member, :url => {:controller => 'members', :action => 'create', :project_id => project},
:remote => true,
:method => :post,
:html => {:id => "members_add_form"}) do |f| %>
<fieldset>
<legend><%= l(:label_member_new) %></legend>
<div class="splitcontentleft">

@ -1,8 +1,14 @@
{
"results":
{
"items": <%= @principals.collect {|item| { :id => item.id, :name => item.name } }.to_json %>,
"total": <%= @total ? @total.to_json : @principals.size.to_json %>,
"more": <%= @more ? @more.to_json : 0.to_json %>
"items":[
<% @principals.each_with_index do |principal, ix| %>
{
"id": <%= principal.id.to_json.html_safe %>,
"name": <%= principal.name.to_json.html_safe %>
} <%= "," unless ix == @principals.length - 1 %>
<% end %> ],
"total": <%= @total ? @total : @principals.size %>,
"more": <%= @more ? @more : 0 %>
}
}

@ -1,8 +1,14 @@
{
"results":
{
"items": <%= @roles.collect {|item| { :id => item.id, :name => item.name } }.to_json %>,
"total": <%= @total.to_json %>,
"more": <%= @more.to_json %>
"items":[
<% @roles.each_with_index do |role, ix| %>
{
"id": <%= role.id.to_json.html_safe %>,
"name": <%= role.name.to_json.html_safe %>
} <%= "," unless ix == @roles.length - 1 %>
<% end %> ],
"total": <%= @total ? @total : @roles.size %>,
"more": <%= @more ? @more : 0 %>
}
}
}

Loading…
Cancel
Save