Skip to content

Commit

Permalink
Resolves #361 (DG Toolkit side)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmandrescu committed Jun 4, 2021
1 parent 57c22b2 commit 307e407
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.csp.CSPDirective;
import org.apache.wicket.markup.head.filter.JavaScriptFilteredIntoFooterHeaderResponse;
import org.apache.wicket.markup.html.IPackageResourceGuard;
import org.apache.wicket.markup.html.SecurePackageResourceGuard;
Expand Down Expand Up @@ -240,6 +241,13 @@ protected void init() {
// TODO make Wicket usage CSP compliant (temporarily disabled)
// https://ci.apache.org/projects/wicket/guide/9.x/single.html#_content_security_policy_csp
getCspSettings().blocking().disabled();
/*
// wicket-bootstrap-extension has to be CSP compliant to enable it
getCspSettings().blocking()
.strict()
// whitelist images rendered via data:
.add(CSPDirective.IMG_SRC, "data:");
*/
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxCallListener;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnEventHeaderItem;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.devgateway.toolkit.forms.wicket.components.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent;

Expand Down Expand Up @@ -53,7 +53,6 @@ public BootstrapDeleteButton(final String id) {
@Override
protected void onInitialize() {
super.onInitialize();
add(new AttributeAppender("onclick", new Model<String>("window.onbeforeunload = null;"), " "));
setDefaultFormProcessing(false);
setIconType(FontAwesome5IconType.trash_s);

Expand All @@ -62,6 +61,11 @@ protected void onInitialize() {
}
}

public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(OnEventHeaderItem.forComponent(this, "onclick", "window.onbeforeunload = null;"));
}

@Override
public void onEvent(final IEvent<?> event) {
if (event.getPayload() instanceof EditingDisabledEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* Development Gateway - initial API and implementation
*******************************************************************************/
/**
*
*
*/
package org.devgateway.toolkit.forms.wicket.components.form;

import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.CssClassNameAppender;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.form.datetime.DatetimePicker;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.form.datetime.DatetimePickerConfig;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.model.IModel;
Expand All @@ -25,7 +25,7 @@

/**
* @author mpostelnicu
*
*
*/
public class DateTimeFieldBootstrapFormComponent extends GenericBootstrapFormComponent<Date, DatetimePicker> {
private static final long serialVersionUID = 6829640010904041758L;
Expand Down Expand Up @@ -69,15 +69,15 @@ public String getUpdateEvent() {

/*
* (non-Javadoc)
*
*
* @see org.devgateway.toolkit.forms.wicket.components.form.
* GenericBootstrapFormComponent#onConfigure()
*/
@Override
protected void onInitialize() {
super.onInitialize();

border.add(new AttributeModifier("style", "position:relative;"));
border.add(new CssClassNameAppender("position-relative"));

IndicatingAjaxLink<String> clearDateLink = new IndicatingAjaxLink<String>("clearDate") {
private static final long serialVersionUID = -1705495886974891511L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<a wicket:id="downloadLink"><span wicket:id="downloadText"/></a>
</td>
<td class="col-md-2">
<i style="cursor: pointer;" wicket:id="download"/>
<i style="cursor: pointer;" wicket:id="delete"/>
<i role="button" wicket:id="download"/>
<i role="button" wicket:id="delete"/>
</td>
</tr>
</tbody>
Expand All @@ -39,7 +39,7 @@
<span wicket:id="fileTitle"/>
</td>
<td class="col-md-2">
<i style="cursor: pointer;" wicket:id="delete"/>
<i role="button" wicket:id="delete"/>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div wicket:id="enclosing-field-group" class="input-group"
style="display: block">
<span style="display: table-cell; white-space: nowrap;">
<span wicket:id="tooltipLabel"></span> <input
wicket:id="field" type="text" placeholder="%"></input> <label
wicket:id="label">[[label]]</label>
<div wicket:id="enclosing-field-group" class="input-group d-block">
<span class="d-table-cell text-nowrap">
<span wicket:id="tooltipLabel"></span>
<input wicket:id="field" type="text" placeholder="%" class="d-inline-block"></input>
<label wicket:id="label">[[label]]</label>
</span>
<wicket:child />
<span wicket:id="viewModeField"></span>
</div>
</wicket:panel>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.google.common.io.BaseEncoding;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.InputBehavior;
import de.agilecoders.wicket.core.util.Attributes;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteConfig;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteEditorCssReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteEditorFormDataReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteEditorJavaScriptReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteEditorOverlayCssReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteStorage;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.editor.SummernoteStoredImageResourceReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesomeCssReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5CssReference;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.references.SpinJsReference;
import de.agilecoders.wicket.jquery.IKey;
import org.apache.commons.fileupload.FileItem;
Expand Down Expand Up @@ -108,7 +109,7 @@ public ToolkitSummernoteEditor(final String id, final IModel<String> model, fina
@Override
protected void onComponentTag(final ComponentTag tag) {
if (!isEnabledInHierarchy()) {
tag.put("style", "display:none;");
Attributes.addClass(tag, "d-none");
if (tag.isOpenClose()) {
// always transform the tag to <div></div> so even labels defined as <span/> render
tag.setType(XmlTag.TagType.OPEN);
Expand Down Expand Up @@ -159,7 +160,7 @@ public void renderHead(final IHeaderResponse response) {
return;
}
response.render(CssHeaderItem.forReference(SummernoteEditorCssReference.instance()));
response.render(CssHeaderItem.forReference(FontAwesomeCssReference.instance()));
response.render(CssHeaderItem.forReference(FontAwesome5CssReference.instance()));
response.render(CssHeaderItem.forReference(SummernoteEditorOverlayCssReference.instance()));
response.render(JavaScriptHeaderItem.forReference(SummernoteEditorJavaScriptReference.instance()));
response.render(JavaScriptHeaderItem.forReference(SummernoteEditorFormDataReference.instance()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="row" style="float: right">
<div class="row float-right">
<ul class="pagination l-float">
<li>
<a href="#" wicket:id="first" class="first">««</a>
Expand All @@ -23,4 +23,4 @@
</div>
</wicket:panel>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<wicket:fragment wicket:id="entityButtons">
<span wicket:id="extraStatusEntityButtons"></span>
<button wicket:id="saveSubmit" type="button" class="btn btn-info btn-form-action">Save</button>
<button wicket:id="saveContinue" type="button" class="btn btn-info btn-form-action btn-save-as-draft" style="display: none;">Save & Continue</button>
<button wicket:id="saveContinue" type="button" class="btn btn-info btn-form-action btn-save-as-draft">Save & Continue</button>
<button wicket:id="submitAndNext" type="button" class="btn btn-info btn-form-action">Save & Next</button>
<button wicket:id="approve" type="button" class="btn btn-success btn-form-action">Save & Approve</button>
<button wicket:id="revertToDraft" type="button" class="btn btn-warning btn-form-action">Save & Validate</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<div wicket:id="colorPicker" class="col-md-4"></div>
</div>

<div class="row">
<div wicket:id="percentage" class="col-md-4"></div>
</div>

<div class="row">
<div wicket:id="fileInput" class="col-md-12"></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.devgateway.toolkit.forms.wicket.components.form.DateFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.DateTimeFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.FileInputBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.PercentageFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.Select2ChoiceBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.Select2MultiChoiceBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.SummernoteBootstrapFormComponent;
Expand Down Expand Up @@ -136,6 +137,10 @@ protected void onInitialize() {
dateTime.required();
editForm.add(dateTime);

PercentageFieldBootstrapFormComponent percentage = new PercentageFieldBootstrapFormComponent("percentage");
percentage.required();
editForm.add(percentage);

FileInputBootstrapFormComponent fileInput = new FileInputBootstrapFormComponent("fileInput");
fileInput.required();
editForm.add(fileInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ checkboxPicker.label=Checkbox Picker
checkboxToggle.label=Checkbox Toggle
date.label=Date
dateTime.label=Datetime
percentage.label=Percentage
fileInput.label=File Input
summernote.label=Summernote Editor
colorPicker.label=Color Picker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="row">
<div class="col-md-10 col-md-offset-1">
<form wicket:id="filterForm">
<button type="submit" style="display: none;">Submit</button>
<button type="submit" class="d-none">Submit</button>
<table class="dataview table" wicket:id="table"></table>
</form>
<button wicket:id="new" type="button" class="btn-add-output">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -76,6 +77,8 @@ public class TestForm extends AbstractStatusAuditableEntity {

private Date dateTime;

private BigDecimal percentage;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@ManyToOne
private Group preloadedEntitySelect;
Expand Down Expand Up @@ -161,6 +164,14 @@ public void setDateTime(final Date dateTime) {
this.dateTime = dateTime;
}

public BigDecimal getPercentage() {
return percentage;
}

public void setPercentage(final BigDecimal percentage) {
this.percentage = percentage;
}

public String getSummernote() {
return summernote;
}
Expand Down

0 comments on commit 307e407

Please sign in to comment.