|
1 | | -<cd-modal [modalRef]="activeModal"> |
2 | | - <ng-container i18n="form title" |
3 | | - class="modal-title">{{ action | titlecase }} {{ groupType | upperFirst }} Flow</ng-container> |
4 | | - |
5 | | - <ng-container class="modal-content"> |
6 | | - <form name="flowForm" |
7 | | - #frm="ngForm" |
8 | | - [formGroup]="currentFormGroupContext" |
9 | | - novalidate> |
10 | | - <div class="modal-body"> |
11 | | - <div class="form-group row"> |
12 | | - <label class="cd-col-form-label required" |
13 | | - for="flow_id" |
14 | | - i18n>Name</label> |
15 | | - <div class="cd-col-form-input"> |
16 | | - <input class="form-control" |
17 | | - type="text" |
18 | | - placeholder="Flow Name..." |
19 | | - id="flow_id" |
20 | | - name="flow_id" |
21 | | - formControlName="flow_id"/> |
22 | | - </div> |
23 | | - </div> |
24 | | - <div class="form-group row"> |
25 | | - <label class="cd-col-form-label" |
26 | | - for="bucket" |
27 | | - i18n>Bucket Name</label> |
28 | | - <div class="cd-col-form-input"> |
29 | | - <input id="bucket" |
30 | | - name="bucket" |
31 | | - class="form-control" |
32 | | - type="text" |
33 | | - i18n-placeholder |
34 | | - placeholder="Bucket Name..." |
35 | | - formControlName="bucket_name"/> |
36 | | - <span class="invalid-feedback" |
37 | | - *ngIf="currentFormGroupContext.showError('bucket_name', frm, 'bucketNameNotAllowed')" |
38 | | - i18n>The bucket with chosen name does not exist.</span> |
39 | | - </div> |
40 | | - </div> |
41 | | - <ng-container *ngIf="groupType == flowType.symmetrical; else directionalFlow"> |
42 | | - <div class="form-group row"> |
43 | | - <label class="cd-col-form-label required" |
44 | | - for="zones"> |
45 | | - <ng-container i18n>Zones</ng-container> |
46 | | - <cd-helper> |
47 | | - <span i18n>Flow need to be associated with atleast one zone</span> |
48 | | - </cd-helper> |
49 | | - </label> |
50 | | - <div class="cd-col-form-input"> |
51 | | - <ng-container *ngTemplateOutlet="zoneMultiSelect;context: { name: 'zones', zone: zones }"></ng-container> |
52 | | - </div> |
53 | | - </div> |
54 | | - </ng-container> |
55 | | - <ng-template #directionalFlow> |
56 | | - <div class="form-group row"> |
57 | | - <label class="cd-col-form-label required" |
58 | | - for="source_zone" |
59 | | - i18n>Source Zone |
60 | | - </label> |
61 | | - <div class="cd-col-form-input"> |
62 | | - <ng-container *ngTemplateOutlet="sourceAndDestZone;context: { name: 'source_zone', zones: zones }"></ng-container> |
63 | | - </div> |
64 | | - </div> |
65 | | - <div class="form-group row"> |
66 | | - <label class="cd-col-form-label required" |
67 | | - for="destination_zone" |
68 | | - i18n>Destination Zone</label> |
69 | | - <div class="cd-col-form-input"> |
70 | | - <ng-container *ngTemplateOutlet="sourceAndDestZone;context: { name: 'destination_zone', zones: zones }"></ng-container> |
71 | | - </div> |
72 | | - </div> |
| 1 | +<cds-modal size="sm" |
| 2 | + [open]="open"> |
| 3 | + <cds-modal-header (closeSelect)="closeModal()"> |
| 4 | + <h3 cdsModalHeaderHeading |
| 5 | + i18n>{{ action | titlecase }} {{ groupType }} flow</h3> |
| 6 | + <cd-help-text [formAllFieldsRequired]="true"></cd-help-text> |
| 7 | + </cds-modal-header> |
| 8 | + <form name="flowForm" |
| 9 | + #frm="ngForm" |
| 10 | + [formGroup]="currentFormGroupContext" |
| 11 | + novalidate> |
| 12 | + <div cdsModalContent> |
| 13 | + <!-- Flow Name--> |
| 14 | + <div class="form-item"> |
| 15 | + <cds-text-label for="flow_id" |
| 16 | + [invalid]="!currentFormGroupContext.controls.flow_id.valid && currentFormGroupContext.controls.flow_id.dirty" |
| 17 | + [invalidText]="flowIdError"> |
| 18 | + <ng-container i18n>Name</ng-container> |
| 19 | + <input cdsText |
| 20 | + type="text" |
| 21 | + id="flow_id" |
| 22 | + formControlName="flow_id" |
| 23 | + autofocus |
| 24 | + [invalid]="!currentFormGroupContext.controls.flow_id.valid && currentFormGroupContext.controls.flow_id.dirty"> |
| 25 | + </cds-text-label> |
| 26 | + <ng-template #flowIdError> |
| 27 | + @if (currentFormGroupContext.showError('flow_id', formDir, 'required')) { |
| 28 | + <span class="invalid-feedback"> |
| 29 | + <ng-container i18n> This field is required. </ng-container> |
| 30 | + </span> |
| 31 | + } |
73 | 32 | </ng-template> |
74 | 33 | </div> |
75 | | - <div class="modal-footer"> |
76 | | - <cd-form-button-panel (submitActionEvent)="submit()" |
77 | | - [form]="currentFormGroupContext" |
78 | | - [submitText]="(action | titlecase) + ' ' + (groupType | upperFirst) + ' ' + 'Flow'"></cd-form-button-panel> |
| 34 | + <!-- Bucket Name--> |
| 35 | + @if (currentFormGroupContext.controls.bucket_name.value) { |
| 36 | + <div class="form-item"> |
| 37 | + <cds-text-label for="bucket_name" |
| 38 | + cdOptionalField="Bucket name"> |
| 39 | + <ng-container i18n>Bucket name</ng-container> |
| 40 | + <input cdsText |
| 41 | + type="text" |
| 42 | + id="bucket_name" |
| 43 | + formControlName="bucket_name" |
| 44 | + [readOnly]="true"> |
| 45 | + </cds-text-label> |
79 | 46 | </div> |
80 | | - </form> |
81 | | - </ng-container> |
82 | | -</cd-modal> |
83 | | - |
84 | | -<ng-template #zoneMultiSelect |
85 | | - let-name="name" |
86 | | - let-zone="zone"> |
87 | | - <cd-select-badges [id]="name" |
88 | | - [name]="name" |
89 | | - [customBadges]="zone.customBadges" |
90 | | - [customBadgeValidators]="zone.data.validators" |
91 | | - [messages]="zone.data.messages" |
92 | | - [data]="zone.data.selected" |
93 | | - [options]="zone.data.available" |
94 | | - (selection)="zoneSelection()"> |
95 | | - </cd-select-badges> |
96 | | - |
97 | | - <svg *ngIf="zone.data.selected.length <= 0" |
98 | | - [cdsIcon]="icons.warning" |
99 | | - [size]="icons.size16" |
100 | | - title="Flow should be associated with {{name?.split('_').join(' ')}}" |
101 | | - class="cds-warning-color" |
102 | | - i18n-title></svg> |
103 | | - <span class="invalid-feedback" |
104 | | - *ngIf="currentFormGroupContext.showError(name, frm, 'required')" |
105 | | - i18n>{{name?.split('_').join(' ')}} selection is required! |
106 | | - </span> |
107 | | -</ng-template> |
| 47 | + } |
| 48 | + <!-- Symmetrical flow zones --> |
| 49 | + @if (groupType == flowType.symmetrical) { |
| 50 | + <div class="form-item"> |
| 51 | + <cds-combo-box label="Zones" |
| 52 | + type="multi" |
| 53 | + selectionFeedback="top-after-reopen" |
| 54 | + for="zones" |
| 55 | + formControlName="zones" |
| 56 | + [helperText]="'Flow need to be associated with atleast one zone'" |
| 57 | + i18n-helperText |
| 58 | + [appendInline]="true" |
| 59 | + [items]="zones" |
| 60 | + itemValueKey="content" |
| 61 | + id="zones" |
| 62 | + cdDynamicInputCombobox |
| 63 | + [invalid]="currentFormGroupContext.controls?.zones?.invalid && currentFormGroupContext.controls?.zones?.dirty" |
| 64 | + [invalidText]="'Zone selection is required!'" |
| 65 | + i18n> |
| 66 | + <cds-dropdown-list></cds-dropdown-list> |
| 67 | + </cds-combo-box> |
| 68 | + </div> |
| 69 | + } @else { |
| 70 | + <div class="form-item"> |
| 71 | + <ng-container *ngTemplateOutlet="sourceAndDestZone;context: { formControl: 'source_zone', zones: zones, name: 'Source zone' }"></ng-container> |
| 72 | + </div> |
| 73 | + <div class="form-item"> |
| 74 | + <ng-container *ngTemplateOutlet="sourceAndDestZone;context: { formControl: 'destination_zone', zones: zones, name: 'Destination zone' }"></ng-container> |
| 75 | + </div> |
| 76 | + } |
| 77 | + <!-- Directional flow zones --> |
| 78 | + </div> |
| 79 | + <cd-form-button-panel (submitActionEvent)="submit()" |
| 80 | + [form]="currentFormGroupContext" |
| 81 | + [modalForm]="true" |
| 82 | + [submitText]="(action | titlecase)"></cd-form-button-panel> |
| 83 | + </form> |
| 84 | +</cds-modal> |
108 | 85 |
|
109 | 86 | <ng-template #sourceAndDestZone |
110 | 87 | let-name="name" |
111 | | - let-zones="zones"> |
112 | | - <select [id]="name" |
113 | | - [name]="name" |
114 | | - class="form-select" |
115 | | - (change)="onChangeZoneDropdown(name, $event)" |
116 | | - [autofocus]="editing"> |
117 | | - <option i18n |
118 | | - *ngIf="zones.data.available.length == 0" |
119 | | - [ngValue]="null">Loading...</option> |
120 | | - <option i18n |
121 | | - *ngIf="zones.data.available.length > 0" |
122 | | - [ngValue]="null">-- Select {{name.split('_').join(' ')}} --</option> |
123 | | - <option *ngFor="let destinationZone of zones.data.available" |
124 | | - [value]="destinationZone.name">{{ destinationZone.name }}</option> |
125 | | - </select> |
126 | | - <span class="invalid-feedback" |
127 | | - *ngIf="currentFormGroupContext.showError(name, frm, 'required')" |
128 | | - i18n>This field is required.</span> |
| 88 | + let-zones="zones" |
| 89 | + let-formControl="formControl" |
| 90 | + [formGroup]="currentFormGroupContext"> |
| 91 | + <cds-select [label]="name" |
| 92 | + [formControlName]="formControl" |
| 93 | + [id]="formControl" |
| 94 | + [invalid]="currentFormGroupContext.controls[formControl].invalid && (currentFormGroupContext.controls[formControl].dirty)" |
| 95 | + [invalidText]="zoneError" |
| 96 | + i18n> |
| 97 | + @if (zones.length == 0) { |
| 98 | + <option [ngValue]="null">Loading...</option> |
| 99 | + } |
| 100 | + @if (zones.length > 0) { |
| 101 | + <option [ngValue]="null">-- Select {{name}} --</option> |
| 102 | + } |
| 103 | + @for (zone of zones; track zone) { |
| 104 | + <option [value]="zone.name">{{ zone.name }}</option> |
| 105 | + } |
| 106 | + </cds-select> |
| 107 | + <ng-template #zoneError> |
| 108 | + @if (currentFormGroupContext.showError(formControl, frm, 'required')) { |
| 109 | + <span class="invalid-feedback" |
| 110 | + i18n>This field is required.</span> |
| 111 | + } |
| 112 | + </ng-template> |
129 | 113 | </ng-template> |
0 commit comments