diff --git a/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee b/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee index ef84570f5e..5ab68c43e1 100644 --- a/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee +++ b/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee @@ -3,6 +3,7 @@ angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) -> templateUrl: "admin/tags_input.html" scope: object: "=" + form: "=" tagsAttr: "@?" tagListAttr: "@?" findTags: "&" @@ -18,7 +19,15 @@ angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) -> scope.limitReached = scope.object[scope.tagsAttr].length >= scope.max if scope.max != undefined scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",") + scope.$watch "object", (newObject) -> + scope.object = newObject + init() + $timeout -> + init() + + init = -> + return unless scope.object # Initialize properties if necessary scope.tagsAttr ||= "tags" scope.tagListAttr ||= "tag_list" diff --git a/app/views/admin/order_cycles/_simple_form.html.haml b/app/views/admin/order_cycles/_simple_form.html.haml index 3c828d7777..8b8ac6f200 100644 --- a/app/views/admin/order_cycles/_simple_form.html.haml +++ b/app/views/admin/order_cycles/_simple_form.html.haml @@ -19,6 +19,10 @@ %tr.products %td{ ng: { include: "'admin/panels/exchange_products_simple.html'" } } +%br += label_tag t('.tags') +%tags-with-translation{ object: 'order_cycle.outgoing_exchanges[0]', form: 'order_cycle_form' } + %br/ = label_tag t('.fees') = render 'coordinator_fees', f: f diff --git a/config/locales/en.yml b/config/locales/en.yml index d7a2282288..80b27b4a2f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1219,6 +1219,7 @@ en: customer_instructions_placeholder: Pick-up or delivery notes products: Products fees: Fees + tags: Tags destroy_errors: orders_present: That order cycle has been selected by a customer and cannot be deleted. To prevent customers from accessing it, please close it instead. schedule_present: That order cycle is linked to a schedule and cannot be deleted. Please unlink or delete the schedule first. diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index c3c84f18e5..7f275f493d 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -635,6 +635,13 @@ describe ' check "order_cycle_incoming_exchange_0_variants_#{v3.id}" uncheck "order_cycle_incoming_exchange_0_variants_#{v3.id}" + # Add tags + expect(page).to have_content "TAGS" + + within "tags-with-translation" do + find(:css, "tags-input .tags input").set "wholesale\n" + end + # And I select some fees and update click_link 'order_cycle_coordinator_fee_0_remove' expect(page).not_to have_select 'order_cycle_coordinator_fee_0_id' @@ -669,6 +676,9 @@ describe ' ex = oc.exchanges.outgoing.first expect(ex.pickup_time).to eq('xy') expect(ex.pickup_instructions).to eq('yyz') + + # And it should have the tags + expect(ex.tag_list).to eq ['wholesale'] end end