Skip to content

Commit

Permalink
Closes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Feb 9, 2024
1 parent 9b66b28 commit 3341d9d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def edit_all
load_article_units
end

def prepare_units_migration
end

def migrate_units
build_article_migration_samples
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 9 additions & 7 deletions app/views/articles/migrate_units.html.haml
Original file line number Diff line number Diff line change
@@ -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)};
Expand All @@ -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}"}
Expand Down Expand Up @@ -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'
8 changes: 8 additions & 0 deletions app/views/articles/prepare_units_migration.haml
Original file line number Diff line number Diff line change
@@ -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?
20 changes: 20 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}."
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}."
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3341d9d

Please sign in to comment.