Verified Commit 123da0dc authored by Prosper De Laure's avatar Prosper De Laure Committed by Alexis Ragot
Browse files

Reset button for start date added in modification modal + code refactoring

parent f2fc0d09
......@@ -971,25 +971,3 @@ msgstr "Aucune organisation sélectionnée"
msgid "You have to choose a working organization unit to proceed this action."
msgstr "L'utilisateur courant n'est affecté à aucune organisation. Contactez votre administrateur."
msgid "unlimited"
msgstr "Illimitée"
msgid "Code"
msgstr "Nom de la règle"
msgctxt "archiveInformation"
msgid "Archive Transfer"
msgstr "Demander le transfert sortant"
msgid "Error"
msgstr "Erreur"
msgid "Invalid object"
msgstr "Objet invalide"
msgid "Do not update the final disposition"
msgstr "Ne pas mettre à jour le sort final"
msgid "Edit metadata"
msgstr "Modifier les métadonnées"
<table id="accessCode" class="table table-condensed modificationForm">
<tr id="startDate">
<td><strong>Start date</strong></td>
<td>
<input class='form-control input-sm ruleInput datePicker' name="startDate"/>
<input type="checkbox" id="resetAccessRuleStartDate"/> <span>Reset start date</span>
</td>
</tr>
<td><strong>Code</strong></td>
<td>
<select id="accessRuleCode" name="accessRuleCode" class="form-control input-sm ruleInputAccess">
<option value="">Select a rule</option>
<?merge accessRules ?>
<option value='[?merge .code ?]' data-json='[?merge .json ?]'><?merge .code ?></option>
</select><br>
<dl class="dl dl-horizontal" id="accessRule">
<dt><span>Duration</span> : </dt><dd span id="accessRuleDuration"></dd>
<dt><span>Description</span> : </dt><dd id="accessRuleDescription"></dd>
</dl>
</td>
</table>
<script type="text/javascript">
$('#resetAccessRuleStartDate').on('click', function() {
var input = $('#accessCode').find('input[name="startDate"]');
if($(this).is(':checked')) {
input.val('').prop('disabled', true);
} else {
input.prop('disabled', false);
}
})
var accessRule_serialize = function() {
var form = $('#accessCode');
var parameter = {}
var code = form.find('[name="accessRuleCode"]').find('option:selected').data('json');
parameter.accessRule = {
accessRuleCode : form.find('[name="accessRuleCode"]').val(),
accessRuleStartDate : form.find('[name="startDate"]').val(),
accessRuleDuration : code.duration,
resetStartDate : $('#resetAccessRuleStartDate').is(':checked')
}
return parameter;
}
var accessRule_load = function(archiveId, archiveName, type) {
$('#accessCode').css('display', '');
ModificationModal.loadRule(archiveId, archiveName, type);
}
var accessRule_loadMultiple = function() {
$('#accessCode').css('display', '');
}
</script>
\ No newline at end of file
<div class="panel panel-default" id="archiveModificationForm">
<div class="panel-body">
<h4>Archive(s)</h4>
<br/>
<div class="table-responsive">
<table class="table table-condensed">
<tbody>
<tr id="selectedArchiveId">
<td><strong>Reference</strong></td>
<td><span></span></td>
</tr>
<tr id="selectedArchiveReference">
<td><strong>Archive name</strong></td>
<td><span></span></td>
</tr>
</tbody>
</table>
<?hinclude recordsManagement/archive/archiveModificationModal/accessRule.html?>
<?hinclude recordsManagement/archive/archiveModificationModal/retentionRule.html?>
</div>
</div>
</div>
<script>
var ArchiveModification = {
modal: $('#modificationModal'),
serialize: function(type) {
parameter = {};
try {
parameter = eval(type+"_serialize()");
}
catch(err) {
parameter = {};
}
return parameter;
}
}
</script>
<table id="retentionCode" class="table table-condensed modificationForm">
<tr id="startDate">
<td><strong>Start date</strong></td>
<td>
<input class='form-control input-sm ruleInput datePicker' name="startDate"/>
<input type="checkbox" id="resetRetentionStartDate"/> <span>Reset start date</span>
</td>
</tr>
<td><strong>Code</strong></td>
<td>
<select id="retentionRuleCode" name="retentionRuleCode" class="form-control input-sm ruleInputAccess">
<option value="">Select a rule</option>
<?merge retentionRules ?>
<option value='[?merge .code ?]' data-json='[?merge .json ?]'><?merge .label ?></option>
</select>
<br>
<dl class="dl dl-horizontal" id="retentionRule">
<dt><span>Duration</span> : </dt><dd id="retentionRuleDuration"></dd>
<dt><span>Final disposition</span> : </dt>
<dd>
<div class="col-md-6">
<select id="finalDisposition" name="finalDisposition" class="form-control input-sm">
<option value=''> To be defined later </option>
<option value='destruction'>Destruction</option>
<option value='preservation'>Preservation</option>
</select>
</div>
</dd>
<dt><span>Description</span> : </dt><dd id="retentionRuleDescription"></dd>
</dl>
</td>
</table>
<script type="text/javascript">
$('#resetRetentionStartDate').on('click', function() {
var input = $('#retentionCode').find('input[name="startDate"]');
if($(this).is(':checked')) {
input.val('').prop('disabled', true);
} else {
input.prop('disabled', false);
}
})
var retentionRule_serialize = function() {
var form = $('#retentionCode');
var parameter = {};
var code = form.find('[name="retentionRuleCode"]').find('option:selected').data('json');
parameter.retentionRule = {
retentionStartDate : form.find('[name="startDate"]').val(),
retentionRuleCode : form.find('[name="retentionRuleCode"]').val(),
retentionDuration : code.duration,
finalDisposition : $('#finalDisposition').val(),
resetStartDate : $('#resetRetentionStartDate').is(':checked')
}
return parameter;
}
var retentionRule_load = function(archiveId, archiveName, type) {
$('#retentionCode').css('display', '');
ModificationModal.loadRule(archiveId, archiveName, type);
}
var retentionRule_loadMultiple = function() {
$('#retentionCode').css('display', '');
}
</script>
\ No newline at end of file
<div class="panel panel-default" id="archiveModificationForm">
<div class="panel-body">
<h4>Archive(s)</h4>
<br/>
<div class="table-responsive">
<table class="table table-condensed">
<tbody>
<tr id="selectedArchiveId">
<td><strong>Reference</strong></td>
<td><span></span></td>
</tr>
<tr id="selectedArchiveReference">
<td><strong>Archive name</strong></td>
<td><span></span></td>
</tr>
<tr id="startDate" style="display: none;">
<td><strong>Start date</strong></td>
<td><input class='form-control input-sm ruleInput datePicker' name="startDate"></td>
</tr>
<tr id="finalDisposition">
<td><strong>Final disposition</strong></td>
<td>
<select id="retentionRuleFinalDisposition" name="retentionRuleFinalDisposition" class="form-control">
<option value=''> To be defined later</option>
<option value='destruction'>Destruction</option>
<option value='preservation'>Preservation</option>
</select>
<div id="updateFinalDisposition" style="display: none;">
<input id="checkboxUpdateFinalDisposition" type="checkbox"> Do not update the final disposition
</div>
</td>
</tr>
<tr id="accessCode">
<td><strong>Code</strong></td>
<td>
<select id="accessRuleCode" name="accessRuleCode" class="form-control input-sm ruleInputAccess">
<option value="">Select a rule</option>
<?merge accessRules ?>
<option value='[?merge .code ?]' data-json='[?merge .json ?]'><?merge .code ?></option>
</select><br>
<dl class="dl dl-horizontal" id="accessRule">
<dt><span>Duration</span> :</dt>
<dd span id="accessRuleDuration"></dd>
<dt><span>Description</span> :</dt>
<dd id="accessRuleDescription"></dd>
</dl>
</td>
</tr>
<tr id="retentionCode">
<td><strong>Code</strong></td>
<td>
<select id="retentionRuleCode" name="retentionRuleCode"
class="form-control input-sm ruleInputAccess">
<option value="">Select a rule</option>
<?merge retentionRules ?>
<option value='[?merge .code ?]' data-json='[?merge .json ?]'><?merge .label ?></option>
</select><br>
<dl class="dl dl-horizontal" id="retentionRule">
<dt><span>Duration</span> :</dt>
<dd id="retentionRuleDuration"></dd>
<div class="pull-left">
<dt><span>Description</span> :</dt>
<dd id="retentionRuleDescription"></dd>
</div>
</dl>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
var ArchiveModification = {
modal: $('#modificationModal'),
serialize: function (type) {
var parameter = {};
if (type === "accessRule") {
var code = this.modal.find('[name="accessRuleCode"]').find('option:selected').data('json');
parameter.accessRule = {
accessRuleCode: this.modal.find('[name="accessRuleCode"]').val(),
accessRuleStartDate: this.modal.find('[name="startDate"]').val(),
accessRuleDuration: code.duration
}
} else if (type === "retentionRule") {
var code = this.modal.find('[name="retentionRuleCode"]').find('option:selected').data('json');
parameter.retentionRule = {
retentionStartDate: this.modal.find('[name="startDate"]').val(),
retentionRuleCode: this.modal.find('[name="retentionRuleCode"]').val()
};
if (code) {
parameter.retentionRule.retentionDuration = code.duration;
}
if (!($("#updateFinalDisposition").css('display') === 'block' && $('#retentionRuleFinalDisposition').prop("disabled"))) {
parameter.retentionRule.finalDisposition = $('#retentionRuleFinalDisposition').val();
}
}
parameter.comment = " ";
return parameter;
}
}
</script>
......@@ -9,7 +9,7 @@
</div>
<div class="container-fluid">
<div class="sidebar-offcanvas col-sm-12">
<?hinclude recordsManagement/archive/archiveModificationForm.html?>
<?hinclude recordsManagement/archive/archiveModificationModal/archiveModificationForm.html?>
<div class="panel panel-default" data-translate-context="validationModal" id="modal_multipleSelection">
<div class="panel-body">
<h4><strong style="color:red"><span id="modal_selected"></span></strong> archives selected.</h4>
......@@ -48,7 +48,6 @@
<span id="mtext_cancelDestruction">Cancel destruction</span>
<span id="mtext_freeze">Freeze</span>
<span id="mtext_unfreeze">Unfreeze</span>
<span id="mtext_flagForTransfer">Archive Transfer</span>
<span id="empty_text">The fields with a star are required.</span>
<span id="empty_archivalAgency">No archival agency found</span>
......@@ -57,7 +56,6 @@
<span id="text_Y">year(s)</span>
<span id="text_preservation">preservation</span>
<span id="text_destruction">destruction</span>
<span id="text_unlimited">unlimited</span>
</div>
<style>
......@@ -73,14 +71,6 @@
ModificationModal.loadRetentionCode();
});
$("#checkboxUpdateFinalDisposition").on('change', function () {
if (this.checked) {
$("#retentionRuleFinalDisposition").prop("disabled",true);
} else {
$("#retentionRuleFinalDisposition").prop("disabled",false);
}
});
$("#comment").bind('input propertychange', function () {
if ($("#comment").val() == "") {
$("#save").prop("disabled",true);
......@@ -117,29 +107,26 @@
if (type == 'accessRule') {
$('#startDate, #accessCode').css('display', '');
$('#retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#retentionCode').css('display', 'none');
$('#archivalAgency').css('display', 'none');
this.loadRule(archiveId, archiveName, type);
} else if (type == "retentionRule") {
$('#retentionRuleDuration').text('');
$('#retentionRuleDescription').text('');
$('#startDate, #retentionCode, #finalDisposition').css('display', '');
$('#accessCode, #updateFinalDisposition').css('display', 'none');
} else if (type == "retentionRule") {
$('#startDate,#retentionCode').css('display', '');
$('#accessCode').css('display', 'none');
$('#archivalAgency').css('display', 'none');
this.loadRule(archiveId, archiveName);
} else if (type == "flagForTransfer") {
$('#archivalAgency').css('display', '');
$('#startDate, #accessCode, #retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#startDate,#accessCode,#retentionCode').css('display', 'none');
this.loadArchivalAgency();
} else {
$('#archivalAgency').css('display', 'none');
$('#startDate, #accessCode, #retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#startDate,#accessCode,#retentionCode').css('display', 'none');
this.modal.modal();
}
$('#save').data("archiveids", "");
$('#archiveModificationForm').css('display', '');
$('#modal_multipleSelection').css('display', 'none');
......@@ -239,29 +226,26 @@
if( type === "accessRule") {
$('#startDate, #accessCode').css('display', '');
$('#retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#retentionCode').css('display', 'none');
$('#archiveModificationForm').css('display', '');
$('#archivalAgency').css('display', 'none');
} else if ( type === "retentionRule") {
$('#retentionRuleDuration').text('');
$('#retentionRuleDescription').text('');
$('#startDate, #retentionCode, #finalDisposition, #updateFinalDisposition').css('display', '');
$('#startDate,#retentionCode').css('display', '');
$('#accessCode').css('display', 'none');
$('#archiveModificationForm').css('display', '');
$('#archivalAgency').css('display', 'none');
} else if (type == "flagForTransfer") {
$('#archivalAgency').css('display', '');
$('#startDate, #accessCode, #retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#startDate,#accessCode,#retentionCode').css('display', 'none');
this.loadArchivalAgency();
} else {
$('#archivalAgency').css('display', 'none');
$('#startDate, #accessCode, #retentionCode, #finalDisposition, #updateFinalDisposition').css('display', 'none');
$('#startDate,#accessCode,#retentionCode').css('display', 'none');
this.modal.modal();
}
$('#save').data("archiveids", ids);
$('#modal_multipleSelection').css('display', '');
$('#modal_selected').html(selected);
......@@ -309,20 +293,18 @@
success : function (response) {
gritter.show(response.message, response.status, response.errors);
if (response.status) {
$("#retentionRuleFinalDisposition").prop("disabled",false);
$("#checkboxUpdateFinalDisposition").prop("checked",false);
ModificationModal.close();
ModificationModal.modal.one('hidden.bs.modal', function () {
console.log("passage");
//$('#modificationModal').modal();*
$('#archive_search').click();
});
}
},
error : function(response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
},
complete : function(response) {
if (response.status) {
$('#archive_search').click();
}
},
}
});
},
......@@ -369,30 +351,21 @@
var retentionRuleCode = $("#retentionRuleCode").find(':selected').data('json');
var retentionRules = "";
var retentionRuleTable = $('#retentionRuleTable');
if (retentionRuleCode) {
if (retentionRuleCode) {
var retentionRuleDurationUnit = retentionRuleCode.duration.substr(retentionRuleCode.duration.length - 1, 1);
var retentionRuleDuration = (retentionRuleCode.duration.split(retentionRuleDurationUnit))[0].split("P");
if (rule) {
$('#retentionRule').css("display", '');
if(retentionRuleDuration[1] >= 9999){
$('#retentionRuleDuration').text($('#text_unlimited').text());
} else {
$('#retentionRuleDuration').text(retentionRuleDuration[1] + ' ' + $('#text_' + retentionRuleDurationUnit).html());
}
$('#retentionRuleDuration').text(retentionRuleDuration[1] + ' ' + $('#text_' + retentionRuleDurationUnit).html());
$('#retentionRuleFinalDisposition').val(rule.finalDisposition);
$('#retentionRuleDescription').text(retentionRuleCode.description);
} else {
$('#retentionRule').css("display", '');
if(retentionRuleDuration[1] >= 9999){
$('#retentionRuleDuration').text($('#text_unlimited').text());
} else {
$('#retentionRuleDuration').text(retentionRuleDuration[1] + ' ' + $('#text_' + retentionRuleDurationUnit).html());
}
$('#retentionRuleDuration').text(retentionRuleDuration[1] + ' ' + $('#text_' + retentionRuleDurationUnit).html());
$('#retentionRuleFinalDisposition').val(retentionRuleCode.finalDisposition);
$('#retentionRuleDescription').text(retentionRuleCode.description);
}
......
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