Skip to content

Commit

Permalink
MID-2862 Lock-out status should not be set to Locked
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 13, 2016
1 parent 6149ac9 commit 1d0eff1
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 7 deletions.
Expand Up @@ -17,12 +17,14 @@
<wicket:panel xmlns:wicket="http://wicket.apache.org">

<div class="form-inline search-form">
<div class="row">
<div class="form-group col-md-12">
<label><wicket:message key="roleMemberPanel.type" /></label>
<select class="form-control input-sm" wicket:id="type" />
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>
<wicket:message key="roleMemberPanel.type"/>
</label>
<select class="form-control input-sm" wicket:id="type"/>
</div>
</div>
<div wicket:id="countContainer">
<div class="form-group col-md-3">
<label><wicket:message key="typedAssignablePanel.selectedResources" /></label>
Expand Down
@@ -0,0 +1,28 @@
<!--
~ 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.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div class="col-md-12">
<div wicket:id="container">
<div class="col-md-11" wicket:id="label"></div>
<div class="col-md-1 btn btn-primary btn-xs" wicket:id="button"></div>
</div>
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,117 @@
package com.evolveum.midpoint.web.component;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

/**
* Created by Kate on 12.04.2016.
*/
public class LockoutStatusPanel extends Panel {
private static final String ID_CONTAINER = "container";
private static final String ID_LABEL = "label";
private static final String ID_BUTTON = "button";
private static final String BUTTON_UNDO_LABEL = "Undo";
private static final String BUTTON_UNLOCK_LABEL = "Unlock";
private boolean isInitialState = true;
private boolean isUndo = false;

public LockoutStatusPanel(String id){
this(id, null);
}

public LockoutStatusPanel(String id, IModel<LockoutStatusType> model){
super(id);
LockoutStatusType l = model.getObject();
isUndo = l != null && model.getObject().value() != null &&
model.getObject().equals(LockoutStatusType.LOCKED);
initLayout(model);
}

private void initLayout(final IModel<LockoutStatusType> model){
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
add(container);

Label label = new Label(ID_LABEL, new IModel<String>() {
@Override
public String getObject() {
LockoutStatusType object = model != null ? model.getObject() : null;

return object == null ?
((PageBase)getPage()).createStringResource("LockoutStatusType.UNDEFINED").getString()
: WebComponentUtil.createLocalizedModelForEnum(object, getLabel()).getObject();
}

@Override
public void setObject(String s) {
}

@Override
public void detach() {

}
});
label.setOutputMarkupId(true);
container.add(label);

AjaxButton button = new AjaxButton(ID_BUTTON, getButtonModel()) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
if (!isInitialState){
model.setObject(LockoutStatusType.LOCKED);
} else {
model.setObject(LockoutStatusType.NORMAL);
}
isInitialState = !isInitialState;
ajaxRequestTarget.add(getButton());
ajaxRequestTarget.add(getLabel());
}
};
button.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return isUndo;
}
});
button.setOutputMarkupId(true);
container.add(button);
}

private IModel<String> getButtonModel(){
return new IModel<String>() {
@Override
public String getObject() {
if (isInitialState){
return BUTTON_UNLOCK_LABEL;
} else {
return BUTTON_UNDO_LABEL;
}
}

@Override
public void setObject(String s) {

}

@Override
public void detach() {

}
};
}

private Component getButton(){
return get(ID_CONTAINER).get(ID_BUTTON);
}

private Component getLabel(){
return get(ID_CONTAINER).get(ID_LABEL);
}
}
Expand Up @@ -43,6 +43,7 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.LockoutStatusPanel;
import com.evolveum.midpoint.web.component.form.ValueChoosePanel;
import com.evolveum.midpoint.web.component.input.*;
import com.evolveum.midpoint.web.component.model.delta.DeltaDto;
Expand Down Expand Up @@ -434,7 +435,7 @@ private Panel createTypedInputComponent(String id) {
if (ActivationType.F_ADMINISTRATIVE_STATUS.equals(definition.getName())) {
return WebComponentUtil.createEnumPanel(ActivationStatusType.class, id, new PropertyModel<ActivationStatusType>(model, baseExpression), this);
} else if(ActivationType.F_LOCKOUT_STATUS.equals(definition.getName())){
return WebComponentUtil.createEnumPanel(LockoutStatusType.class, id, new PropertyModel<LockoutStatusType>(model, baseExpression), this);
return new LockoutStatusPanel(id, new PropertyModel<LockoutStatusType>(model, baseExpression));
} else {
// nothing to do
}
Expand Down
Expand Up @@ -470,6 +470,7 @@ LimitationsEditorDialog.label.read=Read
LimitationsEditorDialog.label.schema=Schema
LockoutStatusType.LOCKED=Locked
LockoutStatusType.NORMAL=Normal
LockoutStatusType.UNDEFINED=Undefined
logger.duplicate=Logger with name '{0}' is already defined
logger.emptyLogger=Logger must not be empty
LoggingComponentType.ALL=All
Expand Down
Expand Up @@ -471,6 +471,7 @@ LimitationsEditorDialog.label.read=Read
LimitationsEditorDialog.label.schema=Schema
LockoutStatusType.LOCKED=Locked
LockoutStatusType.NORMAL=Normal
LockoutStatusType.UNDEFINED=Undefined
logger.duplicate=Logger with name '{0}' is already defined
logger.emptyLogger=Logger must not be empty
LoggingComponentType.ALL=All
Expand Down

0 comments on commit 1d0eff1

Please sign in to comment.