Skip to content

Commit cd3b32a

Browse files
committed
adding files that somehow got lost in the refactoring...
1 parent 642d0f7 commit cd3b32a

File tree

306 files changed

+297943
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+297943
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# Identity
3+
The DG Toolkit logo is based on this image form Wikimedia Commons:
4+
> Wikimedia Commons is an online repository of free-use images, sound, and other media files. It is a project of the Wikimedia Foundation.
5+
> https://commons.wikimedia.org/wiki/File:Leaf_Simple_Green_L.svg
6+
7+
## Logo
8+
![DT Toolkit logo](./images/raster/toolkit-logo-0256.png)
9+
10+
11+
## Favicon
12+
![DT Toolkit favicon](./images/raster/toolkit-favicon-0032.png)
13+
14+
15+
## Favicon files
16+
Favicon specific were generated using http://realfavicongenerator.net/
17+
18+
Insert the following code in the <head> section of your pages:
19+
```
20+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
21+
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
22+
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
23+
<link rel="manifest" href="/manifest.json">
24+
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#4996f1">
25+
<meta name="msapplication-TileColor" content="#ffffff">
26+
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
27+
<meta name="theme-color" content="#ffffff">
28+
```
29+
And serve the content of the `images/favicons` directory from the root of your website.
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2016 Development Gateway, Inc and others.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the MIT License (MIT)
6+
* which accompanies this distribution, and is available at
7+
* https://opensource.org/licenses/MIT
8+
*
9+
* Contributors:
10+
* Development Gateway - initial API and implementation
11+
*******************************************************************************/
12+
package org.devgateway.ocds.forms.wicket.page.edit;
13+
14+
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
15+
import org.apache.wicket.request.mapper.parameter.PageParameters;
16+
import org.apache.wicket.spring.injection.annot.SpringBean;
17+
import org.devgateway.ocds.forms.wicket.page.list.ListAllDashboardsPage;
18+
import org.devgateway.ocds.forms.wicket.providers.LabelPersistableJpaRepositoryTextChoiceProvider;
19+
import org.devgateway.ocds.persistence.dao.UserDashboard;
20+
import org.devgateway.ocds.persistence.repository.UserDashboardRepository;
21+
import org.devgateway.toolkit.web.security.SecurityConstants;
22+
import org.devgateway.toolkit.forms.wicket.components.form.Select2MultiChoiceBootstrapFormComponent;
23+
import org.devgateway.toolkit.forms.wicket.components.form.TextAreaFieldBootstrapFormComponent;
24+
import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
25+
import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditPage;
26+
import org.devgateway.toolkit.persistence.dao.Person;
27+
import org.devgateway.toolkit.persistence.repository.PersonRepository;
28+
import org.wicketstuff.annotation.mount.MountPath;
29+
30+
@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN)
31+
@MountPath("/editUserDashboard")
32+
public class EditUserDashboardPage extends AbstractEditPage<UserDashboard> {
33+
34+
private static final long serialVersionUID = -6069250112046118104L;
35+
36+
@Override
37+
protected UserDashboard newInstance() {
38+
return new UserDashboard();
39+
}
40+
41+
@SpringBean
42+
private UserDashboardRepository userDashboardRepository;
43+
44+
@SpringBean
45+
private PersonRepository personRepository;
46+
47+
public EditUserDashboardPage(final PageParameters parameters) {
48+
super(parameters);
49+
this.jpaRepository = userDashboardRepository;
50+
this.listPageClass = ListAllDashboardsPage.class;
51+
52+
}
53+
54+
@Override
55+
protected void onInitialize() {
56+
super.onInitialize();
57+
58+
TextFieldBootstrapFormComponent<String> name = new TextFieldBootstrapFormComponent<>("name");
59+
name.required();
60+
editForm.add(name);
61+
62+
TextAreaFieldBootstrapFormComponent<String> formUrlEncodedBody =
63+
new TextAreaFieldBootstrapFormComponent<>("formUrlEncodedBody");
64+
formUrlEncodedBody.required();
65+
formUrlEncodedBody.getField().setEnabled(false);
66+
editForm.add(formUrlEncodedBody);
67+
68+
Select2MultiChoiceBootstrapFormComponent<Person> defaultDashboardUsers =
69+
new Select2MultiChoiceBootstrapFormComponent<>("defaultDashboardUsers",
70+
new LabelPersistableJpaRepositoryTextChoiceProvider<>(personRepository));
71+
defaultDashboardUsers.setEnabled(false);
72+
editForm.add(defaultDashboardUsers);
73+
74+
Select2MultiChoiceBootstrapFormComponent<Person> users =
75+
new Select2MultiChoiceBootstrapFormComponent<>("users",
76+
new LabelPersistableJpaRepositoryTextChoiceProvider<>(personRepository));
77+
editForm.add(users);
78+
79+
80+
}
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
###############################################################################
2+
# Copyright (c) 2015 Development Gateway, Inc and others.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the MIT License (MIT)
6+
# which accompanies this distribution, and is available at
7+
# https://opensource.org/licenses/MIT
8+
#
9+
# Contributors:
10+
# Development Gateway - initial API and implementation
11+
###############################################################################
12+
page.title=All Dashboards
13+
name=Name
14+
defaultDashboardUsers=Default Dashboard For Users
15+
users=Users
16+
view=View
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2015 Development Gateway, Inc and others.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the MIT License (MIT)
6+
* which accompanies this distribution, and is available at
7+
* https://opensource.org/licenses/MIT
8+
*
9+
* Contributors:
10+
* Development Gateway - initial API and implementation
11+
*******************************************************************************/
12+
package org.devgateway.toolkit.forms.models;
13+
14+
import java.text.SimpleDateFormat;
15+
import java.util.Collection;
16+
import java.util.Date;
17+
18+
import org.apache.wicket.model.AbstractReadOnlyModel;
19+
import org.apache.wicket.model.IModel;
20+
import org.devgateway.toolkit.forms.WebConstants;
21+
import org.devgateway.toolkit.forms.wicket.components.form.GenericBootstrapFormComponent;
22+
23+
/**
24+
* @author mpostelnicu Converter for {@link GenericBootstrapFormComponent}
25+
* viewModeField This will be used when
26+
* {@link WebConstants#PARAM_VIEW_MODE} is true in the browser and will
27+
* convert the model object to something printable (string-like)
28+
*/
29+
public class ViewModeConverterModel<T> extends AbstractReadOnlyModel<String> {
30+
31+
private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
32+
33+
/**
34+
*
35+
*/
36+
private static final long serialVersionUID = 1L;
37+
private IModel<T> originalModel;
38+
39+
/**
40+
*
41+
*/
42+
public ViewModeConverterModel(final IModel<T> originalModel) {
43+
this.originalModel = originalModel;
44+
}
45+
46+
/*
47+
* (non-Javadoc)
48+
*
49+
* @see org.apache.wicket.model.IModel#getObject()
50+
*/
51+
@Override
52+
public String getObject() {
53+
T object = originalModel.getObject();
54+
if (object == null) {
55+
return "";
56+
}
57+
58+
// for booleans we return yes/no
59+
if (object instanceof Boolean) {
60+
return ((Boolean) object).booleanValue() ? "Yes" : "No";
61+
}
62+
63+
// for collections that are empty, we return empty
64+
if (object instanceof Collection<?>) {
65+
if (((Collection<?>) object).size() == 0) {
66+
return "";
67+
}
68+
}
69+
70+
// convert date to a nicer format
71+
if (object instanceof Date) {
72+
return sdf.format((Date) object);
73+
}
74+
75+
// alas just return the string value of the object
76+
return object.toString();
77+
}
78+
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2015 Development Gateway, Inc and others.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the MIT License (MIT)
6+
* which accompanies this distribution, and is available at
7+
* https://opensource.org/licenses/MIT
8+
*
9+
* Contributors:
10+
* Development Gateway - initial API and implementation
11+
*******************************************************************************/
12+
/**
13+
*
14+
*/
15+
package org.devgateway.toolkit.forms.validators;
16+
17+
import java.util.Date;
18+
19+
import org.apache.wicket.model.StringResourceModel;
20+
import org.apache.wicket.validation.IValidatable;
21+
import org.apache.wicket.validation.IValidator;
22+
import org.apache.wicket.validation.ValidationError;
23+
import org.devgateway.toolkit.forms.wicket.components.form.DateFieldBootstrapFormComponent;
24+
25+
/**
26+
* @author mpostelnicu {@link DateFieldBootstrapFormComponent} validator for
27+
* dates that have a chronology
28+
*/
29+
public class EarlierThanDateFieldValidator implements IValidator<Date> {
30+
31+
private static final long serialVersionUID = 1L;
32+
33+
private DateFieldBootstrapFormComponent highDate;
34+
35+
/**
36+
* Provide a {@link DateFieldBootstrapFormComponent} that has to be
37+
* chronologically after the current's
38+
* {@link DateFieldBootstrapFormComponent} validator
39+
*/
40+
public EarlierThanDateFieldValidator(final DateFieldBootstrapFormComponent highDate) {
41+
this.highDate = highDate;
42+
}
43+
44+
@Override
45+
public void validate(final IValidatable<Date> validatable) {
46+
highDate.getField().validate();
47+
if (!highDate.getField().isValid()) {
48+
return;
49+
}
50+
51+
Date endDate = (Date) highDate.getField().getConvertedInput();
52+
53+
if (endDate != null && validatable.getValue() != null && endDate.before(validatable.getValue())) {
54+
ValidationError error = new ValidationError(this);
55+
error.setVariable("highDateName",
56+
new StringResourceModel(highDate.getLabelKey(), highDate.getParent(), null).getString());
57+
validatable.error(error);
58+
}
59+
}
60+
61+
}

0 commit comments

Comments
 (0)