From 1a249fc02a6ff5d9c07f6371872b4bdda00fa41f Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 1 Feb 2024 12:51:41 +0200 Subject: [PATCH 1/2] Run middleware on priority change instantly --- .../authoring/directives/AuthoringHeaderDirective.ts | 11 +++++++++++ scripts/apps/authoring/views/authoring-header.html | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts b/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts index 86edbf4d83..c211ac2726 100644 --- a/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts +++ b/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts @@ -9,6 +9,7 @@ import {getReadOnlyLabel} from './ArticleEditDirective'; import {translateArticleType, gettext} from 'core/utils'; import {IArticle} from 'superdesk-api'; import {slideUpDown} from 'core/ui/slide-up-down'; +import {runBeforeUpdateMiddlware} from '../services/AuthoringService'; AuthoringHeaderDirective.$inject = [ 'api', @@ -223,6 +224,16 @@ export function AuthoringHeaderDirective( return Promise.resolve(); } + /** + * Applies changes of the priority field instantly without the timeout introduced by autosave. + * Specifically implemented because of custom ANSA headline changes functionality, + * triggered on priority field change. (SDANSA-531) + */ + scope.priorityCustomFunction = () => { + runBeforeUpdateMiddlware(scope.item, scope.origItem); + scope.autosave(scope.item); + }; + /** * Sets the anpa category corresponding to the required subservice: if a subservice * field (defined in vocabularies) was declared as required in a content profile diff --git a/scripts/apps/authoring/views/authoring-header.html b/scripts/apps/authoring/views/authoring-header.html index d3e56b0947..beaccaf573 100644 --- a/scripts/apps/authoring/views/authoring-header.html +++ b/scripts/apps/authoring/views/authoring-header.html @@ -290,7 +290,7 @@ data-label="Priority" ng-disabled="!_editable || schema.priority.readonly === true" data-key="qcode" - data-change="autosave(item)" + data-change="priorityCustomFunction()" tabindex="{{editor.priority.order}}">
{{helper_text.priority}}
@@ -635,5 +635,5 @@
- +
From 53800fcca5d82a95a51cc072d9bee0e991ad3c14 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 1 Feb 2024 13:39:09 +0200 Subject: [PATCH 2/2] Improve function name --- .../authoring/authoring/directives/AuthoringHeaderDirective.ts | 2 +- scripts/apps/authoring/views/authoring-header.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts b/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts index c211ac2726..2651740901 100644 --- a/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts +++ b/scripts/apps/authoring/authoring/directives/AuthoringHeaderDirective.ts @@ -229,7 +229,7 @@ export function AuthoringHeaderDirective( * Specifically implemented because of custom ANSA headline changes functionality, * triggered on priority field change. (SDANSA-531) */ - scope.priorityCustomFunction = () => { + scope.autosavePriority = () => { runBeforeUpdateMiddlware(scope.item, scope.origItem); scope.autosave(scope.item); }; diff --git a/scripts/apps/authoring/views/authoring-header.html b/scripts/apps/authoring/views/authoring-header.html index beaccaf573..0ea37cde10 100644 --- a/scripts/apps/authoring/views/authoring-header.html +++ b/scripts/apps/authoring/views/authoring-header.html @@ -290,7 +290,7 @@ data-label="Priority" ng-disabled="!_editable || schema.priority.readonly === true" data-key="qcode" - data-change="priorityCustomFunction()" + data-change="autosavePriority()" tabindex="{{editor.priority.order}}">
{{helper_text.priority}}