Skip to content

Commit

Permalink
Merge pull request #2034 from jhawthorn/replace_select2
Browse files Browse the repository at this point in the history
Replace select2 with <select class="custom-select">
  • Loading branch information
gmacdougall authored Jun 28, 2017
2 parents 90d69f5 + 3cb19c7 commit 55a72e7
Show file tree
Hide file tree
Showing 60 changed files with 111 additions and 129 deletions.
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/adjustments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="col-3">
<%= f.field_container :label do %>
<%= f.label :adjustment_reason_id %><br/>
<%= f.collection_select(:adjustment_reason_id, reasons_for(@adjustment), :id, :name, {include_blank: true}, {"data-placeholder" => Spree.t(:select_a_reason), class: 'select2 fullwidth'}) %>
<%= f.collection_select(:adjustment_reason_id, reasons_for(@adjustment), :id, :name, {include_blank: true}, {"data-placeholder" => Spree.t(:select_a_reason), class: 'custom-select fullwidth'}) %>
<% end %>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
<%= item_fields.check_box :resellable, { checked: return_item.resellable } %>
</td>
<td class="align-center">
<%= item_fields.select :reception_status_event, return_item.potential_reception_transitions, {include_blank: true}, {class: 'add-item select2 fullwidth'} %>
<%= item_fields.select :reception_status_event, return_item.potential_reception_transitions, {include_blank: true}, {class: 'add-item custom-select fullwidth'} %>
</td>
<td class="align-center">
<%= item_fields.select :return_reason_id, @reasons.collect{|r|[r.name, r.id]}, {include_blank: true}, {class: 'select2 fullwidth'} %>
<%= item_fields.select :return_reason_id, @reasons.collect{|r|[r.name, r.id]}, {include_blank: true}, {class: 'custom-select fullwidth'} %>
</td>
</tr>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<%= f.field_container :stock_location do %>
<%= f.label :stock_location_id, Spree::StockLocation.model_name.human %>
<%= f.select :stock_location_id, Spree::StockLocation.order_default.to_a.collect{|l|[l.name, l.id]}, {include_blank: true}, {class: 'select2 fullwidth', "data-placeholder" => Spree.t(:select_a_stock_location)} %>
<%= f.select :stock_location_id, Spree::StockLocation.order_default.to_a.collect{|l|[l.name, l.id]}, {include_blank: true}, {class: 'custom-select fullwidth', "data-placeholder" => Spree.t(:select_a_stock_location)} %>
<%= f.error_message_on :stock_location_id %>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/images/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div data-hook="variant" class="field">
<%= f.label :viewable_id, Spree::Variant.model_name.human %><br>
<%= f.select :viewable_id, @variants, {}, { class: 'select2 fullwidth' } %>
<%= f.select :viewable_id, @variants, {}, { class: 'custom-select fullwidth' } %>
</div>
</div>
<div data-hook="alt_text" class="field col-4">
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/orders/_shipment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<%= label_tag 'selected_shipping_rate_id', Spree::ShippingMethod.model_name.human %>
<%= select_tag :selected_shipping_rate_id,
options_for_select(shipment.shipping_rates.map {|sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id),
{class: 'select2 fullwidth', data: {'shipment-number' => shipment.number } } %>
{class: 'custom-select fullwidth', data: {'shipment-number' => shipment.number } } %>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions backend/app/views/spree/admin/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<div class="field">
<%= label_tag :q_state_eq, Spree.t(:status) %>
<%= f.select :state_eq, Spree::Order.state_machines[:state].states.collect {|s| [Spree.t("order_state.#{s.name}"), s.value]}, {include_blank: true}, class: 'select2' %>
<%= f.select :state_eq, Spree::Order.state_machines[:state].states.collect {|s| [Spree.t("order_state.#{s.name}"), s.value]}, {include_blank: true}, class: 'custom-select fullwidth' %>
</div>

<div class="field">
Expand Down Expand Up @@ -85,8 +85,8 @@
<div class="col-12 col-md-6 col-lg-4 col-xl-3">
<% if Spree::Store.count > 1 %>
<div class="field">
<%= label_tag nil, Spree.t(:store) %>
<%= f.select :store_id_eq, Spree::Store.all.map { |s| [s.name, s.id] }, { include_blank: true }, { class: "select2" } %>
<%= label_tag :q_store_id_eq, Spree.t(:store) %>
<%= f.select :store_id_eq, Spree::Store.all.map { |s| [s.name, s.id] }, { include_blank: true }, { class: "custom-select fullwidth" } %>
</div>
<% end %>

Expand Down
8 changes: 4 additions & 4 deletions backend/app/views/spree/admin/payment_methods/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<div class="col-3">
<div id="preference-settings">
<div class="field">
<%= f.label :type %>
<%= collection_select(:payment_method, :type, @providers, :to_s, :name, {}, {id: 'gtwy-type', class: 'select2 fullwidth js-gateway-type'}) %>
<%= label :payment_method, :type %>
<%= collection_select(:payment_method, :type, @providers, :to_s, :name, {}, {class: 'custom-select fullwidth js-gateway-type'}) %>
</div>

<div class="field js-preference-source-wrapper">
<%= f.label :preference_source %>
<%= f.select(:preference_source, [[Spree.t(:preference_source_none), nil]] + @object.class.available_preference_sources, {}, class: 'select2 fullwidth js-preference-source') %>
<%= f.select(:preference_source, [[Spree.t(:preference_source_none), nil]] + @object.class.available_preference_sources, {}, class: 'custom-select fullwidth js-preference-source') %>
</div>

<div class="gateway-settings js-gateway-settings">
Expand All @@ -35,7 +35,7 @@
</div>
<div data-hook="auto_capture" class="field">
<%= f.label :auto_capture %>
<%= select(:payment_method, :auto_capture, [["#{Spree.t(:use_app_default)} (#{Spree::Config[:auto_capture]})", ''], [Spree.t(:say_yes), true], [Spree.t(:say_no), false]], {}, {class: 'select2 fullwidth'}) %>
<%= select(:payment_method, :auto_capture, [["#{Spree.t(:use_app_default)} (#{Spree::Config[:auto_capture]})", ''], [Spree.t(:say_yes), true], [Spree.t(:say_no), false]], {}, {class: 'custom-select fullwidth'}) %>
</div>
<div data-hook="active" class="field">
<%= label_tag nil, Spree::PaymentMethod.human_attribute_name(:active) %>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/prices/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= f.select :variant_id,
@product.variants_including_master.map { |v| [v.descriptive_name, v.id] },
{},
class: "select2 fullwidth", disabled: !f.object.new_record? %>
class: "custom-select fullwidth", disabled: !f.object.new_record? %>
<% end %>
</div>

Expand All @@ -20,7 +20,7 @@
include_blank: t(:any_country, scope: [:spree, :admin, :prices]),
selected: Spree::Config.admin_vat_country_iso
},
{ class: 'select2 fullwidth', disabled: !f.object.new_record? } %>
{ class: 'custom-select fullwidth', disabled: !f.object.new_record? } %>
<% end %>
</div>

Expand Down
6 changes: 3 additions & 3 deletions backend/app/views/spree/admin/prices/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<%= f.select :variant_id_eq,
@product.variants_including_master.map { |v| [v.descriptive_name, v.id] },
{include_blank: true},
class: "select2 fullwidth" %>
class: "custom-select fullwidth" %>
</div>
</div>

Expand All @@ -32,7 +32,7 @@
<%= f.select :currency_eq,
@prices.map(&:currency).uniq,
{include_blank: true},
class: "select2 fullwidth" %>
class: "custom-select fullwidth" %>
</div>
</div>

Expand All @@ -42,7 +42,7 @@
<%= f.select :country_iso_eq,
@prices.map(&:country).compact.uniq.map { |c| [c.name, c.iso]},
{include_blank: true},
class: "select2 fullwidth" %>
class: "custom-select fullwidth" %>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<% @option_types.each do |option_type, option_values| %>
<div class="field">
<%= label :option_type_presentation, option_type.presentation %>
<%= select_tag "ovi[]", options_from_collection_for_select(option_values, :id, :presentation, params[:ovi]), class: 'select2 fullwidth', include_blank: true, id: "#{option_type.name}_option_type_select" %>
<%= select_tag "ovi[]", options_from_collection_for_select(option_values, :id, :presentation, params[:ovi]), class: 'custom-select fullwidth', include_blank: true, id: "#{option_type.name}_option_type_select" %>
</div>
<% end %>
<div class="form-buttons filter-actions actions">
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/products/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<%= f.field_container :shipping_categories do %>
<%= f.label :shipping_category_id, Spree::ShippingCategory.model_name.human %>
<%= f.field_hint :shipping_category %>
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2' }) %>
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'custom-select' }) %>
<%= f.error_message_on :shipping_category %>
<% end %>
</div>
Expand All @@ -130,7 +130,7 @@
<%= f.field_container :tax_category do %>
<%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %>
<%= f.field_hint :tax_category %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2' }) %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'custom-select' }) %>
<%= f.error_message_on :tax_category %>
<% end %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/products/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<%= f.label :shipping_category_id, Spree::ShippingCategory.
model_name.human, class: 'required' %>
<%= f.field_hint :shipping_category %><br />
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2 fullwidth' }) %>
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'custom-select fullwidth' }) %>
<%= f.error_message_on :shipping_category_id %>
<% end %>
</div>
Expand All @@ -56,7 +56,7 @@
<%= f.field_container :tax_category do %>
<%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %>
<%= f.field_hint :tax_category %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2 fullwidth' }) %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'custom-select fullwidth' }) %>
<%= f.error_message_on :tax_category %>
<% end %>
</div>
Expand Down
3 changes: 0 additions & 3 deletions backend/app/views/spree/admin/products/new.js.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
$("#new_product_wrapper").html('<%= escape_javascript(render template: "spree/admin/products/new", formats: [:html], handlers: [:erb]) %>');
handle_date_picker_fields();
<% unless Rails.env.test? %>
$('select.select2').select2();
<% end %>
$("#table-filter").hide();
$("#admin_new_product").parent().hide();
2 changes: 0 additions & 2 deletions backend/app/views/spree/admin/promotion_actions/create.js.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
$('#actions').append('<%= escape_javascript( render(partial: 'spree/admin/promotions/promotion_action', object: @promotion_action) ) %>');
$('#actions .no-objects-found').hide();
$(".variant_autocomplete").variantAutocomplete();
//enable select2 functions for recently added box
$('select.type-select.select2').last().select2();

initPromotionActions();

Expand Down
8 changes: 0 additions & 8 deletions backend/app/views/spree/admin/promotion_rules/create.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@ $('.product_picker').productAutocomplete();
$('.user_picker').userAutocomplete();
$('.taxon_picker').taxonAutocomplete();

$('select.select2').select2({
allowClear: true,
dropdownAutoWidth: true,
minimumResultsForSearch: 8
});

$('#promotion_rule_type').html('<%= escape_javascript options_for_promotion_rule_types(@promotion) %>');
$('#promotion_rule_type').select2();

2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if can?(:update, @promotion) %>
<div class="field">
<%= label_tag :action_type, Spree.t(:add_action_of_type)%>
<%= select_tag 'action_type', options, class: 'select2 fullwidth' %>
<%= select_tag 'action_type', options, class: 'custom-select fullwidth' %>
</div>
<div class="filter-actions actions">
<%= button Spree.t('actions.add') %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<%= f.field_container :category do %>
<%= f.label :promotion_category_id, Spree::PromotionCategory.model_name.human %><br />
<%= f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2 fullwidth' }) %>
<%= f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'custom-select fullwidth' }) %>
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_rules.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if can?(:update, @promotion) %>
<div class="field">
<%= label_tag :promotion_rule_type, Spree.t(:add_rule_of_type) %>
<%= select_tag('promotion_rule[type]', options_for_promotion_rule_types(@promotion), class: 'select2 fullwidth') %>
<%= select_tag('promotion_rule[type]', options_for_promotion_rule_types(@promotion), class: 'custom-select fullwidth') %>
</div>
<div class="filter-actions actions">
<%= button Spree.t('actions.add') %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= label_tag field_name, Spree::Calculator.model_name.human %>
<%= select_tag field_name,
options_from_collection_for_select(calculators, :to_s, :description, promotion_action.calculator.type),
class: 'type-select js-calculator-type select2 fullwidth' %>
class: 'type-select js-calculator-type custom-select fullwidth' %>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Money::Currency.all,
calculator.preferred_currency || Spree::Config[:currency]
),
{ class: 'select2 fullwidth' }
{ class: 'custom-select fullwidth' }
) %>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Money::Currency.all,
calculator.preferred_currency || Spree::Config[:currency]
),
{ class: 'select2 fullwidth' }
{ class: 'custom-select fullwidth' }
) %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<div class="col-3">
<div class="field">
<%= label_tag :q_promotion_category_id_eq, Spree::PromotionCategory.model_name.human %><br>
<%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { include_blank: Spree.t('match_choices.all') }, { class: 'select2 fullwidth' }) %>
<%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { include_blank: Spree.t('match_choices.all') }, { class: 'custom-select fullwidth' }) %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="row">
<div class="col-6">
<div class="field">
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(Spree::Promotion::Rules::ItemTotal::OPERATORS.map{|o| [Spree.t("item_total_rule.operators.#{o}"),o]}, promotion_rule.preferred_operator), {class: 'select2 select_item_total fullwidth'} %>
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(Spree::Promotion::Rules::ItemTotal::OPERATORS.map{|o| [Spree.t("item_total_rule.operators.#{o}"),o]}, promotion_rule.preferred_operator), {class: 'custom-select select_item_total fullwidth'} %>
</div>
</div>
<div class="col-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="col-12">
<div class="field">
<label>
<%= Spree.t('product_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::Product::MATCH_POLICIES.map{|s| [Spree.t("product_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), {class: 'select_product select2'})).html_safe %>
<%= Spree.t('product_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::Product::MATCH_POLICIES.map{|s| [Spree.t("product_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), {class: 'select_product custom-select'})).html_safe %>
</label>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="col-12">
<div class="field">
<label>
<%= Spree.t('taxon_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::Taxon::MATCH_POLICIES.map{|s| [Spree.t("taxon_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), {class: 'select_taxon select2'})).html_safe %>
<%= Spree.t('taxon_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::Taxon::MATCH_POLICIES.map{|s| [Spree.t("taxon_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), {class: 'select_taxon custom-select'})).html_safe %>
</label>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<%= select_tag "#{param_prefix}[preferred_role_ids]",
options_from_collection_for_select(
Spree::Role.all, :id, :name, promotion_rule.preferred_role_ids
), class: 'select2 fullwidth', multiple: true %>
), class: 'custom-select fullwidth', multiple: true %>
</div>
<div class="field alpha omega eight columns">
<label>
<%= Spree.t('user_role_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::UserRole::MATCH_POLICIES.map{ |s| [Spree.t("user_role_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), { class: 'select2'})).html_safe %>
<%= Spree.t('user_role_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::UserRole::MATCH_POLICIES.map{ |s| [Spree.t("user_role_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), { class: 'custom-select'})).html_safe %>
</label>
</div>
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/refunds/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="col-3">
<div class="field">
<%= f.label :refund_reason_id %><br/>
<%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {}, {class: 'select2 fullwidth'}) %>
<%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {}, {class: 'custom-select fullwidth'}) %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/refunds/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="col-3">
<div class="field">
<%= f.label :refund_reason_id %><br/>
<%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {include_blank: true}, {class: 'select2 fullwidth'}) %>
<%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {include_blank: true}, {class: 'custom-select fullwidth'}) %>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/reimbursements/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<%= item_fields.select(:override_reimbursement_type_id,
reimbursement_types.collect { |r| [r.name.humanize, r.id] },
{include_blank: true},
{class: 'select2 fullwidth'}
{class: 'custom-select fullwidth'}
) %>
</td>
<td class="align-center">
Expand All @@ -52,7 +52,7 @@
<% if return_item.exchange_processed? %>
<%= return_item.exchange_variant.exchange_name %>
<% else %>
<%= item_fields.collection_select :exchange_variant_id, return_item.eligible_exchange_variants(@stock_locations), :id, :exchange_name, { include_blank: true }, { class: "select2 fullwidth return-item-exchange-selection" } %>
<%= item_fields.collection_select :exchange_variant_id, return_item.eligible_exchange_variants(@stock_locations), :id, :exchange_name, { include_blank: true }, { class: "custom-select fullwidth return-item-exchange-selection" } %>
<% end %>
</td>
</tr>
Expand Down
Loading

0 comments on commit 55a72e7

Please sign in to comment.