Skip to content

Commit

Permalink
Merge pull request guardian#4297 from bbc/t1766-restrictions-panel-up…
Browse files Browse the repository at this point in the history
…dating

Fixing bug where metadata-validity and image-cost-message controls don't update correctly when usage rights category is modified.
  • Loading branch information
paperboyo authored Jul 10, 2024
2 parents 6387314 + 89ee2aa commit 977165f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@ import './gr-image-cost-message.css';
export const module = angular.module('gr.imageCostMessage', [imageService.name]);

module.controller('grImageCostMessage', [
'imageService',
'$rootScope', 'imageService',

function (imageService) {
function ($rootScope, imageService) {
let ctrl = this;

ctrl.$onInit = () => {
const states = imageService(ctrl.image).states;
ctrl.messageState = (states.hasRestrictions) ? "conditional" : states.costState;
ctrl.restrictionsText = () => {
return restrictionsText(this.image);
function updateState() {
ctrl.image.get().then(image => {
const states = imageService(image).states;
ctrl.messageState = (states.hasRestrictions) ? "conditional" : states.costState;
ctrl.restrictionsText = () => {
return restrictionsText(image);
};
});
};

$rootScope.$on('images-updated', () => {
updateState();
});

updateState();

};

}
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module.controller('grMetadataValidityCtrl', [ '$rootScope', '$window', function
updateState();
});

$rootScope.$on('images-updated', () => {
updateState();
});

updateState();
};
}]);
Expand Down

0 comments on commit 977165f

Please sign in to comment.