]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Product-only:
authorRoland Häder <roland@mxchange.org>
Fri, 24 Apr 2020 12:47:09 +0000 (14:47 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 24 Apr 2020 12:47:09 +0000 (14:47 +0200)
- 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 <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/generic_product/action/FinancialAdminGenericProductActionWebViewBean.java
src/java/org/mxchange/localization/product_de_DE.properties
src/java/org/mxchange/localization/product_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl
web/WEB-INF/templates/admin/menu/project.tpl
web/admin/generic_product/admin_generic_product_edit.xhtml

index ba2b0a0e3fecc7131d2c1a23cff2218627066985..b1c5cc38f6140c760b5b0133cee516aa94d5cc46 100644 (file)
@@ -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
+        * <p>
+        * @return Product's FSC number
+        */
+       public String getProductFscNumber () {
+               return this.productFscNumber;
+       }
+
+       /**
+        * Setter for product's FSC number
+        * <p>
+        * @param productFscNumber Product's FSC number
+        */
+       public void setProductFscNumber (final String productFscNumber) {
+               this.productFscNumber = productFscNumber;
+       }
+
        /**
         * Getter for product's gross price
         * <p>
@@ -524,9 +550,11 @@ public class FinancialAdminGenericProductActionWebViewBean extends BaseFinancial
        /**
         * Updates given product data from request to database
         * <p>
+        * @return Redirection outcome
+        * <p>
         * @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;
        }
index 18003df186b2f4b42fc5e6a6fc21e3b606a34904..983ae2de3a22e2093661d4ffad0223bb6ff6c87c 100644 (file)
@@ -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.
index 2c84632a0a3506003dd51f358dbb1a50b4eab800..a4a2996ea4434af4954d6d07bee07bbcc5432e8b 100644 (file)
@@ -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.
index de114e1a5dd820f657784eb8adb851d27737c634..9245b55082d0dba783df1eb137f99edb45bca767 100644 (file)
                        <to-view-id>/admin/employee/admin_employee_list.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
-                       <from-outcome>admin_list_category</from-outcome>
+                       <from-outcome>admin_list_product_categories</from-outcome>
                        <to-view-id>/admin/product_category/admin_product_category_list.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
-                       <from-outcome>admin_list_product</from-outcome>
+                       <from-outcome>admin_list_generic_products</from-outcome>
                        <to-view-id>/admin/generic_product/admin_generic_product_list.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
                        <to-view-id>/admin/basic_data/admin_basic_data_show.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/admin/generic_product/admin_generic_product_edit.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>admin_list_generic_products</from-outcome>
+                       <to-view-id>/admin/generic_product/admin_generic_product_list.xhtml</to-view-id>
+                       <redirect></redirect>
+               </navigation-case>
+       </navigation-rule>
        <navigation-rule>
                <from-view-id>/admin/financial/receipt/admin_receipt_list.xhtml</from-view-id>
                <navigation-case>
index c016be80170b9b74a64a67c157a55aa4a68833e2..c2ed32d639e35a5d2d0de50d556748774e6057ed 100644 (file)
@@ -1,7 +1,4 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!--
-@TODO: title="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND_TITLE}"
--->
 <ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:product="http://mxchange.org/jsf/jproduct/widgets"
@@ -10,7 +7,10 @@
        xmlns:p="http://primefaces.org/ui"
        >
 
-       <p:fieldset legend="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND}">
+       <p:fieldset
+               legend="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND}"
+               title="#{product.ADMIN_GENERIC_PRODUCT_DATA_LEGEND_TITLE}"
+               >
                <p:panelGrid
                        layout="grid"
                        columns="2"
 
                                <f:converter converterId="ProductCategoryConverter" />
 
-                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+                               <f:selectItem
+                                       itemValue="#{null}"
+                                       itemLabel="#{msg.PLEASE_SELECT}"
+                                       noSelectionOption="true"
+                                       itemDisabled="true"
+                                       />
 
                                <f:selectItems
                                        value="#{categoryListController.allCategories}"
                                title="#{product.ADMIN_ENTER_GENERIC_PRODUCT_NUMBER_TITLE}"
                                />
 
+                       <p:outputLabel for="productFscNumber" value="#{product.ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER}" />
+                       <p:inputText
+                               id="productFscNumber"
+                               value="#{adminGenericProductActionController.productFscNumber}"
+                               size="7"
+                               maxlength="7"
+                               title="#{product.ADMIN_ENTER_GENERIC_PRODUCT_FSC_NUMBER_TITLE}"
+                               validatorMessage="#{product.ERROR_PRODUCT_FSC_NUMBER_NOT_VALID}"
+                               >
+                               <f:validateRegex pattern="C[0-9]{6}" />
+                       </p:inputText>
+
                        <p:outputLabel for="productBarCodeNumber" value="#{product.ADMIN_ENTER_GENERIC_PRODUCT_BARCODE_NUMBER}" />
                        <p:inputText
                                id="productBarCodeNumber"
index dec86691451eb1ec33e753fa3ee09dfafe9632b0..44874c3b28617cbfb1aee901259296e771e252d2 100644 (file)
@@ -11,7 +11,7 @@
        </p:submenu>
 
        <p:submenu label="#{product.ADMIN_MENU_PRODUCTS_CATEGORIES_TITLE}" expanded="false">
-               <p:menuitem title="#{product.ADMIN_LINK_LIST_GENERIC_PRODUCTS_TITLE}" outcome="admin_list_product" value="#{product.ADMIN_LINK_LIST_GENERIC_PRODUCTS}" />
-               <p:menuitem title="#{product.ADMIN_LINK_LIST_PRODUCT_CATEGORIES_TITLE}" outcome="admin_list_category" value="#{product.ADMIN_LINK_LIST_PRODUCT_CATEGORIES}" />
+               <p:menuitem title="#{product.ADMIN_LINK_LIST_GENERIC_PRODUCTS_TITLE}" outcome="admin_list_generic_products" value="#{product.ADMIN_LINK_LIST_GENERIC_PRODUCTS}" />
+               <p:menuitem title="#{product.ADMIN_LINK_LIST_PRODUCT_CATEGORIES_TITLE}" outcome="admin_list_product_categories" value="#{product.ADMIN_LINK_LIST_PRODUCT_CATEGORIES}" />
        </p:submenu>
 </ui:composition>
index 3974b99d0427a49b7eb6dd42bd7ec72fc9bdd497..0b01325c7aa261de194267f797d7de377288c1b3 100644 (file)
        </ui:define>
 
        <ui:define name="content">
-               <h:form rendered="#{not empty adminGenericProductActionController.currentProduct}">
+               <h:form
+                       id="admin-form-edit-generic-product"
+                       rendered="#{not empty adminGenericProductActionController.currentProduct}"
+                       >
                        <h:inputHidden value="#{adminGenericProductActionController.productId}" />
 
                        <p:panelGrid