mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Merge pull request #13404 from cyrillefr/UnsavedChangesMustAppearOnRemovingSingleTagFromOrderCycle
Fixes Save button does not enable when removing only tag in OC
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
%span.text-normal
|
||||
{{ 'admin.tags' | t }}
|
||||
%br
|
||||
%tags-with-translation.fullwidth{ object: 'object' }
|
||||
%tags-with-translation.fullwidth{ object: 'object', form: 'order_cycle_form', id: 'tags_with_translation'}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
%td.receival-details
|
||||
= text_field_tag 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', '', 'id' => 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', 'placeholder' => t('.receival_instructions_placeholder'), 'ng-model' => 'exchange.receival_instructions'
|
||||
- if type == 'distributor'
|
||||
%td.tags.panel-toggle.text-center{ name: "tags", "ng-if": 'enterprises[exchange.enterprise_id].managed || order_cycle.viewing_as_coordinator' }
|
||||
%td.tags.panel-toggle.text-center{ name: "tags", id: "tags", "ng-if": 'enterprises[exchange.enterprise_id].managed || order_cycle.viewing_as_coordinator' }
|
||||
{{ exchange.tags.length }}
|
||||
%td.collection-details
|
||||
= text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', '', 'ng-init' => 'setPickupTimeFieldDirty($index, exchange.pickup_time)', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', 'required' => 'required', 'placeholder' => t('.pickup_time_placeholder'), 'ng-model' => 'exchange.pickup_time', 'ng-disabled' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator', 'maxlength' => 35
|
||||
@@ -36,5 +36,5 @@
|
||||
- if type == 'distributor'
|
||||
%tr.panel-row{ object: "exchange",
|
||||
panels: "{products: 'exchange_products_distributed', tags: 'exchange_tags'}",
|
||||
locals: "$index,exchangeTotalVariants,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading",
|
||||
locals: "$index,exchangeTotalVariants,order_cycle,exchange,enterprises,setExchangeVariants,incomingExchangeVariantsFor,variantSuppliedToOrderCycle,initializeExchangeProductsPanel,loadMoreExchangeProducts,loadAllExchangeProducts,productsLoading,order_cycle_form",
|
||||
colspan: 5 }
|
||||
|
||||
46
spec/system/admin/order_cycles/tags_spec.rb
Normal file
46
spec/system/admin/order_cycles/tags_spec.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'system_helper'
|
||||
|
||||
RSpec.describe '
|
||||
As an administrator
|
||||
I want to manage order cycle tags
|
||||
' do
|
||||
include AdminHelper
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
|
||||
it "adds and removes a tag under outgoing products" do
|
||||
c = create(:distributor_enterprise, is_primary_producer: true)
|
||||
|
||||
# OC with a mono-enterprise outgoing exchange
|
||||
oc_outgoing = create(:simple_order_cycle, coordinator: c, distributors: [c])
|
||||
|
||||
login_as_admin
|
||||
visit admin_order_cycle_outgoing_path(oc_outgoing)
|
||||
expect(page).to have_button "Save", disabled: true
|
||||
find("#tags").click
|
||||
# add one tag
|
||||
find("#tags_with_translation").fill_in with: "Tag 1"
|
||||
|
||||
expect(page).to have_content('You have unsaved changes')
|
||||
expect(page).to have_button "Save", disabled: false
|
||||
click_on "Save"
|
||||
expect(page).to have_content('Your order cycle has been updated')
|
||||
|
||||
page.refresh
|
||||
find("#tags").click
|
||||
|
||||
within(".tags .tag-list") do
|
||||
expect(page).to have_content 'tag-1'
|
||||
end
|
||||
|
||||
# There is only one tag here so first and only tag is correct target
|
||||
# Important to test use case with only one tag as there was a bug with
|
||||
# this scenario. For future specs, add some other test cases but this
|
||||
# one should not be removed/replaced
|
||||
find('.remove-button').click
|
||||
expect(page).to have_content('You have unsaved changes')
|
||||
expect(page).to have_button "Save", disabled: false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user