From a4210a1cabcd0d1740f76b9d5e8f06a3d96aa34b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 15 Jul 2018 00:14:29 +0100 Subject: [PATCH 1/3] PI post-save UI changes --- app/views/admin/product_import/_save_results.html.haml | 4 ++-- config/locales/en.yml | 5 +++-- spec/features/admin/product_import_spec.rb | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/admin/product_import/_save_results.html.haml b/app/views/admin/product_import/_save_results.html.haml index 9ab9652ac1..901bb466e1 100644 --- a/app/views/admin/product_import/_save_results.html.haml +++ b/app/views/admin/product_import/_save_results.html.haml @@ -56,8 +56,8 @@ %a.button.view{href: main_app.admin_inventory_path, ng: {show: 'updates.inventory_created > 0 || updates.inventory_updated > 0'}} = t('admin.product_import.save.view_inventory') - %a.button.view{href: admin_products_path + '?latest_import=true', ng: {show: 'updates.products_created > 0 || updates.products_updated > 0'}} + %a.button.view{href: admin_products_path, ng: {show: 'updates.products_created > 0 || updates.products_updated > 0'}} = t('admin.product_import.save.view_products') %a.button{href: main_app.admin_product_import_path} - = t('admin.back') + = t('admin.product_import.save.import_again') diff --git a/config/locales/en.yml b/config/locales/en.yml index 67c8d17fd3..ebe1c524bb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -516,8 +516,9 @@ en: all_saved: "All items saved successfully" some_saved: "items saved successfully" save_errors: Save errors - view_products: View Products - view_inventory: View Inventory + import_again: Upload Another File + view_products: Go To Products Page + view_inventory: Go To Inventory Page variant_overrides: loading_flash: diff --git a/spec/features/admin/product_import_spec.rb b/spec/features/admin/product_import_spec.rb index 35ebee5b1a..faedb012b7 100644 --- a/spec/features/admin/product_import_spec.rb +++ b/spec/features/admin/product_import_spec.rb @@ -72,7 +72,7 @@ feature "Product Import", js: true do wait_until { page.find("a.button.view").present? } - click_link 'View Products' + click_link I18n.t('admin.product_import.save.view_products') expect(page).to have_content 'Bulk Edit Products' wait_until { page.find("#p_#{potatoes.id}").present? } @@ -174,7 +174,7 @@ feature "Product Import", js: true do potatoes = Spree::Product.find_by_name('Potatoes') expect(potatoes.variants.first.import_date).to be_within(1.minute).of Time.zone.now - click_link 'View Products' + click_link I18n.t('admin.product_import.save.view_products') wait_until { page.find("#p_#{carrots.id}").present? } @@ -251,7 +251,7 @@ feature "Product Import", js: true do expect(Float(cabbage_override.price)).to eq 1.50 expect(cabbage_override.count_on_hand).to eq 2001 - click_link 'View Inventory' + click_link I18n.t('admin.product_import.save.view_inventory') expect(page).to have_content 'Inventory' select enterprise2.name, from: "hub_id", visible: false From 18206c9369afcd95be517f8f41af1d50719bf9e5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 18 Jul 2018 11:42:07 +0100 Subject: [PATCH 2/3] Remove old view file --- app/views/admin/product_import/save.html.haml | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 app/views/admin/product_import/save.html.haml diff --git a/app/views/admin/product_import/save.html.haml b/app/views/admin/product_import/save.html.haml deleted file mode 100644 index 4d88bef979..0000000000 --- a/app/views/admin/product_import/save.html.haml +++ /dev/null @@ -1,63 +0,0 @@ -- content_for :page_title do - #{t('admin.product_import.title')} - -= render partial: 'spree/admin/shared/product_sub_menu' - -%h5= t('admin.product_import.save.final_results') -%br - -%div.post-save-results{ng: {app: 'admin.productImport'}} - - - if @importer.products_created_count > 0 - %p - %i.fa{ng: {class: "{'fa-info-circle': #{@importer.products_created_count} == 0, 'fa-check-circle': #{@importer.products_created_count} != 0}"}} - %strong.created-count= @importer.products_created_count - = t('admin.product_import.save.products_created') - - - if @importer.products_updated_count > 0 - %p - %i.fa{ng: {class: "{'fa-info-circle': #{@importer.products_updated_count} == 0, 'fa-check-circle': #{@importer.products_updated_count} != 0}"}} - %strong.updated-count= @importer.products_updated_count - = t('admin.product_import.save.products_updated') - - - if @importer.inventory_created_count > 0 - %p - %i.fa{ng: {class: "{'fa-info-circle': #{@importer.inventory_created_count} == 0, 'fa-check-circle': #{@importer.inventory_created_count} != 0}"}} - %strong.inv-created-count= @importer.inventory_created_count - = t('admin.product_import.save.inventory_created') - - - if @importer.inventory_updated_count > 0 - %p - %i.fa{ng: {class: "{'fa-info-circle': #{@importer.inventory_updated_count} == 0, 'fa-check-circle': #{@importer.inventory_updated_count} != 0}"}} - %strong.inv-updated-count= @importer.inventory_updated_count - = t('admin.product_import.save.inventory_updated') - - - if @importer.products_reset_count > 0 - %p - %i.fa.fa-info-circle - %strong.reset-count= @importer.products_reset_count - - if @import_into == 'inventories' - = t('admin.product_import.save.inventory_reset') - - else - = t('admin.product_import.save.products_reset') - - %br - - - if @importer.errors.count == 0 - %p= t('admin.product_import.save.all_saved', { num: "#{@importer.total_saved_count}" }) - - else - %p= t('admin.product_import.save.total_saved', { num: "#{@importer.total_saved_count}" }) - %br - %h5= t('admin.product_import.save.save_errors') - - @importer.errors.full_messages.each do |error| - %p.save-error -  -  #{error} - - %br - - if @importer.total_saved_count > 0 - - if @import_into == 'inventories' - %a.button{href: main_app.admin_inventory_path}= t('admin.product_import.save.view_inventory') - - else - %a.button{href: admin_products_path + '?latest_import=true'}= t('admin.product_import.save.view_products') - - %a.button{href: main_app.admin_product_import_path}= t('admin.back') From b37bea35fa211c49f1fa539b9d7150d137e98f9a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 18 Jul 2018 11:43:31 +0100 Subject: [PATCH 3/3] Use relative translation keys --- .../product_import/_save_results.html.haml | 26 +++++++++---------- config/locales/en.yml | 2 +- spec/features/admin/product_import_spec.rb | 8 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/views/admin/product_import/_save_results.html.haml b/app/views/admin/product_import/_save_results.html.haml index 901bb466e1..90cf847468 100644 --- a/app/views/admin/product_import/_save_results.html.haml +++ b/app/views/admin/product_import/_save_results.html.haml @@ -1,5 +1,5 @@ -%h5= t('admin.product_import.save.final_results') +%h5= t('.final_results') %br %div.post-save-results @@ -8,45 +8,45 @@ %i.fa{ng: {class: "{'fa-info-circle': updates.products_created == 0, 'fa-check-circle': updates.products_created > 0}"}} %strong.created-count {{ updates.products_created }} - = t('admin.product_import.save.products_created') + = t('.products_created') %p{ng: {show: 'updates.products_updated'}} %i.fa{ng: {class: "{'fa-info-circle': updates.products_updated == 0, 'fa-check-circle': updates.products_updated > 0}"}} %strong.updated-count {{ updates.products_updated }} - = t('admin.product_import.save.products_updated') + = t('.products_updated') %p{ng: {show: 'updates.inventory_created'}} %i.fa{ng: {class: "{'fa-info-circle': updates.inventory_created == 0, 'fa-check-circle': updates.inventory_created > 0}"}} %strong.inv-created-count {{ updates.inventory_created }} - = t('admin.product_import.save.inventory_created') + = t('.inventory_created') %p{ng: {show: 'updates.inventory_updated'}} %i.fa{ng: {class: "{'fa-info-circle': updates.inventory_updated == 0, 'fa-check-circle': updates.inventory_updated > 0}"}} %strong.inv-updated-count {{ updates.inventory_updated }} - = t('admin.product_import.save.inventory_updated') + = t('.inventory_updated') %p{ng: {show: 'updates.products_reset'}} %i.fa.fa-info-circle %strong.reset-count {{ updates.products_reset }} - if @import_into == 'inventories' - = t('admin.product_import.save.inventory_reset') + = t('.inventory_reset') - else - = t('admin.product_import.save.products_reset') + = t('.products_reset') %br %p{ng: {show: 'update_errors.length == 0'}} - = t('admin.product_import.save.all_saved') + = t('.all_saved') %div{ng: {show: 'update_errors.length > 0'}} - %p {{ updated_total }} #{t('admin.product_import.save.some_saved')} + %p {{ updated_total }} #{t('.some_saved')} %br - %h5= t('admin.product_import.save.save_errors') + %h5= t('.save_errors') %p.save-error{ng: {repeat: 'error in update_errors'}}  -  {{ error }} @@ -54,10 +54,10 @@ %br %div{ng: {show: 'updated_total > 0'}} %a.button.view{href: main_app.admin_inventory_path, ng: {show: 'updates.inventory_created > 0 || updates.inventory_updated > 0'}} - = t('admin.product_import.save.view_inventory') + = t('.view_inventory') %a.button.view{href: admin_products_path, ng: {show: 'updates.products_created > 0 || updates.products_updated > 0'}} - = t('admin.product_import.save.view_products') + = t('.view_products') %a.button{href: main_app.admin_product_import_path} - = t('admin.product_import.save.import_again') + = t('.import_again') diff --git a/config/locales/en.yml b/config/locales/en.yml index ebe1c524bb..4c550c9d07 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -505,7 +505,7 @@ en: inventory_to_reset: Existing inventory items will have their stock reset to zero line: Line item_line: Item line - save: + save_results: final_results: Import final results products_created: Products created products_updated: Products updated diff --git a/spec/features/admin/product_import_spec.rb b/spec/features/admin/product_import_spec.rb index faedb012b7..4ea5076eac 100644 --- a/spec/features/admin/product_import_spec.rb +++ b/spec/features/admin/product_import_spec.rb @@ -72,7 +72,7 @@ feature "Product Import", js: true do wait_until { page.find("a.button.view").present? } - click_link I18n.t('admin.product_import.save.view_products') + click_link I18n.t('admin.product_import.save_results.view_products') expect(page).to have_content 'Bulk Edit Products' wait_until { page.find("#p_#{potatoes.id}").present? } @@ -174,7 +174,7 @@ feature "Product Import", js: true do potatoes = Spree::Product.find_by_name('Potatoes') expect(potatoes.variants.first.import_date).to be_within(1.minute).of Time.zone.now - click_link I18n.t('admin.product_import.save.view_products') + click_link I18n.t('admin.product_import.save_results.view_products') wait_until { page.find("#p_#{carrots.id}").present? } @@ -251,7 +251,7 @@ feature "Product Import", js: true do expect(Float(cabbage_override.price)).to eq 1.50 expect(cabbage_override.count_on_hand).to eq 2001 - click_link I18n.t('admin.product_import.save.view_inventory') + click_link I18n.t('admin.product_import.save_results.view_inventory') expect(page).to have_content 'Inventory' select enterprise2.name, from: "hub_id", visible: false @@ -437,6 +437,6 @@ feature "Product Import", js: true do wait_until { page.find("button.view_results:not([disabled='disabled'])").present? } find('button.view_results').trigger 'click' - expect(page).to have_content I18n.t('admin.product_import.save.final_results') + expect(page).to have_content I18n.t('admin.product_import.save_results.final_results') end end