From 3341d9d553e3f8a22ce0ce7c7cabf485a33213c4 Mon Sep 17 00:00:00 2001 From: Florian Lentsch Date: Fri, 9 Feb 2024 14:56:34 +0100 Subject: [PATCH] Closes #31 --- app/controllers/articles_controller.rb | 3 +++ app/views/articles/index.html.haml | 2 +- app/views/articles/migrate_units.html.haml | 16 ++++++++------- .../articles/prepare_units_migration.haml | 8 ++++++++ config/locales/de.yml | 20 +++++++++++++++++++ config/locales/en.yml | 20 +++++++++++++++++++ config/routes.rb | 1 + 7 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 app/views/articles/prepare_units_migration.haml diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index e4973dc8..aa589c5f 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -99,6 +99,9 @@ def edit_all load_article_units end + def prepare_units_migration + end + def migrate_units build_article_migration_samples end diff --git a/app/views/articles/index.html.haml b/app/views/articles/index.html.haml index 17cf698a..ff1dc903 100644 --- a/app/views/articles/index.html.haml +++ b/app/views/articles/index.html.haml @@ -23,7 +23,7 @@ = link_to t('.ext_db.sync'), sync_supplier_articles_path(@supplier), method: :post, class: 'btn btn-success' .btn-group - = link_to t('.migrate_units') + '...', migrate_units_supplier_articles_path(@supplier), class: 'btn btn-success' if @supplier.unit_migration_completed.nil? + = link_to t('.migrate_units') + '...', prepare_units_migration_supplier_articles_path(@supplier), class: 'btn btn-success' if @supplier.unit_migration_completed.nil? .btn-group = link_to t('.new'), new_supplier_article_path(@supplier), remote: true, class: "btn #{'btn-primary' if @supplier.supplier_remote_source.nil?}" = link_to t('.edit_all'), edit_all_supplier_articles_path(@supplier), class: 'btn' diff --git a/app/views/articles/migrate_units.html.haml b/app/views/articles/migrate_units.html.haml index 870774ab..f146e765 100644 --- a/app/views/articles/migrate_units.html.haml +++ b/app/views/articles/migrate_units.html.haml @@ -1,3 +1,5 @@ +- title t('.title', supplier: @supplier.name) +%span= simple_format(t('.explanation')) - content_for :javascript do :javascript const units = #{raw(@all_units.to_json)}; @@ -14,12 +16,12 @@ %table.table#migrate-units %thead %tr - %th= heading_helper Article, :apply - %th= heading_helper Article, :original_plaintext_unit - %th= heading_helper Article, :affected_articles - %th= heading_helper Article, :supplier_order_unit - %th= heading_helper Article, :contains - %th= heading_helper Article, :allow_orders_per + %th= t('.column_headers.apply') + %th= t('.column_headers.original_plaintext_unit') + %th= t('.column_headers.affected_articles') + %th= heading_helper ArticleVersion, :supplier_order_unit + %th= t('.column_headers.contains') + %th= heading_helper ArticleVersion, :group_order_granularity %tbody - @samples.each_with_index do |sample, index| %tr{:id => "sample_row_#{index}"} @@ -69,4 +71,4 @@ %span = '×'.html_safe = form.input :group_order_unit, as: :select, collection: [], input_html: {'data-initial-value': sample[:conversion_result][:group_order_unit], class: 'input-medium'}, label: false, include_blank: false - = f.submit class: 'btn btn-primary' + = f.submit t('.run_migration'), class: 'btn btn-primary' diff --git a/app/views/articles/prepare_units_migration.haml b/app/views/articles/prepare_units_migration.haml new file mode 100644 index 00000000..5e22ee7b --- /dev/null +++ b/app/views/articles/prepare_units_migration.haml @@ -0,0 +1,8 @@ +- title t('.title', supplier: @supplier.name) +%p.mb-1 + =simple_format(t('.explanation')) += link_to t('.download'), supplier_articles_path(@supplier, format: :csv), class: 'btn' +%br/ +%br/ +%p.mt-1 + = link_to t('.migrate_units') + '...', migrate_units_supplier_articles_path(@supplier), class: 'btn btn-success' if @supplier.unit_migration_completed.nil? diff --git a/config/locales/de.yml b/config/locales/de.yml index b5235014..18c9ec4d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -504,6 +504,8 @@ de: notice_unavail: Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt update_sync: notice: Alle Artikel und Preise wurden aktualisiert + complete_units_migration: + notice: Artikel erfolgreich migriert destroy_active_article: drop: entfernen note: "%{article} wird in laufenden Bestellungen verwendet und kann nicht gelöscht werden. Bitte zuerst den Artikel aus den Bestellungen %{drop_link}." @@ -537,6 +539,24 @@ de: search_placeholder: Name ... title: Artikel von %{supplier} (%{count}) upload: Artikel hochladen + prepare_units_migration: + title: Artikel von %{supplier} migrieren + explanation: | + TODO: Allgemeine Erklärung + Es wird sehr empfohlen ein Backup herunterzuladen ehe Sie fortfahren: + download: Artikel-Backup herunterladen + migrate_units: Nächster Schritt + migrate_units: + title: Artikel von %{supplier} migrieren + explanation: | + Die Artikeleinheiten werden nun in eine neue, flexiblere Form konvertiert. Passen Sie die Konvertierungsvorschläge an, ehe sie fortfahren. + TODO: Besser erklären; vielleicht mit Doku verlinken? + column_headers: + apply: Konvertieren + original_plaintext_unit: Ursprüngliche Volltext-Einheit + affected_articles: Betroffene Artikel + contains: Beinhaltet + run_migration: Migration jetzt durchführen model: error_in_use: "%{article} kann nicht gelöscht werden. Der Artikel befindet sich in einer laufenden Bestellung!" error_nosel: Du hast keine Artikel ausgewählt diff --git a/config/locales/en.yml b/config/locales/en.yml index aea1dcca..611074a0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -507,6 +507,8 @@ en: notice_unavail: All selected articles were set to be unavailable. update_sync: notice: All articles and prices were updated. + complete_units_migration: + notice: Articles successfully migrated destroy_active_article: drop: delete note: "%{article} is used in current orders and can not be deleted Please first ... the article from orders %{drop_link}." @@ -523,6 +525,7 @@ en: change_supplier: Change supplier ... download: Download articles edit_all: Edit all + migrate_units: Migrate old article units ext_db: import: Import article sync: Synchronise @@ -536,6 +539,23 @@ en: search_placeholder: Name ... title: Articles from %{supplier} (%{count}) upload: Upload articles + prepare_units_migration: + explanation: | + TODO: General explanation + It's highly recommended to download a backup before continuing: + title: Migrate articles of %{supplier} + download: Download articles backup + migrate_units: + title: Migrate articles of %{supplier} + explanation: | + This will try to migrate articles to their new, more versatile format. You may adapt the suggested changes before continuing if you see fit. + TODO: Expand on this explanation - maybe link to some docs + column_headers: + apply: Convert + original_plaintext_unit: Original plaintext unit + affected_articles: Affected articles + contains: Contains + run_migration: Run migration now model: error_in_use: "%{article} can not be deleted because the article is part of a current order!" error_nosel: You have selected no articles diff --git a/config/routes.rb b/config/routes.rb index 4825ed14..8f3cd852 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -135,6 +135,7 @@ collection do post :update_selected get :edit_all + get :prepare_units_migration get :migrate_units post :complete_units_migration post :update_all