Skip to content

Commit

Permalink
Merge pull request #358 from devgateway/master-updates
Browse files Browse the repository at this point in the history
Master updates
  • Loading branch information
mpostelnicu authored Nov 1, 2019
2 parents ae00952 + 072fbad commit 7b029cf
Show file tree
Hide file tree
Showing 74 changed files with 894 additions and 397 deletions.
10 changes: 5 additions & 5 deletions forms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>makueni</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0</version>
</parent>

<properties>
Expand All @@ -45,26 +45,26 @@
<dependency>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>persistence</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>persistence-mongodb</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>ui</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0</version>
</dependency>


<dependency>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>web</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import de.agilecoders.wicket.extensions.markup.html.bootstrap.ladda.LaddaAjaxButton;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.event.IEventSink;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand All @@ -24,6 +27,8 @@
import org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton;
import org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton;
import org.devgateway.toolkit.forms.wicket.components.util.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent;
import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditStatusEntityPage;
import org.devgateway.toolkit.persistence.dao.AbstractAuditableEntity;
import org.devgateway.toolkit.persistence.dao.ListViewItem;
import org.slf4j.Logger;
Expand Down Expand Up @@ -61,6 +66,14 @@ public ListViewSectionPanel(final String id) {
super(id);
}

protected void checkAndSendEventForDisableEditing(IEventSink sink) {
Page page = getPage();
if (page instanceof AbstractEditStatusEntityPage && ((AbstractEditStatusEntityPage) page)
.isDisableEditingEvent()) {
send(sink, Broadcast.BREADTH, new EditingDisabledEvent());
}
}

@Override
protected void onInitialize() {
super.onInitialize();
Expand Down Expand Up @@ -145,6 +158,8 @@ protected void populateItem(final ListItem<T> item) {
populateCompoundListItem(item);

addAcordion(item);

checkAndSendEventForDisableEditing(item);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public abstract class GenericBootstrapFormComponent<TYPE, FIELD extends FormComp
private TooltipConfig.OpenTrigger configWithTrigger = TooltipConfig.OpenTrigger.hover;

// use a flag if we need to display a Tooltip since StringResourceModel it's expensive
private Boolean showTooltip = false;
private Boolean showTooltip = true;

private final IModel<String> labelModel;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2015 Development Gateway, Inc and others.
* <p>
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the MIT License (MIT)
* which accompanies this distribution, and is available at
* https://opensource.org/licenses/MIT
* <p>
* Contributors:
* Development Gateway - initial API and implementation
*/
/**
*
*/
package org.devgateway.toolkit.forms.wicket.components.form;

import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.model.IModel;
import org.apache.wicket.validation.validator.StringValidator;
import org.devgateway.toolkit.forms.WebConstants;

/**
* @author mpostelnicu
*
* A {@link TextAreaFieldBootstrapFormComponent} that has TextArea{@link #isRequired()} exposed
*
*/
public abstract class OptionallyRequiredTextAreaFieldComponent<TYPE> extends TextAreaFieldBootstrapFormComponent<TYPE> {
private StringValidator validator = WebConstants.StringValidators.MAXIMUM_LENGTH_VALIDATOR_ONE_LINE_TEXTAREA;

private static final long serialVersionUID = 1L;

public OptionallyRequiredTextAreaFieldComponent(final String id, final IModel<String> labelModel,
final IModel<TYPE> model) {
super(id, labelModel, model);
}

public OptionallyRequiredTextAreaFieldComponent(final String id, final IModel<String> labelModel) {
super(id, labelModel, null);
}

/**
* @param id
*/
public OptionallyRequiredTextAreaFieldComponent(final String id) {
super(id);
}

public abstract boolean isRequired();

@Override
protected TextArea<TYPE> inputField(final String id, final IModel<TYPE> model) {
TextArea<TYPE> textArea = new TextArea<TYPE>(id, initFieldModel()) {
@Override
public boolean isRequired() {
return OptionallyRequiredTextAreaFieldComponent.this.isRequired();
}
};
return textArea;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
package org.devgateway.toolkit.forms.wicket.page;

import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.CssClassNameAppender;
import de.agilecoders.wicket.core.markup.html.bootstrap.button.BootstrapBookmarkablePageLink;
import de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink;
import de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.MenuDivider;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
import de.agilecoders.wicket.core.markup.html.bootstrap.html.HtmlTag;
import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton;
import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarComponents;
Expand Down Expand Up @@ -49,6 +51,7 @@
import org.apache.wicket.util.string.StringValue;
import org.devgateway.toolkit.forms.WebConstants;
import org.devgateway.toolkit.forms.wicket.page.edit.EditAdminSettingsPage;
import org.devgateway.toolkit.forms.wicket.page.lists.AbstractListPage;
import org.devgateway.toolkit.forms.wicket.page.lists.ListFiscalYearPage;
import org.devgateway.toolkit.forms.wicket.page.lists.ListTestFormPage;
import org.devgateway.toolkit.forms.wicket.page.lists.ListUserPage;
Expand Down Expand Up @@ -276,6 +279,30 @@ private NavbarButton<Homepage> newHomeMenu() {
}


private <L extends AbstractListPage> BootstrapBookmarkablePageLink<L>
createListMenu(Class<L> clazz, String resourceKey, IconType iconType) {
return new MenuBookmarkablePageLink<L>(clazz, null,
new StringResourceModel(resourceKey, this, null))
.setIconType(iconType);
}

private <L extends AbstractListPage> BootstrapBookmarkablePageLink<L>
createAddListMenu(List<AbstractLink> list, Class<L> clazz, String resourceKey, IconType iconType) {
BootstrapBookmarkablePageLink<L> menu = new MenuBookmarkablePageLink<L>(clazz, null,
new StringResourceModel(resourceKey, this, null))
.setIconType(iconType);
list.add(menu);
return menu;
}

private <L extends AbstractListPage> void
createAddListMenuWithRole(List<AbstractLink> list, String role, Class<L> clazz, String resourceKey,
IconType iconType) {
BootstrapBookmarkablePageLink<L> menu = createAddListMenu(list, clazz, resourceKey, iconType);
MetaDataRoleAuthorizationStrategy.authorize(menu, Component.RENDER, role);
}


private NavbarDropDownButton newMetadataMenu() {
// metadata menu
final NavbarDropDownButton metadataMenu = new NavbarDropDownButton(
Expand All @@ -285,71 +312,48 @@ private NavbarDropDownButton newMetadataMenu() {
protected List<AbstractLink> newSubMenuButtons(final String arg0) {
final List<AbstractLink> list = new ArrayList<>();

list.add(new MenuBookmarkablePageLink<ListDepartmentPage>(ListDepartmentPage.class, null,
new StringResourceModel("navbar.departments", this, null))
.setIconType(FontAwesomeIconType.bank));

list.add(new MenuBookmarkablePageLink<ListFiscalYearPage>(
ListFiscalYearPage.class, null,
new StringResourceModel("navbar.fiscalyear", this, null))
.setIconType(FontAwesomeIconType.calendar_times_o));

list.add(new MenuBookmarkablePageLink<ListTargetGroupPage>(
ListTargetGroupPage.class, null,
new StringResourceModel("navbar.targetgroup", this, null))
.setIconType(FontAwesomeIconType.object_group));

list.add(new MenuBookmarkablePageLink<ListContractDocumentTypePage>(
ListContractDocumentTypePage.class, null,
new StringResourceModel("navbar.ContractDocumentType", this, null))
.setIconType(FontAwesomeIconType.file));

list.add(new MenuBookmarkablePageLink<ListItemPage>(
ListItemPage.class, null,
new StringResourceModel("navbar.items", this, null))
.setIconType(FontAwesomeIconType.list));

list.add(new MenuBookmarkablePageLink<ListChargeAccountPage>(
ListChargeAccountPage.class, null,
new StringResourceModel("navbar.chargeaccounts", this, null))
.setIconType(FontAwesomeIconType.money));

list.add(new MenuBookmarkablePageLink<ListSupplierPage>(
ListSupplierPage.class, null,
new StringResourceModel("navbar.suppliers", this, null))
.setIconType(FontAwesomeIconType.list));

list.add(new MenuBookmarkablePageLink<ListStaffPage>(
ListStaffPage.class, null,
new StringResourceModel("navbar.stafflist", this, null))
.setIconType(FontAwesomeIconType.list));

list.add(new MenuBookmarkablePageLink<ListProcuringEntityPage>(
ListProcuringEntityPage.class, null,
new StringResourceModel("navbar.procuringentitylist", this, null))
.setIconType(FontAwesomeIconType.list));

list.add(new MenuBookmarkablePageLink<ListSubcountyPage>(
ListSubcountyPage.class, null,
new StringResourceModel("navbar.subcountylist", this, null))
.setIconType(FontAwesomeIconType.flag));

list.add(new MenuBookmarkablePageLink<ListWardPage>(
ListWardPage.class, null,
new StringResourceModel("navbar.wardlist", this, null))
.setIconType(FontAwesomeIconType.flag));
createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListDepartmentPage.class,
"navbar.departments", FontAwesomeIconType.bank);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListFiscalYearPage.class,
"navbar.fiscalyear", FontAwesomeIconType.calendar_times_o);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListTargetGroupPage.class,
"navbar.targetgroup", FontAwesomeIconType.object_group);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListContractDocumentTypePage.class,
"navbar.ContractDocumentType", FontAwesomeIconType.file);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListItemPage.class,
"navbar.items", FontAwesomeIconType.list);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListChargeAccountPage.class,
"navbar.chargeaccounts", FontAwesomeIconType.money);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_USER, ListSupplierPage.class,
"navbar.suppliers", FontAwesomeIconType.list);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListStaffPage.class,
"navbar.stafflist", FontAwesomeIconType.user_times);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListProcuringEntityPage.class,
"navbar.procuringentitylist", FontAwesomeIconType.list);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListSubcountyPage.class,
"navbar.subcountylist", FontAwesomeIconType.flag);

createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListWardPage.class,
"navbar.wardlist", FontAwesomeIconType.flag);

list.add(new MenuBookmarkablePageLink<ListUnitPage>(
ListUnitPage.class, null,
new StringResourceModel("navbar.unitlist", this, null))
.setIconType(FontAwesomeIconType.list));
createAddListMenuWithRole(list, SecurityConstants.Roles.ROLE_ADMIN, ListUnitPage.class,
"navbar.unitlist", FontAwesomeIconType.list);

return list;
}
};

metadataMenu.setIconType(FontAwesomeIconType.code);
MetaDataRoleAuthorizationStrategy.authorize(metadataMenu, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);

return metadataMenu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,21 @@ public EditForm(final String id) {
deleteButton.setVisibilityAllowed(false);
}

add(new BootstrapCancelButton("cancel", new StringResourceModel("cancelButton", this, null)) {
private static final long serialVersionUID = -249084359200507749L;

@Override
protected void onSubmit(final AjaxRequestTarget target) {
setResponsePage(listPageClass);
}
});
add(getCancelButton());
}
}

protected BootstrapCancelButton getCancelButton() {
return new BootstrapCancelButton("cancel", new StringResourceModel("cancelButton", this, null)) {
private static final long serialVersionUID = -249084359200507749L;

@Override
protected void onSubmit(final AjaxRequestTarget target) {
setResponsePage(listPageClass);
}
};
}


/**
* Generic functionality for the save page button, this can be extended further by subclasses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@
</tr>
</tbody>
</table>

<div wicket:id="newStatusComment"/>
</div>
<div wicket:id="newStatusComment"/>
</div>

<input type="hidden" wicket:id="verticalPosition"/>
Expand Down
Loading

0 comments on commit 7b029cf

Please sign in to comment.