Extend document replacement logic to include storedObject and update components

- Updated `replaceDocument` function to handle `storedObject` and ensure proper version assignment.
- Added `@on-stored-object-refresh` event handling in `DocumentsList.vue` for dynamic updates.
- Introduced `refresh-stored-object-auto` prop in various components to control auto-refresh behavior.
This commit is contained in:
2026-04-15 18:10:18 +02:00
parent fbb04eb783
commit d24842fc17
6 changed files with 9 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
:can-download="true"
:dav-link="dav_link_href ?? ''"
:dav-link-expiration="dav_link_expiration ?? 0"
:refresh-stored-object-auto="false"
/>
</li>
<li>

View File

@@ -27,6 +27,7 @@
<document-action-buttons-group
:stored-object="storedObject"
:filename="filename"
:refresh-stored-object-auto="false"
></document-action-buttons-group>
</p>
</template>

View File

@@ -53,6 +53,7 @@ const canRemove = computed<boolean>((): boolean => {
<li>
<document-action-buttons-group
:stored-object="a.genericDoc.storedObject"
:refresh-stored-object-auto="false"
></document-action-buttons-group>
</li>
<li v-if="canRemove">

View File

@@ -38,6 +38,7 @@ const clickOnAddButton = () => {
<li v-if="props.genericDoc.storedObject !== null">
<document-action-buttons-group
:stored-object="props.genericDoc.storedObject"
:refresh-stored-object-auto="false"
></document-action-buttons-group>
</li>
<li>

View File

@@ -106,6 +106,7 @@
@on-stored-object-status-change="
$emit('statusDocumentChanged', $event)
"
@on-stored-object-refresh="(newStoredObject) => replaceDocument(d, newStoredObject, newStoredObject.currentVersion)"
></document-action-buttons-group>
</li>
<!--replace document-->
@@ -318,6 +319,7 @@ async function goToGenerateWorkflowEvaluationDocument({
* @return {void}
*/
async function replaceDocument(oldDocument, storedObject, storedObjectVersion) {
console.log('replaceDocument', storedObject, storedObjectVersion);
let document = {
type: "accompanying_period_work_evaluation_document",
storedObject: storedObject,
@@ -328,6 +330,7 @@ async function replaceDocument(oldDocument, storedObject, storedObjectVersion) {
key: props.evaluation.key,
document,
oldDocument: oldDocument,
storedObject: storedObject,
stored_object_version: storedObjectVersion,
});
}

View File

@@ -344,7 +344,7 @@ const store = createStore({
* Replaces a document in the state with a new document.
*
* @param {object} state - The current state of the application.
* @param {{key: number, oldDocument: {key: number}, stored_object_version: StoredObjectVersion}} payload - The object containing the information about the document to be replaced.
* @param {{key: number, oldDocument: {key: number}, stored_object_version: StoredObjectVersion, storedObject: StoredObject}} payload - The object containing the information about the document to be replaced.
* @return {void} - returns nothing.
*/
replaceDocument(state, payload) {
@@ -364,6 +364,7 @@ const store = createStore({
return;
}
doc.storedObject = payload.storedObject;
doc.storedObject.currentVersion = payload.stored_object_version;
return;
let newDocument = Object.assign(payload.document, {