From c335ec3b294ae0aa76dac92040be57a5f704498a Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Fri, 14 May 2021 20:31:04 +0530 Subject: [PATCH 1/4] # This is a combination of 5 commits.tree d6d4f31283e42c44c9c4d116567ce7b1a99a13ab parent b680697af61d67ce8312fcc4ce4d9092fbc78a5e author Nihal Mohammed 1621004464 +0530 committer Nihal Mohammed 1621022463 +0530 # This is a combination of 4 commits. # This is the 1st commit message: Add advanced settings button to incoming and outgoing pages in OC cycle edit # This is the commit message #2: Remove extra header text # This is the commit message #3: Moved repeating code blocks to partial # This is the commit message #4: Refactored code # This is the commit message #5: Delete _advanced_settings_hidden.html.haml --- .../_order_cycle_top_buttons.haml | 19 +++++++++++++++++++ .../admin/order_cycles/incoming.html.haml | 17 +++++++++++++++++ .../admin/order_cycles/outgoing.html.haml | 17 +++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 app/views/admin/order_cycles/_order_cycle_top_buttons.haml diff --git a/app/views/admin/order_cycles/_order_cycle_top_buttons.haml b/app/views/admin/order_cycles/_order_cycle_top_buttons.haml new file mode 100644 index 0000000000..97b14ddf1b --- /dev/null +++ b/app/views/admin/order_cycles/_order_cycle_top_buttons.haml @@ -0,0 +1,19 @@ +- content_for :page_actions do + :javascript + function toggleSettings(){ + if( $('#advanced_settings').is(":visible") ){ + $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") + } + else { + $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") + } + $("#advanced_settings").slideToggle() + } + + %li + %button#toggle_settings{ onClick: 'toggleSettings()' } + = t('.advanced_settings') + %i.icon-chevron-down + +#advanced_settings{ hidden: true } + = render partial: "/admin/order_cycles/advanced_settings" \ No newline at end of file diff --git a/app/views/admin/order_cycles/incoming.html.haml b/app/views/admin/order_cycles/incoming.html.haml index faaa81e03b..3bc3dd86b3 100644 --- a/app/views/admin/order_cycles/incoming.html.haml +++ b/app/views/admin/order_cycles/incoming.html.haml @@ -1,3 +1,20 @@ +- content_for :page_actions do + :javascript + function toggleSettings(){ + if( $('#advanced_settings').is(":visible") ){ + $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") + } + else { + $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") + } + $("#advanced_settings").slideToggle() + } + + %li + %button#toggle_settings{ onClick: 'toggleSettings()' } + = t('.advanced_settings') + %i.icon-chevron-down + - content_for :page_title do = t :edit_order_cycle diff --git a/app/views/admin/order_cycles/outgoing.html.haml b/app/views/admin/order_cycles/outgoing.html.haml index 0623d1f71e..890faa9553 100644 --- a/app/views/admin/order_cycles/outgoing.html.haml +++ b/app/views/admin/order_cycles/outgoing.html.haml @@ -1,3 +1,20 @@ +- content_for :page_actions do + :javascript + function toggleSettings(){ + if( $('#advanced_settings').is(":visible") ){ + $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") + } + else { + $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") + } + $("#advanced_settings").slideToggle() + } + + %li + %button#toggle_settings{ onClick: 'toggleSettings()' } + = t('.advanced_settings') + %i.icon-chevron-down + - content_for :page_title do = t :edit_order_cycle From 18282a6f73eb4b3f3080bfe93e89c559bdaad1dd Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Sat, 15 May 2021 01:36:26 +0530 Subject: [PATCH 2/4] Add advanced settings button to incoming and outgoing pages in OC cycle edit --- .../admin/order_cycles_controller.rb | 2 +- ...aml => _order_cycle_top_buttons.html.haml} | 2 +- app/views/admin/order_cycles/edit.html.haml | 19 +------------------ .../admin/order_cycles/incoming.html.haml | 17 +---------------- .../admin/order_cycles/outgoing.html.haml | 17 +---------------- 5 files changed, 5 insertions(+), 52 deletions(-) rename app/views/admin/order_cycles/{_order_cycle_top_buttons.haml => _order_cycle_top_buttons.html.haml} (90%) diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index 05b6cb891d..f8becca16c 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -64,7 +64,7 @@ module Admin if @order_cycle_form.save respond_to do |format| flash[:notice] = I18n.t(:order_cycles_update_notice) if params[:reloading] == '1' - format.html { redirect_to main_app.edit_admin_order_cycle_path(@order_cycle) } + format.html { redirect_back(fallback_location: root_path) } format.json { render json: { success: true } } end else diff --git a/app/views/admin/order_cycles/_order_cycle_top_buttons.haml b/app/views/admin/order_cycles/_order_cycle_top_buttons.html.haml similarity index 90% rename from app/views/admin/order_cycles/_order_cycle_top_buttons.haml rename to app/views/admin/order_cycles/_order_cycle_top_buttons.html.haml index 97b14ddf1b..86ca6b2ae4 100644 --- a/app/views/admin/order_cycles/_order_cycle_top_buttons.haml +++ b/app/views/admin/order_cycles/_order_cycle_top_buttons.html.haml @@ -16,4 +16,4 @@ %i.icon-chevron-down #advanced_settings{ hidden: true } - = render partial: "/admin/order_cycles/advanced_settings" \ No newline at end of file + = render partial: "/admin/order_cycles/advanced_settings" diff --git a/app/views/admin/order_cycles/edit.html.haml b/app/views/admin/order_cycles/edit.html.haml index 2a781974ca..5c700c5b18 100644 --- a/app/views/admin/order_cycles/edit.html.haml +++ b/app/views/admin/order_cycles/edit.html.haml @@ -1,25 +1,8 @@ += render partial: "/admin/order_cycles/order_cycle_top_buttons" - content_for :page_actions do - :javascript - function toggleSettings(){ - if( $('#advanced_settings').is(":visible") ){ - $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") - } - else { - $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") - } - $("#advanced_settings").slideToggle() - } - - if can? :notify_producers, @order_cycle %li = button_to t(:notify_producers), main_app.notify_producers_admin_order_cycle_path, :id => 'admin_notify_producers', :confirm => t(:are_you_sure) - %li - %button#toggle_settings{ onClick: 'toggleSettings()' } - = t('.advanced_settings') - %i.icon-chevron-down - -#advanced_settings{ hidden: true } - = render partial: "/admin/order_cycles/advanced_settings" - content_for :page_title do = t :edit_order_cycle diff --git a/app/views/admin/order_cycles/incoming.html.haml b/app/views/admin/order_cycles/incoming.html.haml index 3bc3dd86b3..254119bf24 100644 --- a/app/views/admin/order_cycles/incoming.html.haml +++ b/app/views/admin/order_cycles/incoming.html.haml @@ -1,19 +1,4 @@ -- content_for :page_actions do - :javascript - function toggleSettings(){ - if( $('#advanced_settings').is(":visible") ){ - $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") - } - else { - $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") - } - $("#advanced_settings").slideToggle() - } - - %li - %button#toggle_settings{ onClick: 'toggleSettings()' } - = t('.advanced_settings') - %i.icon-chevron-down += render partial: "/admin/order_cycles/order_cycle_top_buttons" - content_for :page_title do = t :edit_order_cycle diff --git a/app/views/admin/order_cycles/outgoing.html.haml b/app/views/admin/order_cycles/outgoing.html.haml index 890faa9553..9924e3dae9 100644 --- a/app/views/admin/order_cycles/outgoing.html.haml +++ b/app/views/admin/order_cycles/outgoing.html.haml @@ -1,19 +1,4 @@ -- content_for :page_actions do - :javascript - function toggleSettings(){ - if( $('#advanced_settings').is(":visible") ){ - $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down") - } - else { - $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up") - } - $("#advanced_settings").slideToggle() - } - - %li - %button#toggle_settings{ onClick: 'toggleSettings()' } - = t('.advanced_settings') - %i.icon-chevron-down += render partial: "/admin/order_cycles/order_cycle_top_buttons" - content_for :page_title do = t :edit_order_cycle From cd0b97bf0a5ab8a8d1e372e609213d44f308cdb2 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Thu, 3 Jun 2021 17:54:44 +0530 Subject: [PATCH 3/4] Update i18n configs --- config/locales/en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 89af6187d2..91910ef186 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -996,7 +996,6 @@ en: cancel: "Cancel" back_to_list: "Back To List" edit: - advanced_settings: "Advanced Settings" save: "Save" save_and_next: "Save and Next" next: "Next" @@ -1049,6 +1048,8 @@ en: preferred_product_selection_from_coordinator_inventory_only_here: Coordinator's Inventory Only preferred_product_selection_from_coordinator_inventory_only_all: All Available Products save_reload: Save and Reload Page + advanced_settings_toggle: + advanced_settings: "Advanced Settings" coordinator_fees: add: Add coordinator fee filters: From f7795ca21a6fc4267bd3eb21c9bf7cc296315002 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Fri, 25 Jun 2021 03:26:14 +0530 Subject: [PATCH 4/4] Fix failing specs --- config/locales/en.yml | 2 +- spec/features/admin/enterprise_groups_spec.rb | 2 -- spec/features/admin/overview_spec.rb | 4 ++-- spec/features/admin/shipping_methods_spec.rb | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 91910ef186..8a151dd959 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1048,7 +1048,7 @@ en: preferred_product_selection_from_coordinator_inventory_only_here: Coordinator's Inventory Only preferred_product_selection_from_coordinator_inventory_only_all: All Available Products save_reload: Save and Reload Page - advanced_settings_toggle: + order_cycle_top_buttons: advanced_settings: "Advanced Settings" coordinator_fees: add: Add coordinator fee diff --git a/spec/features/admin/enterprise_groups_spec.rb b/spec/features/admin/enterprise_groups_spec.rb index e702f98cd5..fb0a7b8d6e 100644 --- a/spec/features/admin/enterprise_groups_spec.rb +++ b/spec/features/admin/enterprise_groups_spec.rb @@ -119,7 +119,5 @@ feature ' click_link 'Groups' expect(page).to have_content 'My Group' end - - xit "should show me only enterprises I manage when creating a new enterprise group" end end diff --git a/spec/features/admin/overview_spec.rb b/spec/features/admin/overview_spec.rb index fb1c772b4b..ef710d59e3 100644 --- a/spec/features/admin/overview_spec.rb +++ b/spec/features/admin/overview_spec.rb @@ -43,7 +43,7 @@ feature ' end end - pending "when user is a profile only" do + context "when user is a profile only" do before do d1.sells = "none" d1.save! @@ -51,7 +51,7 @@ feature ' it "does not show a products item" do visit '/admin' - page.should_not have_selector "#products" + expect(page).to have_no_selector "#products" end end end diff --git a/spec/features/admin/shipping_methods_spec.rb b/spec/features/admin/shipping_methods_spec.rb index 691483305c..bc716a0c0e 100644 --- a/spec/features/admin/shipping_methods_spec.rb +++ b/spec/features/admin/shipping_methods_spec.rb @@ -45,8 +45,6 @@ feature 'shipping methods' do expect(sm.distributors).to match_array [distributor1, distributor2] end - it "at checkout, user can only see shipping methods for their current distributor (checkout spec)" - scenario "deleting a shipping method" do visit_delete spree.admin_shipping_method_path(@shipping_method)