Skip to content

Commit

Permalink
OCMAKU-360 Procurement plan items not filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
mpostelnicu committed Oct 14, 2019
1 parent 865dd53 commit 73bf178
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import de.agilecoders.wicket.extensions.markup.html.bootstrap.ladda.LaddaAjaxButton;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.event.IEventSink;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand All @@ -24,6 +27,8 @@
import org.devgateway.toolkit.forms.wicket.components.form.BootstrapAddButton;
import org.devgateway.toolkit.forms.wicket.components.form.BootstrapDeleteButton;
import org.devgateway.toolkit.forms.wicket.components.util.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.events.EditingDisabledEvent;
import org.devgateway.toolkit.forms.wicket.page.edit.AbstractEditStatusEntityPage;
import org.devgateway.toolkit.persistence.dao.AbstractAuditableEntity;
import org.devgateway.toolkit.persistence.dao.ListViewItem;
import org.slf4j.Logger;
Expand Down Expand Up @@ -61,6 +66,14 @@ public ListViewSectionPanel(final String id) {
super(id);
}

protected void checkAndSendEventForDisableEditing(IEventSink sink) {
Page page = getPage();
if (page instanceof AbstractEditStatusEntityPage && ((AbstractEditStatusEntityPage) page)
.isDisableEditingEvent()) {
send(sink, Broadcast.BREADTH, new EditingDisabledEvent());
}
}

@Override
protected void onInitialize() {
super.onInitialize();
Expand Down Expand Up @@ -145,6 +158,8 @@ protected void populateItem(final ListItem<T> item) {
populateCompoundListItem(item);

addAcordion(item);

checkAndSendEventForDisableEditing(item);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,15 @@ private boolean isViewMode() {
}

protected void checkAndSendEventForDisableEditing() {
if (!Strings.isEqual(editForm.getModelObject().getStatus(), DBConstants.Status.DRAFT) || isViewMode()) {
if (isDisableEditingEvent()) {
send(getPage(), Broadcast.BREADTH, new EditingDisabledEvent());
}
}

public boolean isDisableEditingEvent() {
return !Strings.isEqual(editForm.getModelObject().getStatus(), DBConstants.Status.DRAFT) || isViewMode();
}

private void addAutosaveLabel() {
autoSaveLabel = new Label("autoSaveLabel",
new StringResourceModel("autoSaveLabelMessage", this).setParameters(settingsUtils.getAutosaveTime()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.feedback.FeedbackMessages;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.GenericPanel;
Expand All @@ -27,6 +28,7 @@
import org.devgateway.toolkit.forms.wicket.components.form.Select2ChoiceBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.util.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.providers.GenericPersistableJpaTextChoiceProvider;
import org.devgateway.toolkit.persistence.dao.categories.Item;
import org.devgateway.toolkit.persistence.dao.form.PlanItem;
import org.devgateway.toolkit.persistence.dao.form.ProcurementPlan;
Expand Down Expand Up @@ -306,10 +308,18 @@ private class PlanItemFilterPanel extends GenericPanel<PlanItemFilterBean> {
protected void onInitialize() {
super.onInitialize();

final Select2ChoiceBootstrapFormComponent<Item> filterItem =
ComponentUtil.addSelect2ChoiceField(this, "filterItem", itemService);
final GenericPersistableJpaTextChoiceProvider<Item> choiceProvider
= new GenericPersistableJpaTextChoiceProvider<>(itemService);

final Select2ChoiceBootstrapFormComponent<Item> filterItem = new Select2ChoiceBootstrapFormComponent<Item>(
"filterItem", choiceProvider) {
@Override
public void onEvent(IEvent event) {
}
};

filterItem.getField().add(new AjaxComponentUpdatingBehavior("change"));
this.add(filterItem);
}

private class AjaxComponentUpdatingBehavior extends AjaxFormComponentUpdatingBehavior {
Expand Down

0 comments on commit 73bf178

Please sign in to comment.