Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/new-approva…
Browse files Browse the repository at this point in the history
…l-gui

# Conflicts:
#	gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/prism/PrismValuePanel.java
#	gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/PageProcessInstances.java
#	gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/workflow/PageWorkItems.java
  • Loading branch information
mederly committed Mar 21, 2016
2 parents c5d36c9 + ffc78fb commit f83fe08
Show file tree
Hide file tree
Showing 30 changed files with 376 additions and 549 deletions.
Expand Up @@ -17,10 +17,11 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="linkContainer"><span wicket:id="passwordSet"/> <span class="btn-group" style="float:right"><a href="#" wicket:id="changePasswordLink" class="btn btn-primary btn-xs"></a></span></span>
<div wicket:id="inputContainer">
<span wicket:id="linkContainer" class="col-md-11"><span wicket:id="passwordSet"/><span wicket:id="passwordRemove"/> <span class="btn-group" style="float:right"><a href="#" wicket:id="changePasswordLink" class="btn btn-primary btn-xs"></a></span></span>
<div wicket:id="inputContainer" class="col-md-11">
<input class="form-control input-sm" wicket:id="password1" type="password" autocomplete="off" about="password1"/>
<input class="form-control input-sm" wicket:id="password2" type="password" style="margin-top: 5px;" about="password2"/>
</div>
</div>
<div wicket:id="removeButtonContainer" class="col-md-1"><span class="btn-group" style="float:right"><a href="#" wicket:id="removePasswordLink" class="btn btn-primary btn-xs"></a></span></div>
</wicket:panel>
</html>
Expand Up @@ -48,7 +48,10 @@ public class PasswordPanel extends InputPanel {

private static final String ID_LINK_CONTAINER = "linkContainer";
private static final String ID_PASSWORD_SET = "passwordSet";
private static final String ID_PASSWORD_REMOVE = "passwordRemove";
private static final String ID_CHANGE_PASSWORD_LINK = "changePasswordLink";
private static final String ID_REMOVE_PASSWORD_LINK = "removePasswordLink";
private static final String ID_REMOVE_BUTTON_CONTAINER = "removeButtonContainer";
private static final String ID_INPUT_CONTAINER = "inputContainer";
private static final String ID_PASSWORD_ONE = "password1";
private static final String ID_PASSWORD_TWO = "password2";
Expand All @@ -58,18 +61,18 @@ public class PasswordPanel extends InputPanel {
private boolean passwordInputVisble;

public PasswordPanel(String id, IModel<ProtectedStringType> model) {
this(id, model, false);
this(id, model, false, false);
}

public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly) {
public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly, boolean showRemoveButton) {
super(id);

initLayout(model, isReadOnly);
initLayout(model, isReadOnly, showRemoveButton);
}

private void initLayout(IModel<ProtectedStringType> model, final boolean isReadOnly) {
private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly, boolean showRemoveButton) {
setOutputMarkupId(true);

passwordInputVisble = model.getObject() == null;
// TODO: remove
// LOGGER.trace("PASSWORD model: {}", model.getObject());
Expand Down Expand Up @@ -116,11 +119,16 @@ public boolean isVisible() {
}
};
inputContainer.setOutputMarkupId(true);
linkContainer.setOutputMarkupId(true);
add(linkContainer);

Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
linkContainer.add(passwordSetLabel);

final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel"));
passwordRemoveLabel.setVisible(false);
linkContainer.add(passwordRemoveLabel);

AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
Expand All @@ -142,14 +150,39 @@ public boolean isVisible() {
link.setBody(new ResourceModel("passwordPanel.passwordChange"));
link.setOutputMarkupId(true);
linkContainer.add(link);


final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
onRemovePassword(model, target);
}

};
removePassword.setVisible(showRemoveButton);
removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
removePassword.setOutputMarkupId(true);
removeButtonContainer.add(removePassword);
add(removeButtonContainer);
}

private void onLinkClick(AjaxRequestTarget target) {
passwordInputVisble = true;
target.add(this);
}

private void onRemovePassword(IModel<ProtectedStringType> model, AjaxRequestTarget target) {
get(ID_LINK_CONTAINER).get(ID_PASSWORD_SET).setVisible(false);
get(ID_LINK_CONTAINER).get(ID_PASSWORD_REMOVE).setVisible(true);
passwordInputVisble = false;
target.add(this);

ProtectedStringType newValue = new ProtectedStringType();
byte[] temp = new byte[0];
newValue.setClearBytes(temp);
model.setObject(null);
}

@Override
public List<FormComponent> getFormComponents() {
List<FormComponent> list = new ArrayList<FormComponent>();
Expand Down
Expand Up @@ -332,6 +332,13 @@ public ObjectDelta<O> getObjectDelta() throws SchemaException {
if (itemWrapper instanceof PropertyWrapper) {
ItemDelta pDelta = computePropertyDeltas((PropertyWrapper) itemWrapper, containerPath);
if (!pDelta.isEmpty()) {
//HACK to remove a password replace delta is to be created
if (containerWrapper.getName().equals(CredentialsType.F_PASSWORD)) {
if (pDelta.getValuesToDelete() != null){
pDelta.resetValuesToDelete();
pDelta.setValuesToReplace(new ArrayList());
}
}
delta.addModification(pDelta);
}
} else if (itemWrapper instanceof ReferenceWrapper) {
Expand Down
Expand Up @@ -49,7 +49,9 @@
import com.evolveum.midpoint.web.component.model.delta.ModificationsPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.LookupPropertyModel;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.web.util.DateValidator;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
Expand Down Expand Up @@ -434,9 +436,12 @@ private Panel createTypedInputComponent(String id) {
panel = new DatePanel(id, new PropertyModel<XMLGregorianCalendar>(model, baseExpression));

} else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
boolean showRemovePasswordButton = true;
if (((PageUser)pageBase).getObjectWrapper().getObject().getOid().equals(SecurityUtils.getPrincipalUser().getOid())){
showRemovePasswordButton = false;
}
panel = new PasswordPanel(id, new PropertyModel<ProtectedStringType>(model, baseExpression),
model.getObject().isReadonly());

model.getObject().isReadonly(), showRemovePasswordButton);
} else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) {
panel = new TriStateComboPanel(id, new PropertyModel<Boolean>(model, baseExpression));

Expand Down
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright (c) 2010-2013 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<form class="form-inline pull-right search-form" wicket:id="searchForm">
<div wicket:id="search"/>
</form>
</wicket:panel>
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;

/**
* @author Viliam Repan (lazyman)
*/
public class SearchFormPanel extends BasePanel<Search> {

private static final String ID_SEARCH = "search";
private static final String ID_SEARCH_FORM = "searchForm";

public SearchFormPanel(String id, IModel<Search> model) {
super(id, model);

initLayout();
}

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

SearchPanel search = new SearchPanel(ID_SEARCH, getModel()) {

@Override
public void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {
SearchFormPanel.this.searchPerformed(query, target);
}
};
searchForm.add(search);
}

protected void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {

}
}
Expand Up @@ -25,7 +25,6 @@
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.MarkupContainer;
Expand Down Expand Up @@ -447,10 +446,13 @@ public Object getDisplayValue(DisplayableValue<T> object) {
public String getIdValue(DisplayableValue<T> object, int index) {
return Integer.toString(index);
}

@Override
public DisplayableValue<T> getObject(String id, IModel<? extends List<? extends DisplayableValue<T>>> choices) {
return choices.getObject().get(Integer.parseInt(id));
if (StringUtils.isEmpty(id)) {
return null;
}
return choices.getObject().get(Integer.parseInt(id));
}

@Override
Expand Down
Expand Up @@ -208,7 +208,7 @@ public void finishProcessing(AjaxRequestTarget target, OperationResult result) {

}
}
goBackPage();
redirectBack();
} else {
getProgressReporter().showBackButton(target);
getProgressReporter().hideAbortButton(target);
Expand Down
Expand Up @@ -617,28 +617,6 @@ protected void performAdditionalValidation(PrismObject<O> object,

}

// TODO: fix name, confusing. clashes with goBack()
// todo: we should navigate using breadcrumb stack [lazyman]
@Deprecated
public void goBackPage() {
StringValue orgReturn = getPageParameters().get(PARAM_RETURN_PAGE);
if (PageOrgTree.PARAM_ORG_RETURN.equals(orgReturn.toString())) {
setResponsePage(getSessionStorage().getPreviousPage());
} else if (getPreviousPage() != null) {
goBack(PageDashboard.class); // the class parameter is not necessary, is previousPage is set
} else if (getSessionStorage() != null){
if (getSessionStorage().getPreviousPageInstance() != null){
setResponsePage(getSessionStorage().getPreviousPageInstance());
} else if (getSessionStorage().getPreviousPage() != null){
setResponsePage(getSessionStorage().getPreviousPage());
} else {
setResponsePage(getDefaultBackPage());
}
} else {
setResponsePage(getDefaultBackPage());
}
}

public abstract PageBase getDefaultBackPage();

public List<ObjectFormType> getObjectFormTypes() {
Expand Down
Expand Up @@ -511,7 +511,7 @@ private void listObjectsPerformed(ObjectQuery query, AjaxRequestTarget target) {

if (selected != null) {
provider.setType(selected.getClassDefinition());
// addOrReplaceTable(provider);
addOrReplaceTable(provider);
}

// save object type category to session storage, used by back button
Expand Down
Expand Up @@ -21,10 +21,6 @@
<div wicket:id="deleteResourcesPopup" />
<div wicket:id="deleteHostsPopup" />

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

<form wicket:id="mainForm" class="clearfix form-horizontal">
<h3><wicket:message key="pageResources.resources"/></h3>
<div wicket:id="table"/>
Expand Down

0 comments on commit f83fe08

Please sign in to comment.