Merge pull request #9356 from jibees/9248-add-tags-to-a-producer-only-order-cycle

Add tags to producer-only order cycle interface
This commit is contained in:
Filipe
2022-07-07 23:45:02 +01:00
committed by GitHub
4 changed files with 24 additions and 0 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -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.

View File

@@ -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