Skip to content

Commit

Permalink
remove chosen plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
swatijadhav committed May 30, 2014
1 parent b8c14ee commit 481d34f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 123 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js.erb
Expand Up @@ -15,8 +15,6 @@
//= require crm_sortable
//= require textarea_autocomplete
//= require crm_textarea_autocomplete
//= require ajax-chosen-jquery
//= require crm_chosen
//= require crm_select2
//= require ransack_ui_jquery
//= require search
Expand Down
14 changes: 6 additions & 8 deletions app/assets/javascripts/crm.js.coffee
Expand Up @@ -92,11 +92,10 @@
# Hide accounts dropdown and show create new account edit field instead.
#----------------------------------------------------------------------------
create_account: ->
crm.makeAjaxChosen()
$("#account_disabled_title").hide()
$("#account_select_title").hide()
$("#account_create_title").show()
$("#account_id_chzn").hide()
$("#s2id_account_id").hide()
$("#account_id").prop('disabled', true)
$("#account_name").prop('disabled', false)
$("#account_name").html ""
Expand All @@ -106,20 +105,19 @@
# Hide create account edit field and show accounts dropdown instead.
#----------------------------------------------------------------------------
select_account: ->
crm.makeAjaxChosen()
$("#account_disabled_title").hide()
$("#account_create_title").hide()
$("#account_select_title").show()
$("#account_name").hide()
$("#account_name").prop('disabled', true)
$("#account_id").prop('disabled', false)
$("#account_id_chzn").show()
$("#account_id").show()
$("#s2id_account_id").show()


# Show accounts dropdown and disable it to prevent changing the account.
#----------------------------------------------------------------------------
select_existing_account: ->
crm.makeAjaxChosen()
$("#account_create_title").hide()
$("#account_select_title").hide()
$("#account_id").hide()
Expand All @@ -130,7 +128,7 @@
# Disable chosen account select
$("#account_id").prop('disabled', true)
$("#account_id").trigger "liszt:updated"
$("#account_id_chzn").show()
$("#s2id_account_id").show()

# Enable hidden account id select so that value is POSTed
$("#account_id").prop('disabled', false)
Expand Down Expand Up @@ -395,12 +393,12 @@
$("#auto_complete_query").val ""
else
window.location.href = @base_url + "/" + controller + "/" + ui.item.value

focus: (event, ui) =>
event.preventDefault()
$("#auto_complete_query").val(ui.item.label)
)

$.extend $.ui.autocomplete::,
_renderItem: (ul, item) ->
term = new RegExp( "(" + @element.val() + ")", "gi" )
Expand Down
29 changes: 0 additions & 29 deletions app/assets/javascripts/crm_chosen.js.coffee

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.css.erb
Expand Up @@ -15,8 +15,6 @@
*= require base
*= require header
*= require common
*= require chosen
*= require ffcrm_chosen
*= require fields
*= require textarea_autocomplete
*= require admin/fields
Expand Down
69 changes: 0 additions & 69 deletions app/assets/stylesheets/ffcrm_chosen.scss

This file was deleted.

12 changes: 6 additions & 6 deletions app/helpers/accounts_helper.rb
Expand Up @@ -27,12 +27,12 @@ def account_summary(account)
#----------------------------------------------------------------------------
def account_select(options = {})
options[:selected] = (@account && @account.id) || 0
accounts = ([@account] + Account.my.order(:name).limit(25)).compact.uniq
collection_select :account, :id, accounts, :id, :name, options,
{:"data-placeholder" => t(:select_an_account),
:"data-url" => auto_complete_accounts_path(format: 'json'),
:style => "width:330px; display:none;",
:class => 'ajax_chosen' }
accounts = ([@account.new_record? ? nil : @account] +
Account.my.order(:name).limit(25)).compact.uniq

collection_select :account, :id, accounts, :id, :name,
{ prompt: t(:select_an_account), include_blank: false },
{ style: "width:330px; display:none;", class: 'select2' }
end

# Select an existing account or create a new one.
Expand Down
10 changes: 4 additions & 6 deletions app/helpers/opportunities_helper.rb
Expand Up @@ -38,11 +38,9 @@ def opportunity_campaign_select(options = {})
options[:selected] ||= @opportunity.campaign_id || 0
selected_campaign = Campaign.find_by_id(options[:selected])
campaigns = ([selected_campaign] + Campaign.my.order(:name).limit(25)).compact.uniq
collection_select :opportunity, :campaign_id, campaigns, :id, :name, options,
{:"data-placeholder" => t(:select_a_campaign),
:"data-url" => auto_complete_campaigns_path(format: 'json'),
:style => "width:330px; display:none;",
:class => 'ajax_chosen' }
end

collection_select :opportunity, :campaign_id, campaigns, :id, :name,
{ selected: options[:selected], prompt: t(:select_a_campaign) },
{ style: "width:330px;", class: 'select2' }
end
end
2 changes: 1 addition & 1 deletion app/views/opportunities/_top_section.html.haml
Expand Up @@ -38,7 +38,7 @@
!= account_select_or_create(a) do |options|
-# Add [-- None --] account choice when editing existing opportunity that has an account.
- options[:selected] = @account.id || 0
- options[:include_blank] = true #t(:select_none) unless @opportunity.new_record? || @opportunity.account.blank?

%td= spacer
%td
.label.req #{t :assigned_to}:
Expand Down

0 comments on commit 481d34f

Please sign in to comment.