diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 86805334..b87d7185 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -240,6 +240,10 @@ tr.unavailable { // ********* Tweaks & fixes +// Fix bootstrap dropdown menu on mobile +// https://github.com/twbs/bootstrap/issues/4550#issuecomment-31916049 +.dropdown-backdrop { position: static; } + // need more space for supplier&order information (in German, at least) .dl-horizontal { dt { width: 160px; } diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 711d67ae..49ecbdb7 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -31,4 +31,11 @@ class SessionsController < ApplicationController session[:return_to] = nil redirect_to login_url, :notice => I18n.t('sessions.logged_out') end + + # redirect to root, going to default foodcoop when none given + # this may not be so much session-related, but it must be somewhere + def redirect_to_foodcoop + redirect_to root_path + end + end diff --git a/app/models/order_article.rb b/app/models/order_article.rb index 84612616..ba53a278 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -1,7 +1,7 @@ # An OrderArticle represents a single Article that is part of an Order. class OrderArticle < ActiveRecord::Base - attr_reader :update_current_price + attr_reader :update_global_price belongs_to :order belongs_to :article @@ -168,14 +168,20 @@ class OrderArticle < ActiveRecord::Base if price_attributes.present? article_price.attributes = price_attributes if article_price.changed? - # Updates also price attributes of article if update_current_price is selected - if update_current_price + # Updates also price attributes of article if update_global_price is selected + if update_global_price article.update_attributes!(price_attributes) - self.article_price = article.article_prices.first # Assign new created article price to order article + self.article_price = article.article_prices.first and save # Assign new created article price to order article else # Creates a new article_price if neccessary # Set created_at timestamp to order ends, to make sure the current article price isn't changed create_article_price!(price_attributes.merge(created_at: order.ends)) and save + # TODO: The price_attributes do not include an article_id so that + # the entry in the database will not "know" which article is + # referenced. Let us check the effect of that and change it or + # comment on the meaning. + # Possibly this is the real reason why the global price is not + # affected instead of the `created_at: order.ends` injection. end # Updates ordergroup values @@ -185,8 +191,8 @@ class OrderArticle < ActiveRecord::Base end end - def update_current_price=(value) - @update_current_price = (value == true or value == '1') ? true : false + def update_global_price=(value) + @update_global_price = (value == true or value == '1') ? true : false end # Units missing for the next full unit_quantity of the article diff --git a/app/views/order_articles/_edit.html.haml b/app/views/order_articles/_edit.html.haml index 9220577d..f93878c7 100644 --- a/app/views/order_articles/_edit.html.haml +++ b/app/views/order_articles/_edit.html.haml @@ -25,7 +25,7 @@ = render partial: 'shared/article_fields_units', locals: {f_unit: f, f_uq: fprice} = render partial: 'shared/article_fields_price', locals: {f: fprice} - = form.input :update_current_price, as: :boolean + = form.input :update_global_price, as: :boolean = f.input :order_number .modal-footer = link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'} diff --git a/config/initializers/number_display.rb b/config/initializers/number_display.rb new file mode 100644 index 00000000..49f2e1e6 --- /dev/null +++ b/config/initializers/number_display.rb @@ -0,0 +1,17 @@ +# we'd like to show "0.0" as "0" + +class Float + alias :foodsoft_to_s :to_s + def to_s + foodsoft_to_s.chomp(".0") + end +end + +if defined? BigDecimal + class BigDecimal + alias :foodsoft_to_s :to_s + def to_s(format = DEFAULT_STRING_FORMAT) + foodsoft_to_s(format).chomp(".0") + end + end +end diff --git a/config/locales/de.yml b/config/locales/de.yml index 79046d4e..cefa289f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -88,7 +88,7 @@ de: units_received_short: Geliefert units_to_order: Bestellte Gebinde units_to_order_short: Bestellt - update_current_price: Globalen Preis aktualisieren + update_global_price: Globalen Preis aktualisieren order_comment: text: Kommentiere diese Bestellung ... ordergroup: @@ -480,7 +480,7 @@ de: title: ! 'Sortiermatrix der Bestellung: %{name}, beendet am %{date}' total: one: Insgesamt ein Artikel - other: ! 'Insgesamt %{count} Artikel' + other: Insgesamt %{count} Artikel errors: general: Ein Problem ist aufgetreten. general_again: Ein Fehler ist aufgetreten. Bitte erneut versuchen. @@ -1083,6 +1083,12 @@ de: home: Startseite title: Wiki workgroups: Arbeitsgruppen + order_articles: + edit: + stock_alert: Preise von Lagerartikeln können nicht geändert werden! + title: Artikel aktualisieren + new: + title: Neuer gelieferter Artikel der Bestellung ordergroups: edit: title: Bestellgruppe bearbeiten @@ -1091,12 +1097,6 @@ de: model: error_single_group: ! '%{user} ist schon in einer anderen Bestellgruppe' invalid_balance: ist keine gültige Zahl - order_articles: - edit: - stock_alert: Preise von Lagerartikeln können nicht geändert werden! - title: Artikel aktualisieren - new: - title: Neuer gelieferter Artikel der Bestellung orders: articles: article_count: ! 'Bestellte Artikel:' @@ -1155,7 +1155,7 @@ de: notice_none: Keine neuen Artikel für den Empfang ausgewählt. rest_to_stock: Rest ins Lager submit: Bestellung in Empfang nehmen - surplus_options: 'Verteilungsoptionen:' + surplus_options: ! 'Verteilungsoptionen:' title: »%{order}« in Empfang nehmen show: action_end: Beenden! @@ -1189,10 +1189,11 @@ de: update: notice: Die Bestellung wurde aktualisiert. update_order_amounts: - update_order_amounts: - msg1: "%{count} Artikel (%{units} Einheiten) aktualisiert" - msg2: "%{count} (%{units}) Toleranzmenge" - msg4: "%{count} (%{units}) übrig" + msg1: ! '%{count} Artikel (%{units} Einheiten) aktualisiert' + msg2: ! '%{count} (%{units}) Toleranzmenge' + msg3: + msg4: ! '%{count} (%{units}) übrig' + update_order_amounts: pages: all: new_page: Neue Seite anlegen @@ -1319,7 +1320,7 @@ de: private: Nachricht erscheint nicht im Foodsoft Posteingang order_article: units_to_order: Wenn Du die Gesamtanzahl gelieferter Gebinde änderst, musst Du auch die individuelle Anzahl der einzelnen Bestellgruppen anpassen, indem Du auf den Artikelnamen klickst. Sie werden nicht automatisch neuberechnet und andernfalls werden den Bestellgruppen Artikel in Rechnung gestellt, die nicht geliefert wurden! - update_current_price: Ändert auch den Preis für aktuelle Bestellungen + update_global_price: Ändert auch den Preis für zukünftige Bestellungen stock_article: copy: name: Bitte ändern diff --git a/config/locales/en.yml b/config/locales/en.yml index 8cb16c3e..54a409a9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -88,7 +88,7 @@ en: units_received_short: Received units_to_order: Ordered units units_to_order_short: Ordered - update_current_price: Globally update current price + update_global_price: Globally update current price order_comment: text: Add comment to this order ... ordergroup: @@ -1085,6 +1085,12 @@ en: home: Home title: Wiki workgroups: Workgroups + order_articles: + edit: + stock_alert: The price of stock articles cannot be changed! + title: Update article + new: + title: Add delivered article to order ordergroups: edit: title: Edit ordergroups @@ -1093,12 +1099,6 @@ en: model: error_single_group: ! '%{user} is already a member of another ordergroup' invalid_balance: is not a valid number - order_articles: - edit: - stock_alert: The price of stock articles cannot be changed! - title: Update article - new: - title: Add delivered article to order orders: articles: article_count: ! 'Ordered articles:' @@ -1157,7 +1157,7 @@ en: notice_none: No new articles to receive rest_to_stock: rest to stock submit: Receive order - surplus_options: 'Distribution options:' + surplus_options: ! 'Distribution options:' title: Receiving %{order} show: action_end: Close! @@ -1198,10 +1198,11 @@ en: update: notice: The order was updated. update_order_amounts: - msg1: "%{count} articles (%{units} units) updated" - msg2: "%{count} (%{units}) using tolerance" - msg3: "%{count} (%{units}) go to stock if foodsoft would support that [don't translate]" - msg4: "%{count} (%{units}) left over" + msg1: ! '%{count} articles (%{units} units) updated' + msg2: ! '%{count} (%{units}) using tolerance' + msg3: ! '%{count} (%{units}) go to stock if foodsoft would support that [don''t translate]' + msg4: ! '%{count} (%{units}) left over' + update_order_amounts: pages: all: new_page: Create new page @@ -1328,7 +1329,7 @@ en: private: Message doesn’t show in Foodsoft mail inbox order_article: units_to_order: If you change the total amount of delivered units, you also have to change individual group amounts by clicking on the article name. They will not be automatically recalculated and so ordergroups may be accounted for articles that were not delivered! - update_current_price: Also update the price of the current order + update_global_price: Also update the price of future orders stock_article: copy: name: Please modify diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 189a5073..a9f52f22 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -77,12 +77,18 @@ fr: note: starts: Ouverture le status: + supplier: order_article: article: Article missing_units: Unités manquantes missing_units_short: + quantity: + quantity_short: + units_received: + units_received_short: units_to_order: Quantité - update_current_price: Mettre à jour le prix global + units_to_order_short: + update_global_price: Mettre à jour le prix global order_comment: text: Commenter cette commande... ordergroup: @@ -756,6 +762,7 @@ fr: new_invoice: Ajouter une nouvelle facture show_invoice: Afficher la facture orders: + old_price: option_choose: Choix d'unE fournisseusE_r option_stock: Stock order_pdf: Générer un PDF @@ -1081,6 +1088,12 @@ fr: home: Page d'accueil title: Wiki workgroups: Équipes + order_articles: + edit: + stock_alert: + title: Mettre à jour la liste des article + new: + title: ordergroups: edit: title: Modifier les cellules @@ -1089,12 +1102,6 @@ fr: model: error_single_group: ! '%{user} fait déjà partie d''une autre cellule' invalid_balance: n'est pas un nombre valide - order_articles: - edit: - stock_alert: - title: Mettre à jour la liste des article - new: - title: orders: articles: article_count: ! 'Articles commandés:' @@ -1106,6 +1113,9 @@ fr: notice: La commande a bien été définie. edit: title: Modifier la commande + edit_amount: + field_locked_title: + field_unlocked_title: fax: amount: Quantité articles: Articles @@ -1124,6 +1134,7 @@ fr: title: Article index: action_end: Terminer + action_receive: confirm_delete: Vraiment supprimer la commande? confirm_end: Veux tu vraiment mettre fin à la commande %{order}? Attention, il n'y aura pas d'annulation possible. new_order: Définir une nouvelle commande @@ -1142,6 +1153,15 @@ fr: warning_ordered_stock: new: title: Définir une nouvelle commande + receive: + add_article: + consider_member_tolerance: + notice: + notice_none: + rest_to_stock: + submit: + surplus_options: + title: show: action_end: Clore! amounts: ! 'Total net/brut:' @@ -1171,6 +1191,12 @@ fr: open: en cours update: notice: La commande a été mise à jour. + update_order_amounts: + msg1: + msg2: + msg3: + msg4: + update_order_amounts: pages: all: new_page: Créer une nouvelle page @@ -1297,7 +1323,7 @@ fr: private: Le message n'apparaîtra pas dans la boîte de réception du Foodsoft order_article: units_to_order: - update_current_price: Modifie aussi le prix des commandes en cours + update_global_price: stock_article: copy: name: Merci de modifier diff --git a/config/locales/nl.yml b/config/locales/nl.yml index f9f305d8..19a83ee5 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -77,12 +77,18 @@ nl: note: Notitie starts: Start op status: Status + supplier: Leverancier order_article: article: Artikel missing_units: Missende eenheden missing_units_short: Nodig + quantity: Gewenst aantal artikelen + quantity_short: Gewenst + units_received: Ontvangen eenheden + units_received_short: Ontvangen units_to_order: Aantal eenheden - update_current_price: Huidige prijs overal bijwerken + units_to_order_short: Besteld + update_global_price: Huidige prijs overal bijwerken order_comment: text: Commentaar voor deze bestelling toevoegen ... ordergroup: @@ -740,6 +746,7 @@ nl: new_invoice: Nieuwe rekening show_invoice: Rekening tonen orders: + old_price: Oude prijs option_choose: Leverancier/voorraad kiezen option_stock: Voorraad order_pdf: PDF maken @@ -1056,6 +1063,12 @@ nl: home: Hoofdpagina title: Wiki workgroups: Werkgroepen + order_articles: + edit: + stock_alert: De prijs van voorraadartikelen kan niet aangepast worden! + title: Artikel bijwerken + new: + title: Geleverd artikel aan bestelling toevoegen ordergroups: edit: title: Huidhouden bewerken @@ -1064,12 +1077,6 @@ nl: model: error_single_group: ! '%{user} behoort al tot een ander huishouden' invalid_balance: is geen geldig nummer - order_articles: - edit: - stock_alert: De prijs van voorraadartikelen kan niet aangepast worden! - title: Artikel bijwerken - new: - title: Geleverd artikel aan bestelling toevoegen orders: articles: article_count: ! 'Bestelde artikelen:' @@ -1081,6 +1088,9 @@ nl: notice: De bestelling is aangemaakt. edit: title: Bestelling aanpassen + edit_amount: + field_locked_title: + field_unlocked_title: fax: amount: Aantal articles: Artikelen @@ -1099,6 +1109,7 @@ nl: title: Artikel index: action_end: Sluiten + action_receive: Ontvangen confirm_delete: Wil je de bestelling werkelijk verwijderen? confirm_end: Wil je de bestelling %{order} werkelijk sluiten? Dit kun je niet ongedaan maken. new_order: Nieuwe bestelling openen @@ -1117,6 +1128,15 @@ nl: warning_ordered_stock: ! 'Opgelet: rood gemarkeerde artikelen zijn al besteld of gekocht door leden. Als je ze hier deselecteert, worden alle bestaande ledenbestellingen/-aankopen van deze artikelen verwijderd, en worden ze niet afgerekend.' new: title: Nieuwe bestelling openen + receive: + add_article: Artikel toevoegen + consider_member_tolerance: verdelen over tolerantie van leden + notice: ! 'Bestelling ontvangen: %{msg}' + notice_none: Geen nieuwe artikelen te ontvangen + rest_to_stock: naar voorraad + submit: Bestelling ontvangen + surplus_options: ! 'Overschot verdelen over:' + title: ! 'Ontvangen: %{order}' show: action_end: Sluiten! amounts: ! 'Totaal netto/bruto:' @@ -1148,6 +1168,12 @@ nl: open: lopend update: notice: De bestelling is bijgewerkt. + update_order_amounts: + msg1: + msg2: + msg3: + msg4: + update_order_amounts: pages: all: new_page: Nieuwe pagina maken @@ -1274,7 +1300,7 @@ nl: private: Bericht wordt niet getoond in de Foodsoft inbox. order_article: units_to_order: Als je het aantal geleverde eenheden wijzigt, moet je daarna de hoeveelheden voor huishoudens aanpassen. Klik daarvoor op de artikelnaam. Als je dit vergeet, kunnen huishoudens belast worden voor artikelen die ze niet hebben gekregen! - update_current_price: Ook prijs in huidige besteling aanpassen + update_global_price: Prijs ook aanpassen voor toekomstige bestellingen stock_article: copy: name: Wijzigen alsjeblieft diff --git a/config/routes.rb b/config/routes.rb index 20de3764..67497f9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Foodsoft::Application.routes.draw do get "sessions/new" - root :to => redirect("/#{FoodsoftConfig.scope}") + root :to => 'sessions#redirect_to_foodcoop' scope '/:foodcoop' do