Skip to content

Commit

Permalink
fix: Redirect should be to related to current page after editing atta…
Browse files Browse the repository at this point in the history
…chment - EXO-71706 (#379)

* fix: Redirect should be to related to current page after editing attachment - EXO-71706
  • Loading branch information
mkrout authored Jul 8, 2024
1 parent 4ad24dc commit 9223715
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
<div class="text-truncate">
<v-icon size="14" class="me-1">fa-comment</v-icon>
<span v-sanitized-html="requestComment" />
<span v-sanitized-html="requestComment"></span>
</div>
</template>
</user-notification-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default {
showRequestEditor() {
this.showEditor = !this.showEditor;
},
open(object, mode, isDraft) {
open(object, mode, isDraft, allowSave) {
if (mode === 'create_work') {
this.work = {};
this.work.workFlow = object;
Expand All @@ -301,6 +301,7 @@ export default {
this.viewMode = false;
this.editDraft = true;
this.firstCreation = false;
this.$root.$emit('update-url-path', 'draftDetails', `/myRequests/draftDetails/${this.work.id}`);
this.$root.$on('can-show-request-editor',() => {
this.showEditor = true;
window.setTimeout(() => {
Expand All @@ -321,7 +322,7 @@ export default {
entityType: this.entityType
});
this.initEditor();
this.attachmentsUpdated = false;
this.attachmentsUpdated = allowSave;
this.$refs.work.open();
},
initEditor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default {
messageAction: null,
messageTargetModel: null,
messageTimer: null,
draftId: null,
updated: false,
};
},
beforeCreate() {
Expand Down Expand Up @@ -200,7 +202,7 @@ export default {
}
this.work = event.object;
this.workComments = event.object.comments;
this.$refs.addWork.open(event.object, event.mode, event.isDraft);
this.$refs.addWork.open(event.object, event.mode, event.isDraft,event.allowSave);
});
this.$root.$on('open-workflow-drawer', event => {
this.$refs.addWorkFlow.open(event.workflow, event.mode);
Expand Down Expand Up @@ -339,6 +341,10 @@ export default {
this.$root.$emit('close-work-drawer');
this.$root.$emit('hideTaskComment');
}
if (path.includes('/myRequests/draftDetails')) {
this.tab = 1;
this.draftId =path.split('draftDetails/')[1].split(/\D/)[0];
}
if (path.includes('/requestDetails') && !path.endsWith('/comments')) {
this.tab = 1;
const workId = path.split('requestDetails/')[1].split(/\D/)[0];
Expand All @@ -354,6 +360,13 @@ export default {
const workId = path.split('requestDetails/')[1].split(/\D/)[0];
this.openWorkComments(workId);
}
if (path.includes('/myRequests/draftDetails')||path.includes('/myRequests/requestDetails')) {
const currentUrlSearchParams = window.location.search;
const queryParams = new URLSearchParams(currentUrlSearchParams);
if (queryParams.has('updated')) {
this.updated = queryParams.get('updated') === 'true';
}
}
},
openCreateWork(workflowId) {
this.$processesService.getWorkflowById(workflowId, '').then(workflow => {
Expand Down Expand Up @@ -464,6 +477,13 @@ export default {
this.loading = true;
return this.$processesService.getWorkDrafts(null, 0, 0, expand).then(drafts => {
this.allWorkDrafts = drafts || [];
if (this.draftId) {
const draft = this.allWorkDrafts.find((element) => element.id.toString() === this.draftId.toString());
if (draft){
this.$root.$emit('open-add-work-drawer', {object: draft, mode: 'edit_work_draft', allowSave: this.updated});
this.handleUpdateUrlPath('draftDetails', `/myRequests/draftDetails/${draft.id}`);
}
}
if (this.query){
this.workDrafts = this.allWorkDrafts.filter(elem=>{
return elem.description && elem.description.replace(/\s/g,'').replace(/<\/?[^>]+(>|$)/gi, '').includes(this.query.replace(/\s/g,''));
Expand Down Expand Up @@ -526,6 +546,7 @@ export default {
this.displayMessage({type: 'success', message: this.$t('processes.workDraft.add.success.message')});
}
this.workDrafts.unshift(draft);
this.$root.$emit('update-url-path', 'draftDetails', `/myRequests/draftDetails/${draft.id}`);
}
}).catch(() => {
this.displayMessage({type: 'error', message: this.$t('processes.workDraft.save.error.message')});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
doc.date = doc.created;
this.$root.$emit('add-new-created-form-document', doc);
this.restInput();
window.open(`${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${doc.id}`, '_blank');
window.open(`${eXo.env.portal.context}/${eXo.env.portal.portalName}/oeditor?docId=${doc.id}&backTo=${window.location.pathname}`, '_blank');
}
},
restInput() {
Expand Down

0 comments on commit 9223715

Please sign in to comment.