diff --git a/kahuna/public/js/preview/image.html b/kahuna/public/js/preview/image.html index 84529115ef..c0cbf69913 100644 --- a/kahuna/public/js/preview/image.html +++ b/kahuna/public/js/preview/image.html @@ -192,7 +192,7 @@ + ng-if="(ctrl.hasSyndicationUsages || ctrl.uploadedByCapture) && ctrl.showSendToPhotoSales() && ctrl.showPaid"> diff --git a/kahuna/public/js/preview/image.js b/kahuna/public/js/preview/image.js index 3dcc92d193..2ec27254b4 100644 --- a/kahuna/public/js/preview/image.js +++ b/kahuna/public/js/preview/image.js @@ -38,6 +38,7 @@ image.controller('uiPreviewImageCtrl', [ 'inject$', '$rootScope', '$window', + 'mediaApi', 'imageService', 'imageUsagesService', 'labelService', @@ -50,6 +51,7 @@ image.controller('uiPreviewImageCtrl', [ inject$, $rootScope, $window, + mediaApi, imageService, imageUsagesService, labelService, @@ -65,6 +67,10 @@ image.controller('uiPreviewImageCtrl', [ }); ctrl.showSendToPhotoSales = () => $window._clientConfig.showSendToPhotoSales; + ctrl.uploadedByCapture = ctrl.image.data.uploadedBy === "Capture_AutoIngest"; + mediaApi.getSession().then(session => { + ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined; + }); ctrl.addLabelToImages = labelService.batchAdd; ctrl.removeLabelFromImages = labelService.batchRemove; diff --git a/kahuna/public/js/search/results.js b/kahuna/public/js/search/results.js index 45d9dda0da..6ef2323853 100644 --- a/kahuna/public/js/search/results.js +++ b/kahuna/public/js/search/results.js @@ -399,26 +399,28 @@ results.controller('SearchResultsCtrl', [ globalErrors.trigger('clipboard', sharedUrl); }; + const imageHasSyndicationUsage = (image) => { + return image.data.usages.data.some(usage => + usage.data.platform === 'syndication' + ); + }; + const validatePhotoSalesSelection = (images) => { - let validImages = []; - let invalidImages = []; - images.forEach( (image) => { - if (image.data.usages.data.length === 0) { - validImages.push(image); + const validImages = []; + const invalidImages = []; + + images.forEach(image => { + if (image.data.uploadedBy === 'Capture_AutoIngest' || imageHasSyndicationUsage(image)) { + invalidImages.push(image); } else { - let syndicationExists = false; - for (const usage of image.data.usages.data) { - if (usage.data.platform === "syndication") { - syndicationExists = true; - break; - } - } - (syndicationExists === true ? invalidImages : validImages).push(image); + validImages.push(image); } }); + return [validImages, invalidImages]; }; + ctrl.showPaid = undefined; mediaApi.getSession().then(session => { ctrl.showPaid = session.user.permissions.showPaid ? session.user.permissions.showPaid : undefined;