[refs #194] show all project labels without searching

This commit is contained in:
Alexander Machehin 2012-03-07 19:36:17 +06:00
parent 9a6beef2da
commit c657efc338
6 changed files with 28 additions and 41 deletions

View File

@ -171,14 +171,13 @@ $(document).ready(function() {
var clone = $(this).clone();
form_new.find('#flag-span').fadeOut(0);
form_new.find('#issue_labels').append(clone);
var labels = $('.current_labels');
labels.find('#'+$(this).attr('id')).remove();
labels.append(clone);
var labels = $('.manage_labels');
labels.append($(this).find('#'+$(this).attr('id')));
});
$('.remove_label.label.selected').live('click', function() {
var id = $(this).attr('id');
$('.current_labels, #active_labels').find('#'+id+'.label.selected.remove_label').remove();
$('.manage_labels, #active_labels').find('#'+id+'.label.selected.remove_label').remove();
var form = $('.form.issue');
if(form.find('.remove_label.label.selected').length == 1) {
form.find('#flag-span').fadeIn(0);
@ -189,6 +188,7 @@ $(document).ready(function() {
label.removeClass('selected').addClass('add_label').removeClass('remove_label');
label.find('.labeltext.selected').attr('style', '').removeClass('selected');
label.find('.flag').fadeIn(0);
$('.manage_labels').find('#'+$(this).attr('id')).remove();
});
$('.issue_status.switch_issue_status').live('click', function () {
@ -249,7 +249,8 @@ $(document).ready(function() {
$('.button.manage_labels').live('click', function() {
$('form#search_labels, .button.update_labels').fadeIn(0);
$('.current_labels .label').addClass('remove_label selected').removeClass('nopointer');
$('.current_labels .label .labeltext.selected').parent().addClass('remove_label selected').removeClass('nopointer');
$('.current_labels .label .labeltext:not(.selected)').parent().addClass('add_label').removeClass('nopointer');
$(this).fadeOut(0);
});

View File

@ -102,11 +102,6 @@ class IssuesController < ApplicationController
render 'issues/_search_collaborators', :layout => false
end
def search_labels
@labels = @project.labels.where("labels.name ILIKE ?", "%#{params[:search_labels]}%").order('labels.name').limit(10)
render 'issues/_search_labels', :layout => false
end
private
def load_and_authorize_label

View File

@ -6,4 +6,5 @@ class Label < ActiveRecord::Base
validates :name, :uniqueness => { :scope => :project_id}
validates :name, :color, :presence => true
validates :color, :format => { :with => /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, :message => I18n.t('layout.issues.invalid_labels')}
end

View File

@ -23,7 +23,7 @@
.both
- else
.people.nopointer
.avatar=image_tag(@issue.user.avatar(25), :alt => 'avatar')
.avatar=image_tag avatar_url(@issue.user), :alt => 'avatar'
.name="#{@issue.user.uname} (#{@issue.user.name})"
.both
=link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_executor") if can_manage
@ -36,26 +36,23 @@
.block
%h3=t('layout.issues.labels')
- if @issue.persisted?
- if can_manage
=form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_labels issue'} do |f|
.current_labels
- (@issue.labels || []).each do |label|
.label.nopointer{:id => "flag#{label.id}"}
.flag{:style => "display:none; background: ##{label.color}"}
.labeltext.selected{:style => "background: ##{label.color}"}=label.name
=hidden_field_tag "label-#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]"
.both
- (@project.labels || []).each do |label|
- is_issue_label = @issue.labels.include? label
.label{:id => "flag#{label.id}", :class => @issue.persisted? ? 'nopointer' : 'add_label'}
.flag{:style => "background: ##{label.color}; #{is_issue_label ? 'display:none;' : ''}"}
.labeltext{:class => is_issue_label ? 'selected' : '', :style => is_issue_label ? "background: ##{label.color}" : ''}=label.name
.both=hidden_field_tag "flag#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]"
=form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_labels issue'} do |f|
.manage_labels
- @issue.labels.each do |label|
=hidden_field_tag "flag#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]"
- else
- (@issue.labels || []).each do |label|
.label.nopointer
.labeltext.selected{:style => "background: ##{label.color};"}
=label.name
.labeltext.selected{:style => "background: ##{label.color};"}=label.name
.both
=link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_labels") if can_manage
- if can_manage
=form_tag search_labels_project_issues_path(@project), :id => 'search_labels', :method => :get, :style => @issue.persisted? ? 'display:none' : '' do
=tracker_search_field(:search_labels, t('layout.issues.search_labels'))
#manage_issue_labels_list
=render 'issues/search_labels'
=link_to(t('layout.issues.done'), '#', :class => "button tmargin10 update_labels", :style => 'display:none') if can_manage
- if can_manage && @issue.persisted?
=link_to(t('layout.issues.label_manage'), '#', :class => "button tmargin10 manage_labels")
=link_to(t('layout.issues.done'), '#', :class => "button tmargin10 update_labels", :style => 'display:none')

View File

@ -1,6 +0,0 @@
- (@labels || []).each do |label|
.add_label.label{:id => "flag#{label.id}"}
.flag{:style => "background: ##{label.color};"}
.labeltext=label.name
=hidden_field_tag "label-#{label.id}", label.id, :name => "issue[labelings_attributes][#{label.id}][label_id]"
.both

View File

@ -125,7 +125,6 @@ Rosa::Application.routes.draw do
collection do
post :create_label
get :search_collaborators
get :search_labels
end
end
post "labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label