From b1b0083c582f44a4ed6cb029fdf14af210050c7d Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 9 Sep 2024 15:44:26 -0400 Subject: [PATCH 1/4] FOUR-18903: The Auto save date is updated without making any changes --- ProcessMaker/Http/Controllers/TaskController.php | 2 +- ProcessMaker/Models/TaskDraft.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ProcessMaker/Http/Controllers/TaskController.php b/ProcessMaker/Http/Controllers/TaskController.php index 2782da3e9e..29fb4a7340 100755 --- a/ProcessMaker/Http/Controllers/TaskController.php +++ b/ProcessMaker/Http/Controllers/TaskController.php @@ -92,7 +92,7 @@ public function edit(ProcessRequestToken $task, string $preview = '') $task->allow_interstitial = $interstitial['allow_interstitial']; $task->definition = $task->getDefinition(); $task->requestor = $task->processRequest->user; - $task->draft = $task->draft(); + $task->draft = TaskDraft::where('task_id', $task->id)->get(); $element = $task->getDefinition(true); $screenFields = $screenVersion ? $screenVersion->screenFilteredFields() : []; $taskDraftsEnabled = TaskDraft::draftsEnabled(); diff --git a/ProcessMaker/Models/TaskDraft.php b/ProcessMaker/Models/TaskDraft.php index f4a5ccb65d..fe6cd8916b 100644 --- a/ProcessMaker/Models/TaskDraft.php +++ b/ProcessMaker/Models/TaskDraft.php @@ -22,6 +22,7 @@ class TaskDraft extends ProcessMakerModel implements HasMedia protected $fillable = [ 'task_id', 'data', + 'updated_at', ]; protected $casts = [ @@ -112,4 +113,8 @@ public static function draftsEnabled() { return config('app.task_drafts_enabled'); } + protected static function getDraft() + { + return $this->belongsTo(ProcessRequestToken::class, 'task_id'); + } } From 623c939e8d1d7ff82282abc12506fc0c65aa85e7 Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 9 Sep 2024 15:47:17 -0400 Subject: [PATCH 2/4] miss files --- ProcessMaker/Models/TaskDraft.php | 5 ----- resources/views/tasks/edit.blade.php | 14 +++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ProcessMaker/Models/TaskDraft.php b/ProcessMaker/Models/TaskDraft.php index fe6cd8916b..f4a5ccb65d 100644 --- a/ProcessMaker/Models/TaskDraft.php +++ b/ProcessMaker/Models/TaskDraft.php @@ -22,7 +22,6 @@ class TaskDraft extends ProcessMakerModel implements HasMedia protected $fillable = [ 'task_id', 'data', - 'updated_at', ]; protected $casts = [ @@ -113,8 +112,4 @@ public static function draftsEnabled() { return config('app.task_drafts_enabled'); } - protected static function getDraft() - { - return $this->belongsTo(ProcessRequestToken::class, 'task_id'); - } } diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index 74b8187072..e249220d24 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -146,7 +146,10 @@ class="btn d-block mr-0 ml-auto button-collapse"
  • -
    +
    ); const task = @json($task); + let draftTask = task.draft[0]; const userHasAccessToTask = {{ Auth::user()->can('update', $task) ? "true": "false" }}; const userIsAdmin = {{ Auth::user()->is_administrator ? "true": "false" }}; const userIsProcessManager = {{ Auth::user()->id === $task->process?->manager_id ? "true": "false" }}; @@ -428,6 +432,7 @@ class="multiselect__tag-icon"> filter: "", showReassignment: false, task, + draftTask, userHasAccessToTask, selectedUser: [], hasErrors: false, @@ -456,13 +461,15 @@ class="multiselect__tag-icon"> task: { deep: true, handler(task, oldTask) { + console.log('fas'); + window.ProcessMaker.breadcrumbs.taskTitle = task.element_name; if (task && oldTask && task.id !== oldTask.id) { history.replaceState(null, null, `/tasks/${task.id}/edit`); } if (task.draft) { - this.lastAutosave = moment(task.draft.updated_at).format("DD MMMM YYYY | HH:mm"); - this.lastAutosaveNav = moment(task.draft.updated_at).format("MMM DD, YYYY / HH:mm"); + this.lastAutosave = moment(this.draftTask.updated_at).format("DD MMMM YYYY | HH:mm"); + this.lastAutosaveNav = moment(this.draftTask.updated_at).format("MMM DD, YYYY / HH:mm"); } else { this.lastAutosave = "-"; this.lastAutosaveNav = "-" @@ -720,6 +727,7 @@ class="multiselect__tag-icon"> this.task.draft, response.data ); + this.draftTask = structuredClone(response.data); }) .catch(() => { this.errorAutosave = true; From 91b5f31e75f2f1f9b464a70396751bab4ca18a55 Mon Sep 17 00:00:00 2001 From: Fabio Date: Mon, 9 Sep 2024 15:48:23 -0400 Subject: [PATCH 3/4] remove console --- resources/views/tasks/edit.blade.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index e249220d24..300162ae42 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -461,8 +461,6 @@ class="multiselect__tag-icon"> task: { deep: true, handler(task, oldTask) { - console.log('fas'); - window.ProcessMaker.breadcrumbs.taskTitle = task.element_name; if (task && oldTask && task.id !== oldTask.id) { history.replaceState(null, null, `/tasks/${task.id}/edit`); From 0c39182b533c237c08f2d242562565e0efa865c9 Mon Sep 17 00:00:00 2001 From: Fabio Date: Tue, 10 Sep 2024 09:07:17 -0400 Subject: [PATCH 4/4] corrections --- ProcessMaker/Http/Controllers/TaskController.php | 2 +- resources/views/tasks/edit.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ProcessMaker/Http/Controllers/TaskController.php b/ProcessMaker/Http/Controllers/TaskController.php index 29fb4a7340..c51fb07695 100755 --- a/ProcessMaker/Http/Controllers/TaskController.php +++ b/ProcessMaker/Http/Controllers/TaskController.php @@ -92,7 +92,7 @@ public function edit(ProcessRequestToken $task, string $preview = '') $task->allow_interstitial = $interstitial['allow_interstitial']; $task->definition = $task->getDefinition(); $task->requestor = $task->processRequest->user; - $task->draft = TaskDraft::where('task_id', $task->id)->get(); + $task->draft = $task->draft; $element = $task->getDefinition(true); $screenFields = $screenVersion ? $screenVersion->screenFilteredFields() : []; $taskDraftsEnabled = TaskDraft::draftsEnabled(); diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index 300162ae42..53941a8029 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -398,7 +398,7 @@ class="multiselect__tag-icon"> ); const task = @json($task); - let draftTask = task.draft[0]; + let draftTask = task.draft; const userHasAccessToTask = {{ Auth::user()->can('update', $task) ? "true": "false" }}; const userIsAdmin = {{ Auth::user()->is_administrator ? "true": "false" }}; const userIsProcessManager = {{ Auth::user()->id === $task->process?->manager_id ? "true": "false" }};