Skip to content

Commit

Permalink
Merge branch 'new-system-configuration-page' of https://github.com/Ev…
Browse files Browse the repository at this point in the history
…olveum/midpoint into new-system-configuration-page
  • Loading branch information
skublik committed Jul 18, 2018
2 parents a261a27 + 0a9cdf0 commit 7240263
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 50 deletions.
Expand Up @@ -16,8 +16,11 @@

package com.evolveum.midpoint.web.component.prism;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.validator.routines.EmailValidator;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -91,6 +94,8 @@ protected void reloadParentContainerPanel(AjaxRequestTarget target){
target.add(ContainerValuePanel.this);
}
};


header.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -127,18 +132,19 @@ private <IW extends ItemWrapper> void addOrReplaceProperties(IModel<ContainerVal

@Override
protected void populateItem(final ListItem<IW> item) {

item.setOutputMarkupId(true);
if (item.getModel().getObject() instanceof ContainerWrapper) {
PrismContainerPanel<C> containerPanel = new PrismContainerPanel("property", (IModel<ContainerWrapper<C>>) item.getModel(), true, form, isPanaleVisible, pageBase);
PrismContainerPanel<C> containerPanel = new PrismContainerPanel<C>("property", (IModel<ContainerWrapper<C>>) item.getModel(), true, form, isPanaleVisible, pageBase);
containerPanel.setOutputMarkupId(true);
item.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

public boolean isVisible(){
return containerPanel.isVisible();
}
});
item.add(containerPanel);
containerPanel.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return (model.getObject().containsMultipleMultivalueContainer() && item.getModelObject().getItemDefinition().isMultiValue() && CollectionUtils.isEmpty(item.getModelObject().getValues())) ? false : true;

}
});
return;
}

Expand All @@ -150,6 +156,7 @@ public boolean isVisible(){
}
};
properties.setReuseItems(true);
properties.setOutputMarkupId(true);
if (isToBeReplaced) {
replace(properties);
} else {
Expand Down
Expand Up @@ -786,12 +786,17 @@ public ContainerValueWrapper<C> findContainerValueWrapper(ItemPath path) {
return null;
}

public boolean containsMultivalueContainer(){
public boolean containsMultipleMultivalueContainer(){
int count = 0;
for (ItemWrapper wrapper : getItems()) {
if (!(wrapper instanceof ContainerWrapper)) {
continue;
}
if (!((ContainerWrapper<C>) wrapper).getItemDefinition().isSingleValue()){
count++;
}

if (count > 1) {
return true;
}
}
Expand Down
Expand Up @@ -492,9 +492,9 @@ public boolean isVisible() {

//TODO: is this correct place? shouldn't we restrict creation for multivalue containers
//dirrectly in factory? this can plausible cause problems while computing deltas.
if (!getItem().isSingleValue() && (getValues() == null || getValues().size() == 0)){
return false;
}
// if (!getItem().isSingleValue() && (getValues() == null || getValues().size() == 0)){
// return false;
// }

switch (objectStatus) {
case MODIFYING:
Expand Down
Expand Up @@ -18,7 +18,8 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:extend>

<a class="btn btn-success btn-sm" wicket:id="addButton"><i class="glyphicon glyphicon-plus"/></a>
<button wicket:id="addButton" wicket:message="title:PrismObjectPanel.addChildContainer"
class="btn btn-box-tool" trigger="hover"><i class="fa fa-plus-circle"></i></button>

</wicket:extend>
</html>
Expand Up @@ -17,6 +17,7 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="header"/>
<div wicket:id="values">
<div class="container-fluid" wicket:id="value"/>
</div>
Expand Down
Expand Up @@ -22,6 +22,8 @@
import com.evolveum.midpoint.web.component.assignment.ConstructionDetailsPanelChainedModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
Expand Down Expand Up @@ -86,27 +88,27 @@ public boolean isVisible() {
}

private void initLayout(final IModel<ContainerWrapper<C>> model, final Form form, ItemVisibilityHandler isPanelVisible, boolean showHeader) {
// PrismContainerHeaderPanel header = new PrismContainerHeaderPanel(ID_HEADER, model) {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected void onButtonClick(AjaxRequestTarget target) {
// addOrReplaceProperties(model, form, isPanelVisible, true);
// target.add(PrismContainerPanel.this.findParent(PrismPanel.class));
// }
//
//
// };
// header.add(new VisibleEnableBehaviour(){
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean isVisible(){
// return showHeader;
// }
// });
// header.setOutputMarkupId(true);
// add(header);
PrismContainerHeaderPanel<C> header = new PrismContainerHeaderPanel<C>(ID_HEADER, model) {
private static final long serialVersionUID = 1L;

@Override
protected void onButtonClick(AjaxRequestTarget target) {
addOrReplaceProperties(model, form, isPanelVisible, true);
target.add(PrismContainerPanel.this.getParent());
}


};
header.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible(){
return model.getObject().getItemDefinition().isMultiValue();
}
});
header.setOutputMarkupId(true);
add(header);

addOrReplaceProperties(model, form, isPanelVisible, false);
}
Expand Down Expand Up @@ -137,11 +139,13 @@ protected void populateItem(ListItem<ContainerValueWrapper<C>> item) {
ContainerValuePanel<C> containerPanel = new ContainerValuePanel<C>("value", item.getModel(), true, form, isPanelVisible, pageBase);
containerPanel.setOutputMarkupId(true);
item.add(containerPanel);
item.setOutputMarkupId(true);

}

};
values.setReuseItems(true);
values.setOutputMarkupId(true);
if (isToBeReplaced) {
replace(values);
} else {
Expand Down
Expand Up @@ -188,14 +188,14 @@ public boolean isOn() {

@Override
public boolean isVisible(){
return getModelObject().containsMultivalueContainer() && getModelObject().getContainer() != null
return getModelObject().containsMultipleMultivalueContainer() && getModelObject().getContainer() != null
// && getModelObject().getContainer().isAddContainerButtonVisible()
&& getModelObject().getDefinition().canModify();
}
});
add(addChildContainerButton);

WebMarkupContainer childContainersSelectorPanel = new WebMarkupContainer(ID_CHILD_CONTAINERS_SELECTOR_PANEL);
WebMarkupContainer childContainersSelectorPanel = new WebMarkupContainer(ID_CHILD_CONTAINERS_SELECTOR_PANEL);
childContainersSelectorPanel.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

Expand All @@ -206,21 +206,26 @@ public boolean isVisible(){
});
childContainersSelectorPanel.setOutputMarkupId(true);
add(childContainersSelectorPanel);

List<QName> pathsList = getModelObject().getChildMultivalueContainersToBeAdded();

if(pathsList.size() != 1) {
List<QName> pathsList = getModelObject().getChildMultivalueContainersToBeAdded();
// if(pathsList.size() != 1) {
DropDownChoicePanel multivalueContainersList = new DropDownChoicePanel<>(ID_CHILD_CONTAINERS_LIST,
Model.of(pathsList.size() > 0 ? pathsList.get(0) : null), Model.ofList(pathsList),
new QNameIChoiceRenderer(getModelObject().getDefinition().getCompileTimeClass().getSimpleName()));
multivalueContainersList.setOutputMarkupId(true);
multivalueContainersList.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
childContainersSelectorPanel.add(multivalueContainersList);
} else {
Label containerName = new Label(ID_CHILD_CONTAINERS_LIST, getPathDisplayName(pathsList.get(0)));
// TextField<String> containerName = new TextField<String>(ID_CHILD_CONTAINERS_LIST, Model.of(getPathDisplayName(pathsList.get(0))));
childContainersSelectorPanel.add(containerName);
}
multivalueContainersList.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return pathsList.size() > 1;
}
});
// } else {
// Label containerName = new Label(ID_CHILD_CONTAINERS_LIST, getPathDisplayName(pathsList.get(0)));
//// TextField<String> containerName = new TextField<String>(ID_CHILD_CONTAINERS_LIST, Model.of(getPathDisplayName(pathsList.get(0))));
// childContainersSelectorPanel.add(containerName);
// }
childContainersSelectorPanel.add(new AjaxButton(ID_ADD_BUTTON, createStringResource("prismValuePanel.add")) {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -298,7 +303,7 @@ protected void addNewContainerValuePerformed(AjaxRequestTarget ajaxRequestTarget
isChildContainersSelectorPanelVisible = false;
getModelObject().setShowEmpty(true, false);
createNewContainerValue(getModelObject(), getSelectedContainerQName());
ajaxRequestTarget.add(getChildContainersSelectorPanel().getParent());
// ajaxRequestTarget.add(getChildContainersSelectorPanel().getParent());
}

private QName getSelectedContainerQName(){
Expand Down Expand Up @@ -330,8 +335,8 @@ private void onShowEmptyClick(AjaxRequestTarget target) {
}

public void createNewContainerValue(ContainerValueWrapper<C> containerValueWrapper, QName path){
ContainerWrapper<C> childContainerWrapper = containerValueWrapper.getContainer().findContainerWrapper(new ItemPath(containerValueWrapper.getPath(),
path));
ItemPath newPath = new ItemPath(containerValueWrapper.getPath(), path);
ContainerWrapper<C> childContainerWrapper = containerValueWrapper.getContainer().findContainerWrapper(newPath);
if (childContainerWrapper == null){
return;
}
Expand All @@ -346,7 +351,7 @@ public void createNewContainerValue(ContainerValueWrapper<C> containerValueWrapp
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<C> newValueWrapper = factory.createContainerValueWrapper(childContainerWrapper,
newContainerValue, containerValueWrapper.getObjectStatus(),
ValueStatus.ADDED, new ItemPath(path), task);
ValueStatus.ADDED, newPath, task);
newValueWrapper.setShowEmpty(true, false);
newValueWrapper.computeStripes();
childContainerWrapper.getValues().add(newValueWrapper);
Expand Down

0 comments on commit 7240263

Please sign in to comment.