Skip to content

Commit

Permalink
Merge pull request #4340 from bbc/conal/IMAGEDAM-1982-prevent_resend_…
Browse files Browse the repository at this point in the history
…of_capture_images_and_restrict_icons

IMAGEDAM-1982: Prevent the resend of capture images and restrict icons
  • Loading branch information
andrew-nowak authored Oct 23, 2024
2 parents 4853417 + 4205430 commit f0408df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion kahuna/public/js/preview/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

<span class="bottom-bar__meta-item preview__has-syndication-usages preview__bottom-icons-align-right"
title="This image exists in BBC Photo Sales"
ng-if="ctrl.hasSyndicationUsages && ctrl.showSendToPhotoSales()">
ng-if="(ctrl.hasSyndicationUsages || ctrl.uploadedByCapture) && ctrl.showSendToPhotoSales() && ctrl.showPaid">
<gr-sent-to-photosales-icon class="gr-sent-to-photosales-icon"></gr-sent-to-photosales-icon>
</span>
</div>
Expand Down
6 changes: 6 additions & 0 deletions kahuna/public/js/preview/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ image.controller('uiPreviewImageCtrl', [
'inject$',
'$rootScope',
'$window',
'mediaApi',
'imageService',
'imageUsagesService',
'labelService',
Expand All @@ -50,6 +51,7 @@ image.controller('uiPreviewImageCtrl', [
inject$,
$rootScope,
$window,
mediaApi,
imageService,
imageUsagesService,
labelService,
Expand All @@ -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;
Expand Down
28 changes: 15 additions & 13 deletions kahuna/public/js/search/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f0408df

Please sign in to comment.