+
+EditUserDashboardPage
+
+
+
+
+
+
+
+
+
+
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.java b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.java
new file mode 100644
index 000000000..741b7c61d
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Development Gateway, Inc and others.
+ *
+ * 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
+ *
+ * Contributors:
+ * Development Gateway - initial API and implementation
+ *******************************************************************************/
+package org.devgateway.ocds.forms.wicket.page.edit;
+
+import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.devgateway.ocds.forms.wicket.page.list.ListAllDashboardsPage;
+import org.devgateway.ocds.forms.wicket.providers.LabelPersistableJpaRepositoryTextChoiceProvider;
+import org.devgateway.ocds.persistence.dao.UserDashboard;
+import org.devgateway.ocds.persistence.repository.UserDashboardRepository;
+import org.devgateway.toolkit.forms.security.SecurityConstants;
+import org.devgateway.toolkit.forms.wicket.components.form.Select2MultiChoiceBootstrapFormComponent;
+import org.devgateway.toolkit.forms.wicket.components.form.TextAreaFieldBootstrapFormComponent;
+import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
+import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditPage;
+import org.devgateway.toolkit.persistence.dao.Person;
+import org.devgateway.toolkit.persistence.repository.PersonRepository;
+import org.wicketstuff.annotation.mount.MountPath;
+
+@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN)
+@MountPath("/editUserDashboard")
+public class EditUserDashboardPage extends AbstractEditPage {
+
+ private static final long serialVersionUID = -6069250112046118104L;
+
+ @Override
+ protected UserDashboard newInstance() {
+ return new UserDashboard();
+ }
+
+ @SpringBean
+ private UserDashboardRepository userDashboardRepository;
+
+ @SpringBean
+ private PersonRepository personRepository;
+
+ public EditUserDashboardPage(final PageParameters parameters) {
+ super(parameters);
+ this.jpaRepository = userDashboardRepository;
+ this.listPageClass = ListAllDashboardsPage.class;
+
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ TextFieldBootstrapFormComponent name = new TextFieldBootstrapFormComponent<>("name");
+ name.required();
+ editForm.add(name);
+
+ TextAreaFieldBootstrapFormComponent formUrlEncodedBody =
+ new TextAreaFieldBootstrapFormComponent<>("formUrlEncodedBody");
+ formUrlEncodedBody.required();
+ formUrlEncodedBody.getField().setEnabled(false);
+ editForm.add(formUrlEncodedBody);
+
+ Select2MultiChoiceBootstrapFormComponent defaultDashboardUsers =
+ new Select2MultiChoiceBootstrapFormComponent<>("defaultDashboardUsers",
+ new LabelPersistableJpaRepositoryTextChoiceProvider<>(personRepository));
+ defaultDashboardUsers.setEnabled(false);
+ editForm.add(defaultDashboardUsers);
+
+ Select2MultiChoiceBootstrapFormComponent users =
+ new Select2MultiChoiceBootstrapFormComponent<>("users",
+ new LabelPersistableJpaRepositoryTextChoiceProvider<>(personRepository));
+ editForm.add(users);
+
+
+ }
+}
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.properties b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.properties
new file mode 100644
index 000000000..2522f3134
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditUserDashboardPage.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2015 Development Gateway, Inc and others.
+#
+# 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
+#
+# Contributors:
+# Development Gateway - initial API and implementation
+###############################################################################
+page.title=Edit User Dashboard
+name.label=Name
+formUrlEncodedBody.label=Filter body
+formUrlEncodedBody.help=This is a list of saved filters from the UI and cannot be edited here.
+defaultDashboardUsers.label=Default Dashboard For Users
+defaultDashboardUsers.help=This is a user setting and can be changed from the User form
+users.label=Assigned Users
+delete_error_message=Cannot delete this dashboard. It is assigned as the default dashboard for at least one user.\
+ Please assign a different default dashboard for the assigned users or select no default dashboard, and then try the delete again.
\ No newline at end of file
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage$DashboardsActionPanel.html b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage$DashboardsActionPanel.html
new file mode 100644
index 000000000..3d00cc949
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage$DashboardsActionPanel.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.java b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.java
new file mode 100644
index 000000000..b6a2bffe3
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Development Gateway, Inc and others.
+ *
+ * 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
+ *
+ * Contributors:
+ * Development Gateway - initial API and implementation
+ *******************************************************************************/
+package org.devgateway.ocds.forms.wicket.page.list;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.BootstrapExternalLink;
+import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
+import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesomeIconType;
+import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.devgateway.ocds.forms.wicket.page.edit.EditUserDashboardPage;
+import org.devgateway.ocds.persistence.dao.UserDashboard;
+import org.devgateway.ocds.persistence.repository.UserDashboardRepository;
+import org.devgateway.toolkit.forms.security.SecurityConstants;
+import org.devgateway.toolkit.forms.wicket.page.lists.AbstractListPage;
+import org.wicketstuff.annotation.mount.MountPath;
+
+@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN)
+@MountPath(value = "/listAllDashboards")
+public class ListAllDashboardsPage extends AbstractListPage {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -324298525712620234L;
+ @SpringBean
+ protected UserDashboardRepository userDashboardRepository;
+
+ public class DashboardsActionPanel extends ActionPanel {
+
+ /**
+ * @param id
+ * @param model
+ */
+ public DashboardsActionPanel(String id, IModel model) {
+ super(id, model);
+
+ UserDashboard entity = (UserDashboard) this.getDefaultModelObject();
+
+ BootstrapExternalLink viewLink = new BootstrapExternalLink("view", Model.of("ui/index.html?dashboardId="
+ + entity.getId()), Buttons.Type.Danger) {
+ };
+ viewLink.setLabel(new StringResourceModel("view", ListAllDashboardsPage.this, null));
+ viewLink.setIconType(FontAwesomeIconType.eye).setSize(Buttons.Size.Small);
+ add(viewLink);
+
+ }
+ }
+
+ public ListAllDashboardsPage(final PageParameters pageParameters) {
+ super(pageParameters);
+ this.jpaRepository = userDashboardRepository;
+ this.editPageClass = EditUserDashboardPage.class;
+ columns.add(new PropertyColumn(
+ new Model((new StringResourceModel("name", ListAllDashboardsPage.this, null)).getString()),
+ "name", "name"));
+ columns.add(new PropertyColumn(new Model(
+ (new StringResourceModel("defaultDashboardUsers", ListAllDashboardsPage.this, null)).getString()),
+ "defaultDashboardUsers", "defaultDashboardUsers"));
+
+ columns.add(new PropertyColumn(new Model(
+ (new StringResourceModel("users", ListAllDashboardsPage.this, null)).getString()),
+ "users", "users"));
+
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ editPageLink.setVisibilityAllowed(false);
+ }
+
+ @Override
+ public ActionPanel getActionPanel(String id, IModel model) {
+ return new DashboardsActionPanel(id, model);
+ }
+}
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.properties b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.properties
new file mode 100644
index 000000000..c961f460c
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllDashboardsPage.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2015 Development Gateway, Inc and others.
+#
+# 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
+#
+# Contributors:
+# Development Gateway - initial API and implementation
+###############################################################################
+page.title=All Dashboards
+name=Name
+defaultDashboardUsers=Default Dashboard For Users
+users=Users
+view=View
\ No newline at end of file
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.java b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.java
new file mode 100644
index 000000000..b7b7f36ea
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Development Gateway, Inc and others.
+ *
+ * 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
+ *
+ * Contributors:
+ * Development Gateway - initial API and implementation
+ *******************************************************************************/
+package org.devgateway.ocds.forms.wicket.page.list;
+
+import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.devgateway.ocds.forms.wicket.providers.PersonDashboardJpaRepositoryProvider;
+import org.devgateway.ocds.persistence.dao.UserDashboard;
+import org.devgateway.toolkit.forms.security.SecurityConstants;
+import org.devgateway.toolkit.forms.wicket.providers.SortableJpaRepositoryDataProvider;
+import org.devgateway.toolkit.persistence.repository.PersonRepository;
+import org.wicketstuff.annotation.mount.MountPath;
+
+@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_PROCURING_ENTITY)
+@MountPath(value = "/listMyDashboards")
+public class ListMyDashboardsPage extends ListAllDashboardsPage {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8105049572554654046L;
+
+ @SpringBean
+ private PersonRepository personRepository;
+
+
+ @Override
+ public SortableJpaRepositoryDataProvider getProvider() {
+ return new PersonDashboardJpaRepositoryProvider(userDashboardRepository, personRepository);
+ }
+
+ public ListMyDashboardsPage(final PageParameters pageParameters) {
+ super(pageParameters);
+ }
+
+}
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.properties b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.properties
new file mode 100644
index 000000000..092626609
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListMyDashboardsPage.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2015 Development Gateway, Inc and others.
+#
+# 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
+#
+# Contributors:
+# Development Gateway - initial API and implementation
+###############################################################################
+page.title=My Dashboards
\ No newline at end of file
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/LabelPersistableJpaRepositoryTextChoiceProvider.java b/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/LabelPersistableJpaRepositoryTextChoiceProvider.java
new file mode 100644
index 000000000..2e83e860b
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/LabelPersistableJpaRepositoryTextChoiceProvider.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Development Gateway, Inc and others.
+ *
+ * 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
+ *
+ * Contributors:
+ * Development Gateway - initial API and implementation
+ *******************************************************************************/
+/**
+ *
+ */
+package org.devgateway.ocds.forms.wicket.providers;
+
+import java.util.Collection;
+
+import org.apache.wicket.model.IModel;
+import org.devgateway.toolkit.forms.wicket.providers.AbstractJpaRepositoryTextChoiceProvider;
+import org.devgateway.toolkit.persistence.dao.GenericPersistable;
+import org.devgateway.toolkit.persistence.dao.Labelable;
+import org.devgateway.toolkit.persistence.repository.category.TextSearchableRepository;
+
+/**
+ * @author mpostelnicu
+ *
+ */
+public class LabelPersistableJpaRepositoryTextChoiceProvider
+ extends AbstractJpaRepositoryTextChoiceProvider {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9109118476966448737L;
+
+ public LabelPersistableJpaRepositoryTextChoiceProvider(
+ final TextSearchableRepository textSearchableRepository) {
+ super(textSearchableRepository);
+ }
+
+ public LabelPersistableJpaRepositoryTextChoiceProvider(
+ final TextSearchableRepository textSearchableRepository,
+ final IModel> restrictedToItemsModel) {
+ super(textSearchableRepository, restrictedToItemsModel);
+ }
+
+ public LabelPersistableJpaRepositoryTextChoiceProvider(
+ final TextSearchableRepository textSearchableRepository, final Class clazz,
+ final Boolean addNewElements) {
+ super(textSearchableRepository, clazz, addNewElements);
+ }
+
+ @Override
+ public String getDisplayValue(final T choice) {
+ return choice.getLabel();
+ }
+}
diff --git a/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/PersonDashboardJpaRepositoryProvider.java b/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/PersonDashboardJpaRepositoryProvider.java
new file mode 100644
index 000000000..86416e401
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/ocds/forms/wicket/providers/PersonDashboardJpaRepositoryProvider.java
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.devgateway.ocds.forms.wicket.providers;
+
+import java.util.Iterator;
+
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.devgateway.ocds.persistence.dao.UserDashboard;
+import org.devgateway.ocds.persistence.repository.UserDashboardRepository;
+import org.devgateway.toolkit.forms.WebConstants;
+import org.devgateway.toolkit.forms.security.SecurityUtil;
+import org.devgateway.toolkit.forms.wicket.providers.SortableJpaRepositoryDataProvider;
+import org.devgateway.toolkit.persistence.repository.PersonRepository;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+
+/**
+ * @author mpost
+ *
+ */
+public class PersonDashboardJpaRepositoryProvider extends SortableJpaRepositoryDataProvider {
+
+ private static final long serialVersionUID = -490237568464403107L;
+
+ private UserDashboardRepository userDashboardRepository;
+
+ private PersonRepository personRepository;
+
+ public PersonDashboardJpaRepositoryProvider(UserDashboardRepository jpaRepository,
+ PersonRepository personRepository) {
+ super(jpaRepository);
+ this.personRepository = personRepository;
+ userDashboardRepository = (UserDashboardRepository) jpaRepository;
+ }
+
+ /**
+ * @see SortableDataProvider#iterator(long, long)
+ */
+ @Override
+ public Iterator iterator(final long first, final long count) {
+ int page = (int) ((double) first / WebConstants.PAGE_SIZE);
+ Page findAll =
+ userDashboardRepository.findDashboardsForPersonId(SecurityUtil.getCurrentAuthenticatedPerson().getId(),
+ new PageRequest(page, WebConstants.PAGE_SIZE, translateSort()));
+ return findAll.iterator();
+ }
+
+ @Override
+ public long size() {
+ return personRepository.getOne(SecurityUtil.getCurrentAuthenticatedPerson().getId()).getDashboards().size();
+ }
+
+}
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/security/SecurityConstants.java b/forms/src/main/java/org/devgateway/toolkit/forms/security/SecurityConstants.java
index 4196152a2..9a6f99a76 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/security/SecurityConstants.java
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/security/SecurityConstants.java
@@ -28,5 +28,6 @@ private Roles() {
public static final String ROLE_ADMIN = "ROLE_ADMIN";
public static final String ROLE_USER = "ROLE_USER";
+ public static final String ROLE_PROCURING_ENTITY = "ROLE_PROCURING_ENTITY";
}
}
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/util/MarkupCacheService.java b/forms/src/main/java/org/devgateway/toolkit/forms/util/MarkupCacheService.java
index 45695b565..5bcc5129f 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/util/MarkupCacheService.java
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/util/MarkupCacheService.java
@@ -62,14 +62,14 @@ public final void flushMarkupCache() {
/**
* Add the content of a report (PDF, Excel, RTF) to cache
- *
+ *
* @param outputType
* @param reportName
* @param parameters
* @param buffer
*/
public void addReportToCache(final String outputType, final String reportName, final String parameters,
- final byte[] buffer) {
+ final byte[] buffer) {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
@@ -80,7 +80,7 @@ public void addReportToCache(final String outputType, final String reportName, f
/**
* Fetch the content of a report from cache
- *
+ *
* @param outputType
* @param reportName
* @param parameters
@@ -139,7 +139,20 @@ public void clearReportsCache() {
if (cache != null) {
cache.removeAll();
}
+ }
+
+ /**
+ * Remove from cache all reports api content
+ */
+ public void clearReportsApiCache() {
+ CacheManager cm = CacheManager.getInstance();
+ // get the reports cache "reportsApiCache", declared in ehcache.xml
+ Cache cache = cm.getCache("reportsApiCache");
+
+ if (cache != null) {
+ cache.removeAll();
+ }
}
private String createCacheKey(final String outputType, final String reportName, final String parameters) {
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.html b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.html
new file mode 100644
index 000000000..52c3ed42a
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.html
@@ -0,0 +1,30 @@
+
+
+ ListSectionPanel
+
+
+
+
+
+
[[title]]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.java
new file mode 100644
index 000000000..9a7e5640a
--- /dev/null
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/ListViewSectionPanel.java
@@ -0,0 +1,142 @@
+package org.devgateway.toolkit.forms.wicket.components;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+import org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton;
+import org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton;
+import org.devgateway.toolkit.persistence.dao.AbstractAuditableEntity;
+
+import java.util.List;
+
+/**
+ * @author idobre
+ * @since 10/5/16
+ *
+ * Class that displays a list of type with the possibility of adding/removing elements.
+ *
+ * @param The current list data type
+ * @param The parent field data type
+ */
+
+public abstract class ListViewSectionPanel
+ extends CompoundSectionPanel> {
+ private WebMarkupContainer listWrapper;
+
+ protected ListView listView;
+
+ public ListViewSectionPanel(final String id) {
+ super(id);
+ }
+
+ /**
+ * Removes a child based on its index
+ *
+ * @param index
+ * @return
+ */
+ private BootstrapDeleteButton getRemoveChildButton(final int index) {
+ BootstrapDeleteButton removeButton = new BootstrapDeleteButton("remove") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form> form) {
+ ListViewSectionPanel.this.getModelObject().remove(index);
+ listView.removeAll();
+ target.add(listWrapper);
+ }
+ };
+
+ removeButton.setOutputMarkupPlaceholderTag(true);
+ return removeButton;
+ }
+
+ /**
+ * Returns the new child button
+ *
+ * @return
+ */
+ protected BootstrapAddButton getAddNewChildButton() {
+ BootstrapAddButton newButton = new BootstrapAddButton("newButton", new ResourceModel("newButton")) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form> form) {
+ @SuppressWarnings("unchecked")
+ T newChild = createNewChild((IModel) ListViewSectionPanel.this.getParent().getDefaultModel());
+ ListViewSectionPanel.this.getModel().getObject().add(newChild);
+
+ listView.removeAll();
+ target.add(listWrapper);
+ }
+
+ };
+
+ newButton.setOutputMarkupPlaceholderTag(true);
+ return newButton;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ setOutputMarkupId(true);
+ setOutputMarkupPlaceholderTag(true);
+
+ listWrapper = new TransparentWebMarkupContainer("listWrapper");
+ listWrapper.setOutputMarkupId(true);
+ add(listWrapper);
+
+ listWrapper.add(new Label("panelTitle", title));
+
+ listView = new ListView("list", getModel()) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(final ListItem item) {
+ // we wrap the item model on a compound model so we can use the field ids as property models
+ final CompoundPropertyModel compoundPropertyModel = new CompoundPropertyModel<>(item.getModel());
+
+ // we set back the model as the compound model, thus ensures the rest of the items added will benefit
+ item.setModel(compoundPropertyModel);
+
+ // we add the rest of the items in the listItem
+ populateCompoundListItem(item);
+
+ // we add the remove button
+ final BootstrapDeleteButton removeButton = getRemoveChildButton(item.getIndex());
+ item.add(removeButton);
+ }
+ };
+
+ listView.setReuseItems(true);
+ listView.setOutputMarkupId(true);
+ listWrapper.add(listView);
+
+ final BootstrapAddButton addButton = getAddNewChildButton();
+ add(addButton);
+ }
+
+ /**
+ * Use the constructor for new children and return the entity after setting
+ * its parent
+ *
+ * @param parentModel the model of the parent
+ * @return
+ */
+ public abstract T createNewChild(IModel parentModel);
+
+ /**
+ * Populates the list item elements
+ *
+ * @param item
+ */
+ public abstract void populateCompoundListItem(ListItem item);
+}
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/GenericBootstrapFormComponent.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/GenericBootstrapFormComponent.java
index 693690f12..e05a7088e 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/GenericBootstrapFormComponent.java
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/components/form/GenericBootstrapFormComponent.java
@@ -159,6 +159,8 @@ public GenericBootstrapFormComponent(final String id, final IModel label
field.add(sizeBehavior);
border.add(field);
+ field.setLabel(labelModel);
+
tooltipLabel = new TooltipLabel("tooltipLabel", id);
border.add(tooltipLabel);
}
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.java
index c508c9443..d3e6fbb3d 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.java
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.java
@@ -47,6 +47,8 @@
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.resource.JQueryResourceReference;
import org.apache.wicket.util.string.StringValue;
+import org.devgateway.ocds.forms.wicket.page.list.ListAllDashboardsPage;
+import org.devgateway.ocds.forms.wicket.page.list.ListMyDashboardsPage;
import org.devgateway.toolkit.forms.WebConstants;
import org.devgateway.toolkit.forms.security.SecurityConstants;
import org.devgateway.toolkit.forms.security.SecurityUtil;
@@ -251,6 +253,17 @@ protected NavbarButton newHomeMenu() {
return homeMenu;
}
+
+ protected NavbarButton newMyDashboardsMenu() {
+ // home
+ NavbarButton menu = new NavbarButton<>(ListMyDashboardsPage.class,
+ this.getPageParameters(), new ResourceModel("mydashboards"));
+ menu.setIconType(GlyphIconType.filter);
+ MetaDataRoleAuthorizationStrategy.authorize(menu, Component.RENDER,
+ SecurityConstants.Roles.ROLE_PROCURING_ENTITY);
+ return menu;
+ }
+
protected NavbarDropDownButton newAdminMenu() {
// admin menu
@@ -311,6 +324,10 @@ protected void onComponentTag(final ComponentTag tag) {
list.add(new MenuBookmarkablePageLink(EditAdminSettingsPage.class,
new StringResourceModel("navbar.adminSettings", BasePage.this, null))
.setIconType(FontAwesomeIconType.briefcase));
+
+ list.add(new MenuBookmarkablePageLink(ListAllDashboardsPage.class,
+ new StringResourceModel("navbar.allDashboard", BasePage.this, null))
+ .setIconType(FontAwesomeIconType.filter));
list.add(uiBrowserLink);
@@ -342,7 +359,9 @@ protected Navbar newNavbar(final String markupId) {
navbar.setPosition(Navbar.Position.TOP);
navbar.setInverted(true);
- navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newHomeMenu(), newAdminMenu(),
+ navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newHomeMenu(),
+ newMyDashboardsMenu(),
+ newAdminMenu(),
newAccountMenu(), newLogoutMenu()));
navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, newLanguageMenu()));
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.properties b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.properties
index b5caa1823..affdef1c6 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.properties
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/BasePage.properties
@@ -22,3 +22,5 @@ navbar.adminSettings=Settings
home=Home
navbar.lang=Language
navbar.jminix=JMX Console
+navbar.allDashboard=All Saved Dashboards
+mydashboards=My Dashboards
\ No newline at end of file
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/EditTestFormPage.java b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/EditTestFormPage.java
index be32b0bd3..ea817b21d 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/EditTestFormPage.java
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/EditTestFormPage.java
@@ -31,8 +31,8 @@
import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditPage;
import org.devgateway.toolkit.forms.wicket.page.lists.ListTestFormPage;
+import org.devgateway.toolkit.forms.wicket.providers.GenericChoiceProvider;
import org.devgateway.toolkit.forms.wicket.providers.GenericPersistableJpaRepositoryTextChoiceProvider;
-import org.devgateway.toolkit.forms.wicket.providers.ListChoiceProvider;
import org.devgateway.toolkit.persistence.dao.TestForm;
import org.devgateway.toolkit.persistence.dao.categories.Group;
import org.devgateway.toolkit.persistence.dao.categories.Role;
@@ -130,7 +130,7 @@ protected void onInitialize() {
editForm.add(fileInput);
Select2ChoiceBootstrapFormComponent preloadedEntitySelect = new Select2ChoiceBootstrapFormComponent<>(
- "preloadedEntitySelect", new ListChoiceProvider<>(groupRepository.findAll()));
+ "preloadedEntitySelect", new GenericChoiceProvider<>(groupRepository.findAll()));
preloadedEntitySelect.required();
editForm.add(preloadedEntitySelect);
}
diff --git a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/Homepage.html b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/Homepage.html
index 1f2e1d6e0..1516f54d7 100644
--- a/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/Homepage.html
+++ b/forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/Homepage.html
@@ -15,7 +15,7 @@
-