refactor Accepting and Unaccepting Documents, new Error Message if more than one document per type, refactor List Accepted Documents

This commit is contained in:
ma0068
2025-06-16 15:38:56 +02:00
parent 7b5b6992c7
commit 5140d9de31
4 changed files with 81 additions and 18 deletions
@@ -94,33 +94,29 @@ class Dokumente extends FHCAPI_Controller
if (hasData($result))
{
$data = getData($result);
array_push($arrayAccepted, current($data));
foreach ($data as $value)
{
array_push($arrayAccepted, $value);
}
}
}
//Merge with Data of Akte
//Array for total list of accepted documents
$newDataMap = [];
//helper, lookupArray
foreach ($arrayAccepted as $item) {
$newDataMap[$item->dokument_kurzbz] = $item;
$newDataMap[] = (array)$item;
}
//add Data of Akte to PrestudentData
foreach ($resultPreDoc as $obj) {
if (isset($newDataMap[$obj->dokument_kurzbz])) {
$obj->akte_id = $newDataMap[$obj->dokument_kurzbz]->akte_id;
$obj->hochgeladenamum = $newDataMap[$obj->dokument_kurzbz]->hochgeladenamum;
$obj->titel_intern = $newDataMap[$obj->dokument_kurzbz]->titel_intern;
$obj->nachgereicht = $newDataMap[$obj->dokument_kurzbz]->nachgereicht;
$obj->akzeptiertamum = $newDataMap[$obj->dokument_kurzbz]->akzeptiertamum;
$obj->dms_id = $newDataMap[$obj->dokument_kurzbz]->dms_id;
$obj->infotext = $newDataMap[$obj->dokument_kurzbz]->infotext;
$obj->anmerkung_intern = $newDataMap[$obj->dokument_kurzbz]->anmerkung_intern;
$obj->nachgereicht_am = $newDataMap[$obj->dokument_kurzbz]->nachgereicht_am;
$obj->vorhanden = $newDataMap[$obj->dokument_kurzbz]->vorhanden;
$listExistingKurzbz = array_column($newDataMap, 'dokument_kurzbz');
foreach ($resultPreDoc as $item)
{
if (!in_array($item->dokument_kurzbz, $listExistingKurzbz))
{
$newDataMap[] = (array)$item;
}
}
$this->terminateWithSuccess($resultPreDoc);
$this->terminateWithSuccess($newDataMap);
}
public function deleteZuordnung($prestudent_id, $dokument_kurzbz)
@@ -215,6 +211,9 @@ class Dokumente extends FHCAPI_Controller
$uid = getAuthUid();
//check if more than 1 dokumentkurzbz
//if()
$result = $this->DokumentprestudentModel->insert(
[
'prestudent_id' => $prestudent_id,
@@ -237,6 +237,27 @@ export default {
});
},
deleteZuordnung(selected) {
//Check if more than one document per dokument_kurzbz should be unaccepted
const counts = {};
for (const item of selected)
{
const value = item.dokument_kurzbz;
if (!counts[value]) {
counts[value] = 1;
}
else {
counts[value]++;
}
if (counts[value] > 1) {
{
this.$fhcAlert.alertError(this.$p.t('dokumente', 'error_duplicateDokument_kurzbz'));
return;
}
}
}
Promise.allSettled(
selected.map(e =>
this.$api
@@ -234,6 +234,27 @@ export default {
this.$refs.modalEdit.open(akte_id);
},
acceptDocuments(selected){
//Check if more than one document per dokument_kurzbz should be accepted
const counts = {};
for (const item of selected)
{
const value = item.dokument_kurzbz;
if (!counts[value]) {
counts[value] = 1;
}
else {
counts[value]++;
}
if (counts[value] > 1) {
{
this.$fhcAlert.alertError(this.$p.t('dokumente', 'error_duplicateDokument_kurzbz'));
return;
}
}
}
Promise
.allSettled(
selected.map(e =>
@@ -318,6 +339,8 @@ export default {
@click:new="actionUploadFile"
>
<template #actions="{selected}">
<p v-for="name in selected">
{{name.dokument_kurzbz}}</p>
<button
class="btn btn-primary"
@click="acceptDocuments(selected)"
+20
View File
@@ -43261,6 +43261,26 @@ and represent the current state of research on the topic. The prescribed citatio
)
)
),
array(
'app' => 'core',
'category' => 'dokumente',
'phrase' => 'error_duplicateDokument_kurzbz',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Akzeptieren / Entakzeptieren von mehr als einem Dokument pro Dokumenttyp nicht zulässig',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Accepting / unaccepting more than one document per document type is not permitted',
'description' => '',
'insertvon' => 'system'
)
)
),
// FHC4 Studierendenverwaltung Dokumente END
// FHC4 Phrases Anrechnungen Start
array(