Verified Commit 903d7eb0 authored by Alexis Ragot's avatar Alexis Ragot
Browse files

Fix access rule modal when the select of rule changed

parent 88fc2146
......@@ -122,17 +122,13 @@ trait archiveModificationTrait
if ($retentionRule->retentionDuration === '') {
$retentionRule->retentionDuration = null;
} elseif (!empty($retentionRule->retentionDuration) && $retentionRule->retentionDuration->y >= 9999) {
$retentionRule->disposalDate = '';
$retentionRule->disposalDate = null;
} else {
if (!empty($retentionRule->retentionDuration) && !empty($retentionRule->retentionStartDate)) {
$retentionRule->disposalDate = $this->calculateDate($retentionRule->retentionStartDate, $retentionRule->retentionDuration);
}
}
if ($retentionRule->disposalDate === '') {
$retentionRule->disposalDate = null;
}
$retentionRule->retentionRuleStatus = "current";
$this->sdoFactory->update($retentionRule, 'recordsManagement/archive');
......@@ -173,6 +169,8 @@ trait archiveModificationTrait
$archives = array();
$operationResult = null;
$accessRuleReceived = $accessRule;
foreach ($archiveIds as $archiveId) {
$archive = $this->getDescription($archiveId);
$this->checkRights($archive);
......@@ -182,20 +180,24 @@ trait archiveModificationTrait
$operationResult = false;
} else {
$accessRule = $accessRuleReceived;
$accessRule->archiveId = $archiveId;
if (!$accessRule->changeStartDate) {
$accessRule->accessRuleStartDate = $archive->accessRuleStartDate;
}
$accessRule->accessRuleComDate = null;
if (empty($accessRule->accessRuleCode)) {
$accessRule->accessRuleCode = $archive->accessRuleCode;
$accessRule->accessRuleDuration = $archive->accessRuleDuration;
}
if ($accessRule->accessRuleDuration != null && $accessRule->accessRuleStartDate != null) {
if ($accessRule->accessRuleDuration === '') {
$accessRule->accessRuleDuration = null;
} elseif (!empty($accessRule->accessRuleDuration) && $accessRule->accessRuleDuration->y >= 9999) {
$accessRule->accessRuleComDate = null;
} elseif (!empty($accessRule->accessRuleDuration) && !empty($accessRule->accessRuleStartDate)) {
$accessRule->accessRuleComDate = $this->calculateDate($accessRule->accessRuleStartDate, $accessRule->accessRuleDuration);
}
......
......@@ -11,7 +11,7 @@ msgstr "mois"
msgid "years"
msgstr "années"
msgid "unlimited"
msgid "Unlimited"
msgstr "illimité"
msgid "years"
......
......@@ -65,7 +65,7 @@ msgstr "Mois"
msgid "Year(s)"
msgstr "Année(s)"
msgid "unlimited"
msgid "Unlimited"
msgstr "Illimité"
msgid "Y"
......
......@@ -30,7 +30,12 @@
} else {
input.val('').prop('disabled', true).val('');
}
})
});
$("#contain").on('change', '#accessRuleCode', function () {
var code = $(this).find('option:selected').data('json');
ModificationModal.loadAccessCode(code);
});
var accessRule_serialize = function() {
var form = $('#accessCode');
......@@ -48,19 +53,19 @@
}
return parameter;
}
};
var accessRule_load = function(archiveId, archiveName, type) {
$('#accessCode').css('display', '').find('[name="startDate"]').attr('placeholder', '');
ModificationModal.loadRule(archiveId, archiveName, type);
$('#changeARStartDate').css('display', 'none').find('input').prop('checked', true);
$('#accessCode').find('input[name="startDate"]').prop('disabled', false);
}
};
var accessRule_loadMultiple = function() {
$('#accessCode').css('display', '').find('[name="startDate"]').attr('placeholder', $("#accessRuleStartDatePlaceholder").html());
$('#changeARStartDate').css('display', '').find('input').prop('checked', false);
$('#accessCode').find('input[name="startDate"]').prop('disabled', true);
}
};
</script>
\ No newline at end of file
......@@ -42,11 +42,10 @@
<td><strong>Depositor</strong></td>
<td><?merge archive.depositorOrg.displayName ?></td>
</tr>
<?merge archive.retentionDuration.bool() ?>
<?merge archive.retentionRuleCode.bool() ?>
<tr>
<td><strong>Disposal rule</strong></td>
<td>
<?merge archive.retentionRuleCode.bool() ?>
<span>
<b data-translate-context="archiveInformation">Code </b>:&nbsp;<?merge archive.retentionRuleCode ?>
<br/>
......@@ -97,12 +96,18 @@
<br/>
<span>
<b>Duration</b>:&nbsp;
<?merge archive.accessRuleDuration ?>&nbsp;
<?merge archive.accessRuleDurationUnit.ifeq('Y') ?><span>Year(s)</span>
<?merge archive.accessRuleDurationUnit.ifeq('M') ?><span>Month(s)</span>
<?merge archive.accessRuleDurationUnit.ifeq('D') ?><span>Day(s)</span>
<br/>
<?merge archive.accessRuleDuration.ifgte(9999) ?>
<div>
<b>Duration</b>:&nbsp;<span>Unlimited</span>
</div>
<?merge archive.accessRuleDuration.iflte(9998) ?>
<div>
<b>Duration</b>:
<?merge archive.accessRuleDuration ?>&nbsp;
<?merge archive.accessRuleDurationUnit.ifeq('Y') ?><span>Year(s)</span>
<?merge archive.accessRuleDurationUnit.ifeq('M') ?><span>Month(s)</span>
<?merge archive.accessRuleDurationUnit.ifeq('D') ?><span>Day(s)</span>
</div>
</span>
<b>Start date</b>:&nbsp;<?merge archive.accessRuleStartDate ?>
......
......@@ -138,11 +138,6 @@
});
})
$("#contain").on('change', '#accessRuleCode', function () {
accessRuleModal.loadAccessCode();
})
var accessRuleModal = {
load: function(archiveId) {
......@@ -204,7 +199,7 @@
if(a.attr('name') != "archiveIds") {
accessRule[a.attr('name')] = a.val();
}
})
});
accessRule['accessRuleDuration'] = retentionRule.duration;
......
......@@ -175,10 +175,6 @@
if (response.status) {
if (ModificationModal.modalType === "accessRule") {
rule = response.accessRule;
if (rule.accessRuleDuration) {
rule.accessRuleDurationUnit = rule.accessRuleDuration.substring(rule.accessRuleDuration.length - 1);
rule.accessRuleDuration = rule.accessRuleDuration.substring(1, rule.accessRuleDuration.length - 1);
}
} else {
rule = response.retentionRule;
}
......@@ -188,7 +184,7 @@
});
if (ModificationModal.modalType === "accessRule") {
ModificationModal.loadAccessCode();
ModificationModal.loadAccessCode(rule);
}
if (ModificationModal.modalType === "retentionRule") {
......@@ -290,27 +286,26 @@
ModificationModal.modal.modal('hide');
},
loadAccessCode: function() {
loadAccessCode: function(rule) {
var accessRuleCode = $("#accessRuleCode").find(':selected').data('json');
var accessRules = "";
var accessRuleTable = $('#accessRuleTable');
if (accessRuleCode) {
if (accessRuleCode.duration) {
var accessRules = accessRuleCode.accessRules;
var accessRuleDurationUnit = accessRuleCode.duration.substr(accessRuleCode.duration.length - 1, 1);
var accessRuleDuration = (accessRuleCode.duration.split(accessRuleDurationUnit))[0].split("P");
$('#accessRule').css("display", '');
$('#accessRuleDuration').text(accessRuleDuration[1] + ' ' + $('#text_' + accessRuleDurationUnit).html());
$('#accessRuleDescription').text(accessRuleCode.description);
} else {
let accessRuleDurationUnit = accessRuleCode.duration.substr(accessRuleCode.duration.length - 1, 1);
let accessRuleDuration = (accessRuleCode.duration.split(accessRuleDurationUnit))[0].split("P");
if (rule) {
$('#accessRule').css("display", '');
$('#accessRuleDuration').text(accessRuleCode.durationUnit);
if(accessRuleDuration[1] >= 9999){
$('#accessRuleDuration').text($('#text_unlimited').text());
} else {
$('#accessRuleDuration').text(accessRuleDuration[1] + ' ' + $('#text_' + accessRuleDurationUnit).html());
}
$('#accessRuleDescription').text(accessRuleCode.description);
}
} else {
$('#accessRule').css("display", 'none');
}
......
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