Skip to content

Commit

Permalink
Merge pull request #341 from devgateway/feature/OCMAKU-370
Browse files Browse the repository at this point in the history
OCMAKU-370 Make the department field optional in the staff meta data …
  • Loading branch information
lilitk authored Oct 22, 2019
2 parents b261821 + 22a59b4 commit 97225da
Showing 1 changed file with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/**
*
*/
package org.devgateway.toolkit.forms.wicket.page.edit.category;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.devgateway.toolkit.forms.WebConstants;
import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.util.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.page.lists.category.ListStaffPage;
import org.devgateway.toolkit.persistence.dao.categories.Staff;
import org.devgateway.toolkit.persistence.service.category.DepartmentService;
import org.devgateway.toolkit.persistence.service.category.StaffService;
import org.devgateway.toolkit.web.security.SecurityConstants;
import org.wicketstuff.annotation.mount.MountPath;

/**
* @author gmutuhu
*
*/
@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN)
@MountPath("/staff")
public class EditStaffPage extends AbstractCategoryEditPage<Staff> {
@SpringBean
private StaffService staffService;

@SpringBean
private DepartmentService departmentService;

public EditStaffPage(final PageParameters parameters) {
super(parameters);
jpaService = staffService;
listPageClass = ListStaffPage.class;
}

@Override
protected void onInitialize() {
super.onInitialize();

final TextFieldBootstrapFormComponent<String> title = ComponentUtil.addTextField(editForm, "title");
title.getField().add(WebConstants.StringValidators.MAXIMUM_LENGTH_VALIDATOR_STD_DEFAULT_TEXT);
ComponentUtil.addSelect2ChoiceField(editForm, "department", departmentService).required();
}
}
/**
*
*/
package org.devgateway.toolkit.forms.wicket.page.edit.category;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.devgateway.toolkit.forms.WebConstants;
import org.devgateway.toolkit.forms.wicket.components.form.TextFieldBootstrapFormComponent;
import org.devgateway.toolkit.forms.wicket.components.util.ComponentUtil;
import org.devgateway.toolkit.forms.wicket.page.lists.category.ListStaffPage;
import org.devgateway.toolkit.persistence.dao.categories.Staff;
import org.devgateway.toolkit.persistence.service.category.DepartmentService;
import org.devgateway.toolkit.persistence.service.category.StaffService;
import org.devgateway.toolkit.web.security.SecurityConstants;
import org.wicketstuff.annotation.mount.MountPath;

/**
* @author gmutuhu
*
*/
@AuthorizeInstantiation(SecurityConstants.Roles.ROLE_ADMIN)
@MountPath("/staff")
public class EditStaffPage extends AbstractCategoryEditPage<Staff> {
@SpringBean
private StaffService staffService;

@SpringBean
private DepartmentService departmentService;

public EditStaffPage(final PageParameters parameters) {
super(parameters);
jpaService = staffService;
listPageClass = ListStaffPage.class;
}

@Override
protected void onInitialize() {
super.onInitialize();

final TextFieldBootstrapFormComponent<String> title = ComponentUtil.addTextField(editForm, "title");
title.getField().add(WebConstants.StringValidators.MAXIMUM_LENGTH_VALIDATOR_STD_DEFAULT_TEXT);

ComponentUtil.addSelect2ChoiceField(editForm, "department", departmentService);
}
}

0 comments on commit 97225da

Please sign in to comment.