Skip to content

Commit

Permalink
Fix:Related content filters do not work for galleries[SDESK-6697] (#4162
Browse files Browse the repository at this point in the history
)
  • Loading branch information
devketanpro authored Dec 20, 2022
1 parent 4ce623a commit 8a9773c
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'owl.carousel';
import _ from 'lodash';
import * as ctrl from '../controllers';
import {waitForMediaToLoad} from 'core/helpers/waitForMediaToBeReady';
import {gettext, gettextPlural} from 'core/utils';
import {getSuperdeskType, gettext, gettextPlural} from 'core/utils';
import {addInternalEventListener} from 'core/internal-events';
import {isAllowedMediaType, getAllowedTypeNames} from './ItemAssociationDirective';
import {getAssociationsByFieldId} from '../controllers/AssociationController';
import {IArticle} from 'superdesk-api';

const carouselContainerSelector = '.sd-media-carousel__content';

Expand Down Expand Up @@ -53,8 +54,8 @@ function isOrderOrItemsChanged(items: Array<any>, prevItems: Array<any>): boolea
* @module superdesk.apps.authoring
* @name sdItemCarousel
*/
ItemCarouselDirective.$inject = ['notify'];
export function ItemCarouselDirective(notify) {
ItemCarouselDirective.$inject = ['notify', 'relationsService'];
export function ItemCarouselDirective(notify, relationsService) {
return {
scope: {
allowAudio: '<',
Expand Down Expand Up @@ -217,6 +218,18 @@ export function ItemCarouselDirective(notify) {
event.preventDefault();
event.stopPropagation();

const type: string = getSuperdeskType(event, false);
const item: IArticle = angular.fromJson(event.originalEvent.dataTransfer.getData(type));
const isWorkflowAllowed: boolean = relationsService.itemHasAllowedStatus(item, scope.field);

if (!isWorkflowAllowed) {
notify.error(gettext(
'The following status is not allowed in this field: {{status}}',
{status: item.state},
));
return;
}

if (isAllowedMediaType(scope, event)) {
const uploadsCount = Object.values(event.originalEvent.dataTransfer.files || []).length;

Expand Down

0 comments on commit 8a9773c

Please sign in to comment.