@gravitee/ui-particles-angular 13.1.5 → 13.1.6-gio-el-editor-7a2794c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/gio-el/gio-el-editor/gio-el-editor-condition-group/gio-el-editor-condition-group.component.mjs +128 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-editor-condition-group/gio-el-editor-condition-group.harness.mjs +159 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-editor.component.mjs +128 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-editor.harness.mjs +25 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-boolean/gio-el-editor-type-boolean.component.mjs +58 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-boolean/gio-el-editor-type-boolean.harness.mjs +31 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-date/gio-el-editor-type-date.component.mjs +75 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-date/gio-el-editor-type-date.harness.mjs +29 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-number/gio-el-editor-type-number.component.mjs +71 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-number/gio-el-editor-type-number.harness.mjs +29 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-string/gio-el-editor-type-string.component.mjs +74 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-string/gio-el-editor-type-string.harness.mjs +29 -0
- package/esm2022/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type.harness.mjs +38 -0
- package/esm2022/gio-el/gravitee-ui-particles-angular-gio-el.mjs +5 -0
- package/esm2022/gio-el/models/Condition.mjs +9 -0
- package/esm2022/gio-el/models/ConditionGroup.mjs +7 -0
- package/esm2022/gio-el/models/ConditionModel.mjs +2 -0
- package/esm2022/gio-el/models/ConditionsModel.mjs +4 -0
- package/esm2022/gio-el/models/ExpressionLanguageBuilder.mjs +79 -0
- package/esm2022/gio-el/models/Operator.mjs +2 -0
- package/esm2022/gio-el/models/public-api.mjs +21 -0
- package/esm2022/gio-el/public-api.mjs +19 -0
- package/esm2022/lib/oem-theme/gio-submenu/gio-submenu.component.mjs +2 -1
- package/fesm2022/gravitee-ui-particles-angular-gio-el.mjs +921 -0
- package/fesm2022/gravitee-ui-particles-angular-gio-el.mjs.map +1 -0
- package/fesm2022/gravitee-ui-particles-angular.mjs +1 -0
- package/fesm2022/gravitee-ui-particles-angular.mjs.map +1 -1
- package/gio-el/gio-el-editor/gio-el-editor-condition-group/gio-el-editor-condition-group.component.d.ts +25 -0
- package/gio-el/gio-el-editor/gio-el-editor-condition-group/gio-el-editor-condition-group.harness.d.ts +32 -0
- package/gio-el/gio-el-editor/gio-el-editor.component.d.ts +26 -0
- package/gio-el/gio-el-editor/gio-el-editor.harness.d.ts +6 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-boolean/gio-el-editor-type-boolean.component.d.ts +15 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-boolean/gio-el-editor-type-boolean.harness.d.ts +6 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-date/gio-el-editor-type-date.component.d.ts +17 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-date/gio-el-editor-type-date.harness.d.ts +6 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-number/gio-el-editor-type-number.component.d.ts +17 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-number/gio-el-editor-type-number.harness.d.ts +6 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-string/gio-el-editor-type-string.component.d.ts +18 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type-string/gio-el-editor-type-string.harness.d.ts +6 -0
- package/gio-el/gio-el-editor/gio-el-type/gio-el-editor-type.harness.d.ts +10 -0
- package/gio-el/index.d.ts +5 -0
- package/gio-el/models/Condition.d.ts +10 -0
- package/gio-el/models/ConditionGroup.d.ts +6 -0
- package/gio-el/models/ConditionModel.d.ts +15 -0
- package/gio-el/models/ConditionsModel.d.ts +8 -0
- package/gio-el/models/ExpressionLanguageBuilder.d.ts +11 -0
- package/gio-el/models/Operator.d.ts +1 -0
- package/gio-el/models/public-api.d.ts +5 -0
- package/gio-el/public-api.d.ts +3 -0
- package/package.json +7 -1
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DestroyRef, Component, Input, EventEmitter, HostBinding, Output, ChangeDetectionStrategy } from '@angular/core';
|
|
3
|
+
import * as i7$1 from '@angular/material/button-toggle';
|
|
4
|
+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
5
|
+
import * as i6 from '@angular/forms';
|
|
6
|
+
import { FormControl, ReactiveFormsModule, FormGroup, Validators, FormArray } from '@angular/forms';
|
|
7
|
+
import * as i6$2 from '@angular/material/button';
|
|
8
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
9
|
+
import * as i8 from '@angular/material/menu';
|
|
10
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
11
|
+
import * as i1$1 from '@angular/material/form-field';
|
|
12
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
13
|
+
import * as i5 from '@angular/material/input';
|
|
14
|
+
import { MatInputModule } from '@angular/material/input';
|
|
15
|
+
import * as i1 from '@angular/common';
|
|
16
|
+
import { CommonModule } from '@angular/common';
|
|
17
|
+
import * as i3 from '@angular/material/select';
|
|
18
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
19
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
20
|
+
import { startWith, map } from 'rxjs/operators';
|
|
21
|
+
import { isEmpty, toString, isDate, isNil, has } from 'lodash';
|
|
22
|
+
import { GioIconsModule } from '@gravitee/ui-particles-angular';
|
|
23
|
+
import * as i7 from '@angular/material/autocomplete';
|
|
24
|
+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
25
|
+
import { Observable } from 'rxjs';
|
|
26
|
+
import * as i4 from '@angular/material/core';
|
|
27
|
+
import { MatSlideToggle } from '@angular/material/slide-toggle';
|
|
28
|
+
import * as i6$1 from '@angular/material/datepicker';
|
|
29
|
+
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
30
|
+
import * as i9 from '@angular/material/icon';
|
|
31
|
+
import { ComponentHarness, parallel, HarnessPredicate } from '@angular/cdk/testing';
|
|
32
|
+
import { MatMenuHarness } from '@angular/material/menu/testing';
|
|
33
|
+
import { MatSelectHarness } from '@angular/material/select/testing';
|
|
34
|
+
import { MatButtonToggleGroupHarness } from '@angular/material/button-toggle/testing';
|
|
35
|
+
import { DivHarness } from '@gravitee/ui-particles-angular/testing';
|
|
36
|
+
import { MatSlideToggleHarness } from '@angular/material/slide-toggle/testing';
|
|
37
|
+
import { MatInputHarness } from '@angular/material/input/testing';
|
|
38
|
+
import { MatDatepickerInputHarness } from '@angular/material/datepicker/testing';
|
|
39
|
+
|
|
40
|
+
const isConditionModel = (conditions) => {
|
|
41
|
+
return 'field' in conditions && 'label' in conditions && 'type' in conditions;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class ConditionGroup {
|
|
45
|
+
constructor(condition, conditions) {
|
|
46
|
+
this.condition = condition;
|
|
47
|
+
this.conditions = conditions;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
53
|
+
*
|
|
54
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
55
|
+
* you may not use this file except in compliance with the License.
|
|
56
|
+
* You may obtain a copy of the License at
|
|
57
|
+
*
|
|
58
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
59
|
+
*
|
|
60
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
61
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
62
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
63
|
+
* See the License for the specific language governing permissions and
|
|
64
|
+
* limitations under the License.
|
|
65
|
+
*/
|
|
66
|
+
class ExpressionLanguageBuilder {
|
|
67
|
+
static { this.CONDITION_MAP = {
|
|
68
|
+
OR: '||',
|
|
69
|
+
AND: '&&',
|
|
70
|
+
}; }
|
|
71
|
+
static { this.OPERATOR_MAP = {
|
|
72
|
+
EQUALS: (field, value) => `#${field} == ${value}`,
|
|
73
|
+
NOT_EQUALS: (field, value) => `#${field} != ${value}`,
|
|
74
|
+
LESS_THAN: (field, value) => `#${field} < ${value}`,
|
|
75
|
+
LESS_THAN_OR_EQUALS: (field, value) => `#${field} <= ${value}`,
|
|
76
|
+
GREATER_THAN: (field, value) => `#${field} > ${value}`,
|
|
77
|
+
GREATER_THAN_OR_EQUALS: (field, value) => `#${field} >= ${value}`,
|
|
78
|
+
CONTAINS: (field, value) => `#${field} matches "${value}"`,
|
|
79
|
+
NOT_CONTAINS: (field, value) => `!#${field} matches "${value}"`,
|
|
80
|
+
STARTS_WITH: (field, value) => `#${field} matches "^${value}"`,
|
|
81
|
+
ENDS_WITH: (field, value) => `#${field} matches "${value}$"`,
|
|
82
|
+
}; }
|
|
83
|
+
static buildConditionGroup(conditionGroup) {
|
|
84
|
+
let el = '';
|
|
85
|
+
for (const condition of conditionGroup.conditions) {
|
|
86
|
+
if (condition instanceof ConditionGroup) {
|
|
87
|
+
el += '( ';
|
|
88
|
+
el += ExpressionLanguageBuilder.buildConditionGroup(condition);
|
|
89
|
+
el += ' )';
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
el += ExpressionLanguageBuilder.buildCondition(condition);
|
|
93
|
+
}
|
|
94
|
+
if (condition !== conditionGroup.conditions[conditionGroup.conditions.length - 1]) {
|
|
95
|
+
el += ` ${ExpressionLanguageBuilder.CONDITION_MAP[conditionGroup.condition]} `;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (el === '') {
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
return el;
|
|
102
|
+
}
|
|
103
|
+
static buildCondition(condition) {
|
|
104
|
+
const operator = ExpressionLanguageBuilder.OPERATOR_MAP[condition.operator];
|
|
105
|
+
return operator(condition.field, ExpressionLanguageBuilder.valueToString(condition.type, condition.value));
|
|
106
|
+
}
|
|
107
|
+
static valueToString(type, value) {
|
|
108
|
+
if (!type) {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
switch (type) {
|
|
112
|
+
case 'string':
|
|
113
|
+
return `"${value}"`;
|
|
114
|
+
case 'date':
|
|
115
|
+
return `${value.getTime()}l`;
|
|
116
|
+
default:
|
|
117
|
+
return `${value}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
constructor(conditionGroup) {
|
|
121
|
+
this.conditionGroup = conditionGroup;
|
|
122
|
+
}
|
|
123
|
+
build() {
|
|
124
|
+
const el = ExpressionLanguageBuilder.buildConditionGroup(this.conditionGroup);
|
|
125
|
+
return `{ ${el} }`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
class Condition {
|
|
130
|
+
constructor(field, type, operator, value) {
|
|
131
|
+
this.field = field;
|
|
132
|
+
this.type = type;
|
|
133
|
+
this.operator = operator;
|
|
134
|
+
this.value = value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
140
|
+
*
|
|
141
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
142
|
+
* you may not use this file except in compliance with the License.
|
|
143
|
+
* You may obtain a copy of the License at
|
|
144
|
+
*
|
|
145
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
146
|
+
*
|
|
147
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
148
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
149
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
150
|
+
* See the License for the specific language governing permissions and
|
|
151
|
+
* limitations under the License.
|
|
152
|
+
*/
|
|
153
|
+
class GioElEditorTypeStringComponent {
|
|
154
|
+
constructor() {
|
|
155
|
+
this.destroyRef = inject(DestroyRef);
|
|
156
|
+
this.operators = [
|
|
157
|
+
{ label: 'Equals', value: 'EQUALS' },
|
|
158
|
+
{ label: 'Not equals', value: 'NOT_EQUALS' },
|
|
159
|
+
];
|
|
160
|
+
this.filteredOptions$ = new Observable();
|
|
161
|
+
}
|
|
162
|
+
ngOnChanges(changes) {
|
|
163
|
+
if (changes.conditionFormGroup) {
|
|
164
|
+
const field = this.conditionFormGroup.controls.field.value;
|
|
165
|
+
if (isEmpty(field) || field?.type !== 'string') {
|
|
166
|
+
throw new Error('String field is required!');
|
|
167
|
+
}
|
|
168
|
+
this.conditionFormGroup.addControl('operator', new FormControl(null));
|
|
169
|
+
this.conditionFormGroup.addControl('value', new FormControl(null));
|
|
170
|
+
const values = field.values;
|
|
171
|
+
if (values && !isEmpty(values)) {
|
|
172
|
+
this.filteredOptions$ = this.conditionFormGroup.get('value').valueChanges.pipe(takeUntilDestroyed(this.destroyRef), startWith(''), map(value => filterValues(values, toString(value) ?? '')));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeStringComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
177
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorTypeStringComponent, isStandalone: true, selector: "gio-el-editor-type-string", inputs: { conditionFormGroup: "conditionFormGroup" }, usesOnChanges: true, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Value</mat-label>\n <input matInput formControlName=\"value\" placeholder=\"Value\" [matAutocomplete]=\"auto\" />\n\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n @for (option of filteredOptions$ | async; track option) {\n <mat-option [value]=\"option\">{{ option }}</mat-option>\n }\n </mat-autocomplete>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatAutocompleteModule }, { kind: "component", type: i7.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i7.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }] }); }
|
|
178
|
+
}
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeStringComponent, decorators: [{
|
|
180
|
+
type: Component,
|
|
181
|
+
args: [{ selector: 'gio-el-editor-type-string', standalone: true, imports: [CommonModule, MatFormFieldModule, MatSelectModule, MatInputModule, ReactiveFormsModule, MatAutocompleteModule], template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Value</mat-label>\n <input matInput formControlName=\"value\" placeholder=\"Value\" [matAutocomplete]=\"auto\" />\n\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n @for (option of filteredOptions$ | async; track option) {\n <mat-option [value]=\"option\">{{ option }}</mat-option>\n }\n </mat-autocomplete>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}\n"] }]
|
|
182
|
+
}], propDecorators: { conditionFormGroup: [{
|
|
183
|
+
type: Input,
|
|
184
|
+
args: [{
|
|
185
|
+
required: true,
|
|
186
|
+
}]
|
|
187
|
+
}] } });
|
|
188
|
+
const filterValues = (values, value) => {
|
|
189
|
+
const filterValue = value.toLowerCase();
|
|
190
|
+
return values.filter(option => option.toLowerCase().includes(filterValue));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
195
|
+
*
|
|
196
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
+
* you may not use this file except in compliance with the License.
|
|
198
|
+
* You may obtain a copy of the License at
|
|
199
|
+
*
|
|
200
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
+
*
|
|
202
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
203
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
+
* See the License for the specific language governing permissions and
|
|
206
|
+
* limitations under the License.
|
|
207
|
+
*/
|
|
208
|
+
class GioElEditorTypeBooleanComponent {
|
|
209
|
+
constructor() {
|
|
210
|
+
this.operators = [
|
|
211
|
+
{ label: 'Equals', value: 'EQUALS' },
|
|
212
|
+
{ label: 'Not equals', value: 'NOT_EQUALS' },
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
ngOnChanges(changes) {
|
|
216
|
+
if (changes.conditionFormGroup) {
|
|
217
|
+
const field = this.conditionFormGroup.controls.field.value;
|
|
218
|
+
if (isEmpty(field) || field?.type !== 'boolean') {
|
|
219
|
+
throw new Error('Boolean field is required!');
|
|
220
|
+
}
|
|
221
|
+
this.conditionFormGroup.addControl('operator', new FormControl(null));
|
|
222
|
+
this.conditionFormGroup.addControl('value', new FormControl(null));
|
|
223
|
+
this.conditionFormGroup.get('value')?.setValue(true);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeBooleanComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
227
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorTypeBooleanComponent, isStandalone: true, selector: "gio-el-editor-type-boolean", inputs: { conditionFormGroup: "conditionFormGroup" }, usesOnChanges: true, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-slide-toggle class=\"toggle\" #valueToggle formControlName=\"value\">\n <mat-label>{{ valueToggle.checked ? 'True' : 'False' }}</mat-label>\n </mat-slide-toggle>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;align-self:center;margin-left:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: MatSlideToggle, selector: "mat-slide-toggle", inputs: ["name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "color", "disabled", "disableRipple", "tabIndex", "checked", "hideIcon", "disabledInteractive"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }] }); }
|
|
228
|
+
}
|
|
229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeBooleanComponent, decorators: [{
|
|
230
|
+
type: Component,
|
|
231
|
+
args: [{ selector: 'gio-el-editor-type-boolean', standalone: true, imports: [CommonModule, MatFormFieldModule, MatSelectModule, ReactiveFormsModule, MatSlideToggle], template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-slide-toggle class=\"toggle\" #valueToggle formControlName=\"value\">\n <mat-label>{{ valueToggle.checked ? 'True' : 'False' }}</mat-label>\n </mat-slide-toggle>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;align-self:center;margin-left:8px}\n"] }]
|
|
232
|
+
}], propDecorators: { conditionFormGroup: [{
|
|
233
|
+
type: Input,
|
|
234
|
+
args: [{
|
|
235
|
+
required: true,
|
|
236
|
+
}]
|
|
237
|
+
}] } });
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
241
|
+
*
|
|
242
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
243
|
+
* you may not use this file except in compliance with the License.
|
|
244
|
+
* You may obtain a copy of the License at
|
|
245
|
+
*
|
|
246
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
247
|
+
*
|
|
248
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
249
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
250
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
251
|
+
* See the License for the specific language governing permissions and
|
|
252
|
+
* limitations under the License.
|
|
253
|
+
*/
|
|
254
|
+
class GioElEditorTypeNumberComponent {
|
|
255
|
+
constructor() {
|
|
256
|
+
this.operators = [
|
|
257
|
+
{ label: 'Equals', value: 'EQUALS' },
|
|
258
|
+
{ label: 'Not equals', value: 'NOT_EQUALS' },
|
|
259
|
+
{ label: 'Less than', value: 'LESS_THAN' },
|
|
260
|
+
{ label: 'Less than or equals', value: 'LESS_THAN_OR_EQUALS' },
|
|
261
|
+
{ label: 'Greater than', value: 'GREATER_THAN' },
|
|
262
|
+
{ label: 'Greater than or equals', value: 'GREATER_THAN_OR_EQUALS' },
|
|
263
|
+
];
|
|
264
|
+
this.min = null;
|
|
265
|
+
this.max = null;
|
|
266
|
+
}
|
|
267
|
+
ngOnChanges(changes) {
|
|
268
|
+
if (changes.conditionFormGroup) {
|
|
269
|
+
const field = this.conditionFormGroup.controls.field.value;
|
|
270
|
+
if (isEmpty(field) || field?.type !== 'number') {
|
|
271
|
+
throw new Error('Number field is required!');
|
|
272
|
+
}
|
|
273
|
+
if (field.min) {
|
|
274
|
+
this.min = field.min;
|
|
275
|
+
}
|
|
276
|
+
if (field.max) {
|
|
277
|
+
this.max = field.max;
|
|
278
|
+
}
|
|
279
|
+
this.conditionFormGroup.addControl('operator', new FormControl(null));
|
|
280
|
+
this.conditionFormGroup.addControl('value', new FormControl(true));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeNumberComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
284
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorTypeNumberComponent, isStandalone: true, selector: "gio-el-editor-type-number", inputs: { conditionFormGroup: "conditionFormGroup" }, usesOnChanges: true, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Value</mat-label>\n <input matInput formControlName=\"value\" placeholder=\"Value\" type=\"number\" [min]=\"min\" [max]=\"max\" />\n <mat-error *ngIf=\"conditionFormGroup.get('value')?.hasError('min')\"> Value must be at least {{ min }} </mat-error>\n <mat-error *ngIf=\"conditionFormGroup.get('value')?.hasError('max')\"> Value must be at most {{ max }} </mat-error>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;margin-left:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i1$1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i6.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i6.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }] }); }
|
|
285
|
+
}
|
|
286
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeNumberComponent, decorators: [{
|
|
287
|
+
type: Component,
|
|
288
|
+
args: [{ selector: 'gio-el-editor-type-number', standalone: true, imports: [CommonModule, MatFormFieldModule, MatSelectModule, MatInputModule, ReactiveFormsModule], template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Value</mat-label>\n <input matInput formControlName=\"value\" placeholder=\"Value\" type=\"number\" [min]=\"min\" [max]=\"max\" />\n <mat-error *ngIf=\"conditionFormGroup.get('value')?.hasError('min')\"> Value must be at least {{ min }} </mat-error>\n <mat-error *ngIf=\"conditionFormGroup.get('value')?.hasError('max')\"> Value must be at most {{ max }} </mat-error>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;margin-left:8px}\n"] }]
|
|
289
|
+
}], propDecorators: { conditionFormGroup: [{
|
|
290
|
+
type: Input,
|
|
291
|
+
args: [{
|
|
292
|
+
required: true,
|
|
293
|
+
}]
|
|
294
|
+
}] } });
|
|
295
|
+
|
|
296
|
+
/*
|
|
297
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
298
|
+
*
|
|
299
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
300
|
+
* you may not use this file except in compliance with the License.
|
|
301
|
+
* You may obtain a copy of the License at
|
|
302
|
+
*
|
|
303
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
304
|
+
*
|
|
305
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
306
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
307
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
308
|
+
* See the License for the specific language governing permissions and
|
|
309
|
+
* limitations under the License.
|
|
310
|
+
*/
|
|
311
|
+
class GioElEditorTypeDateComponent {
|
|
312
|
+
constructor() {
|
|
313
|
+
this.destroyRef = inject(DestroyRef);
|
|
314
|
+
this.operators = [
|
|
315
|
+
{ label: 'Equals', value: 'EQUALS' },
|
|
316
|
+
{ label: 'Not equals', value: 'NOT_EQUALS' },
|
|
317
|
+
{ label: 'Less than', value: 'LESS_THAN' },
|
|
318
|
+
{ label: 'Less than or equals', value: 'LESS_THAN_OR_EQUALS' },
|
|
319
|
+
{ label: 'Greater than', value: 'GREATER_THAN' },
|
|
320
|
+
{ label: 'Greater than or equals', value: 'GREATER_THAN_OR_EQUALS' },
|
|
321
|
+
];
|
|
322
|
+
this.datepickerControl = new FormControl();
|
|
323
|
+
}
|
|
324
|
+
ngOnChanges(changes) {
|
|
325
|
+
if (changes.conditionFormGroup) {
|
|
326
|
+
const field = this.conditionFormGroup.controls.field.value;
|
|
327
|
+
if (isEmpty(field) || field?.type !== 'date') {
|
|
328
|
+
throw new Error('Date field is required!');
|
|
329
|
+
}
|
|
330
|
+
this.conditionFormGroup.addControl('operator', new FormControl(null));
|
|
331
|
+
this.conditionFormGroup.addControl('value', new FormControl(true));
|
|
332
|
+
this.datepickerControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => {
|
|
333
|
+
if (!isDate(value)) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
// Convert date to UTC ignoring timezone
|
|
337
|
+
const dateUtc = Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds());
|
|
338
|
+
this.conditionFormGroup.controls.value.setValue(new Date(dateUtc));
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeDateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
343
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorTypeDateComponent, isStandalone: true, selector: "gio-el-editor-type-date", inputs: { conditionFormGroup: "conditionFormGroup" }, usesOnChanges: true, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Choose a date</mat-label>\n <input matInput [matDatepicker]=\"picker\" [formControl]=\"datepickerControl\" />\n <mat-hint>MM/DD/YYYY</mat-hint>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;margin-left:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i1$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i1$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i6.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i6$1.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i6$1.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i6$1.MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }] }); }
|
|
344
|
+
}
|
|
345
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorTypeDateComponent, decorators: [{
|
|
346
|
+
type: Component,
|
|
347
|
+
args: [{ selector: 'gio-el-editor-type-date', standalone: true, imports: [CommonModule, MatFormFieldModule, MatSelectModule, MatInputModule, ReactiveFormsModule, MatDatepickerModule], template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n@if (conditionFormGroup) {\n <div [formGroup]=\"conditionFormGroup\" class=\"condition\">\n <mat-form-field>\n <mat-label>Operator</mat-label>\n\n <mat-select formControlName=\"operator\" placeholder=\"Select Operator\">\n @for (operator of operators; track operator.value) {\n <mat-option [value]=\"operator.value\">{{ operator.label }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field>\n <mat-label>Choose a date</mat-label>\n <input matInput [matDatepicker]=\"picker\" [formControl]=\"datepickerControl\" />\n <mat-hint>MM/DD/YYYY</mat-hint>\n <mat-datepicker-toggle matIconSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n </div>\n}\n", styles: [".condition{display:flex;flex-direction:row;align-items:flex-start;gap:8px}.toggle{min-width:80px;margin-left:8px}\n"] }]
|
|
348
|
+
}], propDecorators: { conditionFormGroup: [{
|
|
349
|
+
type: Input,
|
|
350
|
+
args: [{
|
|
351
|
+
required: true,
|
|
352
|
+
}]
|
|
353
|
+
}] } });
|
|
354
|
+
|
|
355
|
+
/*
|
|
356
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
357
|
+
*
|
|
358
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
359
|
+
* you may not use this file except in compliance with the License.
|
|
360
|
+
* You may obtain a copy of the License at
|
|
361
|
+
*
|
|
362
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
363
|
+
*
|
|
364
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
365
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
366
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
367
|
+
* See the License for the specific language governing permissions and
|
|
368
|
+
* limitations under the License.
|
|
369
|
+
*/
|
|
370
|
+
class GioElEditorConditionGroupComponent {
|
|
371
|
+
constructor() {
|
|
372
|
+
/**
|
|
373
|
+
* Condition models to generate the fields for the conditions.
|
|
374
|
+
*/
|
|
375
|
+
this.conditionModels = [];
|
|
376
|
+
/**
|
|
377
|
+
* Level of the node in the tree. Useful for testing with Harness to limit the scope of the query.
|
|
378
|
+
*/
|
|
379
|
+
this.nodeLvl = 0;
|
|
380
|
+
this.remove = new EventEmitter();
|
|
381
|
+
}
|
|
382
|
+
addConditionGroup() {
|
|
383
|
+
this.conditionGroupFormGroup.controls.conditions.push(newConditionGroupFormGroup$1(), { emitEvent: true });
|
|
384
|
+
this.checkMultipleCondition();
|
|
385
|
+
}
|
|
386
|
+
addCondition() {
|
|
387
|
+
this.conditionGroupFormGroup.controls.conditions.push(newConditionFormGroup());
|
|
388
|
+
this.checkMultipleCondition();
|
|
389
|
+
}
|
|
390
|
+
removeCondition(conditionIndex) {
|
|
391
|
+
this.conditionGroupFormGroup.controls.conditions.removeAt(conditionIndex);
|
|
392
|
+
this.checkMultipleCondition();
|
|
393
|
+
}
|
|
394
|
+
removeConditionGroup() {
|
|
395
|
+
this.remove.emit();
|
|
396
|
+
this.checkMultipleCondition();
|
|
397
|
+
}
|
|
398
|
+
isConditionGroupForm(formGroup) {
|
|
399
|
+
return 'condition' in formGroup.controls && 'conditions' in formGroup.controls;
|
|
400
|
+
}
|
|
401
|
+
checkMultipleCondition() {
|
|
402
|
+
if (this.conditionGroupFormGroup.controls.conditions.length > 1) {
|
|
403
|
+
this.conditionGroupFormGroup.controls.condition.enable();
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
this.conditionGroupFormGroup.controls.condition.disable();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorConditionGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
410
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorConditionGroupComponent, isStandalone: true, selector: "gio-el-editor-condition-group", inputs: { conditionGroupFormGroup: "conditionGroupFormGroup", conditionModels: "conditionModels", nodeLvl: "nodeLvl" }, outputs: { remove: "remove" }, host: { properties: { "attr.node-lvl": "this.nodeLvl" } }, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<div class=\"conditionGroup\" [formGroup]=\"conditionGroupFormGroup\">\n <div class=\"conditionGroup__header\">\n <div class=\"conditionGroup__header__conditionField\"></div>\n <mat-button-toggle-group\n class=\"gio-button-toggle-group\"\n name=\"condition\"\n aria-label=\"Condition\"\n formControlName=\"condition\"\n [hideSingleSelectionIndicator]=\"true\"\n >\n <mat-button-toggle class=\"mat-button-toggle-group\" value=\"AND\">AND</mat-button-toggle>\n <mat-button-toggle class=\"mat-button-toggle-group\" value=\"OR\">OR</mat-button-toggle>\n </mat-button-toggle-group>\n\n <div class=\"conditionGroup__header__addBtn\">\n <button mat-button [matMenuTriggerFor]=\"addBtn\">\n <mat-icon svgIcon=\"gio:plus\">Add</mat-icon>\n </button>\n <mat-menu #addBtn=\"matMenu\">\n <button mat-menu-item (click)=\"addConditionGroup()\">Add Group</button>\n <button mat-menu-item (click)=\"addCondition()\">Add Condition</button>\n </mat-menu>\n </div>\n\n @if (nodeLvl > 0) {\n <button class=\"conditionGroup__header__removeBtn\" mat-button aria-label=\"Remove Group\" (click)=\"removeConditionGroup()\">\n <mat-icon svgIcon=\"gio:cancel\"></mat-icon>\n </button>\n }\n </div>\n\n <div class=\"conditionGroup__conditions\">\n @for (condition of conditionGroupFormGroup.controls.conditions.controls; track conditionIndex; let conditionIndex = $index) {\n @if (isConditionGroupForm(condition)) {\n <gio-el-editor-condition-group\n class=\"conditionGroup__conditions__conditionGroup\"\n [conditionGroupFormGroup]=\"condition\"\n [conditionModels]=\"conditionModels\"\n [nodeLvl]=\"nodeLvl + 1\"\n (remove)=\"removeCondition(conditionIndex)\"\n ></gio-el-editor-condition-group>\n } @else {\n <div\n class=\"conditionGroup__conditions__condition\"\n [formGroup]=\"conditionGroupFormGroup.controls.conditions.at(conditionIndex)\"\n [attr.node-lvl]=\"nodeLvl\"\n >\n <mat-form-field class=\"conditionGroup__conditions__condition__field\">\n <mat-label>Field</mat-label>\n\n <mat-select formControlName=\"field\" placeholder=\"Select Field\">\n <mat-option *ngFor=\"let field of conditionModels\" [value]=\"field\">{{ field.label }}</mat-option>\n </mat-select>\n </mat-form-field>\n\n @switch (condition.controls.field.value?.type) {\n @case ('string') {\n <gio-el-editor-type-string [conditionFormGroup]=\"condition\"></gio-el-editor-type-string>\n }\n @case ('boolean') {\n <gio-el-editor-type-boolean [conditionFormGroup]=\"condition\"></gio-el-editor-type-boolean>\n }\n @case ('number') {\n <gio-el-editor-type-number [conditionFormGroup]=\"condition\"></gio-el-editor-type-number>\n }\n @case ('date') {\n <gio-el-editor-type-date [conditionFormGroup]=\"condition\"></gio-el-editor-type-date>\n }\n }\n\n <button\n class=\"conditionGroup__conditions__condition__removeBtn\"\n mat-button\n aria-label=\"Remove Condition\"\n (click)=\"removeCondition(conditionIndex)\"\n >\n <mat-icon svgIcon=\"gio:cancel\"></mat-icon>\n </button>\n </div>\n }\n }\n </div>\n</div>\n", styles: [".conditionGroup{display:flex;flex-direction:column;gap:8px}.conditionGroup__header{display:flex;flex-direction:row;align-items:center;gap:8px}.conditionGroup__header .gio-button-toggle-group{margin-bottom:0}.conditionGroup__conditions{display:flex;flex-direction:column;gap:8px}.conditionGroup__conditions__condition{display:flex;align-items:flex-start;gap:8px}.conditionGroup__conditions__condition__field{flex:0 0 auto}.conditionGroup__conditions__condition__removeBtn{align-self:center}.conditionGroup__conditions__conditionGroup{margin-left:18px}\n"], dependencies: [{ kind: "component", type: GioElEditorConditionGroupComponent, selector: "gio-el-editor-condition-group", inputs: ["conditionGroupFormGroup", "conditionModels", "nodeLvl"], outputs: ["remove"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i6.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i6.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1$1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i3.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6$2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: i7$1.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled", "disabledInteractive", "hideSingleSelectionIndicator", "hideMultipleSelectionIndicator"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i7$1.MatButtonToggle, selector: "mat-button-toggle", inputs: ["aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "disableRipple", "appearance", "checked", "disabled", "disabledInteractive"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i8.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i8.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i8.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "ngmodule", type: GioIconsModule }, { kind: "component", type: i9.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: GioElEditorTypeBooleanComponent, selector: "gio-el-editor-type-boolean", inputs: ["conditionFormGroup"] }, { kind: "component", type: GioElEditorTypeDateComponent, selector: "gio-el-editor-type-date", inputs: ["conditionFormGroup"] }, { kind: "component", type: GioElEditorTypeStringComponent, selector: "gio-el-editor-type-string", inputs: ["conditionFormGroup"] }, { kind: "component", type: GioElEditorTypeNumberComponent, selector: "gio-el-editor-type-number", inputs: ["conditionFormGroup"] }] }); }
|
|
411
|
+
}
|
|
412
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorConditionGroupComponent, decorators: [{
|
|
413
|
+
type: Component,
|
|
414
|
+
args: [{ selector: 'gio-el-editor-condition-group', standalone: true, imports: [
|
|
415
|
+
CommonModule,
|
|
416
|
+
ReactiveFormsModule,
|
|
417
|
+
MatFormFieldModule,
|
|
418
|
+
MatSelectModule,
|
|
419
|
+
MatButtonModule,
|
|
420
|
+
MatButtonToggleModule,
|
|
421
|
+
MatMenuModule,
|
|
422
|
+
GioIconsModule,
|
|
423
|
+
GioElEditorTypeBooleanComponent,
|
|
424
|
+
GioElEditorTypeDateComponent,
|
|
425
|
+
GioElEditorTypeStringComponent,
|
|
426
|
+
GioElEditorTypeNumberComponent,
|
|
427
|
+
], template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n<div class=\"conditionGroup\" [formGroup]=\"conditionGroupFormGroup\">\n <div class=\"conditionGroup__header\">\n <div class=\"conditionGroup__header__conditionField\"></div>\n <mat-button-toggle-group\n class=\"gio-button-toggle-group\"\n name=\"condition\"\n aria-label=\"Condition\"\n formControlName=\"condition\"\n [hideSingleSelectionIndicator]=\"true\"\n >\n <mat-button-toggle class=\"mat-button-toggle-group\" value=\"AND\">AND</mat-button-toggle>\n <mat-button-toggle class=\"mat-button-toggle-group\" value=\"OR\">OR</mat-button-toggle>\n </mat-button-toggle-group>\n\n <div class=\"conditionGroup__header__addBtn\">\n <button mat-button [matMenuTriggerFor]=\"addBtn\">\n <mat-icon svgIcon=\"gio:plus\">Add</mat-icon>\n </button>\n <mat-menu #addBtn=\"matMenu\">\n <button mat-menu-item (click)=\"addConditionGroup()\">Add Group</button>\n <button mat-menu-item (click)=\"addCondition()\">Add Condition</button>\n </mat-menu>\n </div>\n\n @if (nodeLvl > 0) {\n <button class=\"conditionGroup__header__removeBtn\" mat-button aria-label=\"Remove Group\" (click)=\"removeConditionGroup()\">\n <mat-icon svgIcon=\"gio:cancel\"></mat-icon>\n </button>\n }\n </div>\n\n <div class=\"conditionGroup__conditions\">\n @for (condition of conditionGroupFormGroup.controls.conditions.controls; track conditionIndex; let conditionIndex = $index) {\n @if (isConditionGroupForm(condition)) {\n <gio-el-editor-condition-group\n class=\"conditionGroup__conditions__conditionGroup\"\n [conditionGroupFormGroup]=\"condition\"\n [conditionModels]=\"conditionModels\"\n [nodeLvl]=\"nodeLvl + 1\"\n (remove)=\"removeCondition(conditionIndex)\"\n ></gio-el-editor-condition-group>\n } @else {\n <div\n class=\"conditionGroup__conditions__condition\"\n [formGroup]=\"conditionGroupFormGroup.controls.conditions.at(conditionIndex)\"\n [attr.node-lvl]=\"nodeLvl\"\n >\n <mat-form-field class=\"conditionGroup__conditions__condition__field\">\n <mat-label>Field</mat-label>\n\n <mat-select formControlName=\"field\" placeholder=\"Select Field\">\n <mat-option *ngFor=\"let field of conditionModels\" [value]=\"field\">{{ field.label }}</mat-option>\n </mat-select>\n </mat-form-field>\n\n @switch (condition.controls.field.value?.type) {\n @case ('string') {\n <gio-el-editor-type-string [conditionFormGroup]=\"condition\"></gio-el-editor-type-string>\n }\n @case ('boolean') {\n <gio-el-editor-type-boolean [conditionFormGroup]=\"condition\"></gio-el-editor-type-boolean>\n }\n @case ('number') {\n <gio-el-editor-type-number [conditionFormGroup]=\"condition\"></gio-el-editor-type-number>\n }\n @case ('date') {\n <gio-el-editor-type-date [conditionFormGroup]=\"condition\"></gio-el-editor-type-date>\n }\n }\n\n <button\n class=\"conditionGroup__conditions__condition__removeBtn\"\n mat-button\n aria-label=\"Remove Condition\"\n (click)=\"removeCondition(conditionIndex)\"\n >\n <mat-icon svgIcon=\"gio:cancel\"></mat-icon>\n </button>\n </div>\n }\n }\n </div>\n</div>\n", styles: [".conditionGroup{display:flex;flex-direction:column;gap:8px}.conditionGroup__header{display:flex;flex-direction:row;align-items:center;gap:8px}.conditionGroup__header .gio-button-toggle-group{margin-bottom:0}.conditionGroup__conditions{display:flex;flex-direction:column;gap:8px}.conditionGroup__conditions__condition{display:flex;align-items:flex-start;gap:8px}.conditionGroup__conditions__condition__field{flex:0 0 auto}.conditionGroup__conditions__condition__removeBtn{align-self:center}.conditionGroup__conditions__conditionGroup{margin-left:18px}\n"] }]
|
|
428
|
+
}], propDecorators: { conditionGroupFormGroup: [{
|
|
429
|
+
type: Input,
|
|
430
|
+
args: [{
|
|
431
|
+
required: true,
|
|
432
|
+
}]
|
|
433
|
+
}], conditionModels: [{
|
|
434
|
+
type: Input,
|
|
435
|
+
args: [{
|
|
436
|
+
required: true,
|
|
437
|
+
}]
|
|
438
|
+
}], nodeLvl: [{
|
|
439
|
+
type: Input
|
|
440
|
+
}, {
|
|
441
|
+
type: HostBinding,
|
|
442
|
+
args: ['attr.node-lvl']
|
|
443
|
+
}], remove: [{
|
|
444
|
+
type: Output
|
|
445
|
+
}] } });
|
|
446
|
+
const newConditionGroupFormGroup$1 = () => {
|
|
447
|
+
return new FormGroup({
|
|
448
|
+
condition: new FormControl({ value: 'AND', disabled: true }, { nonNullable: true, validators: Validators.required }),
|
|
449
|
+
conditions: new FormArray([]),
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
const newConditionFormGroup = () => {
|
|
453
|
+
return new FormGroup({
|
|
454
|
+
field: new FormControl(null),
|
|
455
|
+
operator: new FormControl(null),
|
|
456
|
+
value: new FormControl(null),
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/*
|
|
461
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
462
|
+
*
|
|
463
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
464
|
+
* you may not use this file except in compliance with the License.
|
|
465
|
+
* You may obtain a copy of the License at
|
|
466
|
+
*
|
|
467
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
468
|
+
*
|
|
469
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
470
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
471
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
472
|
+
* See the License for the specific language governing permissions and
|
|
473
|
+
* limitations under the License.
|
|
474
|
+
*/
|
|
475
|
+
class GioElEditorComponent {
|
|
476
|
+
constructor() {
|
|
477
|
+
this.destroyRef = inject(DestroyRef);
|
|
478
|
+
this.conditionsModel = [];
|
|
479
|
+
this.conditionsGroupFormArray = new FormArray([]);
|
|
480
|
+
this.conditionGroupFormGroup = newConditionGroupFormGroup();
|
|
481
|
+
this.fields = [];
|
|
482
|
+
}
|
|
483
|
+
ngOnInit() {
|
|
484
|
+
for (const conditionModel of this.conditionsModel) {
|
|
485
|
+
if (isConditionModel(conditionModel)) {
|
|
486
|
+
// TOTO: Impl Deep Tree for conditions Limit to fist Node for fist impl
|
|
487
|
+
this.fields.push(conditionModel);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
this.conditionGroupFormGroup.valueChanges
|
|
491
|
+
.pipe(takeUntilDestroyed(this.destroyRef), map(() => this.conditionGroupFormGroup.getRawValue()), map(value => {
|
|
492
|
+
const toCondition = (conditionValue) => {
|
|
493
|
+
if (isConditionGroupValue(conditionValue)) {
|
|
494
|
+
return toConditionGroup(conditionValue);
|
|
495
|
+
}
|
|
496
|
+
if (!isConditionValue(conditionValue) ||
|
|
497
|
+
isNil(conditionValue.field) ||
|
|
498
|
+
isNil(conditionValue.operator) ||
|
|
499
|
+
isNil(conditionValue.value)) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
return new Condition(conditionValue.field.field, conditionValue.field.type, conditionValue.operator, conditionValue.value);
|
|
503
|
+
};
|
|
504
|
+
const toConditionGroup = (conditionGroupValue) => {
|
|
505
|
+
const conditions = [];
|
|
506
|
+
if (!conditionGroupValue.condition || !conditionGroupValue.conditions || isEmpty(conditionGroupValue.conditions)) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
for (const conditionValue of conditionGroupValue.conditions) {
|
|
510
|
+
const condition = toCondition(conditionValue);
|
|
511
|
+
if (condition) {
|
|
512
|
+
conditions.push(condition);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (isEmpty(conditions)) {
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
return new ConditionGroup(conditionGroupValue.condition, conditions);
|
|
519
|
+
};
|
|
520
|
+
const conditionGroupValue = toConditionGroup(value);
|
|
521
|
+
if (conditionGroupValue) {
|
|
522
|
+
this.elOutput = new ExpressionLanguageBuilder(conditionGroupValue).build();
|
|
523
|
+
}
|
|
524
|
+
}))
|
|
525
|
+
.subscribe();
|
|
526
|
+
}
|
|
527
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
528
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: GioElEditorComponent, isStandalone: true, selector: "gio-el-editor", inputs: { conditionsModel: "conditionsModel" }, ngImport: i0, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n\n<gio-el-editor-condition-group\n [conditionGroupFormGroup]=\"conditionGroupFormGroup\"\n [conditionModels]=\"fields\"\n></gio-el-editor-condition-group>\n\n@if (elOutput) {\n <div class=\"elOutput\">\n {{ elOutput }}\n </div>\n}\n", styles: [".conditionGroup{display:flex;flex-direction:column;gap:8px}.conditionGroup__header{display:flex;flex-direction:row;align-items:center;gap:8px}.conditionGroup__conditions{display:flex;flex-direction:column;gap:8px}.condition{display:flex;align-items:flex-start;gap:8px}.condition__removeBtn{align-self:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: GioIconsModule }, { kind: "ngmodule", type: MatMenuModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: GioElEditorConditionGroupComponent, selector: "gio-el-editor-condition-group", inputs: ["conditionGroupFormGroup", "conditionModels", "nodeLvl"], outputs: ["remove"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
529
|
+
}
|
|
530
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioElEditorComponent, decorators: [{
|
|
531
|
+
type: Component,
|
|
532
|
+
args: [{ selector: 'gio-el-editor', standalone: true, imports: [
|
|
533
|
+
CommonModule,
|
|
534
|
+
MatButtonToggleModule,
|
|
535
|
+
ReactiveFormsModule,
|
|
536
|
+
MatButtonModule,
|
|
537
|
+
GioIconsModule,
|
|
538
|
+
MatMenuModule,
|
|
539
|
+
MatFormFieldModule,
|
|
540
|
+
MatInputModule,
|
|
541
|
+
MatSelectModule,
|
|
542
|
+
GioElEditorTypeStringComponent,
|
|
543
|
+
GioElEditorTypeBooleanComponent,
|
|
544
|
+
GioElEditorTypeNumberComponent,
|
|
545
|
+
GioElEditorTypeDateComponent,
|
|
546
|
+
GioElEditorConditionGroupComponent,
|
|
547
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--\n\n Copyright (C) 2024 The Gravitee team (http://gravitee.io)\n \n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n \n http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n-->\n\n<gio-el-editor-condition-group\n [conditionGroupFormGroup]=\"conditionGroupFormGroup\"\n [conditionModels]=\"fields\"\n></gio-el-editor-condition-group>\n\n@if (elOutput) {\n <div class=\"elOutput\">\n {{ elOutput }}\n </div>\n}\n", styles: [".conditionGroup{display:flex;flex-direction:column;gap:8px}.conditionGroup__header{display:flex;flex-direction:row;align-items:center;gap:8px}.conditionGroup__conditions{display:flex;flex-direction:column;gap:8px}.condition{display:flex;align-items:flex-start;gap:8px}.condition__removeBtn{align-self:center}\n"] }]
|
|
548
|
+
}], propDecorators: { conditionsModel: [{
|
|
549
|
+
type: Input,
|
|
550
|
+
args: [{ required: true }]
|
|
551
|
+
}] } });
|
|
552
|
+
const newConditionGroupFormGroup = () => {
|
|
553
|
+
return new FormGroup({
|
|
554
|
+
condition: new FormControl({ value: 'AND', disabled: true }, { nonNullable: true, validators: Validators.required }),
|
|
555
|
+
conditions: new FormArray([]),
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
const isConditionGroupValue = (value) => {
|
|
559
|
+
return !!value && has(value, 'condition') && has(value, 'conditions');
|
|
560
|
+
};
|
|
561
|
+
const isConditionValue = (value) => {
|
|
562
|
+
return !!value && has(value, 'field') && has(value, 'operator') && has(value, 'value');
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
/*
|
|
566
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
567
|
+
*
|
|
568
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
569
|
+
* you may not use this file except in compliance with the License.
|
|
570
|
+
* You may obtain a copy of the License at
|
|
571
|
+
*
|
|
572
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
573
|
+
*
|
|
574
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
575
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
576
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
577
|
+
* See the License for the specific language governing permissions and
|
|
578
|
+
* limitations under the License.
|
|
579
|
+
*/
|
|
580
|
+
class GioElEditorTypeComponentHarness extends ComponentHarness {
|
|
581
|
+
constructor() {
|
|
582
|
+
super(...arguments);
|
|
583
|
+
this.getOperatorSelector = this.locatorFor(MatSelectHarness.with({ selector: '[formControlName="operator"]' }));
|
|
584
|
+
}
|
|
585
|
+
async getAvailableOperators() {
|
|
586
|
+
const operatorSelector = await this.getOperatorSelector();
|
|
587
|
+
await operatorSelector.open();
|
|
588
|
+
const options = await operatorSelector.getOptions();
|
|
589
|
+
return parallel(() => options.map(async (option) => await option.getText()));
|
|
590
|
+
}
|
|
591
|
+
async selectOperator(operator) {
|
|
592
|
+
const operatorSelector = await this.getOperatorSelector();
|
|
593
|
+
await operatorSelector.clickOptions({ text: operator });
|
|
594
|
+
}
|
|
595
|
+
async getOperatorValue() {
|
|
596
|
+
const operatorSelector = await this.getOperatorSelector();
|
|
597
|
+
return operatorSelector.getValueText();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/*
|
|
602
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
603
|
+
*
|
|
604
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
605
|
+
* you may not use this file except in compliance with the License.
|
|
606
|
+
* You may obtain a copy of the License at
|
|
607
|
+
*
|
|
608
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
609
|
+
*
|
|
610
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
611
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
612
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
613
|
+
* See the License for the specific language governing permissions and
|
|
614
|
+
* limitations under the License.
|
|
615
|
+
*/
|
|
616
|
+
class GioElEditorTypeBooleanHarness extends GioElEditorTypeComponentHarness {
|
|
617
|
+
static { this.hostSelector = 'gio-el-editor-type-boolean'; }
|
|
618
|
+
async getValue() {
|
|
619
|
+
const slideToggleHarness = await this.locatorFor(MatSlideToggleHarness)();
|
|
620
|
+
return await slideToggleHarness.isChecked();
|
|
621
|
+
}
|
|
622
|
+
async setValue(value) {
|
|
623
|
+
const slideToggleHarness = await this.locatorFor(MatSlideToggleHarness)();
|
|
624
|
+
if (value !== (await slideToggleHarness.isChecked())) {
|
|
625
|
+
await slideToggleHarness.toggle();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/*
|
|
631
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
632
|
+
*
|
|
633
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
634
|
+
* you may not use this file except in compliance with the License.
|
|
635
|
+
* You may obtain a copy of the License at
|
|
636
|
+
*
|
|
637
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
638
|
+
*
|
|
639
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
640
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
641
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
642
|
+
* See the License for the specific language governing permissions and
|
|
643
|
+
* limitations under the License.
|
|
644
|
+
*/
|
|
645
|
+
class GioElEditorTypeStringHarness extends GioElEditorTypeComponentHarness {
|
|
646
|
+
static { this.hostSelector = 'gio-el-editor-type-string'; }
|
|
647
|
+
async getValue() {
|
|
648
|
+
const input = await this.locatorFor(MatInputHarness)();
|
|
649
|
+
return await input.getValue();
|
|
650
|
+
}
|
|
651
|
+
async setValue(value) {
|
|
652
|
+
const input = await this.locatorFor(MatInputHarness)();
|
|
653
|
+
await input.setValue(value);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/*
|
|
658
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
659
|
+
*
|
|
660
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
661
|
+
* you may not use this file except in compliance with the License.
|
|
662
|
+
* You may obtain a copy of the License at
|
|
663
|
+
*
|
|
664
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
665
|
+
*
|
|
666
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
667
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
668
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
669
|
+
* See the License for the specific language governing permissions and
|
|
670
|
+
* limitations under the License.
|
|
671
|
+
*/
|
|
672
|
+
class GioElEditorTypeNumberHarness extends GioElEditorTypeComponentHarness {
|
|
673
|
+
static { this.hostSelector = 'gio-el-editor-type-number'; }
|
|
674
|
+
async getValue() {
|
|
675
|
+
const input = await this.locatorFor(MatInputHarness)();
|
|
676
|
+
return Number(await input.getValue());
|
|
677
|
+
}
|
|
678
|
+
async setValue(value) {
|
|
679
|
+
const input = await this.locatorFor(MatInputHarness)();
|
|
680
|
+
await input.setValue(value.toString());
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/*
|
|
685
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
686
|
+
*
|
|
687
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
688
|
+
* you may not use this file except in compliance with the License.
|
|
689
|
+
* You may obtain a copy of the License at
|
|
690
|
+
*
|
|
691
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
692
|
+
*
|
|
693
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
694
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
695
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
696
|
+
* See the License for the specific language governing permissions and
|
|
697
|
+
* limitations under the License.
|
|
698
|
+
*/
|
|
699
|
+
class GioElEditorTypeDateHarness extends GioElEditorTypeComponentHarness {
|
|
700
|
+
static { this.hostSelector = 'gio-el-editor-type-date'; }
|
|
701
|
+
async getValue() {
|
|
702
|
+
const datepickerInputHarness = await this.locatorFor(MatDatepickerInputHarness)();
|
|
703
|
+
return await datepickerInputHarness.getValue();
|
|
704
|
+
}
|
|
705
|
+
async setValue(value) {
|
|
706
|
+
const datepickerInputHarness = await this.locatorFor(MatDatepickerInputHarness)();
|
|
707
|
+
await datepickerInputHarness.setValue(value.toISOString());
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/*
|
|
712
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
713
|
+
*
|
|
714
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
715
|
+
* you may not use this file except in compliance with the License.
|
|
716
|
+
* You may obtain a copy of the License at
|
|
717
|
+
*
|
|
718
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
719
|
+
*
|
|
720
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
721
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
722
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
723
|
+
* See the License for the specific language governing permissions and
|
|
724
|
+
* limitations under the License.
|
|
725
|
+
*/
|
|
726
|
+
class GioElEditorConditionGroupHarness extends ComponentHarness {
|
|
727
|
+
constructor() {
|
|
728
|
+
super(...arguments);
|
|
729
|
+
this.getNodeLvl = () => this.host().then(host => host.getAttribute('node-lvl'));
|
|
730
|
+
this.getAddMenuButton = this.locatorFor(MatMenuHarness.with({ triggerText: /Add/ }));
|
|
731
|
+
this.getConditionButtonToggleGroup = this.locatorFor(MatButtonToggleGroupHarness.with({ selector: '[formControlName="condition"]' }));
|
|
732
|
+
this.getConditionsHarness = async () => {
|
|
733
|
+
const nodeLvl = await this.getNodeLvl();
|
|
734
|
+
if (!nodeLvl) {
|
|
735
|
+
throw new Error('Node level not found');
|
|
736
|
+
}
|
|
737
|
+
return this.locatorForAll(DivHarness.with({
|
|
738
|
+
selector: `.conditionGroup__conditions__condition[node-lvl="${nodeLvl}"]`,
|
|
739
|
+
}), GioElEditorConditionGroupHarness.with({
|
|
740
|
+
selector: `.conditionGroup__conditions__conditionGroup[node-lvl="${Number(nodeLvl) + 1}"]`,
|
|
741
|
+
}))();
|
|
742
|
+
};
|
|
743
|
+
// private ee = (await this.locatorFor(DivHarness.with({ selector: '.conditionGroup__conditions' }))()).childLocatorForAll();
|
|
744
|
+
this.getConditionHarness = async (index) => (await this.getConditionsHarness()).at(index);
|
|
745
|
+
this.getConditionTypeHarness = (divHarness) => divHarness.childLocatorForOptional(GioElEditorTypeStringHarness, GioElEditorTypeBooleanHarness, GioElEditorTypeNumberHarness, GioElEditorTypeDateHarness)();
|
|
746
|
+
this.getConditionField = (divHarness) => divHarness.childLocatorFor(MatSelectHarness.with({ selector: '[formControlName="field"]' }))();
|
|
747
|
+
}
|
|
748
|
+
static { this.hostSelector = 'gio-el-editor-condition-group'; }
|
|
749
|
+
static with(options = {}) {
|
|
750
|
+
return new HarnessPredicate(GioElEditorConditionGroupHarness, options);
|
|
751
|
+
}
|
|
752
|
+
async clickAddNewConditionButton() {
|
|
753
|
+
await (await this.getAddMenuButton()).clickItem({ text: /Add Condition/ });
|
|
754
|
+
}
|
|
755
|
+
async clickAddNewGroupButton() {
|
|
756
|
+
await (await this.getAddMenuButton()).clickItem({ text: /Add Group/ });
|
|
757
|
+
}
|
|
758
|
+
async getConditionValue() {
|
|
759
|
+
const conditionButtonToggleGroup = await this.getConditionButtonToggleGroup();
|
|
760
|
+
const selectedToggles = await conditionButtonToggleGroup.getToggles({ checked: true });
|
|
761
|
+
if (selectedToggles.length !== 1) {
|
|
762
|
+
throw new Error('No operator selected');
|
|
763
|
+
}
|
|
764
|
+
const andOrMap = {
|
|
765
|
+
AND: 'AND',
|
|
766
|
+
OR: 'OR',
|
|
767
|
+
};
|
|
768
|
+
return andOrMap[await selectedToggles[0].getText()];
|
|
769
|
+
}
|
|
770
|
+
async selectConditionValue(operator) {
|
|
771
|
+
const conditionButtonToggleGroup = await this.getConditionButtonToggleGroup();
|
|
772
|
+
const toggles = await conditionButtonToggleGroup.getToggles({ text: operator });
|
|
773
|
+
if (toggles.length !== 1) {
|
|
774
|
+
throw new Error('No operator selected');
|
|
775
|
+
}
|
|
776
|
+
return toggles[0].check();
|
|
777
|
+
}
|
|
778
|
+
async selectConditionField(index, field) {
|
|
779
|
+
const conditionDiv = await this.getConditionHarness(index);
|
|
780
|
+
if (!conditionDiv || !(conditionDiv instanceof DivHarness)) {
|
|
781
|
+
throw new Error(`Condition with index ${index} not found`);
|
|
782
|
+
}
|
|
783
|
+
const fieldSelect = await this.getConditionField(conditionDiv);
|
|
784
|
+
await fieldSelect.clickOptions({ text: field });
|
|
785
|
+
}
|
|
786
|
+
async selectConditionOperator(index, operator) {
|
|
787
|
+
const conditionDiv = await this.getConditionHarness(index);
|
|
788
|
+
if (!conditionDiv || !(conditionDiv instanceof DivHarness)) {
|
|
789
|
+
throw new Error(`Condition with index ${index} not found`);
|
|
790
|
+
}
|
|
791
|
+
const conditionType = await this.getConditionTypeHarness(conditionDiv);
|
|
792
|
+
if (!conditionType) {
|
|
793
|
+
throw new Error(`Condition type not found. Select field first`);
|
|
794
|
+
}
|
|
795
|
+
await conditionType.selectOperator(operator);
|
|
796
|
+
}
|
|
797
|
+
async getConditionAvailableOperators(index) {
|
|
798
|
+
const conditionDiv = await this.getConditionHarness(index);
|
|
799
|
+
if (!conditionDiv || !(conditionDiv instanceof DivHarness)) {
|
|
800
|
+
throw new Error(`Condition with index ${index} not found`);
|
|
801
|
+
}
|
|
802
|
+
const conditionType = await this.getConditionTypeHarness(conditionDiv);
|
|
803
|
+
if (!conditionType) {
|
|
804
|
+
throw new Error(`Condition type not found. Select field first`);
|
|
805
|
+
}
|
|
806
|
+
return conditionType.getAvailableOperators();
|
|
807
|
+
}
|
|
808
|
+
async setConditionValue(index, value) {
|
|
809
|
+
const conditionDiv = await this.getConditionHarness(index);
|
|
810
|
+
if (!conditionDiv || !(conditionDiv instanceof DivHarness)) {
|
|
811
|
+
throw new Error(`Condition with index ${index} not found`);
|
|
812
|
+
}
|
|
813
|
+
const conditionType = await this.getConditionTypeHarness(conditionDiv);
|
|
814
|
+
if (!conditionType) {
|
|
815
|
+
throw new Error(`Condition type not found. Select field first`);
|
|
816
|
+
}
|
|
817
|
+
if (conditionType instanceof GioElEditorTypeStringHarness && typeof value === 'string') {
|
|
818
|
+
await conditionType.setValue(value);
|
|
819
|
+
}
|
|
820
|
+
else if (conditionType instanceof GioElEditorTypeBooleanHarness && typeof value === 'boolean') {
|
|
821
|
+
await conditionType.setValue(value);
|
|
822
|
+
}
|
|
823
|
+
else if (conditionType instanceof GioElEditorTypeNumberHarness && typeof value === 'number') {
|
|
824
|
+
await conditionType.setValue(value);
|
|
825
|
+
}
|
|
826
|
+
else if (conditionType instanceof GioElEditorTypeDateHarness && value instanceof Date) {
|
|
827
|
+
await conditionType.setValue(value);
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
throw new Error(`Invalid value for condition type`);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
async getConditionGroup(index) {
|
|
834
|
+
const conditionGroup = await this.getConditionHarness(index);
|
|
835
|
+
if (!conditionGroup || !(conditionGroup instanceof GioElEditorConditionGroupHarness)) {
|
|
836
|
+
throw new Error(`Condition group with index ${index} not found`);
|
|
837
|
+
}
|
|
838
|
+
return conditionGroup;
|
|
839
|
+
}
|
|
840
|
+
async getConditions() {
|
|
841
|
+
const getConditionsDiv = await this.getConditionsHarness();
|
|
842
|
+
const conditions = await parallel(() => getConditionsDiv.map(async (condition) => {
|
|
843
|
+
if (condition instanceof GioElEditorConditionGroupHarness) {
|
|
844
|
+
return await condition.getConditions();
|
|
845
|
+
}
|
|
846
|
+
const conditionField = await this.getConditionField(condition);
|
|
847
|
+
const conditionType = await this.getConditionTypeHarness(condition);
|
|
848
|
+
return {
|
|
849
|
+
field: await conditionField.getValueText(),
|
|
850
|
+
operator: await conditionType?.getOperatorValue(),
|
|
851
|
+
value: await conditionType?.getValue(),
|
|
852
|
+
};
|
|
853
|
+
}));
|
|
854
|
+
return {
|
|
855
|
+
condition: await this.getConditionValue(),
|
|
856
|
+
conditions,
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/*
|
|
862
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
863
|
+
*
|
|
864
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
865
|
+
* you may not use this file except in compliance with the License.
|
|
866
|
+
* You may obtain a copy of the License at
|
|
867
|
+
*
|
|
868
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
869
|
+
*
|
|
870
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
871
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
872
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
873
|
+
* See the License for the specific language governing permissions and
|
|
874
|
+
* limitations under the License.
|
|
875
|
+
*/
|
|
876
|
+
class GioElEditorHarness extends ComponentHarness {
|
|
877
|
+
constructor() {
|
|
878
|
+
super(...arguments);
|
|
879
|
+
this.getMainConditionGroup = this.locatorFor(GioElEditorConditionGroupHarness);
|
|
880
|
+
}
|
|
881
|
+
static { this.hostSelector = 'gio-el-editor'; }
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/*
|
|
885
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
886
|
+
*
|
|
887
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
888
|
+
* you may not use this file except in compliance with the License.
|
|
889
|
+
* You may obtain a copy of the License at
|
|
890
|
+
*
|
|
891
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
892
|
+
*
|
|
893
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
894
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
895
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
896
|
+
* See the License for the specific language governing permissions and
|
|
897
|
+
* limitations under the License.
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
/*
|
|
901
|
+
* Copyright (C) 2024 The Gravitee team (http://gravitee.io)
|
|
902
|
+
*
|
|
903
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
904
|
+
* you may not use this file except in compliance with the License.
|
|
905
|
+
* You may obtain a copy of the License at
|
|
906
|
+
*
|
|
907
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
908
|
+
*
|
|
909
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
910
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
911
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
912
|
+
* See the License for the specific language governing permissions and
|
|
913
|
+
* limitations under the License.
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Generated bundle index. Do not edit.
|
|
918
|
+
*/
|
|
919
|
+
|
|
920
|
+
export { Condition, ExpressionLanguageBuilder, GioElEditorComponent, GioElEditorHarness, isConditionModel };
|
|
921
|
+
//# sourceMappingURL=gravitee-ui-particles-angular-gio-el.mjs.map
|