Skip to content

Commit

Permalink
Prefer select crops button to disabled button in iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-nowak committed Jan 22, 2025
1 parent 6260b5f commit 658dcb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ batchExportOriginalImages.controller('grBatchExportOriginalImagesCtrl', [
function($q, $scope, $rootScope, $state, mediaCropper) {
let ctrl = this;

const checkForFullCrops = () => ctrl.images.every(
const checkForFullCrops = () => ctrl.images.filter(
image => image.data.exports.some(
crop => crop.specification.type === 'full'
)
);
).size;

const croppable = () => ctrl.images.filter(
image => image.data.valid && image.data.softDeletedMetadata === undefined &&
Expand All @@ -24,17 +24,19 @@ batchExportOriginalImages.controller('grBatchExportOriginalImagesCtrl', [
);

$scope.$watchGroup(['ctrl.images', 'ctrl.cropping'], () => {
ctrl.allHaveFullCrops = checkForFullCrops();
const numberWithFullCrops = checkForFullCrops();
const allHaveFullCrops = numberWithFullCrops === ctrl.images.size;
const someHaveFullCrops = numberWithFullCrops > 0;
const croppableImages = croppable();

ctrl.allCroppable = croppableImages.size === ctrl.images.size;
ctrl.noneCroppable = croppableImages.size === 0;

const pageIsEmbedded = window.parent !== window;

ctrl.canBatchCrop = !ctrl.allHaveFullCrops && !ctrl.cropping && !ctrl.noneCroppable;
ctrl.cropDisabled = !ctrl.allHaveFullCrops && !ctrl.cropping && ctrl.noneCroppable;
ctrl.canSelectCrops = ctrl.allHaveFullCrops && !ctrl.cropping && pageIsEmbedded;
ctrl.canBatchCrop = !ctrl.cropping && !allHaveFullCrops && !ctrl.noneCroppable;
ctrl.canSelectCrops = !ctrl.cropping && !ctrl.canBatchCrop && someHaveFullCrops && pageIsEmbedded;
ctrl.cropDisabled = !ctrl.cropping && !ctrl.canBatchCrop && !ctrl.canSelectCrops && ctrl.noneCroppable && !allHaveFullCrops;
}, true);

ctrl.callBatchCrop = function() {
Expand Down
6 changes: 5 additions & 1 deletion kahuna/public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,14 @@ button[disabled],
.inner-clickable {
height: 100%;
display: inline-flex;
gap: 2px;
align-items: center;
}

.inner-clickable--disabled {
opacity: 0.7;
color: #9e9e9e;
fill: #9e9e9e;
cursor: default;
}

.button-right-side {
Expand Down Expand Up @@ -1421,6 +1424,7 @@ textarea.ng-invalid {

gr-batch-export-original-images .batch-export-original-images {
padding: 0 10px;
height: 100%;
}

.results-toolbar-item {
Expand Down

0 comments on commit 658dcb8

Please sign in to comment.