use of com.helger.html.hc.impl.HCNodeList in project peppol-practical by phax.
the class PageSecureCommentAdmin method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final CommentThreadManager aCommentThreadMgr = CommentThreadManager.getInstance();
boolean bShowList = true;
final String sSelectedObjectType = aWPEC.params().getAsString(PARAM_TYPE);
final String sSelectedOwningObjectID = aWPEC.params().getAsString(CPageParam.PARAM_OBJECT);
if (aWPEC.hasAction(CPageParam.ACTION_VIEW) && StringHelper.hasText(sSelectedObjectType) && StringHelper.hasText(sSelectedOwningObjectID)) {
final TypedObject<String> aTO = TypedObject.create(new ObjectType(sSelectedObjectType), sSelectedOwningObjectID);
final List<ICommentThread> aCommentThreads = aCommentThreadMgr.getAllCommentThreadsOfObject(aTO);
if (!aCommentThreads.isEmpty()) {
// Don't allow comment creation
aNodeList.addChild(CommentUI.getCommentList(aWPEC, aTO, CommentAction.createGeneric(ECommentAction.NONE), null, null, false));
// Toolbar
final IButtonToolbar<?> aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton(EPhotonCoreText.BACK_TO_OVERVIEW.getDisplayText(aDisplayLocale), aWPEC.getSelfHref(), EDefaultIcon.BACK_TO_LIST);
aNodeList.addChild(aToolbar);
bShowList = false;
}
}
if (bShowList) {
// Refresh button
final IButtonToolbar<?> aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton(EPhotonCoreText.BUTTON_REFRESH.getDisplayText(aDisplayLocale), aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aNodeList.addChild(aToolbar);
final ITabBox<?> aTabBox = new BootstrapTabBox();
for (final ObjectType aOT : CollectionHelper.getSorted(aCommentThreadMgr.getAllRegisteredObjectTypes())) {
final HCNodeList aTab = new HCNodeList();
final HCTable aTable = new HCTable(new DTCol(EText.HEADER_OBJECT_ID.getDisplayText(aDisplayLocale)), new DTCol(EText.HEADER_THREADS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_COMMENTS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_ACTIVE_COMMENTS.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol(EText.HEADER_LAST_CHANGE.getDisplayText(aDisplayLocale)).addClass(CSS_CLASS_RIGHT).setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING)).setID(getID() + aOT.getName());
final CommentThreadObjectTypeManager aCTOTMgr = aCommentThreadMgr.getManagerOfObjectType(aOT);
for (final Map.Entry<String, ICommonsList<ICommentThread>> aEntry : aCTOTMgr.getAllCommentThreads().entrySet()) {
final String sOwningObjectID = aEntry.getKey();
final ISimpleURL aViewURL = AbstractWebPageForm.createViewURL(aWPEC, sOwningObjectID).add(PARAM_TYPE, aOT.getName());
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewURL).addChild(sOwningObjectID));
aRow.addCell(Integer.toString(aEntry.getValue().size()));
int nActiveComments = 0;
final ICommonsList<IComment> aAllComments = new CommonsArrayList<>();
for (final ICommentThread aCommentThread : aEntry.getValue()) {
aAllComments.addAll(aCommentThread.getAllComments());
nActiveComments += aCommentThread.getTotalActiveCommentCount();
}
Collections.sort(aAllComments, Comparator.comparing(IComment::getLastChangeDateTime).reversed());
aRow.addCell(Integer.toString(aAllComments.size()));
aRow.addCell(Integer.toString(nActiveComments));
if (aAllComments.isEmpty())
aRow.addCell();
else
aRow.addCell(PDTToString.getAsString(aAllComments.get(0).getLastChangeDateTime(), aDisplayLocale));
}
aTab.addChild(aTable);
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aTab.addChild(aDataTables);
aTabBox.addTab(aOT.getName(), aOT.getName(), aTab, aOT.getName().equals(sSelectedObjectType));
}
aNodeList.addChild(aTabBox);
}
}
use of com.helger.html.hc.impl.HCNodeList in project peppol-practical by phax.
the class PagePublicLogin method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
aNodeList.addChild(AppCommonUI.createViewLoginForm(aWPEC, null, true));
}
use of com.helger.html.hc.impl.HCNodeList in project peppol-practical by phax.
the class PagePublicNewsletterSubscribe method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
final CRMSubscriberManager aCRMSubscriberMgr = PPMetaManager.getCRMSubscriberMgr();
final FormErrorList aFormErrors = new FormErrorList();
ICommonsList<String> aSelectedCRMGroupIDs = null;
if (aWPEC.hasAction(CPageParam.ACTION_SAVE)) {
final String sSalutationID = aWPEC.params().getAsString(FIELD_SALUTATION);
final ESalutation eSalutation = ESalutation.getFromIDOrNull(sSalutationID);
final String sName = aWPEC.params().getAsString(FIELD_NAME);
final String sEmailAddress = aWPEC.params().getAsString(FIELD_EMAIL_ADDRESS);
aSelectedCRMGroupIDs = aWPEC.params().getAsStringList(FIELD_GROUP);
final ICommonsSet<ICRMGroup> aSelectedCRMGroups = new CommonsHashSet<>();
ICRMSubscriber aSameEmailAddressSubscriber = null;
if (StringHelper.hasNoText(sName))
aFormErrors.addFieldError(FIELD_NAME, "You must provide your name!");
if (StringHelper.hasNoText(sEmailAddress))
aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "You must provide your email address!");
else if (!EmailAddressHelper.isValid(sEmailAddress))
aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "The provided email address is invalid!");
else {
// Check if the email address is already in use
aSameEmailAddressSubscriber = aCRMSubscriberMgr.getCRMSubscriberOfEmailAddress(sEmailAddress);
}
if (aSelectedCRMGroupIDs != null)
for (final String sCRMGroupID : aSelectedCRMGroupIDs) {
final ICRMGroup aGroup = aCRMGroupMgr.getCRMGroupOfID(sCRMGroupID);
if (aGroup == null)
aFormErrors.addFieldError(FIELD_GROUP, "The selected mailing list is not existing!");
else
aSelectedCRMGroups.add(aGroup);
}
if (aSelectedCRMGroups.isEmpty())
aFormErrors.addFieldError(FIELD_GROUP, "At least one mailing list must be selected!");
else {
if (aSameEmailAddressSubscriber != null) {
// Merge with existing subscriber
aSelectedCRMGroups.addAll(aSameEmailAddressSubscriber.getAllAssignedGroups());
}
}
if (aFormErrors.isEmpty()) {
// Save
if (aSameEmailAddressSubscriber == null) {
// Create a new one
aCRMSubscriberMgr.createCRMSubscriber(eSalutation, sName, sEmailAddress, aSelectedCRMGroups);
} else {
// Update an existing one
aCRMSubscriberMgr.updateCRMSubscriber(aSameEmailAddressSubscriber.getID(), eSalutation, sName, sEmailAddress, aSelectedCRMGroups);
}
aNodeList.addChild(success("Successfully subscribed '" + sEmailAddress + "' to mailing lists"));
} else {
aNodeList.addChild(getUIHandler().createIncorrectInputBox(aWPEC));
}
}
final BootstrapForm aForm = getUIHandler().createFormSelf(aWPEC);
aForm.setLeft(3);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Your salutation").setCtrl(new HCSalutationSelect(new RequestField(FIELD_SALUTATION), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SALUTATION)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your name").setCtrl(new HCEdit(new RequestField(FIELD_NAME))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL_ADDRESS))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL_ADDRESS)));
{
final ICommonsList<? extends ICRMGroup> aAllCRMGroups = aCRMGroupMgr.getAll();
if (aAllCRMGroups.size() == 1) {
// No need for selection - use hidden field
aForm.addChild(new HCHiddenField(FIELD_GROUP, aAllCRMGroups.getFirst().getID()));
} else if (aAllCRMGroups.isNotEmpty()) {
// Show selection
final HCNodeList aGroups = new HCNodeList();
for (final ICRMGroup aCRMGroup : aAllCRMGroups.getSorted(IHasDisplayName.getComparatorCollating(aDisplayLocale))) {
final String sCRMGroupID = aCRMGroup.getID();
final RequestFieldBooleanMultiValue aRFB = new RequestFieldBooleanMultiValue(FIELD_GROUP, sCRMGroupID, false);
aGroups.addChild(new HCDiv().addChild(new HCCheckBox(aRFB)).addChild(" " + aCRMGroup.getDisplayName()));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Mailing lists to subscribe to").setCtrl(aGroups).setErrorList(aFormErrors.getListOfField(FIELD_GROUP)));
}
}
// Toolbar
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_SAVE);
aToolbar.addSubmitButton("Subscribe", EDefaultIcon.YES);
aNodeList.addChild(aForm);
}
use of com.helger.html.hc.impl.HCNodeList in project peppol-practical by phax.
the class PagePublicNewsletterUnsubscribe method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final CRMSubscriberManager aCRMSubscriberMgr = PPMetaManager.getCRMSubscriberMgr();
final FormErrorList aFormErrors = new FormErrorList();
if (aWPEC.hasAction(CPageParam.ACTION_SAVE)) {
final String sEmailAddress = aWPEC.params().getAsString(FIELD_EMAIL_ADDRESS);
ICRMSubscriber aCRMSubscriber = null;
if (StringHelper.hasNoText(sEmailAddress))
aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "You must provide your email address!");
else if (!EmailAddressHelper.isValid(sEmailAddress))
aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "The provided email address is invalid!");
else {
aCRMSubscriber = aCRMSubscriberMgr.getCRMSubscriberOfEmailAddress(sEmailAddress);
if (aCRMSubscriber == null)
aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "The provided email address is not registered to any mailing list!");
}
if (aFormErrors.isEmpty()) {
// Update an existing one
aCRMSubscriberMgr.updateCRMSubscriberGroupAssignments(aCRMSubscriber.getID(), null);
aNodeList.addChild(success("Successfully unsubscribed '" + sEmailAddress + "' from all mailing lists"));
} else {
aNodeList.addChild(getUIHandler().createIncorrectInputBox(aWPEC));
}
}
final BootstrapForm aForm = getUIHandler().createFormSelf(aWPEC);
aForm.setLeft(3);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL_ADDRESS))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL_ADDRESS)));
// Toolbar
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_SAVE);
aToolbar.addSubmitButton("Unsubscribe", EDefaultIcon.YES);
aNodeList.addChild(aForm);
}
use of com.helger.html.hc.impl.HCNodeList in project peppol-practical by phax.
the class PageSecureSMLConfiguration method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMLConfiguration aSelectedObject) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of SML configuration '" + aSelectedObject.getDisplayName() + "'"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("ID").setCtrl(aSelectedObject.getID()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Name").setCtrl(aSelectedObject.getDisplayName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("DNS Zone").setCtrl(aSelectedObject.getDNSZone()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Publisher DNS Zone").setCtrl(aSelectedObject.getPublisherDNSZone()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Management Service URL").setCtrl(HCA.createLinkedWebsite(aSelectedObject.getManagementServiceURL())));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Manage Service Metadata Endpoint").setCtrl(HCA.createLinkedWebsite(aSelectedObject.getManageServiceMetaDataEndpointAddress().toExternalForm())));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Manage Participant Identifier Endpoint").setCtrl(HCA.createLinkedWebsite(aSelectedObject.getManageParticipantIdentifierEndpointAddress().toExternalForm())));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Client certificate required?").setCtrl(EPhotonCoreText.getYesOrNo(aSelectedObject.isClientCertificateRequired(), aDisplayLocale)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("SMP API type").setCtrl(aSelectedObject.getSMPAPIType().getDisplayName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("SMP identifier type").setCtrl(aSelectedObject.getSMPIdentifierType().getDisplayName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Production SML?").setCtrl(EPhotonCoreText.getYesOrNo(aSelectedObject.isProduction(), aDisplayLocale)));
aNodeList.addChild(aForm);
}
Aggregations