Skip to content

Commit

Permalink
Run middleware on priority change instantly (#4425)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Feb 1, 2024
1 parent 805da7d commit 904da8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.autosavePriority = () => {
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
Expand Down
4 changes: 2 additions & 2 deletions scripts/apps/authoring/views/authoring-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
data-label="Priority"
ng-disabled="!_editable || schema.priority.readonly === true"
data-key="qcode"
data-change="autosave(item)"
data-change="autosavePriority()"
tabindex="{{editor.priority.order}}">
</div>
<div class="authoring-header__hint" ng-if="helper_text.priority">{{helper_text.priority}}</div>
Expand Down Expand Up @@ -635,5 +635,5 @@
</div>

<div class="authoring-header__toggle-container">
<button class="authoring-header__toggle" ng-class="{active: isCollapsed}" ng-click="toggleCollapsed()" tabindex="-1"><i class="icon-chevron-up-thin"></i></button>
<button class="authoring-header__toggle" ng-class="{active: isCollapsed}" ng-click="toggleCollapsed()" tabindex="-1"><i class="icon-chevron-up-thin"></i></button>
</div>

0 comments on commit 904da8b

Please sign in to comment.