Skip to content

Commit

Permalink
MID-6100 Make "Show no response cases only" default ON
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar authored and PetrGasparik committed Mar 13, 2020
1 parent 20d4fac commit 995c6cf
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
Expand Up @@ -38,6 +38,7 @@
import com.evolveum.midpoint.web.page.admin.certification.dto.SearchingUtils;
import com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses;
import com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction;
import com.evolveum.midpoint.web.session.CertDecisionsStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.TooltipBehavior;
Expand All @@ -64,6 +65,7 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.xpath.operations.Bool;

import javax.xml.datatype.XMLGregorianCalendar;
import java.util.ArrayList;
Expand Down Expand Up @@ -103,9 +105,12 @@ public class PageCertDecisions extends PageAdminCertification {

private CertDecisionHelper helper = new CertDecisionHelper();

private IModel<Boolean> showNotDecidedOnlyModel = new Model<>(false);

public PageCertDecisions() {
}

@Override
protected void onInitialize(){
super.onInitialize();
initLayout();
}

Expand Down Expand Up @@ -148,7 +153,8 @@ private void initLayout() {

@Override
protected WebMarkupContainer createHeader(String headerId) {
return new SearchFragment(headerId, ID_TABLE_HEADER, PageCertDecisions.this, showNotDecidedOnlyModel);
return new SearchFragment(headerId, ID_TABLE_HEADER, PageCertDecisions.this,
Model.of(getCertDecisionsStorage().getShowNotDecidedOnly()));
}
};
table.setShowPaging(true);
Expand Down Expand Up @@ -485,7 +491,7 @@ private void searchFilterPerformed(AjaxRequestTarget target) {
DataTable table = panel.getDataTable();
CertWorkItemDtoProvider provider = (CertWorkItemDtoProvider) table.getDataProvider();
provider.setQuery(query);
provider.setNotDecidedOnly(Boolean.TRUE.equals(showNotDecidedOnlyModel.getObject()));
provider.setNotDecidedOnly(getCertDecisionsStorage().getShowNotDecidedOnly().booleanValue());
table.setCurrentPage(0);

target.add(getFeedbackPanel());
Expand Down Expand Up @@ -515,6 +521,10 @@ private void searchFilterPerformed(AjaxRequestTarget target) {
// }
// }

private CertDecisionsStorage getCertDecisionsStorage(){
return getSessionStorage().getCertDecisions();
}

private static class SearchFragment extends Fragment {

public SearchFragment(String id, String markupId, MarkupContainer markupProvider,
Expand Down Expand Up @@ -542,7 +552,9 @@ private AjaxFormComponentUpdatingBehavior createFilterAjaxBehaviour() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
PageCertDecisions page = (PageCertDecisions) getPage();
page.getCertDecisionsStorage().setShowNotDecidedOnly((Boolean) getDefaultModelObject());
page.searchFilterPerformed(target);

}
};
}
Expand Down
@@ -0,0 +1,67 @@
/*
* 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.session;

import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.web.component.search.Search;

/**
* @author honchar
* */
public class CertDecisionsStorage implements PageStorage {
private static final long serialVersionUID = 1L;

private ObjectPaging certDecisionsPaging;
private Search search;
private Boolean showNotDecidedOnly = Boolean.TRUE;

public Boolean getShowNotDecidedOnly() {
return showNotDecidedOnly;
}

public void setShowNotDecidedOnly(Boolean showNotDecidedOnly) {
this.showNotDecidedOnly = showNotDecidedOnly;
}

@Override
public ObjectPaging getPaging() {
return certDecisionsPaging;
}

@Override
public void setPaging(ObjectPaging certDecisionsPaging) {
this.certDecisionsPaging = certDecisionsPaging;
}

@Override
public Search getSearch() {
return search;
}

@Override
public void setSearch(Search search) {
this.search = search;
}

@Override
public String debugDump() {
return debugDump(0);
}

@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append("CertDecisionsStorage\n");
DebugUtil.debugDumpWithLabelLn(sb, "showNotDecidedOnly", showNotDecidedOnly, indent+1);
DebugUtil.debugDumpWithLabelLn(sb, "campaignsPaging", certDecisionsPaging, indent+1);
DebugUtil.debugDumpWithLabel(sb, "search", search, indent+1);
return sb.toString();
}

}
Expand Up @@ -53,6 +53,7 @@ public class SessionStorage implements Serializable, DebugDumpable {

private static final String KEY_TASKS = "tasks";
private static final String KEY_CERT_CAMPAIGNS = "certCampaigns";
private static final String KEY_CERT_DECISIONS = "certDecisions";

/**
* Contains state for first level menu items. Key is menu label text, value if true then
Expand Down Expand Up @@ -207,6 +208,13 @@ public CertCampaignsStorage getCertCampaigns() {
return (CertCampaignsStorage)pageStorageMap.get(KEY_CERT_CAMPAIGNS);
}

public CertDecisionsStorage getCertDecisions() {
if (pageStorageMap.get(KEY_CERT_DECISIONS) == null) {
pageStorageMap.put(KEY_CERT_DECISIONS, new CertDecisionsStorage());
}
return (CertDecisionsStorage)pageStorageMap.get(KEY_CERT_DECISIONS);
}

public ReportsStorage getReports() {
if (pageStorageMap.get(KEY_REPORTS) == null) {
pageStorageMap.put(KEY_REPORTS, new ReportsStorage());
Expand Down

0 comments on commit 995c6cf

Please sign in to comment.