From ec2820f9436e78abce162068b6f98c485f1f631a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 8 Oct 2017 18:55:25 +0200 Subject: [PATCH] Please cherry-pick: - rewrote administrative user list to PrimeFaces with filters and multi-sortable and resizable columns - fixed header facet for mobile provider list - rewrote admin_form_user/contact_data.tpl to response p:panelGrid - converted div to h:panelGroup - added more "static" data like personal title, account status and profile mode - added missing i18n strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsCompanyEmployeeWebRequestBean.java | 1 + .../JobsOpeningTimeWebRequestBean.java | 29 +++ .../data/JobsDataWebApplicationBean.java | 30 +++ .../beans/user/JobsUserWebRequestBean.java | 77 +++++-- .../JobsPersonalTitleConverter.java | 39 ++++ .../JobsProfileModeConverter.java | 39 ++++ .../JobsUserAccountStatusConverter.java | 39 ++++ .../localization/bundle_de_DE.properties | 3 + .../localization/bundle_en_US.properties | 2 + .../contact/admin_form_contact_data.tpl | 143 ++++++------- .../form_data/user/admin_form_user_data.tpl | 101 +++------ .../user/admin_form_user_personal_data.tpl | 4 +- .../admin/user/admin_show_user_data.tpl | 5 +- .../admin/user/admin_show_user_data_mini.tpl | 21 +- .../admin_mobile_provider_list.xhtml | 17 +- web/admin/user/admin_user_list.xhtml | 201 ++++++++++-------- 16 files changed, 488 insertions(+), 263 deletions(-) create mode 100644 src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java create mode 100644 src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java create mode 100644 src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java index ae48e17a..43ad415a 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsCompanyEmployeeWebRequestBean.java @@ -105,6 +105,7 @@ public class JobsEmployeeWebRequestBean extends BaseJobsBean implements JobsEmpl // Add employee to cache and list this.employeeCache.put(event.getEmployee().getEmployeeId(), event.getEmployee()); + this.allEmployees.add(event.getEmployee()); } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java index b98f7339..ca350fa7 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsOpeningTimeWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.jjobs.beans.business.opening_time; import fish.payara.cdi.jsr107.impl.NamedCache; +import java.text.MessageFormat; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; @@ -25,8 +26,10 @@ import javax.annotation.PostConstruct; import javax.cache.Cache; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.opening_time.added.ObservableOpeningTimeAddedEvent; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote; import org.mxchange.jjobs.beans.BaseJobsBean; @@ -79,6 +82,32 @@ public class JobsOpeningTimeWebRequestBean extends BaseJobsBean implements JobsO this.allOpeningTimes = new LinkedList<>(); } + /** + * Observes events being thrown when a new opening time has been added + *

+ * @param event Event being fired + */ + public void afterOpeningTimeAddedEvent (@Observes final ObservableOpeningTimeAddedEvent event) { + // Validate parameter + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); + } else if (event.getOpeningTime() == null) { + // Throw it again + throw new NullPointerException("event.openingTime is null"); + } else if (event.getOpeningTime().getOpeningId() == null) { + // Throw it again + throw new NullPointerException("event.openingTime.openingId is null"); + } else if (event.getOpeningTime().getOpeningId() < 1) { + // Throw it again + throw new NullPointerException(MessageFormat.format("event.openingTime.openingId={0} is invalid", event.getOpeningTime().getOpeningId())); + } + + // Add to cache and list + this.openingTimesCache.put(event.getOpeningTime().getOpeningId(), event.getOpeningTime()); + this.allOpeningTimes.add(event.getOpeningTime()); + } + @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allOpeningTimes () { diff --git a/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java index 626dcef7..93cb9841 100644 --- a/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/data/JobsDataWebApplicationBean.java @@ -18,9 +18,12 @@ package org.mxchange.jjobs.beans.data; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; +import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jproduct.model.payment.PaymentType; +import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; +import org.mxchange.jusercore.model.user.status.UserAccountStatus; /** * An application-scoped data bean for any kind of static data @@ -61,4 +64,31 @@ public class JobsDataWebApplicationBean extends BaseJobsBean { public PaymentType[] getPaymentTypes () { return PaymentType.values(); } + + /** + * Returns a list of all personal titles + *

+ * @return A list of all personal titles + */ + public PersonalTitle[] getPersonalTitles () { + return PersonalTitle.values(); + } + + /** + * Returns a list of all profile modes

+ * @return A list of all profile modes + */ + public ProfileMode[] getProfileModes () { + return ProfileMode.values(); + } + + /** + * Returns a list of all user account statuses + *

+ * @return A list of all user account statuses + */ + public UserAccountStatus[] getUserAccountStatuses () { + return UserAccountStatus.values(); + } } diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java index b26a455d..e9d86a42 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.jjobs.beans.user; import fish.payara.cdi.jsr107.impl.NamedCache; import java.text.MessageFormat; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -78,6 +79,11 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR */ private static final long serialVersionUID = 542_145_347_916L; + /** + * List of all users + */ + private final List allUsers; + /** * General contact controller */ @@ -90,6 +96,11 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR @Inject private JobsFeaturesWebApplicationController featureController; + /** + * List of filtered users + */ + private List filteredUsers; + /** * Locale instance */ @@ -159,6 +170,9 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR public JobsUserWebRequestBean () { // Call super constructor super(); + + // Init list + this.allUsers = new LinkedList<>(); } /** @@ -549,23 +563,7 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allUsers () { - // Init list - final List list = new LinkedList<>(); - - // Get iterator - final Iterator> iterator = this.userCache.iterator(); - - // Loop over all - while (iterator.hasNext()) { - // Get next entry - final Cache.Entry next = iterator.next(); - - // Add value to list - list.add(next.getValue()); - } - - // Return it - return list; + return this.allUsers; } /** @@ -708,6 +706,26 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR return "user_contact_data_saved"; //NOI18N } + /** + * Getter for filtered users list + *

+ * @return Filtered users list + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredUsers () { + return this.filteredUsers; + } + + /** + * Setter for filtered users list + *

+ * @param filteredUsers Filtered users list + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredUsers (final List filteredUsers) { + this.filteredUsers = filteredUsers; + } + /** * Getter for user id *

@@ -822,6 +840,29 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR this.userNameCache.put(next.getUserId(), next.getUserName()); } } + + // Is cache filled and list is empty + if ((this.userCache.iterator().hasNext()) && (this.allUsers.isEmpty())) { + // Get iterator + final Iterator> iterator = this.userCache.iterator(); + + // Build up list + while (iterator.hasNext()) { + // GEt next element + final Cache.Entry next = iterator.next(); + + // Add to list + this.allUsers.add(next.getValue()); + } + + // Sort list + this.allUsers.sort(new Comparator() { + @Override + public int compare (final User o1, final User o2) { + return o1.getUserId() > o2.getUserId() ? 1 : o1.getUserId() < o2.getUserId() ? -1 : 0; + } + }); + } } @Override @@ -1119,6 +1160,7 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR // Remove it from lists this.userCache.remove(user.getUserId()); + this.allUsers.remove(user); // Remove name from list this.userNameCache.remove(user.getUserId()); @@ -1153,6 +1195,7 @@ public class JobsUserWebRequestBean extends BaseJobsBean implements JobsUserWebR // Add/update user this.userCache.put(user.getUserId(), user); + this.allUsers.add(user); } } diff --git a/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java b/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java new file mode 100644 index 00000000..00cdc695 --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/personal_title/JobsPersonalTitleConverter.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.converter.personal_title; + +import javax.faces.convert.EnumConverter; +import javax.faces.convert.FacesConverter; +import org.mxchange.jcontacts.model.contact.title.PersonalTitle; + +/** + * A converter for personal titles + *

+ * @author Roland Häder + */ +@FacesConverter("PersonalTitleConverter") +public class JobsPersonalTitleConverter extends EnumConverter { + + /** + * Default constructor which calls the super constructor with the proper + * enumeration as class type. + */ + public JobsPersonalTitleConverter () { + super(PersonalTitle.class); + } + +} diff --git a/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java b/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java new file mode 100644 index 00000000..3e9d4150 --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/profile_mode/JobsProfileModeConverter.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.converter.profile_mode; + +import javax.faces.convert.EnumConverter; +import javax.faces.convert.FacesConverter; +import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; + +/** + * A converter for profile mode + *

+ * @author Roland Häder + */ +@FacesConverter("ProfileModeConverter") +public class JobsProfileModeConverter extends EnumConverter { + + /** + * Default constructor which calls the super constructor with the proper + * enumeration as class type. + */ + public JobsProfileModeConverter () { + super(ProfileMode.class); + } + +} diff --git a/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java b/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java new file mode 100644 index 00000000..371aa53b --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/user_account_status/JobsUserAccountStatusConverter.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.converter.user_account_status; + +import javax.faces.convert.EnumConverter; +import javax.faces.convert.FacesConverter; +import org.mxchange.jusercore.model.user.status.UserAccountStatus; + +/** + * A converter for user account status + *

+ * @author Roland Häder + */ +@FacesConverter("UserAccountStatusConverter") +public class JobsUserAccountStatusConverter extends EnumConverter { + + /** + * Default constructor which calls the super constructor with the proper + * enumeration as class type. + */ + public JobsUserAccountStatusConverter () { + super(UserAccountStatus.class); + } + +} diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 7bfc18c2..b2241bf7 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -1080,3 +1080,6 @@ BUTTON_ADMIN_ADD_OPENING_TIME=Oeffnungszeit hinzufuegen ADMIN_LINK_ASSIGN_DEPARTMENT_BRANCH_OFFICE_TITLE=Dieser Abteilung eine Filiale zuweisen. ADMIN_LINK_ASSIGN_DEPARTMENTS_LEAD_EMPLOYEE_TITLE=Dieser Abteilung einen leitenden Mitarbeiter zuweisen. ADMIN_LINK_ASSIGN_DEPARTMENTS_OWNER_USER_TITLE=Dieser Abteilung einen besitzenden Benutzer zuweisen. +#@TODO Please fix German umlauts! +FIELD_PAYMENT_TYPE_REQUIRED=Bitte waehlen Sie eine Zahlungsmethode aus. +ADMIN_LIST_USERS_HEADER=Liste aller Benutzer diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 72026622..3c1b261a 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -1007,3 +1007,5 @@ BUTTON_ADMIN_ADD_OPENING_TIME=Add opening time ADMIN_LINK_ASSIGN_DEPARTMENT_BRANCH_OFFICE_TITLE=Assign this department a branch office. ADMIN_LINK_ASSIGN_DEPARTMENTS_LEAD_EMPLOYEE_TITLE=Assign this department a leading employee. ADMIN_LINK_ASSIGN_DEPARTMENTS_OWNER_USER_TITLE=Assign this department an owning user. +FIELD_PAYMENT_TYPE_REQUIRED=Please choose a payment method. +ADMIN_LIST_USERS_HEADER=List of all users diff --git a/web/WEB-INF/resources/tags/admin/form_data/contact/admin_form_contact_data.tpl b/web/WEB-INF/resources/tags/admin/form_data/contact/admin_form_contact_data.tpl index 5b9bfee2..d0cce9ad 100644 --- a/web/WEB-INF/resources/tags/admin/form_data/contact/admin_form_contact_data.tpl +++ b/web/WEB-INF/resources/tags/admin/form_data/contact/admin_form_contact_data.tpl @@ -7,78 +7,73 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
    -
  • - -
  • -
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
  • + +
  • +
+
diff --git a/web/WEB-INF/resources/tags/admin/form_data/user/admin_form_user_data.tpl b/web/WEB-INF/resources/tags/admin/form_data/user/admin_form_user_data.tpl index de66672f..acbb6f35 100644 --- a/web/WEB-INF/resources/tags/admin/form_data/user/admin_form_user_data.tpl +++ b/web/WEB-INF/resources/tags/admin/form_data/user/admin_form_user_data.tpl @@ -7,74 +7,35 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - -
- - - - - -
- -
- -
- -
-
- - - - - - -
- -
- -
- -
-
- - - - - - -
- -
- -
- -
-
- - - - - - -
- -
- -
- -
-
- - -
    -
  • - -
  • - - -
  • -
-
-
-
+ + + + + + + + + + + + + + + + + + + +
    +
  • + +
  • + + +
  • +
+
+
diff --git a/web/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl b/web/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl index 724f72ac..549c2121 100644 --- a/web/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl +++ b/web/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl @@ -8,9 +8,9 @@ -
+ -
+ diff --git a/web/WEB-INF/templates/admin/user/admin_show_user_data.tpl b/web/WEB-INF/templates/admin/user/admin_show_user_data.tpl index 2cd43c84..74c460bf 100644 --- a/web/WEB-INF/templates/admin/user/admin_show_user_data.tpl +++ b/web/WEB-INF/templates/admin/user/admin_show_user_data.tpl @@ -7,7 +7,10 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - + + diff --git a/web/WEB-INF/templates/admin/user/admin_show_user_data_mini.tpl b/web/WEB-INF/templates/admin/user/admin_show_user_data_mini.tpl index d0564cfb..cc165a42 100644 --- a/web/WEB-INF/templates/admin/user/admin_show_user_data_mini.tpl +++ b/web/WEB-INF/templates/admin/user/admin_show_user_data_mini.tpl @@ -7,7 +7,10 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - + + @@ -15,7 +18,7 @@ - + @@ -23,29 +26,29 @@ - + - + - + - + - + - + - + diff --git a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml index 669e5c69..a7c0734e 100644 --- a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml +++ b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml @@ -24,7 +24,6 @@ tableStyleClass="table table-full" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" - widgetVar="mobileProviderList" filteredValue="#{mobileProviderController.filteredMobileProviders}" rows="10" reflow="true" @@ -37,9 +36,12 @@ > - - - + + + + + + @@ -67,7 +69,12 @@ title="#{msg.FILTER_BY_MULTIPLE_COUNTRY_TITLE}" > - + diff --git a/web/admin/user/admin_user_list.xhtml b/web/admin/user/admin_user_list.xhtml index e482a110..586b7438 100644 --- a/web/admin/user/admin_user_list.xhtml +++ b/web/admin/user/admin_user_list.xhtml @@ -24,145 +24,176 @@ value="#{userController.allUsers()}" tableStyleClass="table table-full" paginator="true" + paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" + filteredValue="#{userController.filteredUsers}" rows="10" + reflow="true" + resizableColumns="true" + rowsPerPageTemplate="5,10,20,50,100" + sortMode="multiple" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_USERS}" emptyMessage="#{msg.ADMIN_EMPTY_LIST_USER}" widgetVar="userList" > - - - - + + + + + + + + + + - - - - - - - - - + + + - - - + + + + + + + - - - - - + - - - - - + - - - + + + + + + + - - - + + + + + + + - - - - - + - - - - - + - -
+ + -
+
- -
- - - - - -
- -
- -
- - - - -
-
-
-
- - + + + + + + + + + + + + + - + - - + + + + + + + +
-- 2.39.5