Unverified Commit 57d99aeb authored by Dylan's avatar Dylan
Browse files

#6560 metadata read only

parent 6bddfe8a
......@@ -267,8 +267,9 @@ trait archiveModificationTrait
public function modifyMetadata($archiveId, $originatorArchiveId =null, $archiveName = null, $originatingDate=null,$description = null)
{
$archive = $this->getDescription($archiveId);
$archivalProfileDescription = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference)->archiveDescription;
$this->checkRights($archive);
if ($archiveName) {
$archive->archiveName = $archiveName;
}
......@@ -283,6 +284,15 @@ trait archiveModificationTrait
if ($description) {
$descriptionObject = json_decode($description);
foreach ($archivalProfileDescription as $descriptionImmutable){
if($descriptionImmutable->isImmutable) {
$fieldName = (string)$descriptionImmutable->fieldName;
if($descriptionObject->$fieldName != $archive->descriptionObject->$fieldName){
throw new \bundle\recordsManagement\Exception\invalidArchiveException('Invalid object');
}
}
}
if (!empty($archive->archivalProfileReference)) {
$this->useArchivalProfile($archive->archivalProfileReference);
......@@ -302,7 +312,7 @@ trait archiveModificationTrait
$descriptionController->update($archive);
}
$this->sdoFactory->update($archive, 'recordsManagement/archive');
$operationResult = true;
......
......@@ -101,6 +101,9 @@ CREATE TABLE "recordsManagement"."descriptionField"
"maxValue" numeric,
"enumeration" text,
"pattern" text,
"isArray" boolean default false,
PRIMARY KEY ("name")
);
......@@ -114,6 +117,9 @@ CREATE TABLE "recordsManagement"."archiveDescription"
"fieldName" text NOT NULL,
"required" boolean,
"position" integer,
"isImmutable" boolean default false,
"isRetained" boolean default true,
PRIMARY KEY ("archivalProfileId", "fieldName"),
FOREIGN KEY ("archivalProfileId")
REFERENCES "recordsManagement"."archivalProfile" ("archivalProfileId") MATCH SIMPLE
......
......@@ -339,7 +339,6 @@ class welcome
$archivalProfile = null;
$modificationPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveManagement/modifyDescription");
if (!empty($archive->archivalProfileReference)) {
$archivalProfile = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference);
$archive->archivalProfileName = $archivalProfile->name;
......@@ -362,6 +361,7 @@ class welcome
$label = $archiveDescription->descriptionField->label;
$archivalProfileField = true;
$type = $archiveDescription->descriptionField->type;
$isImmutable = $archiveDescription->isImmutable;
}
}
}
......@@ -396,7 +396,7 @@ class welcome
$descriptionHtml .= '<tr>';
}
$descriptionHtml .= '<th title="'.$label.'" name="'.$name.'" data-type="'.$type.'">'.$label.'</th>';
$descriptionHtml .= '<th title="'.$label.'" name="'.$name.'" data-type="'.$type.'"'.'data-Immutable="'.$isImmutable.'">'.$label.'</th>';
if ($type == "date") {
$textValue = \laabs::newDate($value);
$textValue = $textValue->format("d/m/Y");
......@@ -407,8 +407,8 @@ class welcome
if ($type == 'boolean') {
$textValue = $value ? '<i class="fa fa-check" data-value="1"/>' : '<i class="fa fa-times" data-value="0"/>';
}
$descriptionHtml .= '<td title="'.$value.'">'.$textValue.'</td>';
$descriptionHtml .= '</tr>';
}
}
......
......@@ -975,3 +975,6 @@ msgstr "L'utilisateur courant n'est affecté à aucune organisation. Contactez v
msgid "Code"
msgstr "Nom de la règle"
msgctxt "archiveInformation"
msgid "Invalid object"
msgstr "Objet invalide"
......@@ -367,15 +367,24 @@
switch(label.data('type')) {
case 'boolean' :
customField = $("#inputCustomBooleanField").clone();
if(label.data('immutable')) {
customField.prop('disabled', true);
}
var intValue = value.find('i').data('value');
booleanInput = customField.find('input[value="'+intValue+'"]');
break;
case 'number':
customField = $("#inputCustomNumericField").clone();
if(label.data('immutable')) {
customField.prop('disabled', true);
}
customField.val(value.html());
break;
case 'date':
case 'date':
customField = $("#inputCustomField").clone();
if(label.data('immutable')) {
customField.prop('disabled', true);
}
customField.datepicker({
language:$('#wrapper').attr('lang'),
autoclose:true
......@@ -383,6 +392,9 @@
break;
default :
customField = $("#inputCustomField").clone();
if(label.data('immutable')) {
customField.prop('disabled', true);
}
customField.val(value.html());
}
......@@ -406,13 +418,13 @@
var name = input.attr('name');
var type = $(e).find('th').data('type');
switch (valueInput.attr("type")) {
switch (type) {
case "name" :
case "text" :
value = valueInput.val();
break;
case "date" :
value = valueInput.datepicker({ dateFormat: 'yy-mm-dd'}).val();
value = valueInput.data('datepicker').getFormattedDate('yyyy-mm-dd');
break;
case "number" :
value = parseInt(valueInput.val());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment