diff --git a/promotions/config/locales/en.yml b/promotions/config/locales/en.yml index 06d3f481825..3c4ccfbf135 100644 --- a/promotions/config/locales/en.yml +++ b/promotions/config/locales/en.yml @@ -167,6 +167,10 @@ en: general: General starts_at_placeholder: Immediately codes_present: This promotion has promotion codes defined. You cannot select the apply automatically option. + automatic: "Automatic" + path: "Path" + single_code: "Single code" + multiple_codes: "Multiple codes" edit: order_conditions: Order Conditions calculator: diff --git a/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb b/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb index 7010098e2c1..d29a6266e66 100644 --- a/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb +++ b/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb @@ -1,22 +1,22 @@
<%= batch.label :base_code, class: "required" %> - <%= batch.text_field :base_code, class: "fullwidth", required: true %> + <%= batch.text_field :base_code, class: "fullwidth #{'enable' if promotion.can_change_codes?}", required: true, disabled: disabled %>
<%= batch.label :number_of_codes, class: "required" %> - <%= batch.number_field :number_of_codes, class: "fullwidth", min: 1, required: true %> + <%= batch.number_field :number_of_codes, class: "fullwidth #{'enable' if promotion.can_change_codes?}", min: 1, required: true, disabled: disabled %>
<%= batch.label :join_characters %> - <%= batch.text_field :join_characters, class: "fullwidth" %> + <%= batch.text_field :join_characters, class: "fullwidth #{'enable' if promotion.can_change_codes?}", disabled: disabled %>
<% unless promotion_id %>
<%= f.label :per_code_usage_limit %> - <%= f.text_field :per_code_usage_limit, class: "fullwidth" %> + <%= f.text_field :per_code_usage_limit, class: "fullwidth #{'enable' if promotion.can_change_codes?}", disabled: disabled %>
<% end %>
<%= batch.label :email %> - <%= batch.text_field :email, class: "fullwidth" %> + <%= batch.text_field :email, class: "fullwidth #{'enable' if promotion.can_change_codes?}", disabled: disabled %>
diff --git a/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb b/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb index 6f2aa307018..ed492e26665 100644 --- a/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb +++ b/promotions/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb @@ -3,6 +3,6 @@ <% admin_breadcrumb(plural_resource_name(SolidusPromotions::PromotionCodeBatch)) %> <%= form_for :promotion_code_batch, url: collection_url do |batch| %> <%= batch.hidden_field :promotion_id, value: params[:promotion_id] %> - <%= render partial: 'form_fields', locals: {batch: batch, promotion_id: params[:promotion_id]} %> + <%= render partial: 'form_fields', locals: {batch: batch, promotion: @promotion, disabled: false, promotion_id: params[:promotion_id]} %> <%= batch.submit t('spree.actions.create'), class: 'btn btn-primary' %> <% end %> diff --git a/promotions/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb b/promotions/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb index a752bd8ede6..67892f01c74 100644 --- a/promotions/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb +++ b/promotions/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb @@ -85,40 +85,81 @@ -
+
<%= t '.activation' %> - -
- <%= f.field_container :apply_automatically do %> - <%= f.label :apply_automatically do %> - <%= f.check_box :apply_automatically, disabled: f.object.codes.any? || f.object.path.present? %> - <%= SolidusPromotions::Promotion.human_attribute_name(:apply_automatically) %> - <%= f.field_hint :promo_code_will_be_disabled %> - <% end %> - <% end %> -
- - <% if f.object.new_record? || f.object.present? %> -
- <%= f.field_container :path do %> - <%= f.label :path %> - <%= f.text_field :path, class: "fullwidth", disabled: f.object.apply_automatically || f.object.codes.present? %> - <% end %> +
+
+
- <% end %> - -
- <% if f.object.new_record? %> -
- <%= label_tag :single_code, SolidusPromotions::PromotionCode.model_name.human %> - <%= text_field_tag :single_code, @promotion.codes.first.try!(:value), class: "fullwidth", disabled: f.object.apply_automatically || f.object.path.present? %> +
+
+
+ <%= f.field_container :apply_automatically do %> + <%= f.label :apply_automatically do %> + <%= f.check_box :apply_automatically, {disabled: !f.object.can_change_apply_automatically?, class: "#{'enable' if f.object.can_change_apply_automatically?}"} %> + <%= SolidusPromotions::Promotion.human_attribute_name(:apply_automatically) %> + <%= f.field_hint :promo_code_will_be_disabled %> + <% end %> + <% if f.object.codes.present? %> +
+

+ <%= t('.codes_present') %> +

+
+ <% end %> + <% end %>
- <% else %> -
-

- <%= t('.codes_present') %> -

+
+ <%= f.field_container :path do %> + <%= f.label :path %> + <%= f.text_field :path, class: "fullwidth #{'enable' if f.object.can_change_path?}", disabled: true %> + <% end %>
- <% end %> +
+ <%= f.field_container :single_code do%> + <%= label_tag :single_code, SolidusPromotions::PromotionCode.model_name.human %> + <%= text_field_tag :single_code, @promotion.codes.first.try!(:value), class: "fullwidth #{'enable' if f.object.can_change_codes?}", disabled: true %> + <% end %> +
+
+ <%= fields_for :promotion_code_batch, @promotion.code_batches.new do |batch| %> + <%= render partial: 'solidus_promotions/admin/promotion_code_batches/form_fields', locals: {f: f, batch: batch, promotion: @promotion, disabled: true, promotion_id: params[:promotion_id]} %> + <% end %> +
+
+
+ +