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)>
{
"data": <@rmconstraintLib.constraintJSON constraint=constraint />
<#if !errorMessage??>
"data": <@rmconstraintLib.constraintJSON constraint=constraint />
<#else>
"message" : "${msg(errorMessage, title)}"
</#if>
}
</#escape>

View File

@@ -1,3 +1,5 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js">
/**
* Update an rm constraint
*/
@@ -11,12 +13,19 @@ function main()
if (constraint != null)
{
var allowedValues
var title = null;
var allowedValues,
title = null;
if (json.has("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);
}

View File

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

View File

@@ -1,12 +1,36 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/rma/admin/rmconstraint/rmconstraint-utils.js">
/**
* Create a new RM Constraint List
*/
function main()
{
// Parse the passed in details
var title = null;
var name = null;
var allowedValues = {};
var title = null,
name = null,
allowedValues = {};
if (json.has("constraintName"))
{
name = json.get("constraintName");
}
if (json.has("constraintTitle"))
{
title = json.get("constraintTitle");
}
else
{
title = name;
}
if (existsTitle(caveatConfig, title))
{
status.code = 400;
model.errorMessage = "rm.admin.list-already-exists";
model.title = title;
return;
}
if (json.has("allowedValues"))
{
@@ -24,47 +48,7 @@ function main()
}
}
if (json.has("constraintName"))
{
name = json.get("constraintName");
}
if (json.has("constraintTitle"))
{
title = json.get("constraintTitle");
}
else
{
title = name;
}
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;
}
}
var existingConstraint = caveatConfig.getConstraint(title);
if (!alreadyExists)
{
var constraint = caveatConfig.createConstraint(name, title, allowedValues);
model.constraint = constraint;
}
else
{
status.code = 400;
model.errorMessage = "rm.admin.list-already-exists";
model.title = title;
}
model.constraint = caveatConfig.createConstraint(name, title, allowedValues);
}
main();

View File

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