aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/service-path-creator/link-row
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/service-path-creator/link-row')
-rw-r--r--catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.html50
-rw-r--r--catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.ts35
2 files changed, 59 insertions, 26 deletions
diff --git a/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.html b/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.html
index bbbf6ae694..e029b7f1fa 100644
--- a/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.html
+++ b/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.html
@@ -1,5 +1,45 @@
-<ui-element-dropdown data-tests-id="linkSrc" [readonly]="!link.isFirst || (link.isFirst && !link.canEdit)" class="cell link-selector" [values]="source" [(value)]="link.fromNode" (valueChange)="onSourceSelected($event)"></ui-element-dropdown>
-<ui-element-dropdown data-tests-id="linkSrcCP" [readonly]="!link.isFirst || (link.isFirst && !link.canEdit)" class="cell link-selector" [values]="srcCP" [(value)]="link.fromCP" (valueChange)="onSrcCPSelected($event)"></ui-element-dropdown>
-<ui-element-dropdown data-tests-id="linkTarget" [readonly]="!link.canEdit" class="cell link-selector" [values]="target" [(value)]="link.toNode" (valueChange)="onTargetSelected($event)"></ui-element-dropdown>
-<ui-element-dropdown data-tests-id="linkTargetCP" [readonly]="!link.canEdit" class="cell link-selector" [values]="targetCP" [(value)]="link.toCP" (valueChange)="onTargetCPSelected($event)"></ui-element-dropdown>
-<div class="cell remove" data-tests-id="removeLnk"><span *ngIf="link.canRemove" class="sprite-new delete-item-icon" (click)="removeRow()"></span></div> \ No newline at end of file
+<ui-element-dropdown
+ data-tests-id="linkSrc"
+ [readonly]="!link.isFirst || (link.isFirst && !link.canEdit)"
+ class="cell link-selector"
+ [values]="source"
+ [(value)]="link.fromNode"
+ (valueChange)="onSourceSelected($event)">
+</ui-element-dropdown>
+
+<ui-element-dropdown
+ data-tests-id="linkSrcCP"
+ [readonly]="!link.isFirst || (link.isFirst && !link.canEdit)"
+ class="cell link-selector"
+ [values]="srcCP"
+ [(value)]="link.fromCP"
+ (valueChange)="onSrcCPSelected($event)">
+</ui-element-dropdown>
+
+<ui-element-dropdown
+ data-tests-id="linkTarget"
+ [readonly]="!link.canEdit"
+ class="cell link-selector"
+ [values]="target"
+ [(value)]="link.toNode"
+ (valueChange)="onTargetSelected($event)">
+</ui-element-dropdown>
+
+<ui-element-dropdown
+ data-tests-id="linkTargetCP"
+ [readonly]="!link.canEdit"
+ class="cell link-selector"
+ [values]="targetCP"
+ [(value)]="link.toCP"
+ (valueChange)="onTargetCPSelected($event)">
+</ui-element-dropdown>
+
+<div
+ class="cell remove"
+ data-tests-id="removeLnk">
+ <span
+ *ngIf="link.canRemove"
+ class="sprite-new delete-item-icon"
+ (click)="removeRow()">
+ </span>
+</div>
diff --git a/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.ts b/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.ts
index 16433242d6..e4fc1d4522 100644
--- a/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.ts
+++ b/catalog-ui/src/app/ng2/pages/service-path-creator/link-row/link-row.component.ts
@@ -14,7 +14,7 @@ export class LinkRowComponent {
@Input() data:Array<ServicePathMapItem>;
@Input() link:Link;
@Input() removeRow:Function;
- source:Array<DropdownValue> = [];
+ source: Array<DropdownValue> = [];
target: Array<DropdownValue> = [];
srcCP: Array<DropdownValue> = [];
targetCP: Array<DropdownValue> = [];
@@ -32,11 +32,9 @@ export class LinkRowComponent {
if (!srcCPOptions) { return; }
this.srcCP = this.convertValuesToDropDownOptions(srcCPOptions);
if (this.link.fromCP) {
- let targetOptions = this.findOptions(srcCPOptions, this.link.fromCP);
- if (!targetOptions) { return; }
- this.target = this.convertValuesToDropDownOptions(targetOptions);
+ this.target = this.convertValuesToDropDownOptions(data);
if (this.link.toNode) {
- let targetCPOptions = this.findOptions(targetOptions, this.link.toNode);
+ let targetCPOptions = this.findOptions(data, this.link.toNode);
if (!targetCPOptions) { return; }
this.targetCP = this.convertValuesToDropDownOptions(targetCPOptions);
}
@@ -45,7 +43,7 @@ export class LinkRowComponent {
}
private findOptions(items: Array<ServicePathMapItem>, nodeOrCPId: string) {
- let item = items.find((dataItem)=> nodeOrCPId === dataItem.id);
+ let item = _.find(items, (dataItem) => nodeOrCPId === dataItem.id);
if (item && item.data && item.data.options) {
return item.data.options;
}
@@ -53,12 +51,12 @@ export class LinkRowComponent {
return null;
}
- private convertValuesToDropDownOptions(values: Array<ServicePathMapItem>) : Array<DropdownValue> {
- let result = [];
+ private convertValuesToDropDownOptions(values: Array<ServicePathMapItem>): Array<DropdownValue> {
+ let result:Array<DropdownValue> = [];
for (let i = 0; i < values.length ; i++) {
result[result.length] = new DropdownValue(values[i].id, values[i].data.name);
}
- return result;
+ return result.sort((a, b) => a.label.localeCompare(b.label));
}
onSourceSelected(id) {
@@ -75,10 +73,9 @@ export class LinkRowComponent {
onSrcCPSelected (id) {
if (id) {
- let srcCPData = this.data.find((dataItem)=> this.link.fromNode === dataItem.id).data;
- let srcCPOptions = srcCPData.options;
- let targetOptions = this.findOptions(srcCPOptions, id);
- this.target = this.convertValuesToDropDownOptions(targetOptions);
+ let srcCPOptions = this.findOptions(this.data, this.link.fromNode);
+ let srcCPData = srcCPOptions.find(option => id === option.id).data;
+ this.target = this.convertValuesToDropDownOptions(this.data);
this.link.fromCPOriginId = srcCPData.ownerId;
this.link.toNode = '';
this.link.toCP = '';
@@ -89,9 +86,7 @@ export class LinkRowComponent {
onTargetSelected(id) {
if (id) {
- let srcCPOptions = this.findOptions(this.data, this.link.fromNode);
- let targetOptions = this.findOptions(srcCPOptions, this.link.fromCP);
- let targetCPOptions = this.findOptions(targetOptions, id);
+ let targetCPOptions = this.findOptions(this.data, id);
this.targetCP = this.convertValuesToDropDownOptions(targetCPOptions);
this.link.toCP = '';
}
@@ -100,11 +95,9 @@ export class LinkRowComponent {
onTargetCPSelected(id) {
if (id) {
- let srcCPOptions = this.findOptions(this.data, this.link.fromNode);
- let targetOptions = this.findOptions(srcCPOptions, this.link.fromCP);
- let targetCPOptions = this.findOptions(targetOptions, this.link.toNode);
- let targetCPDataObj = targetCPOptions.find((dataItem)=> id === dataItem.id).data;
+ let targetCPOptions = this.findOptions(this.data, this.link.toNode);
+ let targetCPDataObj = targetCPOptions.find(option => id === option.id).data;
this.link.toCPOriginId = targetCPDataObj.ownerId;
}
}
-} \ No newline at end of file
+}