Added template model, freemarker macro and pass checks in EditRequestDispatchController for individual deletion
This commit is contained in:
parent
2e0b3f0f05
commit
af9820b7f3
3 changed files with 31 additions and 1 deletions
|
@ -360,7 +360,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
String formParam = getFormParam(vreq);
|
||||
//if no form parameter, then predicate uri and subject uri must both be populated
|
||||
if (formParam == null || "".equals(formParam)) {
|
||||
if ((formParam == null || "".equals(formParam)) && !isDeleteForm(vreq)) {
|
||||
if ((predicateUri == null || predicateUri.trim().length() == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAct
|
|||
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction.SOME_URI;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -27,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
|
@ -37,6 +39,7 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
|||
public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||
|
||||
private static final Log log = LogFactory.getLog(BaseIndividualTemplateModel.class);
|
||||
private static final String EDIT_PATH = "editRequestDispatch";
|
||||
|
||||
protected final Individual individual;
|
||||
protected final LoginStatusBean loginStatusBean;
|
||||
|
@ -148,6 +151,23 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
|||
public String getName() {
|
||||
return individual.getName();
|
||||
}
|
||||
|
||||
public String getDeleteUrl() {
|
||||
Collection<String> types = getMostSpecificTypes();
|
||||
ParamMap params = new ParamMap(
|
||||
"objectUri", individual.getURI(),
|
||||
"cmd", "delete",
|
||||
"statement_label",getNameStatement().getValue(),
|
||||
"statement_object",individual.getURI()
|
||||
);
|
||||
Iterator<String> typesIterator = types.iterator();
|
||||
if (types.iterator().hasNext()) {
|
||||
String type = typesIterator.next();
|
||||
params.put("statement_type", type);
|
||||
}
|
||||
|
||||
return UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
}
|
||||
|
||||
public Collection<String> getMostSpecificTypes() {
|
||||
ObjectPropertyStatementDao opsDao = vreq.getWebappDaoFactory().getObjectPropertyStatementDao();
|
||||
|
|
|
@ -203,6 +203,16 @@ name will be used as the label. -->
|
|||
<a class="edit-${propertyLocalName}" href="${url}" title="${i18n().edit_entry}"><img class="edit-individual" data-range="${rangeUri}" src="${urls.images}/individual/editIcon.gif" alt="${i18n().edit_entry}" /></a>
|
||||
</#macro>
|
||||
|
||||
<#macro deleteIndividualLink individual redirectUrl="/">
|
||||
<#local url = individual.deleteUrl + "&redirectUrl=" + "${redirectUrl}">
|
||||
<@showDeleteIndividualLink url />
|
||||
</#macro>
|
||||
|
||||
|
||||
<#macro showDeleteIndividualLink url>
|
||||
<a class="delete-individual" href="${url}" title="${i18n().delete_entry}"><img class="delete-individual" src="${urls.images}/individual/deleteIcon.gif" alt="${i18n().delete_entry}" /></a>
|
||||
</#macro>
|
||||
|
||||
<#macro deleteLink propertyLocalName propertyName statement rangeUri="">
|
||||
<#local url = statement.deleteUrl>
|
||||
<#if url?has_content>
|
||||
|
|
Loading…
Add table
Reference in a new issue