-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #628 from devgateway/develop
merge develop into master before 1.2.0
- Loading branch information
Showing
396 changed files
with
25,024 additions
and
10,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
.project | ||
/.springBeans | ||
/.checkstyle | ||
/ehcache-diskstore/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditColorIndicatorPairPage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>EditUserDashboardPage</title> | ||
</head> | ||
<body> | ||
<wicket:extend> | ||
<div wicket:id="firstIndicator"></div> | ||
<div wicket:id="secondIndicator"></div> | ||
<div wicket:id="color"></div> | ||
</wicket:extend> | ||
</body> | ||
</html> |
134 changes: 134 additions & 0 deletions
134
.../src/main/java/org/devgateway/ocds/forms/wicket/page/edit/EditColorIndicatorPairPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/******************************************************************************* | ||
* 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.markup.html.form.Form; | ||
import org.apache.wicket.markup.html.form.FormComponent; | ||
import org.apache.wicket.markup.html.form.validation.AbstractFormValidator; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.request.mapper.parameter.PageParameters; | ||
import org.apache.wicket.spring.injection.annot.SpringBean; | ||
import org.devgateway.ocds.forms.wicket.page.list.ListAllColorIndicatorPage; | ||
import org.devgateway.ocds.persistence.dao.ColorIndicatorPair; | ||
import org.devgateway.ocds.persistence.mongo.flags.FlagsConstants; | ||
import org.devgateway.ocds.persistence.repository.ColorIndicatorPairRepository; | ||
import org.devgateway.toolkit.forms.wicket.components.form.ColorPickerBootstrapFormComponent; | ||
import org.devgateway.toolkit.forms.wicket.components.form.Select2ChoiceBootstrapFormComponent; | ||
import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditPage; | ||
import org.devgateway.toolkit.forms.wicket.providers.GenericChoiceProvider; | ||
import org.devgateway.toolkit.persistence.repository.PersonRepository; | ||
import org.devgateway.toolkit.web.security.SecurityConstants; | ||
import org.wicketstuff.annotation.mount.MountPath; | ||
|
||
@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN) | ||
@MountPath("/editColorIndicatorPairPage") | ||
public class EditColorIndicatorPairPage extends AbstractEditPage<ColorIndicatorPair> { | ||
|
||
private static final long serialVersionUID = -6069250112046118104L; | ||
|
||
@Override | ||
protected ColorIndicatorPair newInstance() { | ||
return new ColorIndicatorPair(); | ||
} | ||
|
||
@SpringBean | ||
private ColorIndicatorPairRepository colorIndicatorPairRepository; | ||
|
||
@SpringBean | ||
private PersonRepository personRepository; | ||
|
||
private Select2ChoiceBootstrapFormComponent<String> firstIndicator; | ||
|
||
private Select2ChoiceBootstrapFormComponent<String> secondIndicator; | ||
|
||
public EditColorIndicatorPairPage(final PageParameters parameters) { | ||
super(parameters); | ||
this.jpaRepository = colorIndicatorPairRepository; | ||
this.listPageClass = ListAllColorIndicatorPage.class; | ||
|
||
} | ||
|
||
|
||
@Override | ||
protected void onInitialize() { | ||
super.onInitialize(); | ||
|
||
firstIndicator = | ||
new Select2ChoiceBootstrapFormComponent<String>("firstIndicator", | ||
new GenericChoiceProvider<String>(FlagsConstants.FLAGS_LIST)); | ||
firstIndicator.required(); | ||
editForm.add(firstIndicator); | ||
|
||
secondIndicator = | ||
new Select2ChoiceBootstrapFormComponent<String>("secondIndicator", | ||
new GenericChoiceProvider<String>(FlagsConstants.FLAGS_LIST)); | ||
secondIndicator.required(); | ||
editForm.add(secondIndicator); | ||
|
||
ColorPickerBootstrapFormComponent color = new ColorPickerBootstrapFormComponent("color"); | ||
color.required(); | ||
editForm.add(color); | ||
editForm.add(new ColorIndicatorDistinctFormValidator()); | ||
editForm.add(new ColorIndicatorUniquePairFormValidator(compoundModel)); | ||
|
||
} | ||
|
||
|
||
private class ColorIndicatorDistinctFormValidator extends AbstractFormValidator { | ||
|
||
@Override | ||
public FormComponent<?>[] getDependentFormComponents() { | ||
return new FormComponent[]{firstIndicator.getField(), secondIndicator.getField()}; | ||
} | ||
|
||
@Override | ||
public void validate(Form<?> form) { | ||
if (firstIndicator.getField().getValue() != null && secondIndicator.getField().getValue() != null | ||
&& firstIndicator.getField().getValue().equals(secondIndicator.getField().getValue())) { | ||
error(firstIndicator.getField()); | ||
error(secondIndicator.getField()); | ||
} | ||
} | ||
} | ||
|
||
|
||
private class ColorIndicatorUniquePairFormValidator extends AbstractFormValidator { | ||
|
||
private final IModel<ColorIndicatorPair> masterModel; | ||
|
||
ColorIndicatorUniquePairFormValidator(IModel<ColorIndicatorPair> masterModel) { | ||
this.masterModel = masterModel; | ||
} | ||
|
||
@Override | ||
public FormComponent<?>[] getDependentFormComponents() { | ||
return new FormComponent[]{firstIndicator.getField(), secondIndicator.getField()}; | ||
} | ||
|
||
@Override | ||
public void validate(Form<?> form) { | ||
if (firstIndicator.getField().getValue() != null && secondIndicator.getField().getValue() != null) { | ||
ColorIndicatorPair indicator = colorIndicatorPairRepository. | ||
findByFirstIndicatorAndSecondIndicator(firstIndicator.getField().getValue(), | ||
secondIndicator.getField().getValue()); | ||
|
||
if ((masterModel.getObject().isNew() && indicator != null) | ||
|| (!masterModel.getObject().isNew() && indicator != null | ||
&& !indicator.getId().equals(masterModel.getObject().getId()))) { | ||
error(firstIndicator.getField()); | ||
error(secondIndicator.getField()); | ||
} | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ain/java/org/devgateway/ocds/forms/wicket/page/edit/EditColorIndicatorPairPage.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
############################################################################### | ||
# 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 Color Indicator Pair | ||
firstIndicator.label=First Indicator | ||
secondIndicator.label=Second Indicator | ||
color.label=Color | ||
ColorIndicatorDistinctFormValidator=Please select two distinct indicators | ||
ColorIndicatorUniquePairFormValidator=A similar pair of indicators was already saved with a color. You can add only distinct pairs. |
50 changes: 50 additions & 0 deletions
50
...s/src/main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllColorIndicatorPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******************************************************************************* | ||
* 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.extensions.markup.html.repeater.data.table.PropertyColumn; | ||
import org.apache.wicket.model.Model; | ||
import org.apache.wicket.request.mapper.parameter.PageParameters; | ||
import org.apache.wicket.spring.injection.annot.SpringBean; | ||
import org.devgateway.ocds.forms.wicket.page.edit.EditColorIndicatorPairPage; | ||
import org.devgateway.ocds.persistence.dao.ColorIndicatorPair; | ||
import org.devgateway.ocds.persistence.repository.ColorIndicatorPairRepository; | ||
import org.devgateway.toolkit.forms.wicket.page.lists.AbstractListPage; | ||
import org.devgateway.toolkit.web.security.SecurityConstants; | ||
import org.wicketstuff.annotation.mount.MountPath; | ||
|
||
@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN) | ||
@MountPath(value = "/listColorIndicators") | ||
public class ListAllColorIndicatorPage extends AbstractListPage<ColorIndicatorPair> { | ||
|
||
@SpringBean | ||
protected ColorIndicatorPairRepository colorIndicatorPairRepository; | ||
|
||
|
||
|
||
public ListAllColorIndicatorPage(final PageParameters pageParameters) { | ||
super(pageParameters); | ||
this.jpaRepository = colorIndicatorPairRepository; | ||
this.editPageClass = EditColorIndicatorPairPage.class; | ||
columns.add(new PropertyColumn<ColorIndicatorPair, String>(new Model<String>("First Indicator"), | ||
"firstIndicator", "firstIndicator")); | ||
|
||
columns.add(new PropertyColumn<ColorIndicatorPair, String>(new Model<String>("Second Indicator"), | ||
"secondIndicator", "secondIndicator")); | ||
|
||
columns.add(new PropertyColumn<ColorIndicatorPair, String>(new Model<String>("Color"), | ||
"color", "color")); | ||
|
||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...main/java/org/devgateway/ocds/forms/wicket/page/list/ListAllColorIndicatorPage.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
############################################################################### | ||
# 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 Color Indicator Pairs | ||
defaultDashboardUsers=Default Dashboard For Users | ||
users=Users | ||
view=View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.