OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
check for active edit state and warn about potential conflict/override
Jonas Jabaridd24597e7cfb
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 322eeb3246f..5928b444704 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -391,6 +391,8 @@ en:format:date: "%{attribute} is no valid date - YYYY-MM-DD expected."general: "An error has occurred."+ warning:+ potential_update_conflict: "The resource you're about to update was edited by another user."homescreen:blocks:diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex 38252596273..23409bb62b5 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -79,7 +79,7 @@ export default class IndexController extends Controller {// without any further checks, this update is currently triggered even after the very first rendering of the activity tab//// this is not ideal but I don't want to introduce another hacky "ui-state-check" for now- this.updateDisplayedWorkPackageAttributes();+ this.safeUpdateDisplayedWorkPackageAttributes();// something like below could be used to check for the ui state in the disconnect method// in order to identify if the activity tab was connected at least once@@ -207,6 +207,21 @@ export default class IndexController extends Controller {private checkForAndHandleWorkPackageUpdate(html:string) {if (html.includes('work-packages-activities-tab-journals-item-component-details--journal-detail-container')) {+ this.safeUpdateDisplayedWorkPackageAttributes();+ }+ }++ private safeUpdateDisplayedWorkPackageAttributes() {+ if (this.anyInlineEditActiveInWpSingleView()) {+ this.toastService.addWarning({+ message: this.i18n.t('js.hal.warning.potential_update_conflict'),+ type: 'warning',+ link: {+ text: this.i18n.t('js.hal.error.update_conflict_refresh'),+ target: () => this.updateDisplayedWorkPackageAttributes(),+ },+ });+ } else {this.updateDisplayedWorkPackageAttributes();}}@@ -217,6 +232,14 @@ export default class IndexController extends Controller {}}+ private anyInlineEditActiveInWpSingleView():boolean {+ const wpSingleViewElement = document.querySelector('wp-single-view');+ if (wpSingleViewElement) {+ return wpSingleViewElement.querySelector('.inline-edit--active-field') !== null;+ }+ return false;+ }+private updateDisplayedWorkPackageAttributes() {const wp = this.apiV3Service.work_packages.id(this.workPackageIdValue);void wp.refresh();