Verified Commit f843596f authored by Jerome Boucher's avatar Jerome Boucher
Browse files

feat/18079 : change originating dservice : create view and routes

parent 31115261
Pipeline #14283 failed with stages
in 1 minute
......@@ -70,4 +70,11 @@ interface archivalAgreementInterface
* @action medona/archivalAgreement/delete
*/
public function delete_archivalAgreementId_();
/**
* @param string $reference Archival Agreement Reference
*
* @action medona/archivalAgreement/getByReference
*/
public function readGetByReference($reference);
}
......@@ -71,7 +71,7 @@ class organization
*
* @return organization/organization[] An array of organization whith service
*/
public function todisplay($ownerOrg, $orgUnit, $term)
public function todisplay($ownerOrg = false, $orgUnit = false, $term = "")
{
$authController = \laabs::newController("auth/userAccount");
$user = $authController->get(\laabs::getToken('AUTH')->accountId);
......
......@@ -354,4 +354,15 @@ interface organizationInterface
* @return boolean Import with reset of table data or not
*/
public function createImport($data, $isReset);
/**
* List descendant services and org from a parent org
*
* @param string $orgId Organization Identifier
*
* @action organization/organization/readDescendantServices
*
* @return array Array of descendant services
*/
public function readDescendantServices($orgId);
}
......@@ -975,4 +975,17 @@ trait archiveModificationTrait
return true;
}
/**
* Update originator service of an array of archives
*
* @param array $archiveIds Array of archive identifiers
* @param string $orgId Organization identified destined to be new originator of archive
*
*/
public function updateOriginator($archiveIds, $orgId)
{
var_dump('dans le controleur');
exit;
}
}
......@@ -469,4 +469,14 @@ interface archivesInterface
* @action recordsManagement/archive/extractFulltext
*/
public function readExtractfulltext($maxResults = null, $timeLimit = null);
/**
* Update originator service or archives
*
* @param array $archiveIds Array of archiveIdentifiers
* @param string $orgId Organization identifier
*
* @action recordsManagement/archive/updateOriginator
*/
public function updateOriginator($archiveIds, $orgId);
}
......@@ -251,6 +251,8 @@ class archive
}
}
$archive->availableOriginatingServices = json_encode($this->getDescendantServices($archive->originatorOwnerOrgId, $archive->archivalAgreementReference));
$hasReachMaxResults = false;
if (
isset(\laabs::configuration('presentation.maarchRM')['maxResults'])
......@@ -311,6 +313,37 @@ class archive
return $resultList;
}
protected function getDescendantServices($orgId, $archivalAgreementReference)
{
$orgs = [];
if (!is_null($archivalAgreementReference)) {
$archivalAgreement = \laabs::callService('medona/archivalAgreement/readGetByReference', $archivalAgreementReference);
foreach ($archivalAgreement->originatorOrgIds as $originatorOrgId) {
$orgs[] = \laabs::callService('organization/organization/read_orgId_', (string) $originatorOrgId);
array_merge(\laabs::callService('organization/organization/readDescendantServices', (string) $originatorOrgId), $orgs);
}
} else {
$orgs = \laabs::callService('organization/organization/readDescendantServices', $orgId);
}
$descendantServices = [];
foreach ($orgs as $key => $org) {
// May be empty if archivalAgreement originatorOrgId has no descendant service
if (!empty($org)) {
$descendantServices[$key] = new \stdClass();
$descendantServices[$key]->orgId = (string) $org->orgId;
$descendantServices[$key]->displayName = $org->displayName;
}
}
// sort by alphabetical order of displayName (php 8)
usort($descendantServices, function ($a, $b) {
return $a->displayName <=> $b->displayName;
});
return $descendantServices;
}
/**
* Get resource contents
* @param digitalResource/digitalResource $digitalResource The resource object
......
......@@ -378,6 +378,9 @@ msgstr "Demander une modification"
msgid "Edit access rule"
msgstr "Modifier la règle de communicabilité"
msgid "Modify originator service"
msgstr "Modifier le service producteur"
msgid "You not have the permission to view the documents of archive"
msgstr "Vous n'avez pas la permission de visualiser les documents de cette archive"
......@@ -1340,3 +1343,6 @@ msgstr "Ajouter le filtre"
msgid "Search in other services"
msgstr "Rechercher dans d'autres services"
msgid "New originating service"
msgstr "Nouveau service producteur"
......@@ -19,6 +19,7 @@
<?hinclude recordsManagement/archive/archiveModificationModal/retentionRule.html?>
<?hinclude recordsManagement/archive/archiveModificationModal/requestCommunication.html?>
<?hinclude recordsManagement/archive/archiveModificationModal/archiveTransfer.html?>
<?hinclude recordsManagement/archive/archiveModificationModal/originatorModification.html?>
</div>
</div>
</div>
......@@ -79,15 +80,24 @@
var transaction = false;
$("#transaction").val() ? transaction = true : transaction = false;
if (type === "accessRule" || type === "retentionRule" || type === "requestCommunication") {
parameter = eval(type+"_serialize()");
} else if (type === "flagForTransfer") {
if ($('#archivalAgencySelect').find('option:selected').val()) {
parameter.archiverOrgRegNumber = $('#archivalAgencySelect').find('option:selected').val();
}
switch (type) {
case "accessRule":
case "retentionRule":
case "requestCommunication":
case "editOriginator":
parameter = eval(type+"_serialize()");
break;
case "flagForTransfer":
if ($('#archivalAgencySelect').find('option:selected').val()) {
parameter.archiverOrgRegNumber = $('#archivalAgencySelect').find('option:selected').val();
}
break;
default:
break;
}
if (transaction) {
if (transaction && type != "editOriginator") {
parameter.identifier = this.modal.find('[name="identifier"]').val();
parameter.comment = this.modal.find('[name="comment"]').val();
parameter.format = this.modal.find('[name="format"]').val()
......
<!-- <tr id="selectedArchiveId">
<td><strong>New originating service</strong></td>
<td>
<select name="originatorList" id="originatorList" class="form-control">
</td>
</tr> -->
<script>
var editOriginator_load = function (archiveId, archiveName, type) {
$('#selectedOriginator').remove();
var selectedOriginatorTr = $('<tr>').attr('id', "selectedOriginator");
selectedOriginatorTr.append($('<td>').append($('<strong>').text('New originating service')));
var td = $('<td>');
var availableOriginatingServices = $('#' + archiveId).data('availableoriginatingservices');
var select = $('<select>').attr('name', "originatorList").attr("id", "originatorList").addClass('form-control');
availableOriginatingServices.forEach(org => {
select.append($('<option>').val(org.orgId).text(org.displayName));
});
td.append(select);
selectedOriginatorTr.append(td);
$('#modificationModal table tbody').append(selectedOriginatorTr);
$('#modificationModal').modal();
}
var editOriginator_serialize = function () {
var parameter = {};
parameter.orgId = $('#originatorList').val();
parameter.archiveIds = [];
parameter.archiveIds.push($('#selectedArchiveId').val());
return parameter;
}
</script>
......@@ -30,6 +30,7 @@
<span id="mtext_flagForTransfer">Flag for transfer</span>
<span id="mtext_retentionRule">Change disposal rule</span>
<span id="mtext_accessRule">Edit access rule</span>
<span id="mtext_editOriginator">Edit Originating service</span>
<span id="mtext_flagForDestruction">Flag for destruction</span>
<span id="mtext_requestModification">Request a modification</span>
<span id="mtext_cancelDestruction">Cancel destruction</span>
......@@ -95,7 +96,8 @@
requestModification : '/modificationRequest',
cancelDestruction : '/recordsManagement/cancelDestruction',
freeze : '/recordsManagement/archive/freeze',
unfreeze : '/recordsManagement/archive/unfreeze'
unfreeze : '/recordsManagement/archive/unfreeze',
editOriginator : '/recordsManagement/archive/originator',
},
actionsType : {},
modal : $('#modificationModal'),
......@@ -117,19 +119,25 @@
this.modal.modal();
}
if (type === 'requestCommunication' && $('#' +archiveId).data('iscommunicable') === 1) {
$('#derogationTr').show();
$('#derogationInputTr').show();
$("#derogationTr .toggle").removeClass('btn-default off');
$("#derogationTr .toggle").addClass('btn-info');
$('#derogationTr').hide();
$('#derogationInputTr').hide();
} else {
$('#derogationTr').hide();
$('#derogationInputTr').hide();
}
if (type === 'requestModification') {
$('#messageFormatTr').hide();
switch (type) {
case 'requestCommunication':
if ($('#' +archiveId).data('iscommunicable') === 1) {
$('#derogationTr').show();
$('#derogationInputTr').show();
$("#derogationTr .toggle").removeClass('btn-default off');
$("#derogationTr .toggle").addClass('btn-info');
}
break;
case 'requestModification':
$('#messageFormatTr').hide();
break;
case 'editOriginator':
$('#message').hide();
break;
default:
}
if (!transaction) {
......@@ -291,8 +299,6 @@
type = 'PUT';
}
console.log(this.actionsList[this.modalType]);
$.ajax({
url : this.actionsList[this.modalType],
type : type,
......
......@@ -6,6 +6,8 @@
<?merge hasModificationPrivilege.bool() ?>
<li class="editAccessRule" data-type="accessRule"><a href="#"><i class="fa fa-edit">&nbsp;</i>&nbsp;Modify access rule</a></li>
<?merge hasModificationPrivilege.bool() ?>
<li class="editOriginator" data-type="editOriginator"><a href="#"><i class="fa fa-edit">&nbsp;</i>&nbsp;Modify originator service</a></li>
<?merge hasModificationPrivilege.bool() ?>
<li class="freeze [?merge .status.ifeq('frozen').then('hide', '') ?]" data-type="freeze"><a href="#"><i class="fa fa-lock">&nbsp;</i>&nbsp;Freeze</a></li>
<?merge hasModificationPrivilege.bool() ?>
<li class="unfreeze [?merge .status.ifne('frozen').then('hide', '') ?]" data-type="unfreeze"><a href="#"><i class="fa fa-unlock">&nbsp;</i>&nbsp;Unfreeze</a></li>
......@@ -25,6 +27,7 @@
<?merge hasIntegrityCheckPrivilege.bool() ?>
<li class="checkHash" data-type="checkHash"><a href="#"><i class="fa fa-database">&nbsp;</i>&nbsp;Verify integrity</a></li>
<li class="divider"></li>
</span>
<li class="requestDelivery" data-type="requestCommunication"><a href="#"><i class="fa fa-upload">&nbsp;</i>&nbsp;Request of communication</a></li>
</ul>
......@@ -38,7 +38,7 @@
</thead>
<tbody>
<?merge archive ?>
<tr id="[?merge .archiveId ?]" name="[?merge .archiveName ?]" class="[?merge .disposable.bool().then('danger') ?] [?merge .hasRights.bool().not().then('text-muted') ?]" data-iscommunicable="[?merge .isCommunicable ?]" data-hasRights="[?merge .hasRights.bool().then('true', 'false') ?]">
<tr id="[?merge .archiveId ?]" name="[?merge .archiveName ?]" class="[?merge .disposable.bool().then('danger') ?] [?merge .hasRights.bool().not().then('text-muted') ?]" data-iscommunicable="[?merge .isCommunicable ?]" data-hasRights="[?merge .hasRights.bool().then('true', 'false') ?]" data-availableoriginatingservices="[?merge .availableOriginatingServices ?]">
<td>
<input type="checkbox"
data-archive-status="[?merge .status ?]"
......
......@@ -4,6 +4,8 @@
<li class="editRetentionRule toto" data-type="retentionRule"><a href="#"><i class="fa fa-edit">&nbsp;</i>&nbsp;Modify retention rule</a></li>
<?merge hasModificationPrivilege.bool() ?>
<li class="editAccessRule" data-type="accessRule"><a href="#"><i class="fa fa-edit">&nbsp;</i>&nbsp;Modify access rule</a></li>
<?merge hasOriginatingPrivilege.bool() ?>
<li class="editOriginator" data-type="editOriginator"><a href="#"><i class="fa fa-edit">&nbsp;</i>&nbsp;Modify originator service</a></li>
<?merge hasModificationPrivilege.bool() ?>
<li class="freeze" data-type="freeze"><a href="#"><i class="fa fa-lock">&nbsp;</i>&nbsp;Freeze</a></li>
<?merge hasModificationPrivilege.bool() ?>
......
<?php
/*
* Copyright (C) 2021 Maarch
*
* This file is part of bundle recordsManagement.
*
* Bundle recordsManagement is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle recordsManagement is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle recordsManagement. If not, see <http://www.gnu.org/licenses/>.
*/
namespace presentation\maarchRM\UserStory\adminArchive;
/**
* Interface for management of description fields
*
* @package adminArchive
* @author Jerome Boucher <alexis.ragot@maarch.org>
*/
interface adminOriginatorInterface
{
/**
* List of description fields
*
* @return recordsManagement/descriptionField/index
*/
public function readDescriptionfields();
/**
* create a description field
* @param recordsManagement/descriptionField $descriptionField The description field object
*
* @return recordsManagement/descriptionField/create
*
* @uses recordsManagement/descriptionField/create
*/
public function createDescriptionfield($descriptionField);
/**
* Edit a description field
*
* @return recordsManagement/descriptionField/edit The profile object
* @uses recordsManagement/descriptionField/read_name_
*/
public function readDescriptionfield_name_();
/**
* Update a description field
* @param recordsManagement/descriptionField $descriptionField The description field object
*
* @return recordsManagement/descriptionField/update
* @uses recordsManagement/descriptionField/update
*/
public function updateDescriptionfield_name_($descriptionField);
/**
* Delete a description field
*
* @return recordsManagement/descriptionField/delete
* @uses recordsManagement/descriptionField/delete_name_
*/
public function deleteDescriptionfield_name_();
/**
* Update a description field
* @param string $reffile The description field reference file
*
* @uses recordsManagement/descriptionField/update_name_Ref
*/
public function updateDescriptionfield_name_Ref($reffile);
/**
* Read a description ref
*
* @return recordsManagement/descriptionField/readRef
* @uses recordsManagement/descriptionField/read_name_Ref
*/
public function readDescriptionfield_name_Ref();
/**
* @uses recordsManagement/archives/updateOriginator
*/
public function updateRecordsmanagementArchiveOriginator($archiveIds, $orgId);
}
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