RM-473 ("Rename" allows you to duplicate list name)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@53995 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-08-13 10:51:11 +00:00
parent 9bf629f7ce
commit 696886df79
6 changed files with 76 additions and 60 deletions

View File

@@ -0,0 +1,18 @@
function existsTitle(caveatConfig, title)
{
var constraints = caveatConfig.allConstraints;
// Check for existing constraint...
var alreadyExists = false;
for (var i = 0; i < constraints.length; i++)
{
var currTitle = constraints[i].title;
if (currTitle + "" == title)
{
alreadyExists = true;
break;
}
}
return alreadyExists;
}

View File

@@ -2,6 +2,10 @@
<#escape x as jsonUtils.encodeJSONString(x)> <#escape x as jsonUtils.encodeJSONString(x)>
{ {
"data": <@rmconstraintLib.constraintJSON constraint=constraint /> <#if !errorMessage??>
"data": <@rmconstraintLib.constraintJSON constraint=constraint />
<#else>
"message" : "${msg(errorMessage, title)}"
</#if>
} }
</#escape> </#escape>

View File

@@ -1,42 +1,51 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js">
/** /**
* Update an rm constraint * Update an rm constraint
*/ */
function main() function main()
{ {
// Get the shortname // Get the shortname
var shortName = url.extension; var shortName = url.extension;
// Get the constraint // Get the constraint
var constraint = caveatConfig.getConstraint(shortName); var constraint = caveatConfig.getConstraint(shortName);
if (constraint != null) if (constraint != null)
{ {
var allowedValues var allowedValues,
var title = null; title = null;
if (json.has("constraintTitle")) if (json.has("constraintTitle"))
{ {
title = json.get("constraintTitle"); title = json.get("constraintTitle");
if (existsTitle(caveatConfig, title))
{
status.code = 400;
model.errorMessage = "rm.admin.list-already-exists";
model.title = title;
return;
}
constraint.updateTitle(title); constraint.updateTitle(title);
} }
if (json.has("allowedValues")) if (json.has("allowedValues"))
{ {
values = json.getJSONArray("allowedValues"); values = json.getJSONArray("allowedValues");
var i = 0; var i = 0;
allowedValues = new Array(); allowedValues = new Array();
if (values != null) if (values != null)
{ {
for (var x = 0; x < values.length(); x++) for (var x = 0; x < values.length(); x++)
{ {
allowedValues[i++] = values.get(x); allowedValues[i++] = values.get(x);
} }
} }
constraint.updateAllowedValues(allowedValues); constraint.updateAllowedValues(allowedValues);
} }
// Pass the constraint detail to the template // Pass the constraint detail to the template
model.constraint = constraint; model.constraint = constraint;
} }

View File

@@ -0,0 +1 @@
rm.admin.list-already-exists=A list with the name "{0}" already exists.

View File

@@ -1,70 +1,54 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js">
/** /**
* Create a new RM Constraint List * Create a new RM Constraint List
*/ */
function main() function main()
{ {
// Parse the passed in details // Parse the passed in details
var title = null; var title = null,
var name = null; name = null,
var allowedValues = {}; allowedValues = {};
if (json.has("allowedValues"))
{
values = json.getJSONArray("allowedValues");
var i = 0;
allowedValues = new Array();
if (values != null)
{
for (var x = 0; x < values.length(); x++)
{
allowedValues[i++] = values.get(x);
}
}
}
if (json.has("constraintName")) if (json.has("constraintName"))
{ {
name = json.get("constraintName"); name = json.get("constraintName");
} }
if (json.has("constraintTitle")) if (json.has("constraintTitle"))
{ {
title = json.get("constraintTitle"); title = json.get("constraintTitle");
} }
else else
{ {
title = name; title = name;
} }
var constraints = caveatConfig.allConstraints; if (existsTitle(caveatConfig, title))
// Check for existing constraint...
var alreadyExists = false;
for (var i=0; i<constraints.length; i++)
{
var currTitle = constraints[i].title;
if (currTitle + "" == title)
{
alreadyExists = true;
break;
}
}
var existingConstraint = caveatConfig.getConstraint(title);
if (!alreadyExists)
{
var constraint = caveatConfig.createConstraint(name, title, allowedValues);
model.constraint = constraint;
}
else
{ {
status.code = 400; status.code = 400;
model.errorMessage = "rm.admin.list-already-exists"; model.errorMessage = "rm.admin.list-already-exists";
model.title = title; model.title = title;
return;
} }
if (json.has("allowedValues"))
{
values = json.getJSONArray("allowedValues");
var i = 0;
allowedValues = new Array();
if (values != null)
{
for (var x = 0; x < values.length(); x++)
{
allowedValues[i++] = values.get(x);
}
}
}
model.constraint = caveatConfig.createConstraint(name, title, allowedValues);
} }
main(); main();

View File

@@ -2,6 +2,6 @@
<#escape x as jsonUtils.encodeJSONString(x)> <#escape x as jsonUtils.encodeJSONString(x)>
{ {
"data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint /> "data": <@rmconstraintLib.constraintWithValuesJSON constraint=constraint />
} }
</#escape> </#escape>