From: Roland Häder Date: Fri, 24 Apr 2020 12:47:09 +0000 (+0200) Subject: Product-only: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=13ea0f0f503db6192c77ab88bd12f99745cf456e;p=jfinancials-war.git Product-only: - added navigation rule from admin-edit-generic-product to admin-list-generic-products - added returned outcome when a product has been successfully updated (admin) - renamed outcome admin_list_product to admin_list_generic_products - renamed outcome admin_list_category to admin_list_product_categories - if the product data has not been updated, output a proper warning message - added missing i18n strings Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java index ba2b0a0e..b1c5cc38 100644 --- a/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java +++ b/src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java @@ -18,10 +18,12 @@ package org.mxchange.jfinancials.beans.generic_product.action; import java.math.BigDecimal; import java.text.MessageFormat; +import java.util.Objects; import javax.ejb.EJB; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.faces.FacesException; +import javax.faces.application.FacesMessage; import javax.faces.view.ViewScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -98,6 +100,11 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial */ private String productCurrencyCode; + /** + * Product's FSC number + */ + private String productFscNumber; + /** * Product's gross price */ @@ -178,7 +185,7 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial // Is product i18n key already used? if (this.productListController.isProductI18nKeyAdded(this.getProductI18nKey())) { // Then throw exception - throw new FacesException(MessageFormat.format("Product i18n key {0} already added.", this.getProductI18nKey())); + throw new FacesException(MessageFormat.format("Product i18n key {0} already added.", this.getProductI18nKey())); //NOI18N } // Create current product instance @@ -221,6 +228,7 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial this.setProductBarCodeNumber(this.getCurrentProduct().getProductBarCodeNumber()); this.setProductCategory(this.getCurrentProduct().getProductCategory()); this.setProductCurrencyCode(this.getCurrentProduct().getProductCurrencyCode()); + this.setProductFscNumber(this.getCurrentProduct().getProductFscNumber()); this.setProductGrossPrice(this.getCurrentProduct().getProductGrossPrice()); this.setProductI18nKey(this.getCurrentProduct().getProductI18nKey()); this.setProductId(this.getCurrentProduct().getProductId()); @@ -341,6 +349,24 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial this.productCurrencyCode = productCurrencyCode; } + /** + * Getter for product's FSC number + *

+ * @return Product's FSC number + */ + public String getProductFscNumber () { + return this.productFscNumber; + } + + /** + * Setter for product's FSC number + *

+ * @param productFscNumber Product's FSC number + */ + public void setProductFscNumber (final String productFscNumber) { + this.productFscNumber = productFscNumber; + } + /** * Getter for product's gross price *

@@ -524,9 +550,11 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial /** * Updates given product data from request to database *

+ * @return Redirection outcome + *

* @throws FaceletException If something unexpected happened */ - public void updateProduct () throws FaceletException { + public String updateProduct () throws FaceletException { // Get new product instance final Product newProduct = this.createProductInstance(); @@ -536,12 +564,19 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial throw new NullPointerException("newProduct is null"); //NOI18N } else if (newProduct.getProductId() == null) { // Throw NPE again - throw new NullPointerException("newProduct.productId is null"); //NOI18N //NOI18N + throw new NullPointerException("newProduct.productId is null"); //NOI18N } else if (newProduct.getProductId() < 1) { // Invalid id throw new IllegalStateException(MessageFormat.format("newProduct.productId={0} is invalid", newProduct.getProductId())); //NOI18N } + // Has the product changed? + if (Objects.equals(newProduct, this.getCurrentProduct())) { + // Is the same product data, output message + this.showFacesMessage("admin-form-edit-generic-product:productI18nKey", "ADMIN_GENERIC_PRODUCT_NOT_UPDATED", FacesMessage.SEVERITY_WARN); //NOI18N + return ""; //NOI18N + } + // Init productr final Product updatedProduct; @@ -558,6 +593,9 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial // Clear bean this.clear(); + + // Return to admin-list view + return "admin_list_generic_products"; //NOI18N } /** @@ -569,6 +607,7 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial this.setProductAvailability(Boolean.FALSE); this.setProductBarCodeNumber(null); this.setProductCategory(null); + this.setProductFscNumber(null); this.setProductGrossPrice(null); this.setProductI18nKey(null); this.setProductId(null); @@ -601,18 +640,14 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial // Set all optional fields newProduct.setProductAgeGroup(this.getProductAgeGroup()); newProduct.setProductBarCodeNumber(this.getProductBarCodeNumber()); + newProduct.setProductFscNumber(this.getProductFscNumber()); + newProduct.setProductId(this.getProductId()); newProduct.setProductManufacturer(this.getProductManufacturer()); - newProduct.setProductNumber(this.getProductNumber()); newProduct.setProductNetPrice(this.getProductNetPrice()); + newProduct.setProductNumber(this.getProductNumber()); newProduct.setProductSize(this.getProductSize()); newProduct.setProductTaxRate(this.getProductTaxRate()); - // Is product id set? - if (this.getProductId() instanceof Long) { - // Set it, too - newProduct.setProductId(this.getProductId()); - } - // Return it return newProduct; } diff --git a/src/java/org/mxchange/localization/product_de_DE.properties b/src/java/org/mxchange/localization/product_de_DE.properties index 18003df1..983ae2de 100644 --- a/src/java/org/mxchange/localization/product_de_DE.properties +++ b/src/java/org/mxchange/localization/product_de_DE.properties @@ -197,3 +197,9 @@ ADMIN_PRODUCT_BARCODE_HEADER=Barcode: ADMIN_MENU_PRODUCTS_CATEGORIES_TITLE=Produkte & Kategorien #@TODO Please fix German umlauts! ADMIN_ENTER_GENERIC_PRODUCT_UNIT_AMOUNT=Einheitengroesse des Produktes eingeben: +ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER=FSC-Nummer eingeben: +#@TODO Please fix German umlauts! +ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER_TITLE=Geben Sie die FSC-Nummer des Produktes mit fuehrendem C und 6 Stellen ein. +ERROR_PRODUCT_FSC_NUMBER_NOT_VALID=Fehler: FSC-Nummer des Produktes entspricht nicht dem Format: Cxxxxxx +#@TODO Please fix German umlauts! +ADMIN_GENERIC_PRODUCT_NOT_UPDATED=Sie haben keine Aenderungen am dem Produkt vorgenommen. diff --git a/src/java/org/mxchange/localization/product_en_US.properties b/src/java/org/mxchange/localization/product_en_US.properties index 2c84632a..a4a2996e 100644 --- a/src/java/org/mxchange/localization/product_en_US.properties +++ b/src/java/org/mxchange/localization/product_en_US.properties @@ -158,3 +158,7 @@ ADMIN_ASSIGN_PARENT_PRODUCT_CATEGORY=Assign parent category: ADMIN_PRODUCT_MANUFACTURER_HEADER=Manufacturer of product: ADMIN_PRODUCT_BARCODE_HEADER=Barcode: ADMIN_MENU_PRODUCTS_CATEGORIES_TITLE=Products & Categories +ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER=Enter FSC number: +ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER_TITLE=Enter product's FSC number with leading C and 6 digits. +ERROR_PRODUCT_FSC_NUMBER_NOT_VALID=Error: FSC number not valid format: Cxxxxxx +ADMIN_GENERIC_PRODUCT_NOT_UPDATED=You have not changed any product data. diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index de114e1a..9245b550 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -133,11 +133,11 @@ /admin/employee/admin_employee_list.xhtml - admin_list_category + admin_list_product_categories /admin/product_category/admin_product_category_list.xhtml - admin_list_product + admin_list_generic_products /admin/generic_product/admin_generic_product_list.xhtml @@ -994,6 +994,14 @@ /admin/basic_data/admin_basic_data_show.xhtml + + /admin/generic_product/admin_generic_product_edit.xhtml + + admin_list_generic_products + /admin/generic_product/admin_generic_product_list.xhtml + + + /admin/financial/receipt/admin_receipt_list.xhtml diff --git a/web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl b/web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl index c016be80..c2ed32d6 100644 --- a/web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl +++ b/web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl @@ -1,7 +1,4 @@ - - + - + + + + + + - - + + diff --git a/web/admin/generic_product/admin_generic_product_edit.xhtml b/web/admin/generic_product/admin_generic_product_edit.xhtml index 3974b99d..0b01325c 100644 --- a/web/admin/generic_product/admin_generic_product_edit.xhtml +++ b/web/admin/generic_product/admin_generic_product_edit.xhtml @@ -34,7 +34,10 @@ - +