fix tag plugin
This commit is contained in:
parent
d54a8428d3
commit
0aaaefeba2
9 changed files with 363 additions and 14 deletions
|
|
@ -22,7 +22,6 @@ class ConversationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
params[:contact_ids] = params[:as_values_contact_ids]
|
|
||||||
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map! do |contact|
|
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map! do |contact|
|
||||||
contact.person_id
|
contact.person_id
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ProfilesController < ApplicationController
|
||||||
def update
|
def update
|
||||||
# upload and set new profile photo
|
# upload and set new profile photo
|
||||||
params[:profile] ||= {}
|
params[:profile] ||= {}
|
||||||
params[:profile][:tag_string] = (params[:as_values_tags]) ? params[:as_values_tags].gsub(',',' ') : ""
|
params[:profile][:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : ""
|
||||||
params[:profile][:searchable] ||= false
|
params[:profile][:searchable] ||= false
|
||||||
params[:profile][:photo] = Photo.where(:author_id => current_user.person.id,
|
params[:profile][:photo] = Photo.where(:author_id => current_user.person.id,
|
||||||
:id => params[:photo_id]).first if params[:photo_id]
|
:id => params[:photo_id]).first if params[:photo_id]
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,17 @@ class TagsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:q].gsub!("#", "")
|
params[:q].gsub!("#", "")
|
||||||
|
params[:limit] = !params[:limit].blank? ? params[:limit].to_i : 10
|
||||||
if params[:q].length > 1
|
if params[:q].length > 1
|
||||||
@tags = ActsAsTaggableOn::Tag.named_like(params[:q]).limit(params[:limit] || 10)
|
@tags = ActsAsTaggableOn::Tag.named_like(params[:q]).limit(params[:limit] - 1)
|
||||||
@array = []
|
@array = []
|
||||||
@tags.each do |obj|
|
@tags.each do |obj|
|
||||||
@array << { :name => ("#"+obj.name),
|
@array << { :name => ("#"+obj.name),
|
||||||
:value => ("#"+obj.name)}
|
:value => ("#"+obj.name)}
|
||||||
end
|
end
|
||||||
|
|
||||||
if @array.empty?
|
@array << { :name => ('#' + params[:q]), :value => ("#" + params[:q])}
|
||||||
@array << { :name => params[:q],
|
@array.uniq!
|
||||||
:value => ("#"+params[:q])}
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json{
|
format.json{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
minChars: 3,
|
minChars: 3,
|
||||||
keyDelay: 0,
|
keyDelay: 0,
|
||||||
startText: '',
|
startText: '',
|
||||||
emptyText: '#{t('.no_results')}',
|
emptyText: '#{t('no_results')}',
|
||||||
preFill: [{ 'name' : "#{params[:name]}",
|
preFill: [{ 'name' : "#{params[:name]}",
|
||||||
'value' : "#{params[:contact_id]}"}]
|
'value' : "#{params[:contact_id]}"}]
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@
|
||||||
minChars: 2,
|
minChars: 2,
|
||||||
keyDelay: 0,
|
keyDelay: 0,
|
||||||
startText: "#{t('profiles.edit.your_tags_placeholder')}",
|
startText: "#{t('profiles.edit.your_tags_placeholder')}",
|
||||||
emptyText: '#{t('.no_results')}',
|
emptyText: '#{t('no_results')}',
|
||||||
preFill: data
|
preFill: data
|
||||||
});
|
});
|
||||||
|
|
||||||
autocompleteInput.bind('keydown', function(evt){
|
autocompleteInput.bind('keydown', function(evt){
|
||||||
if(evt.keyCode == 13 || evt.keyCode == 32){
|
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
|
||||||
if( $('li.as-result-item.active').length == 0 ){
|
if( $('li.as-result-item.active').length == 0 ){
|
||||||
$('li.as-result-item').first().click();
|
$('li.as-result-item').first().click();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ en:
|
||||||
previous: "previous"
|
previous: "previous"
|
||||||
_comments: "Comments"
|
_comments: "Comments"
|
||||||
all_aspects: "All Aspects"
|
all_aspects: "All Aspects"
|
||||||
|
no_results: "No Results Found"
|
||||||
|
|
||||||
|
|
||||||
#for reference translation, the real activerecord english transations are actually
|
#for reference translation, the real activerecord english transations are actually
|
||||||
|
|
@ -192,7 +193,6 @@ en:
|
||||||
to: "to"
|
to: "to"
|
||||||
subject: "subject"
|
subject: "subject"
|
||||||
send: "Send"
|
send: "Send"
|
||||||
no_results: "No Results Found"
|
|
||||||
helper:
|
helper:
|
||||||
new_messages:
|
new_messages:
|
||||||
zero: "no new messages"
|
zero: "no new messages"
|
||||||
|
|
|
||||||
353
public/javascripts/vendor/jquery.autoSuggest.js
vendored
353
public/javascripts/vendor/jquery.autoSuggest.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -46,7 +46,7 @@ describe ConversationsController do
|
||||||
:conversation => {
|
:conversation => {
|
||||||
:subject => "secret stuff",
|
:subject => "secret stuff",
|
||||||
:text => 'text'},
|
:text => 'text'},
|
||||||
:as_values_contact_ids => [@alice.contacts.first.id]
|
:contact_ids => [@alice.contacts.first.id]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ describe ProfilesController do
|
||||||
|
|
||||||
it 'sets tags' do
|
it 'sets tags' do
|
||||||
params = { :id => @user.person.id,
|
params = { :id => @user.person.id,
|
||||||
:as_values_tags => '#apples #oranges'}
|
:tags => '#apples #oranges'}
|
||||||
|
|
||||||
put :update, params
|
put :update, params
|
||||||
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set
|
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue