Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:Related content filters do not work for galleries [SDESK-6697] #4162

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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