You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by tb...@apache.org on 2018/11/09 13:26:44 UTC
[3/4] brooklyn-ui git commit: Update reference to dialog model and
blueprint service
Update reference to dialog model and blueprint service
Signed-off-by: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/d96318f9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/d96318f9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/d96318f9
Branch: refs/heads/master
Commit: d96318f923075850d951393728a9facc7ef24cd8
Parents: b669232
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Nov 9 11:48:04 2018 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Fri Nov 9 12:23:29 2018 +0000
----------------------------------------------------------------------
.../catalog-saver/catalog-saver.directive.js | 46 +++++++++-----------
1 file changed, 20 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d96318f9/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 c1042a9..be05fff 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
@@ -42,20 +42,20 @@ const TYPES = [
];
angular.module(MODULE_NAME, [angularAnimate, uibModal, brUtils])
- .directive('catalogSaver', ['$rootScope', '$uibModal', '$injector', 'composerOverrides', saveToCatalogModalDirective])
+ .directive('catalogSaver', ['$rootScope', '$uibModal', '$injector', 'composerOverrides', 'blueprintService', saveToCatalogModalDirective])
.directive('catalogVersion', ['$parse', catalogVersionDirective])
.run(['$templateCache', templateCache]);
export default MODULE_NAME;
-export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, composerOverrides) {
+export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, composerOverrides, blueprintService) {
return {
restrict: 'E',
templateUrl: function (tElement, tAttrs) {
return tAttrs.templateUrl || TEMPLATE_URL;
},
scope: {
- config: '='
+ config: '=',
},
link: link
};
@@ -64,44 +64,38 @@ export function saveToCatalogModalDirective($rootScope, $uibModal, $injector, co
$scope.buttonText = $scope.config.label || ($scope.config.itemType ? `Update ${$scope.config.name || $scope.config.symbolicName}` : 'Add to catalog');
$scope.activateModal = () => {
- function injectorGet(reference) { return $element.injector().get(reference); }
- let blueprintService = injectorGet('blueprintService');
-
let entity = blueprintService.get();
- let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : { };
- let config = $scope.$parent.$parent.vm.saveToCatalogConfig;
+ let metadata = blueprintService.entityHasMetadata(entity) ? blueprintService.getEntityMetadata(entity) : new Map();
// Reset the config values if this is not an update
- $scope.isUpdate = Object.keys($scope.config).length > 1;
+ $scope.isUpdate = Object.keys($scope.config).length > ($scope.config.label ? 1 : 0);
if (!$scope.isUpdate) {
- config = {
- itemType: 'entity',
- };
+ $scope.config.itemType = 'template';
}
// Set various properties from the blueprint entity data
- if (!config.version && (entity.hasVersion() || metadata.has('version'))) {
- config.version = entity.version || metadata.get('version');
+ if (!$scope.config.version && (entity.hasVersion() || metadata.has('version'))) {
+ $scope.config.version = entity.version || metadata.get('version');
}
- if (!config.iconUrl && (entity.hasIcon() || metadata.has('iconUrl'))) {
- config.iconUrl = entity.icon || metadata.get('iconUrl');
+ if (!$scope.config.iconUrl && (entity.hasIcon() || metadata.has('iconUrl'))) {
+ $scope.config.iconUrl = entity.icon || metadata.get('iconUrl');
}
- if (!config.name && entity.hasName()) {
- config.name = entity.name;
+ if (!$scope.config.name && entity.hasName()) {
+ $scope.config.name = entity.name;
}
- if (!config.symbolicName && (entity.hasId() || metadata.has('id'))) {
- config.symbolicName = entity.id || metadata.get('id');
+ if (!$scope.config.symbolicName && (entity.hasId() || metadata.has('id'))) {
+ $scope.config.symbolicName = entity.id || metadata.get('id');
}
- if (!config.bundle) {
- let bundle = config.symbolicName || config.name || 'untitled';
- config.bundle = bundle.split(/[^-a-zA-Z0-9.,_]+/).join('-').toLowerCase();
- if (!config.symbolicName) {
- config.symbolicName = bundle;
+ if (!$scope.config.bundle) {
+ let bundle = $scope.config.symbolicName || $scope.config.name || 'untitled';
+ $scope.config.bundle = bundle.split(/[^-a-zA-Z0-9._]+/).join('-').toLowerCase();
+ if (!$scope.config.symbolicName) {
+ $scope.config.symbolicName = $scope.config.bundle;
}
}
// Override this callback to update configuration data elsewhere
- $scope.config = (composerOverrides.updateCatalogConfig || ((config, $element) => config))(config, $element);
+ $scope.config = (composerOverrides.updateCatalogConfig || ((config, $element) => config))($scope.config, $element);
let modalInstance = $uibModal.open({
templateUrl: TEMPLATE_MODAL_URL,