Repository: brooklyn-ui Updated Branches: refs/heads/master c2c63714d -> a359d463d
Add callback for customising catalog save configuration Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/39d3fbb3 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/39d3fbb3 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/39d3fbb3 Branch: refs/heads/master Commit: 39d3fbb3c7f1ba541eda014706767bb50823155d Parents: 88c36c3 Author: Andrew Donald Kennedy <[email protected]> Authored: Mon Oct 15 13:38:57 2018 +0100 Committer: Andrew Donald Kennedy <[email protected]> Committed: Wed Oct 24 14:02:52 2018 +0100 ---------------------------------------------------------------------- .../catalog-saver/catalog-saver.directive.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/39d3fbb3/ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js b/ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js index 5da6f77..cb6f0ea 100644 --- a/ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js +++ b/ui-modules/blueprint-composer/app/components/catalog-saver/catalog-saver.directive.js @@ -23,8 +23,11 @@ import template from './catalog-saver.template.html'; import modalTemplate from './catalog-saver.modal.template.html'; import jsYaml from 'js-yaml'; import brUtils from 'brooklyn-ui-utils/utils/general'; +import {yamlState} from "../../views/main/yaml/yaml.state"; +import {graphicalState} from "../../views/main/graphical/graphical.state"; const MODULE_NAME = 'brooklyn.components.catalog-saver'; + const REASONS = { new: 0, deploy: 1 @@ -39,12 +42,12 @@ const TYPES = [ ]; angular.module(MODULE_NAME, [angularAnimate, uibModal, brUtils]) - .directive('catalogSaver', ['$rootScope', '$uibModal', saveToCatalogModalDirective]) + .directive('catalogSaver', ['$rootScope', '$uibModal', '$injector', 'composerOverrides', saveToCatalogModalDirective]) .directive('catalogVersion', ['$parse', catalogVersionDirective]); export default MODULE_NAME; -export function saveToCatalogModalDirective($rootScope, $uibModal) { +export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, composerOverrides) { return { restrict: 'E', template: template, @@ -54,11 +57,17 @@ export function saveToCatalogModalDirective($rootScope, $uibModal) { link: link }; - function link($scope) { + function link($scope, $element) { $scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog'); + + $injector.get('$templateCache').put('catalog-saver.modal.template.html', modalTemplate); + $scope.activateModal = () => { + // Override callback to update catalog configuration data in other applications + $scope.config = (composerOverrides.updateCatalogConfig || (($scope, $element) => $scope.config))($scope, $element); + let modalInstance = $uibModal.open({ - template: modalTemplate, + templateUrl: 'catalog-saver.modal.template.html', size: 'save', controller: ['$scope', 'blueprintService', 'paletteApi', 'brUtilsGeneral', CatalogItemModalController], scope: $scope,
