Commit f565f578 authored by Prosper De Laure's avatar Prosper De Laure
Browse files

Archival profile selection for sub archive matches to the parent archival profile structure

parent 9d116791
......@@ -154,30 +154,56 @@ class welcome
public function archiveInfo($archive)
{
$this->view->addContentFile('dashboard/mainScreen/archiveInformation.html');
// Archive
$originatorOrg = \laabs::callService('organization/organization/readByregnumber_registrationNumber_', $archive->originatorOrgRegNumber);
$archive->originatorOrgName = $originatorOrg->displayName;
$archive->depositDate = $archive->depositDate->format('Y-m-d H:i:s');
// Retention
$retentionRules = \laabs::callService('recordsManagement/retentionRule/readIndex');
for ($i = 0, $count = count($retentionRules); $i < $count; $i++) {
$retentionRules[$i]->durationText = (string) $retentionRules[$i]->duration;
}
$originatorOrg = \laabs::callService('organization/organization/readByregnumber_registrationNumber_', $archive->originatorOrgRegNumber);
$archive->originatorOrgName = $originatorOrg->displayName;
$archive->depositDate = $archive->depositDate->format('Y-m-d H:i:s');
// Add a sub archive
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
if (!empty($archive->archivalProfileReference)) {
$archivalProfile = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference);
$archive->archivalProfileName = $archivalProfile->name;
if (!count($archivalProfile->containedProfiles) && !$archivalProfile->acceptArchiveWithoutProfile && !$archivalProfile->acceptAnyProfile) {
$depositPrivilege = false;
if ($depositPrivilege) {
$archivalProfileList = [];
if (!empty($archive->archivalProfileReference)) {
$archivalProfile = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference);
$archive->archivalProfileName = $archivalProfile->name;
$list = [];
if ($archivalProfile->acceptAnyProfile) {
$list = \laabs::callService('recordsManagement/archivalProfile/readDescendantprofiles');
} else if (count($archivalProfile->containedProfiles)) {
$list = $archivalProfile->containedProfiles;
}
if (count($list)) {
foreach ($list as $profile) {
$profileObject = new \stdClass();
$profileObject->reference = $profile->reference;
$profileObject->name = $profile->name;
$profileObject->json = json_encode($profile);
$archivalProfileList[] = $profileObject;
}
}
if (!count($archivalProfileList) && !$archivalProfile->acceptArchiveWithoutProfile ) {
$depositPrivilege = false;
}
}
}
$this->view->translate();
// $this->view->setSource('containedProfiles', $archivalProfiles->containedProfiles);
$this->view->setSource("status", $archive->status);
$archive->status = $this->view->translator->getText($archive->status, false, "recordsManagement/messages");
......@@ -188,6 +214,8 @@ class welcome
$this->view->setSource('retentionRules', $retentionRules);
$this->view->setSource("archive", $archive);
$this->view->setSource("depositPrivilege", $depositPrivilege);
$this->view->setSource("archivalProfileList", $archivalProfileList);
$this->view->setSource("acceptArchiveWithoutProfile", $archivalProfile->acceptArchiveWithoutProfile);
$this->view->merge();
return $this->view->saveHtml();
......
......@@ -106,7 +106,7 @@
var selectedProfile = "";
if (dataJson !== undefined && dataJson !== null && dataJson !== "") {
selectedProfile = JSON.parse(dataJson);
selectedProfile = dataJson;
}
if (value == '' || selectedProfile.retentionRuleCode == null || selectedProfile.retentionRuleCode == '' || selectedProfile.retentionRuleCode == undefined) {
......@@ -134,7 +134,7 @@
return;
}
var selectedProfile = JSON.parse($('#archivalProfile').data('json'));
var selectedProfile = $('#archivalProfile').data('json');
Metadata.acceptUserIndex(selectedProfile.acceptUserIndex);
......@@ -207,7 +207,7 @@
var selectedProfile = $('#archivalProfile').data('json');
if (selectedProfile !== undefined && selectedProfile !== null && selectedProfile !== "") {
selectedProfile = JSON.parse(selectedProfile);
selectedProfile = selectedProfile;
archive.descriptionClass = selectedProfile.descriptionClass;
}
......
......@@ -7,7 +7,10 @@
<div id="archiveToolbarBtn" class="dropdown pull-right btn-group">
<button type="button" class="btn btn-sm btn-default dropdown-toggle [?merge depositPrivilege.not().then('disabled', '') ?]" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" title="New archive"><span class="fa fa-plus"></span></button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<?merge acceptArchiveWithoutProfile.bool() ?>
<li><a class="small newArchive" style="cursor: pointer;" data-reference="">Without profile</a></li>
<?merge archivalProfileList ?>
<li><a class="userProfile small newArchive" style="cursor: pointer;" data-reference="[?merge .reference ?]" data-json="[?merge .json ?]"><?merge .name?></a></li>
</ul>
</div>
</div>
......@@ -27,7 +30,7 @@
<td title='[?merge archive.archiveName ?]'><?merge archive.archiveName ?></td>
</tr>
<tr class="originator">
<th title="Name">Originator</th>
<th title="Originator">Originator</th>
<td title='[?merge archive.originatorOrgName ?]'><?merge archive.originatorOrgName ?></td>
</tr>
<tr class="archiveId">
......@@ -328,7 +331,6 @@
customField.val(value.html());
value.html('').append(customField);
});
console.log($('#metadata').find('.archivalProfileField'));
$('#metadata').find('.archivalProfileField').find('th input').prop('disabled', true);
},
......@@ -394,22 +396,6 @@
$('#metadata').children('table').append(tr);
},
buildNewArchiveDropdownMenu: function() {
var archivalProfiles = $("#folderToolbarBtn .dropdown-menu").data("archivalprofiles");
var dropdown = $("#archiveToolbarBtn .dropdown-menu");
dropdown.children().not(":first").remove();
for (var i = 0; i < archivalProfiles.length; i++) {
var a = $("<a/>")
.addClass("userProfile small newArchive")
.data("reference", archivalProfiles[i].reference)
.data("json", JSON.stringify(archivalProfiles[i]))
.attr('style', "cursor: pointer;")
.text(archivalProfiles[i].name);
$("<li/>").append(a).appendTo(dropdown);
}
},
loadImportForm: function(e) {
var importPanel = $("#importPanel");
var archiveInformation = $('#archiveInformation');
......
......@@ -87,7 +87,6 @@
type : "GET",
success : function (response) {
$('#rightColumn').empty().html(response);
ArchiveInformation.buildNewArchiveDropdownMenu();
},
error : function (response) {
gritter.show(response.responseText, false);
......
......@@ -223,7 +223,7 @@
var a = $("<a/>")
.addClass("userProfile small newArchive")
.data("reference", archivalProfiles[i].reference)
.data("json", JSON.stringify(archivalProfiles[i]))
.data("json", archivalProfiles[i])
.attr('style', "cursor: pointer;")
.text(archivalProfiles[i].name);
$("<li/>").append(a).appendTo(dropdown);
......
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