From 55b06b518ca4c4bb671bedf0d8a1d3a4f9c65f6b Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Mon, 25 Nov 2019 15:41:45 +0530 Subject: Canvas features and Jointjs Integration Added Jointjs dependency to project and integrated editor bar to the designer canvas Issue-ID: CCSDK-1780 Change-Id: I8276469f76851be4f5b6ac765729304c68d04737 Signed-off-by: Arundathi Patil --- cds-ui/client-frankfurt/angular.json | 7 ++ cds-ui/client-frankfurt/package.json | 10 +- .../packages/designer/designer.component.css | 1 + .../packages/designer/designer.component.html | 2 +- .../packages/designer/designer.component.ts | 101 +++++++++++++++++++++ 5 files changed, 119 insertions(+), 2 deletions(-) (limited to 'cds-ui') diff --git a/cds-ui/client-frankfurt/angular.json b/cds-ui/client-frankfurt/angular.json index 97052b879..fafa6d775 100644 --- a/cds-ui/client-frankfurt/angular.json +++ b/cds-ui/client-frankfurt/angular.json @@ -28,10 +28,17 @@ "./node_modules/bootstrap/dist/css/bootstrap.min.css", "./node_modules/@angular/material/prebuilt-themes/purple-green.css", "./node_modules/font-awesome/css/font-awesome.css", + "./node_modules/jointjs/css/layout.css", + "./node_modules/jointjs/css/themes/material.css", + "./node_modules/jointjs/css/themes/default.css", "src/assets/css/orangeHelvetica.css" ], "scripts": [ + "./node_modules/jquery/dist/jquery.min.js", + "./node_modules/lodash/index.js", + "./node_modules/backbone/backbone.js", + "./node_modules/jointjs/dist/joint.js" ] }, "configurations": { diff --git a/cds-ui/client-frankfurt/package.json b/cds-ui/client-frankfurt/package.json index c1ba7ffec..c4fa1ab62 100644 --- a/cds-ui/client-frankfurt/package.json +++ b/cds-ui/client-frankfurt/package.json @@ -31,7 +31,11 @@ "ng-sidebar": "^9.1.1", "rxjs": "~6.4.0", "tslib": "^1.10.0", - "zone.js": "~0.9.1" + "zone.js": "~0.9.1", + "jquery": "^3.1.1", + "backbone": "^1.4.0", + "jointjs": "^3.0.4", + "lodash": "^3.10.1" }, "devDependencies": { "@angular-devkit/build-angular": "~0.803.9", @@ -41,6 +45,10 @@ "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", + "@types/backbone": "^1.4.1", + "@types/jointjs": "^2.0.0", + "@types/jquery": "^3.3.31", + "@types/lodash": "^3.10.1", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-marbles": "^0.6.0", diff --git a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.css b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.css index d41bf5222..36abc9329 100644 --- a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.css +++ b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.css @@ -344,6 +344,7 @@ p.compType-4{ background:#F4F9FE; border: solid 1px #E8EFF8; box-shadow: 0 2px 6px rgba(47, 83, 151, .1); + margin-left: 20em; } .editBar .btn-group{ box-shadow: 0 2px 6px rgba(47, 83, 151, .15); diff --git a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.html b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.html index 0d55439dd..991e126c0 100644 --- a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.html +++ b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/designer/designer.component.html @@ -126,7 +126,7 @@ -
+
', + '', + '
', + '
', + '', + '', + '', + '
', + '
', + '', + '', + '
', + '
', + '' + ].join(''), + + initialize: function() { + _.bindAll(this, 'updateBox'); + joint.dia.ElementView.prototype.initialize.apply(this, arguments); + + this.$box = $(_.template(this.template)()); + // Prevent paper from handling pointerdown. + this.$box.find('input,select').on('mousedown click', function(evt) { + evt.stopPropagation(); + }); + this.model.on('change', this.updateBox, this); + + this.updateBox(); + }, + render: function() { + joint.dia.ElementView.prototype.render.apply(this, arguments); + this.paper.$el.prepend(this.$box); + this.updateBox(); + return this; + }, + updateBox: function() { + // Set the position and dimension of the box so that it covers the JointJS element. + var bbox = this.model.getBBox(); + this.$box.css({ + width: bbox.width, + height: bbox.height, + left: bbox.x, + top: bbox.y, + transform: 'rotate(' + (this.model.get('angle') || 0) + 'deg)' + }); + } + }); + + var el1 = new joint.shapes["html"].Element({}); + this.graph.addCells([el1]); } + } -- cgit 1.2.3-korg