Skip to content

Commit

Permalink
create new panel for parameter with date type
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jun 1, 2021
1 parent 4a54953 commit d18e641
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 6 deletions.
18 changes: 18 additions & 0 deletions config/initial-objects/270-object-collection-audit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@
<name>deltaColumn</name>
<path>delta</path>
<previousColumn>messageColumn</previousColumn>
<export>
<expression>
<script>
<code>
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.report.impl.ReportUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;

ret = new ArrayList();
for (ObjectDeltaOperationType deltaType : input) {
delta = DeltaConvertor.createObjectDeltaOperation(deltaType, prismContext);
ret.add(ReportUtils.printDelta(delta));
}
return ret
</code>
</script>
</expression>
</export>
</column>
</defaultView>
</objectCollection>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ protected void confirmPerformed(AjaxRequestTarget target) {
target.add(DateIntervalSearchPanel.this);
searchPerformed(target);
}

@Override
protected boolean isInterval() {
return DateIntervalSearchPanel.this.isInterval();
}
};
}

Expand Down Expand Up @@ -68,4 +73,8 @@ public String getObject() {
};
}

protected boolean isInterval() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<wicket:panel>
<form wicket:id="popoverForm" style="width: 455px; padding-top: 10px;">
<div class="form-group col-sm-12" style="padding-bottom: 5px;">
<label class="col-sm-2">
<label class="col-sm-2" wicket:id="fromLabel">
<wicket:message key="UserReportConfigPanel.dateFrom"/>
</label>
<div class="col-sm-10">
<div class="col-sm-10" wicket:id="fromValueContainer">
<div wicket:id="dateFromValue" />
</div>
</div>
<div class="form-group col-sm-12" style="padding-bottom: 5px;">
<div class="form-group col-sm-12" style="padding-bottom: 5px;" wicket:id="toDateContainer">
<label class="col-sm-2">
<wicket:message key="UserReportConfigPanel.dateTo"/>
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.web.component.form.MidpointForm;
import com.evolveum.midpoint.web.component.input.DatePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;

import com.evolveum.midpoint.web.util.DateValidator;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;

import javax.xml.datatype.XMLGregorianCalendar;
Expand All @@ -23,8 +26,11 @@ public class DateIntervalSearchPopupPanel extends PopoverSearchPopupPanel {

private static final long serialVersionUID = 1L;

private static final String ID_DATE_FROM_LABEL = "fromLabel";
private static final String ID_DATE_FROM_VALUE_CONTAINER = "fromValueContainer";
private static final String ID_DATE_FROM_VALUE = "dateFromValue";
private static final String ID_DATE_TO_VALUE = "dateToValue";
private static final String ID_DATE_TO_CONTAINER = "toDateContainer";

private IModel<XMLGregorianCalendar> fromDateModel;
private IModel<XMLGregorianCalendar> toDateModel;
Expand All @@ -39,14 +45,33 @@ public DateIntervalSearchPopupPanel(String id, IModel<XMLGregorianCalendar> from
protected void customizationPopoverForm(MidpointForm popoverForm) {
DateValidator validator = WebComponentUtil.getRangeValidator(popoverForm, SchemaConstants.PATH_ACTIVATION);

WebMarkupContainer fromLabel = new WebMarkupContainer(ID_DATE_FROM_LABEL);
fromLabel.add(new VisibleBehaviour(() -> isInterval()));
popoverForm.add(fromLabel);

WebMarkupContainer fromValueContainer = new WebMarkupContainer(ID_DATE_FROM_VALUE_CONTAINER);
fromValueContainer.add(AttributeAppender.append("class", () -> {
if (isInterval()) {
return "col-sm-10";
}
return "col-sm-12";
}));
popoverForm.add(fromValueContainer);
DatePanel fromDatePanel = new DatePanel(ID_DATE_FROM_VALUE, fromDateModel);
fromDatePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
popoverForm.add(fromDatePanel);
fromValueContainer.add(fromDatePanel);
validator.setDateFrom((DateTimeField) fromDatePanel.getBaseFormComponent());

WebMarkupContainer toContainer = new WebMarkupContainer(ID_DATE_TO_CONTAINER);
toContainer.add(new VisibleBehaviour(() -> isInterval()));
popoverForm.add(toContainer);
DatePanel toDatePanel = new DatePanel(ID_DATE_TO_VALUE, toDateModel);
toDatePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
popoverForm.add(toDatePanel);
toContainer.add(toDatePanel);
validator.setDateFrom((DateTimeField) toDatePanel.getBaseFormComponent());
}

protected boolean isInterval() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.web.component.search;

import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.DateLabelComponent;

/**
* @author honchar
*/
public class DateSearchPanel extends DateIntervalSearchPanel {

private static final long serialVersionUID = 1L;

public DateSearchPanel(String id, IModel<XMLGregorianCalendar> fromDateModel) {
super(id, fromDateModel, (IModel<XMLGregorianCalendar>) () -> null);
}

@Override
protected boolean isInterval() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchItemType;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

import javax.xml.datatype.XMLGregorianCalendar;

/**
* @author honchar
*/
Expand Down Expand Up @@ -116,6 +118,9 @@ public Type getInputType(Class clazz, PageBase pageBase) {
if (ItemPathType.class.isAssignableFrom(clazz)) {
return Type.ITEM_PATH;
}
if (XMLGregorianCalendar.class.isAssignableFrom(clazz)) {
return Type.DATE;
}
return Type.TEXT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,23 @@ protected void onUpdate(AjaxRequestTarget target) {
});
break;
}
case DATE:
inputPanel = new DateSearchPanel(ID_SEARCH_ITEM_FIELD,
new PropertyModel(getModel(), FilterSearchItem.F_INPUT_VALUE)){
@Override
public void searchPerformed(AjaxRequestTarget target) {
SearchFilterPanel.this.searchPerformed(target);
}
};
break;
case ITEM_PATH:
inputPanel = new ItemPathSearchPanel(ID_SEARCH_ITEM_FIELD,
new PropertyModel(getModel(), FilterSearchItem.F_INPUT_VALUE));
new PropertyModel(getModel(), FilterSearchItem.F_INPUT_VALUE)){
@Override
public void searchPerformed(AjaxRequestTarget target) {
SearchFilterPanel.this.searchPerformed(target);
}
};
break;
case TEXT:
LookupTableType lookupTable = getModelObject().getLookupTable(getPageBase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@
<name>deltaColumn</name>
<path>delta</path>
<previousColumn>messageColumn</previousColumn>
<export>
<expression>
<script>
<code>
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.report.impl.ReportUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;

ret = new ArrayList();
for (ObjectDeltaOperationType deltaType : input) {
delta = DeltaConvertor.createObjectDeltaOperation(deltaType, prismContext);
ret.add(ReportUtils.printDelta(delta));
}
return ret
</code>
</script>
</expression>
</export>
</column>
</defaultView>
</objectCollection>

0 comments on commit d18e641

Please sign in to comment.