Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/94#discussion_r228904564
--- Diff:
ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
---
@@ -30,15 +47,43 @@ export function catalogSelectorDirective() {
scope: {
family: '<',
onSelect: '&',
- itemsPerPage: '<',
+ rowsPerPage: '<', // if unset then fill
reservedKeys: '<?',
+ state: '<?',
mode: '@?', // for use by downstream projects to pass in
special modes
},
template: template,
- controller: ['$scope', '$element', '$q', '$uibModal', '$log',
'$templateCache', 'paletteApi', 'paletteDragAndDropService', 'iconGenerator',
'composerOverrides', controller]
+ controller: ['$scope', '$element', '$timeout', '$q', '$uibModal',
'$log', '$templateCache', 'paletteApi', 'paletteDragAndDropService',
'iconGenerator', 'composerOverrides', 'recentlyUsedService', controller],
+ link: link,
};
}
+function link($scope, $element, attrs, controller) {
+ let main =
angular.element($element[0].querySelector(".catalog-palette-main"));
+
+ // repaginate when load completes (and items are shown), or it is
resized
+ $scope.$watchGroup(
+ [ () => $scope.isLoading, () => main[0].offsetHeight, () =>
$scope.state.viewMode.itemsPerRow ],
+ (values) => controller.$timeout( () => repaginate($scope,
$element) ) );
+ // also repaginate on window resize
+ angular.element(window).bind('resize', () => repaginate($scope,
$element));
+}
+
+function repaginate($scope, $element) {
+ let rowsPerPage = $scope.rowsPerPage;
+ if (!rowsPerPage) {
+ let main =
angular.element($element[0].querySelector(".catalog-palette-main"));
+ if (!main || main[0].offsetHeight==0) {
+ // console.log("no main or hidden or items per page fixed");
--- End diff --
Either removing this or use the `$log` service
---