@alauda-fe/crd-form 1.0.1-alpha.0 → 1.0.1-alpha.1
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { InjectionToken, EventEmitter, inject, Output, Input, Directive, forwardRef, ChangeDetectorRef, ChangeDetectionStrategy, Component, ViewChild, Injector, HostBinding, NgModule } from '@angular/core';
|
|
3
3
|
import { escapeRegExp, get, includes, some, cloneDeep, map, reduce, find, set, last, isEmpty, identity, toPath, flatten, times, isArray, flatMap, flatMapDepth, union, pick, startCase, parseInt as parseInt$1, uniqWith, groupBy, sortBy, omit, merge, template, differenceBy, uniq, flattenDeep, fromPairs, toString } from 'lodash-es';
|
|
4
|
-
import { __decorate, __metadata } from 'tslib';
|
|
5
|
-
import * as i2 from '@alauda/ui';
|
|
6
|
-
import { FormModule, IconModule, TooltipModule, ButtonModule, DIALOG_DATA, DialogRef, MessageService, InputModule, DialogModule, DialogService, DialogSize, SelectModule, TagModule, RadioModule, SwitchModule, LabelPosition } from '@alauda/ui';
|
|
7
4
|
import * as i4 from '@alauda-fe/dynamic-plugin-sdk';
|
|
8
5
|
import { parseJSONStream, TRUE, FALSE, parseJson, isEqual, PurePipe, TranslatePipe, K8sApiService, TranslateService, K8S_RESOURCE_NAME_BASE, SecretType, COMMON_RESOURCE_DEFINITIONS, K8sUtilService, publishRef, skipError, ObservableInput, K8S_UTIL_PIPES_MODULE, TOKEN_RESOURCE_DEFINITIONS, ValueHook, SanitizePipe, FieldNotAvailablePipe, bind, stringify, parse, API_GATEWAY, startWithCondition } from '@alauda-fe/dynamic-plugin-sdk';
|
|
9
6
|
import * as i2$1 from '@alauda-fe/dynamic-plugin-shared';
|
|
10
7
|
import { isJsonObjectString, ErrorsMapperComponent, HelpDocDirective, ARRAY_FORM_TABLE_MODULE, StrongPasswordDirective, createNestedFormControl, formatCPU, formatMemory, resourceUnits, getResourceValue, getResourceViewModel, initGreaterValidator, transferResource, RESOURCE_MAC_TYPES, PasswordInputComponent, ReadonlyFieldDirective, ParseJsonTranslatePipe, ScrollToFirstInvalidDirective, ErrorsMapperDirective } from '@alauda-fe/dynamic-plugin-shared';
|
|
8
|
+
import { __decorate, __metadata } from 'tslib';
|
|
9
|
+
import * as i2 from '@alauda/ui';
|
|
10
|
+
import { FormModule, IconModule, TooltipModule, ButtonModule, DIALOG_DATA, DialogRef, MessageService, InputModule, DialogModule, DialogService, DialogSize, SelectModule, TagModule, RadioModule, SwitchModule, LabelPosition } from '@alauda/ui';
|
|
11
11
|
import * as i1 from '@angular/forms';
|
|
12
12
|
import { FormBuilder, Validators, FormsModule, ReactiveFormsModule, FormGroupDirective, NG_VALUE_ACCESSOR, ControlContainer, FormControl } from '@angular/forms';
|
|
13
13
|
import { isImmutable, fromJS, Map as Map$1, List } from 'immutable';
|
|
@@ -20,6 +20,8 @@ import { encode, decode } from 'ab64';
|
|
|
20
20
|
import { BaseResourceFormComponent, BaseResourceFormGroupComponent } from 'ng-resource-form-util';
|
|
21
21
|
import { hashSync } from 'bcryptjs';
|
|
22
22
|
|
|
23
|
+
const CRD_FORM_CONTEXT = new InjectionToken('CRD_FORM_CONTEXT');
|
|
24
|
+
|
|
23
25
|
var Validations;
|
|
24
26
|
(function (Validations) {
|
|
25
27
|
Validations["maximum"] = "maximum";
|
|
@@ -929,6 +931,115 @@ function sortGroupFields(fields, descriptors, descriptorFields) {
|
|
|
929
931
|
}));
|
|
930
932
|
}
|
|
931
933
|
|
|
934
|
+
class BaseOperandFiledArrayComponent {
|
|
935
|
+
constructor() {
|
|
936
|
+
this.readonly = false;
|
|
937
|
+
this.valueChange = new EventEmitter();
|
|
938
|
+
this.itemRemove = new EventEmitter();
|
|
939
|
+
this.getFieldDisplayName = getFieldDisplayName;
|
|
940
|
+
this.crdForm = inject(CRD_FORM_CONTEXT);
|
|
941
|
+
}
|
|
942
|
+
get expanded() {
|
|
943
|
+
return this._expanded ?? !isFolded(this.arrayFieldGroup);
|
|
944
|
+
}
|
|
945
|
+
set expanded(expanded) {
|
|
946
|
+
this._expanded = expanded;
|
|
947
|
+
}
|
|
948
|
+
ngOnChanges({ arrayFieldGroup, formDataState }) {
|
|
949
|
+
if (!this.basicArrayFieldTemplate &&
|
|
950
|
+
arrayFieldGroup.currentValue?.fieldLists?.length > 0) {
|
|
951
|
+
this.basicArrayFieldTemplate = last(arrayFieldGroup.currentValue.fieldLists);
|
|
952
|
+
}
|
|
953
|
+
if (formDataState?.currentValue && formDataState?.previousValue) {
|
|
954
|
+
const currValue = getFormData(formDataState.currentValue, this.arrayFieldGroup.path);
|
|
955
|
+
const arrayFieldLength = this.arrayFieldGroup.fieldLists?.length;
|
|
956
|
+
if (currValue?.size > arrayFieldLength) {
|
|
957
|
+
Array.from({ length: currValue.size - arrayFieldLength }).forEach(() => {
|
|
958
|
+
this.addItem();
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
fieldValueChange(e) {
|
|
964
|
+
this.valueChange.emit(e);
|
|
965
|
+
}
|
|
966
|
+
addItem() {
|
|
967
|
+
const newFields = this.basicArrayFieldTemplate.map(field => {
|
|
968
|
+
const toPath = modifyArrayFieldPathIndex(field.path, () => this.arrayFieldGroup.fieldLists.length);
|
|
969
|
+
return {
|
|
970
|
+
...repairFieldChildPathByCorrectIndex(field, field.path, toPath),
|
|
971
|
+
};
|
|
972
|
+
});
|
|
973
|
+
this.arrayFieldGroup.fieldLists = [
|
|
974
|
+
...this.arrayFieldGroup.fieldLists,
|
|
975
|
+
newFields,
|
|
976
|
+
];
|
|
977
|
+
}
|
|
978
|
+
removeItem(index) {
|
|
979
|
+
const groupToRemove = this.arrayFieldGroup.fieldLists[index];
|
|
980
|
+
const groupUntouched = this.arrayFieldGroup.fieldLists.filter((_, idx) => idx < index);
|
|
981
|
+
const groupToLeftShift = this.arrayFieldGroup.fieldLists.filter((_, idx) => idx > index);
|
|
982
|
+
const leftShiftedGroups = groupToLeftShift.map(group => group.map(field => {
|
|
983
|
+
const toPath = modifyArrayFieldPathIndex(field.path, idx => idx - 1);
|
|
984
|
+
return {
|
|
985
|
+
...repairFieldChildPathByCorrectIndex(field, field.path, toPath),
|
|
986
|
+
};
|
|
987
|
+
}));
|
|
988
|
+
this.arrayFieldGroup.fieldLists = [...groupUntouched, ...leftShiftedGroups];
|
|
989
|
+
const [match, formDataPathToRemove] = /^(.*\[\d+]).*$/.exec(groupToRemove?.[0].path) || [];
|
|
990
|
+
if (match) {
|
|
991
|
+
this.itemRemove.next(formDataPathToRemove);
|
|
992
|
+
}
|
|
993
|
+
this.crdForm.controlMap.forEach((_, key) => {
|
|
994
|
+
if (key.startsWith(`${this.arrayFieldGroup.path}[${this.arrayFieldGroup.fieldLists.length}]`)) {
|
|
995
|
+
this.crdForm.controlMap.delete(key);
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
this.crdForm.refreshValidation();
|
|
999
|
+
this.deleteFormData(`${this.arrayFieldGroup.path}[${index}]`);
|
|
1000
|
+
}
|
|
1001
|
+
deleteFormData(path) {
|
|
1002
|
+
this.valueChange.next({
|
|
1003
|
+
field: {
|
|
1004
|
+
...this.arrayFieldGroup,
|
|
1005
|
+
path,
|
|
1006
|
+
},
|
|
1007
|
+
data: null,
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
fieldIsRequired(field) {
|
|
1011
|
+
return (field?.required ||
|
|
1012
|
+
Object.keys(field?.validations || {})?.includes(Validations.required));
|
|
1013
|
+
}
|
|
1014
|
+
get columnFields() {
|
|
1015
|
+
return this.basicArrayFieldTemplate;
|
|
1016
|
+
}
|
|
1017
|
+
trackByFn(index) {
|
|
1018
|
+
return index;
|
|
1019
|
+
}
|
|
1020
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: BaseOperandFiledArrayComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1021
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: BaseOperandFiledArrayComponent, isStandalone: true, inputs: { arrayFieldGroup: "arrayFieldGroup", formDataState: "formDataState", formErrors: "formErrors", isArrayTable: "isArrayTable", readonly: "readonly", fields: "fields" }, outputs: { valueChange: "valueChange", itemRemove: "itemRemove" }, usesOnChanges: true, ngImport: i0 }); }
|
|
1022
|
+
}
|
|
1023
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: BaseOperandFiledArrayComponent, decorators: [{
|
|
1024
|
+
type: Directive
|
|
1025
|
+
}], propDecorators: { arrayFieldGroup: [{
|
|
1026
|
+
type: Input
|
|
1027
|
+
}], formDataState: [{
|
|
1028
|
+
type: Input
|
|
1029
|
+
}], formErrors: [{
|
|
1030
|
+
type: Input
|
|
1031
|
+
}], isArrayTable: [{
|
|
1032
|
+
type: Input
|
|
1033
|
+
}], readonly: [{
|
|
1034
|
+
type: Input
|
|
1035
|
+
}], fields: [{
|
|
1036
|
+
type: Input
|
|
1037
|
+
}], valueChange: [{
|
|
1038
|
+
type: Output
|
|
1039
|
+
}], itemRemove: [{
|
|
1040
|
+
type: Output
|
|
1041
|
+
}] } });
|
|
1042
|
+
|
|
932
1043
|
const EXPRESSION_PROPS_PREFIX = `${SpecCapability.expression}props.`;
|
|
933
1044
|
const EXPRESSION_PROPS_OPTIONS_PREFIX = `${EXPRESSION_PROPS_PREFIX}options:`;
|
|
934
1045
|
const EXPRESSION_PROPS_DEFAULT_PREFIX = `${EXPRESSION_PROPS_PREFIX}default:`;
|
|
@@ -1193,7 +1304,7 @@ class BasicAuthSecretComponent extends BaseResourceFormComponent {
|
|
|
1193
1304
|
constructor() {
|
|
1194
1305
|
super(inject(Injector));
|
|
1195
1306
|
this.k8sApi = inject(K8sApiService);
|
|
1196
|
-
this.crdForm = inject(
|
|
1307
|
+
this.crdForm = inject(CRD_FORM_CONTEXT);
|
|
1197
1308
|
this.dialog = inject(DialogService);
|
|
1198
1309
|
this.k8sUtil = inject(K8sUtilService);
|
|
1199
1310
|
this.config$ = this.field$.pipe(filter(field => !!field), map$1(field => getBasicAuthSecretConfig(field)), publishRef());
|
|
@@ -1305,7 +1416,7 @@ class K8sResourcePrefixComponent extends BaseResourceFormComponent {
|
|
|
1305
1416
|
constructor() {
|
|
1306
1417
|
super(inject(Injector));
|
|
1307
1418
|
this.k8sApi = inject(K8sApiService);
|
|
1308
|
-
this.crdForm = inject(
|
|
1419
|
+
this.crdForm = inject(CRD_FORM_CONTEXT);
|
|
1309
1420
|
this.resourceDefinitions = inject(TOKEN_RESOURCE_DEFINITIONS);
|
|
1310
1421
|
this.init$$ = new BehaviorSubject(false);
|
|
1311
1422
|
this.readonly = false;
|
|
@@ -1846,7 +1957,7 @@ class OperandFieldComponent {
|
|
|
1846
1957
|
].includes(getFieldType(filed));
|
|
1847
1958
|
this.viewActions = viewActions;
|
|
1848
1959
|
this.viewOptions = yamlReadOptions;
|
|
1849
|
-
this.crdForm = inject(
|
|
1960
|
+
this.crdForm = inject(CRD_FORM_CONTEXT);
|
|
1850
1961
|
this.http = inject(HttpClient);
|
|
1851
1962
|
this.cdr = inject(ChangeDetectorRef);
|
|
1852
1963
|
this.getWidgets = (capabilities) => {
|
|
@@ -2443,7 +2554,12 @@ class CrdFormComponent {
|
|
|
2443
2554
|
this.form.onSubmit(null);
|
|
2444
2555
|
}
|
|
2445
2556
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: CrdFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2446
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.1", type: CrdFormComponent, isStandalone: true, selector: "acl-crd-form", inputs: { openApiSchema: "openApiSchema", descriptors: "descriptors", data: "data", debug: "debug", openApiSchemaPath: "openApiSchemaPath", readonly: "readonly", labelWidth: "labelWidth", labelPosition: "labelPosition", cluster: "cluster", namespace: "namespace", formContext: "formContext", keepEmptyPath: "keepEmptyPath", effectControlDefaultValue: "effectControlDefaultValue", uiContext: "uiContext", widgets: "widgets" }, outputs: { formStateChange: "formStateChange", formSchemaChange: "formSchemaChange" },
|
|
2557
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.1", type: CrdFormComponent, isStandalone: true, selector: "acl-crd-form", inputs: { openApiSchema: "openApiSchema", descriptors: "descriptors", data: "data", debug: "debug", openApiSchemaPath: "openApiSchemaPath", readonly: "readonly", labelWidth: "labelWidth", labelPosition: "labelPosition", cluster: "cluster", namespace: "namespace", formContext: "formContext", keepEmptyPath: "keepEmptyPath", effectControlDefaultValue: "effectControlDefaultValue", uiContext: "uiContext", widgets: "widgets" }, outputs: { formStateChange: "formStateChange", formSchemaChange: "formSchemaChange" }, providers: [
|
|
2558
|
+
{
|
|
2559
|
+
provide: CRD_FORM_CONTEXT,
|
|
2560
|
+
useExisting: CrdFormComponent,
|
|
2561
|
+
},
|
|
2562
|
+
], viewQueries: [{ propertyName: "form", first: true, predicate: ["form"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<form\n auiForm\n [aclScrollToFirstInvalid]=\"!!formErrors\"\n #form=\"ngForm\"\n [auiFormLabelPosition]=\"labelPosition\"\n [auiFormLabelWidth]=\"labelWidth\"\n>\n <!-- normal fields -->\n @for (field of normalFields; track field) {\n <acl-operand-field\n [fields]=\"fields\"\n [field]=\"field\"\n [formDataState]=\"formDataState\"\n [readonly]=\"readonly\"\n (valueChange)=\"fieldValueChange($event)\"\n >\n </acl-operand-field>\n }\n\n <!-- field groups \u517C\u5BB9\uFF0C\u9700\u8981\u4FDD\u7559-->\n @for (group of fieldGroups; track group) {\n <acl-operand-field-group\n [fields]=\"fields\"\n [fieldGroup]=\"group\"\n [formDataState]=\"formDataState\"\n [formErrors]=\"formErrors\"\n [readonly]=\"readonly\"\n (valueChange)=\"fieldValueChange($event)\"\n >\n </acl-operand-field-group>\n }\n\n <!-- array field groups \u517C\u5BB9\uFF0C\u9700\u8981\u4FDD\u7559 -->\n @for (group of arrayFieldGroups; track group) {\n <acl-operand-array-field-group\n [arrayFieldGroup]=\"group\"\n [formDataState]=\"formDataState\"\n [readonly]=\"readonly\"\n (valueChange)=\"fieldValueChange($event)\"\n (itemRemove)=\"deleteFormData($event)\"\n >\n </acl-operand-array-field-group>\n }\n\n <!-- advanced fields -->\n @if (advancedFields?.length) {\n <acl-operand-advanced-field-group\n [fields]=\"fields\"\n [fieldList]=\"advancedFields\"\n [formDataState]=\"formDataState\"\n [readonly]=\"readonly\"\n (valueChange)=\"fieldValueChange($event)\"\n ></acl-operand-advanced-field-group>\n }\n</form>\n", styles: [":host{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: i0.forwardRef(() => FormsModule) }, { kind: "directive", type: i0.forwardRef(() => i1.ɵNgNoValidate), selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i0.forwardRef(() => i1.NgControlStatusGroup), selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i0.forwardRef(() => i1.NgForm), selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: i0.forwardRef(() => FormModule) }, { kind: "directive", type: i0.forwardRef(() => i2.FormDirective), selector: "form[auiForm]", inputs: ["auiFormLabelWidth", "auiFormLabelPosition", "auiFormEmptyAddon", "auiFormInline"], exportAs: ["auiForm"] }, { kind: "component", type: i0.forwardRef(() => OperandFieldComponent), selector: "acl-operand-field", inputs: ["field", "readonly", "fields", "formDataState", "formErrors"], outputs: ["valueChange", "itemRemove"] }, { kind: "component", type: i0.forwardRef(() => OperandFieldGroupComponent), selector: "acl-operand-field-group", inputs: ["fields", "fieldGroup", "formDataState", "formErrors", "readonly"], outputs: ["valueChange"] }, { kind: "component", type: i0.forwardRef(() => OperandArrayFieldGroupComponent), selector: "acl-operand-array-field-group" }, { kind: "component", type: i0.forwardRef(() => OperandAdvancedFieldGroupComponent), selector: "acl-operand-advanced-field-group", inputs: ["fields", "fieldList", "formDataState", "formErrors", "readonly"], outputs: ["valueChange"] }, { kind: "directive", type: i0.forwardRef(() => ScrollToFirstInvalidDirective), selector: "[aclScrollToFirstInvalid]", inputs: ["labelOffset", "aclScrollToFirstInvalid"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2447
2563
|
}
|
|
2448
2564
|
__decorate([
|
|
2449
2565
|
ObservableInput(),
|
|
@@ -2451,7 +2567,12 @@ __decorate([
|
|
|
2451
2567
|
], CrdFormComponent.prototype, "formContext$", void 0);
|
|
2452
2568
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: CrdFormComponent, decorators: [{
|
|
2453
2569
|
type: Component,
|
|
2454
|
-
args: [{ selector: 'acl-crd-form', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true,
|
|
2570
|
+
args: [{ selector: 'acl-crd-form', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, providers: [
|
|
2571
|
+
{
|
|
2572
|
+
provide: CRD_FORM_CONTEXT,
|
|
2573
|
+
useExisting: CrdFormComponent,
|
|
2574
|
+
},
|
|
2575
|
+
], imports: [
|
|
2455
2576
|
FormsModule,
|
|
2456
2577
|
FormModule,
|
|
2457
2578
|
forwardRef(() => OperandFieldComponent),
|
|
@@ -2499,115 +2620,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2499
2620
|
type: Input
|
|
2500
2621
|
}] } });
|
|
2501
2622
|
|
|
2502
|
-
class BaseOperandFiledArrayComponent {
|
|
2503
|
-
constructor() {
|
|
2504
|
-
this.readonly = false;
|
|
2505
|
-
this.valueChange = new EventEmitter();
|
|
2506
|
-
this.itemRemove = new EventEmitter();
|
|
2507
|
-
this.getFieldDisplayName = getFieldDisplayName;
|
|
2508
|
-
this.crdForm = inject(CrdFormComponent);
|
|
2509
|
-
}
|
|
2510
|
-
get expanded() {
|
|
2511
|
-
return this._expanded ?? !isFolded(this.arrayFieldGroup);
|
|
2512
|
-
}
|
|
2513
|
-
set expanded(expanded) {
|
|
2514
|
-
this._expanded = expanded;
|
|
2515
|
-
}
|
|
2516
|
-
ngOnChanges({ arrayFieldGroup, formDataState }) {
|
|
2517
|
-
if (!this.basicArrayFieldTemplate &&
|
|
2518
|
-
arrayFieldGroup.currentValue?.fieldLists?.length > 0) {
|
|
2519
|
-
this.basicArrayFieldTemplate = last(arrayFieldGroup.currentValue.fieldLists);
|
|
2520
|
-
}
|
|
2521
|
-
if (formDataState?.currentValue && formDataState?.previousValue) {
|
|
2522
|
-
const currValue = getFormData(formDataState.currentValue, this.arrayFieldGroup.path);
|
|
2523
|
-
const arrayFieldLength = this.arrayFieldGroup.fieldLists?.length;
|
|
2524
|
-
if (currValue?.size > arrayFieldLength) {
|
|
2525
|
-
Array.from({ length: currValue.size - arrayFieldLength }).forEach(() => {
|
|
2526
|
-
this.addItem();
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
fieldValueChange(e) {
|
|
2532
|
-
this.valueChange.emit(e);
|
|
2533
|
-
}
|
|
2534
|
-
addItem() {
|
|
2535
|
-
const newFields = this.basicArrayFieldTemplate.map(field => {
|
|
2536
|
-
const toPath = modifyArrayFieldPathIndex(field.path, () => this.arrayFieldGroup.fieldLists.length);
|
|
2537
|
-
return {
|
|
2538
|
-
...repairFieldChildPathByCorrectIndex(field, field.path, toPath),
|
|
2539
|
-
};
|
|
2540
|
-
});
|
|
2541
|
-
this.arrayFieldGroup.fieldLists = [
|
|
2542
|
-
...this.arrayFieldGroup.fieldLists,
|
|
2543
|
-
newFields,
|
|
2544
|
-
];
|
|
2545
|
-
}
|
|
2546
|
-
removeItem(index) {
|
|
2547
|
-
const groupToRemove = this.arrayFieldGroup.fieldLists[index];
|
|
2548
|
-
const groupUntouched = this.arrayFieldGroup.fieldLists.filter((_, idx) => idx < index);
|
|
2549
|
-
const groupToLeftShift = this.arrayFieldGroup.fieldLists.filter((_, idx) => idx > index);
|
|
2550
|
-
const leftShiftedGroups = groupToLeftShift.map(group => group.map(field => {
|
|
2551
|
-
const toPath = modifyArrayFieldPathIndex(field.path, idx => idx - 1);
|
|
2552
|
-
return {
|
|
2553
|
-
...repairFieldChildPathByCorrectIndex(field, field.path, toPath),
|
|
2554
|
-
};
|
|
2555
|
-
}));
|
|
2556
|
-
this.arrayFieldGroup.fieldLists = [...groupUntouched, ...leftShiftedGroups];
|
|
2557
|
-
const [match, formDataPathToRemove] = /^(.*\[\d+]).*$/.exec(groupToRemove?.[0].path) || [];
|
|
2558
|
-
if (match) {
|
|
2559
|
-
this.itemRemove.next(formDataPathToRemove);
|
|
2560
|
-
}
|
|
2561
|
-
this.crdForm.controlMap.forEach((_, key) => {
|
|
2562
|
-
if (key.startsWith(`${this.arrayFieldGroup.path}[${this.arrayFieldGroup.fieldLists.length}]`)) {
|
|
2563
|
-
this.crdForm.controlMap.delete(key);
|
|
2564
|
-
}
|
|
2565
|
-
});
|
|
2566
|
-
this.crdForm.refreshValidation();
|
|
2567
|
-
this.deleteFormData(`${this.arrayFieldGroup.path}[${index}]`);
|
|
2568
|
-
}
|
|
2569
|
-
deleteFormData(path) {
|
|
2570
|
-
this.valueChange.next({
|
|
2571
|
-
field: {
|
|
2572
|
-
...this.arrayFieldGroup,
|
|
2573
|
-
path,
|
|
2574
|
-
},
|
|
2575
|
-
data: null,
|
|
2576
|
-
});
|
|
2577
|
-
}
|
|
2578
|
-
fieldIsRequired(field) {
|
|
2579
|
-
return (field?.required ||
|
|
2580
|
-
Object.keys(field?.validations || {})?.includes(Validations.required));
|
|
2581
|
-
}
|
|
2582
|
-
get columnFields() {
|
|
2583
|
-
return this.basicArrayFieldTemplate;
|
|
2584
|
-
}
|
|
2585
|
-
trackByFn(index) {
|
|
2586
|
-
return index;
|
|
2587
|
-
}
|
|
2588
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: BaseOperandFiledArrayComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2589
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: BaseOperandFiledArrayComponent, isStandalone: true, inputs: { arrayFieldGroup: "arrayFieldGroup", formDataState: "formDataState", formErrors: "formErrors", isArrayTable: "isArrayTable", readonly: "readonly", fields: "fields" }, outputs: { valueChange: "valueChange", itemRemove: "itemRemove" }, usesOnChanges: true, ngImport: i0 }); }
|
|
2590
|
-
}
|
|
2591
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: BaseOperandFiledArrayComponent, decorators: [{
|
|
2592
|
-
type: Directive
|
|
2593
|
-
}], propDecorators: { arrayFieldGroup: [{
|
|
2594
|
-
type: Input
|
|
2595
|
-
}], formDataState: [{
|
|
2596
|
-
type: Input
|
|
2597
|
-
}], formErrors: [{
|
|
2598
|
-
type: Input
|
|
2599
|
-
}], isArrayTable: [{
|
|
2600
|
-
type: Input
|
|
2601
|
-
}], readonly: [{
|
|
2602
|
-
type: Input
|
|
2603
|
-
}], fields: [{
|
|
2604
|
-
type: Input
|
|
2605
|
-
}], valueChange: [{
|
|
2606
|
-
type: Output
|
|
2607
|
-
}], itemRemove: [{
|
|
2608
|
-
type: Output
|
|
2609
|
-
}] } });
|
|
2610
|
-
|
|
2611
2623
|
const WIDGETS = [
|
|
2612
2624
|
CrdFormArrayTableComponent,
|
|
2613
2625
|
K8sResourcePrefixComponent,
|
|
@@ -3084,5 +3096,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3084
3096
|
* Generated bundle index. Do not edit.
|
|
3085
3097
|
*/
|
|
3086
3098
|
|
|
3087
|
-
export { BaseOperandFiledArrayComponent, BasicAuthCreateSecretDialogComponent, BasicAuthSecretComponent, CrdFormArrayTableComponent, CrdFormComponent, DEFAULT_VALUE_PATTERN, DESCRIPTOR_DEFINITION_KEY, FieldControlsModule, FormItemComponent, GROUP_PATTERN, HtpasswdComponent, HtpasswdFormComponent, HtpasswdModule, K8sResourcePrefixComponent, LinkComponent, MAX_DEPTH, NamespacedResourceKind, NodeModel, OperandAdvancedFieldGroupComponent, OperandArrayFieldGroupComponent, OperandFieldComponent, OperandFieldGroupComponent, PASSWORD_REVEAL, REGEXP_CAPABILITY_VALIDATION, REGEXP_FIELD_DEPENDENCY_CAPABILITY, REGEXP_K8S_RESOURCE_CAPABILITY, REGEXP_K8S_RESOURCE_SUFFIX, REGEXP_SELECT_CAPABILITY, REGEXP_VALIDATION_SUFFIX, ResourceRequirementsComponent, SCHEMA_PATH, SpecCapability, SpecCapabilityComponent, SpecCapabilityListComponent, SpecCapabilityUIPrefix, SpecCapabilityWidgetsPrefix, Validations, YamlEditorComponent, _isNumberValue, capabilityComponents, capabilityFor, coerceBoolean, coerceNumber, convertBooleanSwitchValue, convertValue, createCapabilityField, evalInContext, fieldShouldReveal, filterMapByKey, flattenNestedProperties, getArrayGroupName, getBasicAuthSecretConfig, getBasicCapabilityType, getBooleanSwitchOptions, getCapabilitiesForOpenApiProperty, getCapabilityDisabled, getCapabilityValidations, getDefaultValue, getFieldDescription$1 as getFieldDescription, getFieldDisplayName, getFieldDocLink, getFieldPlaceholder$1 as getFieldPlaceholder, getFieldTooltip, getFieldType, getFieldsByPath, getFieldsFromDescriptor, getFieldsFromOpenApiSchema, getFormData, getGroupName, getK8sResourcePrefixOptions, getMatchArrayIndex, getMatchedCapabilityValue, getOneOfMap, getOpenApiPropertyByPath, getOperandPath, getPathFromTagPath, getPropertyDepth, getRadioOptions, getRelatedFields, getTreeFields, hasDescriptor, isAllowCreate, isArrayField, isArrayFieldTable, isClearable, isCreatable, isEmptyArray, isFieldCopyable, isFieldDescriptionAsLink, isFolded, isGroupField, isLink, isMultiple, isRemoteField, isRequired, modifyArrayFieldPathIndex, normalizePath, parseArrayPath, parseGroupDescriptor, pathToArray, repairFieldChildPathByCorrectIndex, resolveKVParams, resolveLinkOptions, setRadiosDefaultValue };
|
|
3099
|
+
export { BaseOperandFiledArrayComponent, BasicAuthCreateSecretDialogComponent, BasicAuthSecretComponent, CRD_FORM_CONTEXT, CrdFormArrayTableComponent, CrdFormComponent, DEFAULT_VALUE_PATTERN, DESCRIPTOR_DEFINITION_KEY, FieldControlsModule, FormItemComponent, GROUP_PATTERN, HtpasswdComponent, HtpasswdFormComponent, HtpasswdModule, K8sResourcePrefixComponent, LinkComponent, MAX_DEPTH, NamespacedResourceKind, NodeModel, OperandAdvancedFieldGroupComponent, OperandArrayFieldGroupComponent, OperandFieldComponent, OperandFieldGroupComponent, PASSWORD_REVEAL, REGEXP_CAPABILITY_VALIDATION, REGEXP_FIELD_DEPENDENCY_CAPABILITY, REGEXP_K8S_RESOURCE_CAPABILITY, REGEXP_K8S_RESOURCE_SUFFIX, REGEXP_SELECT_CAPABILITY, REGEXP_VALIDATION_SUFFIX, ResourceRequirementsComponent, SCHEMA_PATH, SpecCapability, SpecCapabilityComponent, SpecCapabilityListComponent, SpecCapabilityUIPrefix, SpecCapabilityWidgetsPrefix, Validations, YamlEditorComponent, _isNumberValue, capabilityComponents, capabilityFor, coerceBoolean, coerceNumber, convertBooleanSwitchValue, convertValue, createCapabilityField, evalInContext, fieldShouldReveal, filterMapByKey, flattenNestedProperties, getArrayGroupName, getBasicAuthSecretConfig, getBasicCapabilityType, getBooleanSwitchOptions, getCapabilitiesForOpenApiProperty, getCapabilityDisabled, getCapabilityValidations, getDefaultValue, getFieldDescription$1 as getFieldDescription, getFieldDisplayName, getFieldDocLink, getFieldPlaceholder$1 as getFieldPlaceholder, getFieldTooltip, getFieldType, getFieldsByPath, getFieldsFromDescriptor, getFieldsFromOpenApiSchema, getFormData, getGroupName, getK8sResourcePrefixOptions, getMatchArrayIndex, getMatchedCapabilityValue, getOneOfMap, getOpenApiPropertyByPath, getOperandPath, getPathFromTagPath, getPropertyDepth, getRadioOptions, getRelatedFields, getTreeFields, hasDescriptor, isAllowCreate, isArrayField, isArrayFieldTable, isClearable, isCreatable, isEmptyArray, isFieldCopyable, isFieldDescriptionAsLink, isFolded, isGroupField, isLink, isMultiple, isRemoteField, isRequired, modifyArrayFieldPathIndex, normalizePath, parseArrayPath, parseGroupDescriptor, pathToArray, repairFieldChildPathByCorrectIndex, resolveKVParams, resolveLinkOptions, setRadiosDefaultValue };
|
|
3088
3100
|
//# sourceMappingURL=alauda-fe-crd-form.mjs.map
|