Skip to content

Commit

Permalink
MID-2785 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Mar 14, 2016
1 parent 00a3995 commit 42478f3
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 12 deletions.
Expand Up @@ -47,6 +47,7 @@

<div class="main-button-bar">
<a class="btn btn-danger" wicket:id="abort"/>
<a class="btn btn-default" wicket:id="back"/>
</div>
</form>
</wicket:panel>
Expand Down
Expand Up @@ -21,10 +21,12 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusIcon;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -221,8 +223,30 @@ protected void onError(AjaxRequestTarget target,
target.add(page.getFeedbackPanel());
}
};
progressReporter.registerAbortButton(abortButton);
progressForm.add(abortButton);

progressReporter.registerAbortButton(abortButton);
progressForm.add(abortButton);

AjaxSubmitButton backButton = new AjaxSubmitButton("back",
createStringResource("pageAdminFocus.button.back")) {

@Override
protected void onSubmit(AjaxRequestTarget target,
org.apache.wicket.markup.html.form.Form<?> form) {
Page page = getPage();
if (page != null && page instanceof PageAdminObjectDetails){
setResponsePage(((PageAdminObjectDetails) page).getDefaultBackPage());
}
}

@Override
protected void onError(AjaxRequestTarget target,
org.apache.wicket.markup.html.form.Form<?> form) {
target.add(page.getFeedbackPanel());
}
};
progressReporter.registerBackButton(backButton);
progressForm.add(backButton);

}

Expand Down
Expand Up @@ -68,6 +68,7 @@ public class ProgressReporter implements Serializable {

// links to wicket artefacts on parent page
private AjaxSubmitButton abortButton;
private AjaxSubmitButton backButton;
private ProgressReportingAwarePage parentPage;
private ProgressPanel progressPanel;
private Behavior refreshingBehavior = null; // behavior is attached to the progress panel
Expand Down Expand Up @@ -191,6 +192,7 @@ public void run() {
if (abortEnabled) {
showAbortButton(target);
}
showBackButton(target);

result.recordInProgress(); // to disable showing not-final results (why does it work? and why is the result shown otherwise?)

Expand Down Expand Up @@ -244,6 +246,13 @@ public void registerAbortButton(AjaxSubmitButton abortButton) {
this.abortButton = abortButton;
}

public void registerBackButton(AjaxSubmitButton backButton) {
backButton.setOutputMarkupId(true);
backButton.setOutputMarkupPlaceholderTag(true);
backButton.setVisible(false);
this.backButton = backButton;
}

/**
* You have to call this method when Abort button is pressed
*/
Expand All @@ -266,7 +275,7 @@ public void onAbortSubmit(AjaxRequestTarget target) {
hideAbortButton(target);
}

private void hideAbortButton(AjaxRequestTarget target) {
public void hideAbortButton(AjaxRequestTarget target) {
abortButton.setVisible(false);
target.add(abortButton);
}
Expand All @@ -276,6 +285,11 @@ public void showAbortButton(AjaxRequestTarget target) {
target.add(abortButton);
}

public void showBackButton(AjaxRequestTarget target) {
backButton.setVisible(true);
target.add(backButton);
}


// ================= Other methods =================

Expand Down
Expand Up @@ -203,7 +203,9 @@ public void finishProcessing(AjaxRequestTarget target, OperationResult result) {
}
goBackPage();
} else {
showResult(result);
getProgressReporter().showBackButton(target);
getProgressReporter().hideAbortButton(target);
showResult(result);
target.add(getFeedbackPanel());

// if we only stayed on the page because of displaying results, hide
Expand Down
Expand Up @@ -637,7 +637,7 @@ public void goBackPage() {
}
}

protected abstract PageBase getDefaultBackPage();
public abstract PageBase getDefaultBackPage();

public List<ObjectFormType> getObjectFormTypes() {
Task task = createSimpleTask(OPERATION_LOAD_GUI_CONFIGURATION);
Expand Down
Expand Up @@ -196,7 +196,7 @@ protected AbstractObjectMainPanel<RoleType> createMainPanel(String id) {
}

@Override
protected PageBase getDefaultBackPage() {
public PageBase getDefaultBackPage() {
return new PageRoles(false, "");
}

Expand Down
Expand Up @@ -165,7 +165,7 @@ protected AbstractObjectMainPanel<OrgType> createMainPanel(String id) {
}

@Override
protected PageBase getDefaultBackPage() {
public PageBase getDefaultBackPage() {
return new PageOrgTree();
}

Expand Down
Expand Up @@ -129,7 +129,7 @@ protected AbstractObjectMainPanel<UserType> createMainPanel(String id) {
}

@Override
protected PageBase getDefaultBackPage() {
public PageBase getDefaultBackPage() {
return new PageUsers();
}

Expand Down
Expand Up @@ -54,7 +54,7 @@ protected String getObjectOidParameter() {
}

@Override
protected PageBase getDefaultBackPage() {
public PageBase getDefaultBackPage() {
return new PageSelfProfile();
}
//
Expand Down
@@ -0,0 +1,43 @@
/*
* 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;

import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.login.PageLogin;
import org.apache.wicket.util.tester.WicketTester;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;

/**
* Created by honchar
*/
@ContextConfiguration(locations = {"classpath:ctx-admin-gui-test-main.xml"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class PageLoginTest extends AbstractInitializedGuiIntegrationTest {

@Test
public void test001BasicRender() {
WicketTester tester = new WicketTester();
PageLogin page = tester.startPage(PageLogin.class);
tester.assertRenderedPage(PageUser.class);
}



}
6 changes: 3 additions & 3 deletions gui/admin-gui/src/test/resources/ctx-admin-gui-test-main.xml
Expand Up @@ -39,7 +39,7 @@
<import resource="classpath*:ctx-workflow.xml" />
<import resource="classpath*:ctx-notifications.xml" />
<import resource="classpath:ctx-certification.xml" />
<import resource="file:src/main/webapp/WEB-INF/ctx-init.xml" />
<import resource="file:src/main/webapp/WEB-INF/ctx-web-security.xml" />
<import resource="file:src/main/webapp/WEB-INF/ctx-webapp.xml" />
<import resource="file:gui/admin-gui/src/main/webapp/WEB-INF/ctx-init.xml" />
<import resource="file:gui/admin-gui/src/main/webapp/WEB-INF/ctx-web-security.xml" />
<import resource="file:gui/admin-gui/src/main/webapp/WEB-INF/ctx-webapp.xml" />
</beans>
4 changes: 4 additions & 0 deletions samples/resources/csvfile/midpoint-flatfile.csv
@@ -1,3 +1,7 @@
"id","firstname","lastname","disabled","password"
"user01","Firstname","Lastname","false","secret"
"user02","Test","Lastname","false","secret"
"nnnnn","fffff","lllll","false","password"
"AAAA_DEL_PROJ11","AAAA_DEL_PROJ","last","false","password"
"maxeassign11","maxeassign1","maxeassign1","false","maxeassign1"
"AAA_del_proj_user","AAA_del_proj_user","AAA_del_proj_user","false","AAA_del_proj_user"

0 comments on commit 42478f3

Please sign in to comment.