Add script task component

This commit is contained in:
mauriziovitale84
2016-10-24 17:04:29 +01:00
parent 156f227ffb
commit da27437f13
9 changed files with 173 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
<diagram-task [data]="data"></diagram-task>
<diagram-icon-script-task [data]="data"></diagram-icon-script-task>

View File

@@ -0,0 +1,40 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { DiagramColorService } from './../services/diagram-color.service';
@Component({
moduleId: module.id,
selector: 'diagram-script-task',
templateUrl: './diagram-script-task.component.html',
styleUrls: ['./diagram-script-task.component.css']
})
export class DiagramScriptTaskComponent {
@Input()
data: any;
@Output()
onError = new EventEmitter();
constructor(public elementRef: ElementRef,
private diagramColorService: DiagramColorService) {}
ngOnInit() {
}
}

View File

@@ -28,6 +28,7 @@ import { DiagramRestCallTaskComponent } from './diagram-rest-call-task.component
import { DiagramGoogleDrivePublishTaskComponent } from './diagram-google-drive-publish-task.component';
import { DiagramBoxPublishTaskComponent } from './diagram-box-publish-task.component';
import { DiagramReceiveTaskComponent } from './diagram-receive-task.component';
import { DiagramScriptTaskComponent } from './diagram-script-task.component';
// primitives
export * from './diagram-container-service-task.component';
@@ -43,6 +44,7 @@ export * from './diagram-rest-call-task.component';
export * from './diagram-google-drive-publish-task.component';
export * from './diagram-box-publish-task.component';
export * from './diagram-receive-task.component';
export * from './diagram-script-task.component';
export const DIAGRAM_ACTIVITIES_DIRECTIVES: any[] = [
DiagramContainerServiceTaskComponent,
@@ -57,5 +59,6 @@ export const DIAGRAM_ACTIVITIES_DIRECTIVES: any[] = [
DiagramRestCallTaskComponent,
DiagramGoogleDrivePublishTaskComponent,
DiagramBoxPublishTaskComponent,
DiagramReceiveTaskComponent
DiagramReceiveTaskComponent,
DiagramScriptTaskComponent
];

View File

@@ -31,6 +31,9 @@
<div *ngSwitchCase="'ReceiveTask'">
<diagram-receive-task [data]="element"></diagram-receive-task>
</div>
<div *ngSwitchCase="'ScriptTask'">
<diagram-script-task [data]="element"></diagram-script-task>
</div>
</div>
</div>
<div *ngFor="let flow of diagram.flows">

View File

@@ -0,0 +1,2 @@
<raphael-icon-script [position]="position" [stroke]="options.stroke" [strokeWidth]="options.strokeWidth"
[fillColors]="options.fillColors" [fillOpacity]="options.fillOpacity"></raphael-icon-script>

View File

@@ -0,0 +1,46 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { DiagramColorService } from './../services/diagram-color.service';
@Component({
moduleId: module.id,
selector: 'diagram-icon-script-task',
templateUrl: './diagram-icon-script-task.component.html',
styleUrls: ['./diagram-icon-script-task.component.css']
})
export class DiagramIconScriptTaskComponent {
@Input()
data: any;
@Output()
onError = new EventEmitter();
position: any;
options: any = {stroke: '', fillColors: '', fillOpacity: '', strokeWidth: ''};
constructor(public elementRef: ElementRef,
private diagramColorService: DiagramColorService) {}
ngOnInit() {
this.position = {x: this.data.x + 4, y: this.data.y + 4};
this.options.stroke = 'none' ;
this.options.fillColors = '#72a7d0' ;
}
}

View File

@@ -26,6 +26,7 @@ import { DiagramIconRestCallTaskComponent } from './diagram-icon-rest-call-task.
import { DiagramIconGoogleDrivePublishTaskComponent } from './diagram-icon-google-drive-publish-task.component';
import { DiagramIconBoxPublishTaskComponent } from './diagram-icon-box-publish-task.component';
import { DiagramIconReceiveTaskComponent } from './diagram-icon-receive-task.component';
import { DiagramIconScriptTaskComponent } from './diagram-icon-script-task.component';
// primitives
export * from './diagram-icon-service-task.component';
@@ -39,6 +40,7 @@ export * from './diagram-icon-rest-call-task.component';
export * from './diagram-icon-google-drive-publish-task.component';
export * from './diagram-icon-box-publish-task.component';
export * from './diagram-icon-receive-task.component';
export * from './diagram-icon-script-task.component';
export const DIAGRAM_ICONS_DIRECTIVES: any[] = [
DiagramIconServiceTaskComponent,
@@ -51,5 +53,6 @@ export const DIAGRAM_ICONS_DIRECTIVES: any[] = [
DiagramIconRestCallTaskComponent,
DiagramIconGoogleDrivePublishTaskComponent,
DiagramIconBoxPublishTaskComponent,
DiagramIconReceiveTaskComponent
DiagramIconReceiveTaskComponent,
DiagramIconScriptTaskComponent
];

View File

@@ -26,6 +26,7 @@ import { RaphaelIconRestCallDirective } from './raphael-icon-rest-call.component
import { RaphaelIconGoogleDrivePublishDirective } from './raphael-icon-google-drive-publish.component';
import { RaphaelIconBoxPublishDirective } from './raphael-icon-box-publish.component';
import { RaphaelIconReceiveDirective } from './raphael-icon-receive.component';
import { RaphaelIconScriptDirective } from './raphael-icon-script.component';
// primitives
export * from './raphael-icon-service.component';
@@ -39,6 +40,7 @@ export * from './raphael-icon-rest-call.component';
export * from './raphael-icon-google-drive-publish.component';
export * from './raphael-icon-box-publish.component';
export * from './raphael-icon-receive.component';
export * from './raphael-icon-script.component';
export const RAPHAEL_ICONS_DIRECTIVES: any[] = [
RaphaelIconServiceDirective,
@@ -51,5 +53,6 @@ export const RAPHAEL_ICONS_DIRECTIVES: any[] = [
RaphaelIconRestCallDirective,
RaphaelIconGoogleDrivePublishDirective,
RaphaelIconBoxPublishDirective,
RaphaelIconReceiveDirective
RaphaelIconReceiveDirective,
RaphaelIconScriptDirective
];

View File

@@ -0,0 +1,68 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Directive, OnInit, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { Point } from './../models/point';
import { RaphaelBase } from './../raphael-base';
import { RaphaelService } from './../raphael.service';
@Directive({selector: 'raphael-icon-script'})
export class RaphaelIconScriptDirective extends RaphaelBase implements OnInit {
@Input()
paper: any;
@Input()
position: Point;
@Input()
text: string;
@Output()
onError = new EventEmitter();
@Input()
strokeWidth: number;
@Input()
fillColors: any;
@Input()
stroke: any;
@Input()
fillOpacity: any;
constructor(public elementRef: ElementRef,
raphaelService: RaphaelService) {
super(elementRef, raphaelService);
}
ngOnInit() {
console.log(this.elementRef);
this.draw(this.position);
}
public draw(position: Point) {
let path1 = this.paper.path(`m 5,2 0,0.094 c 0.23706,0.064 0.53189,0.1645 0.8125,0.375 0.5582,0.4186 1.05109,1.228 1.15625,2.5312
l 8.03125,0 1,0 1,0 c 0,-3 -2,-3 -2,-3 l -10,0 z M 4,3 4,13 2,13 c 0,3 2,3 2,3 l 9,0 c 0,0 2,0 2,-3 L 15,6 6,6 6,5.5 C 6,4.1111
5.5595,3.529 5.1875,3.25 4.8155,2.971 4.5,3 4.5,3 L 4,3 z`).attr({
'stroke': this.stroke,
'fill': this.fillColors
});
return path1.transform('T' + position.x + ',' + position.y);
}
}