Skip to content

Commit

Permalink
roles list update, system configuration minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 7, 2015
1 parent 0c228d4 commit 34d8651
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 60 deletions.
Expand Up @@ -91,9 +91,9 @@ public class PageSystemConfiguration extends PageAdminConfiguration {

public static final String ROOT_APPENDER_INHERITANCE_CHOICE = "(Inherit root)";

LoggingConfigPanel loggingConfigPanel;
ProfilingConfigPanel profilingConfigPanel;
SystemConfigPanel systemConfigPanel;
private LoggingConfigPanel loggingConfigPanel;
private ProfilingConfigPanel profilingConfigPanel;
private SystemConfigPanel systemConfigPanel;

private LoadableModel<SystemConfigurationDto> model;

Expand Down
Expand Up @@ -20,21 +20,20 @@
<wicket:extend>
<div wicket:id="confirmDeletePopup" />

<div class="clearfix">
<form class="form-inline pull-right search-form" wicket:id="searchForm">
<form wicket:id="mainForm" class="form-inline">
<div wicket:id="table"/>
</form>

<wicket:fragment wicket:id="tableHeader">
<form class="form-inline pull-right search-form" wicket:id="searchForm">
<div class="form-group">
<label class="sr-only"><wicket:message key="pageRoles.requestable"/></label>
<select class="form-control input-sm" wicket:id="choice" />
</div>

<div wicket:id="basicSearch"/>
</form>
</div>

<form wicket:id="mainForm" class="clearfix form-horizontal">
<div wicket:id="table"/>
</form>
</wicket:fragment>

</wicket:extend>
</body>
Expand Down
Expand Up @@ -30,8 +30,9 @@
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.BasicSearchPanel;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
import com.evolveum.midpoint.web.component.data.ObjectDataProvider;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.Table;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.LinkColumn;
Expand All @@ -41,20 +42,25 @@
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction;
import com.evolveum.midpoint.web.page.admin.roles.dto.RolesSearchDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UsersDto;
import com.evolveum.midpoint.web.session.RolesStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
Expand Down Expand Up @@ -85,6 +91,7 @@ public class PageRoles extends PageAdminRoles {
private static final String ID_SEARCH_FORM = "searchForm";
private static final String ID_BASIC_SEARCH = "basicSearch";
private static final String ID_SEARCH_REQUESTABLE = "choice";
private static final String ID_TABLE_HEADER = "tableHeader";

private IModel<RolesSearchDto> searchModel;

Expand Down Expand Up @@ -120,11 +127,6 @@ protected RolesSearchDto load() {
}

private void initLayout() {
Form searchForm = new Form(ID_SEARCH_FORM);
searchForm.setOutputMarkupId(true);
add(searchForm);
initSearchForm(searchForm);

Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);

Expand All @@ -139,8 +141,16 @@ protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
provider.setQuery(createQuery());

List<IColumn<RoleType, String>> columns = initColumns();
TablePanel table = new TablePanel<>(ID_TABLE, provider, columns,
UserProfileStorage.TableId.TABLE_ROLES, getItemsPerPage(UserProfileStorage.TableId.TABLE_ROLES));

BoxedTablePanel table = new BoxedTablePanel(ID_TABLE, provider, columns,
UserProfileStorage.TableId.TABLE_ROLES,
(int) getItemsPerPage(UserProfileStorage.TableId.TABLE_ROLES)) {

@Override
protected WebMarkupContainer createHeader(String headerId) {
return new SearchFragment(headerId, ID_TABLE_HEADER, PageRoles.this, searchModel);
}
};
table.setOutputMarkupId(true);

RolesStorage storage = getSessionStorage().getRoles();
Expand All @@ -159,40 +169,6 @@ public void yesPerformed(AjaxRequestTarget target) {
});
}

private void initSearchForm(Form searchForm) {
DropDownChoice requestable = new DropDownChoice(ID_SEARCH_REQUESTABLE,
new PropertyModel(searchModel, RolesSearchDto.F_REQUESTABLE),
WebMiscUtil.createReadonlyModelFromEnum(RolesSearchDto.Requestable.class), new EnumChoiceRenderer(this));
requestable.add(new OnChangeAjaxBehavior() {

@Override
protected void onUpdate(AjaxRequestTarget target) {
listRolesPerformed(target);
}
});

searchForm.add(requestable);

BasicSearchPanel<RolesSearchDto> basicSearch = new BasicSearchPanel<RolesSearchDto>(ID_BASIC_SEARCH) {

@Override
protected IModel<String> createSearchTextModel() {
return new PropertyModel<>(searchModel, RolesSearchDto.F_SEARCH_TEXT);
}

@Override
protected void searchPerformed(AjaxRequestTarget target) {
listRolesPerformed(target);
}

@Override
protected void clearSearchPerformed(AjaxRequestTarget target) {
PageRoles.this.clearSearchPerformed(target);
}
};
searchForm.add(basicSearch);
}

private List<IColumn<RoleType, String>> initColumns() {
List<IColumn<RoleType, String>> columns = new ArrayList<>();

Expand Down Expand Up @@ -249,8 +225,8 @@ public String getObject() {
};
}

private TablePanel getRoleTable() {
return (TablePanel) get(createComponentPath(ID_MAIN_FORM, ID_TABLE));
private Table getRoleTable() {
return (Table) get(createComponentPath(ID_MAIN_FORM, ID_TABLE));
}

private ObjectDataProvider<SelectableBean<RoleType>, RoleType> getRoleDataProvider() {
Expand Down Expand Up @@ -313,7 +289,7 @@ private void deleteConfirmedPerformed(AjaxRequestTarget target) {

showResult(result);
target.add(getFeedbackPanel());
target.add(getRoleTable());
target.add((Component) getRoleTable());
}

private void roleDetailsPerformed(AjaxRequestTarget target, String oid) {
Expand All @@ -331,9 +307,9 @@ private void listRolesPerformed(AjaxRequestTarget target) {
storage.setRolesSearch(searchModel.getObject());
storage.setRolesPaging(null);

TablePanel table = getRoleTable();
Table table = getRoleTable();
table.setCurrentPage(null);
target.add(table);
target.add((Component) table);
target.add(getFeedbackPanel());
}

Expand Down Expand Up @@ -379,7 +355,7 @@ private ObjectQuery createQuery() {
private void clearSearchPerformed(AjaxRequestTarget target) {
searchModel.setObject(new RolesSearchDto());

TablePanel panel = getRoleTable();
Table panel = getRoleTable();
DataTable table = panel.getDataTable();
ObjectDataProvider provider = (ObjectDataProvider) table.getDataProvider();
provider.setQuery(null);
Expand All @@ -390,7 +366,59 @@ private void clearSearchPerformed(AjaxRequestTarget target) {

panel.setCurrentPage(storage.getRolesPaging());

target.add(get(ID_SEARCH_FORM));
target.add(panel);
target.add((Component) panel);
}

private static class SearchFragment extends Fragment {

public SearchFragment(String id, String markupId, MarkupContainer markupProvider,
IModel<RolesSearchDto> model) {
super(id, markupId, markupProvider, model);

initLayout();
}

private void initLayout() {
final Form searchForm = new Form(ID_SEARCH_FORM);
add(searchForm);
searchForm.setOutputMarkupId(true);

final IModel<RolesSearchDto> model = (IModel) getDefaultModel();

BasicSearchPanel<RolesSearchDto> basicSearch = new BasicSearchPanel<RolesSearchDto>(ID_BASIC_SEARCH, model) {

@Override
protected IModel<String> createSearchTextModel() {
return new PropertyModel<String>(model, UsersDto.F_TEXT);
}

@Override
protected void searchPerformed(AjaxRequestTarget target) {
PageRoles page = (PageRoles) getPage();
page.listRolesPerformed(target);
}

@Override
protected void clearSearchPerformed(AjaxRequestTarget target) {
PageRoles page = (PageRoles) getPage();
page.clearSearchPerformed(target);
}
};
searchForm.add(basicSearch);

DropDownChoice requestable = new DropDownChoice(ID_SEARCH_REQUESTABLE,
new PropertyModel(model, RolesSearchDto.F_REQUESTABLE),
WebMiscUtil.createReadonlyModelFromEnum(RolesSearchDto.Requestable.class),
new EnumChoiceRenderer(this));
requestable.add(new OnChangeAjaxBehavior() {

@Override
protected void onUpdate(AjaxRequestTarget target) {
PageRoles page = (PageRoles) getPage();
page.listRolesPerformed(target);
}
});
searchForm.add(requestable);
}
}
}

0 comments on commit 34d8651

Please sign in to comment.