@piying/view-angular-core 1.9.2 → 1.9.4
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.
|
@@ -355,7 +355,7 @@ class ObjectTypeService extends BaseTypeService {
|
|
|
355
355
|
});
|
|
356
356
|
const depList = schema$1.dependentRequired?.[key];
|
|
357
357
|
if (depList) {
|
|
358
|
-
propVSchema = v.pipe(propVSchema, jsonActions.
|
|
358
|
+
propVSchema = v.pipe(propVSchema, jsonActions.mergeHooks({
|
|
359
359
|
allFieldsResolved: (field) => {
|
|
360
360
|
field.form.control.statusChanges.subscribe(() => {
|
|
361
361
|
const valid = field.form.control.valid;
|
|
@@ -627,6 +627,7 @@ function toFixedList(data, labelFn = (a) => a) {
|
|
|
627
627
|
return data.map((item) => ({ label: labelFn(item), value: item }));
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
const EMPTY_DEFINE = v.pipe(v.any(), jsonActions.setComponent(''));
|
|
630
631
|
function arrayIntersection(a, b) {
|
|
631
632
|
if (!isNil(a) && !isNil(b)) {
|
|
632
633
|
a = Array.isArray(a) ? a : [a];
|
|
@@ -827,34 +828,32 @@ class CommonTypeService extends BaseTypeService {
|
|
|
827
828
|
});
|
|
828
829
|
}
|
|
829
830
|
else if ('if' in schema$1) {
|
|
830
|
-
/**
|
|
831
|
-
* 当前设计中if/then/else是采用的分离显示
|
|
832
|
-
* 也就是then/else都会合并base,然后按条件展示,
|
|
833
|
-
*/
|
|
834
|
-
const useThen$ = new BehaviorSubject(undefined);
|
|
835
|
-
let base1Schema = v.pipe(this.#jsonSchemaBase(schema$1, () => [
|
|
836
|
-
...this.getValidationActionList(schema$1),
|
|
837
|
-
]));
|
|
838
|
-
const baseSchema = v.pipe(base1Schema, jsonActions.hideWhen({
|
|
839
|
-
disabled: false,
|
|
840
|
-
listen: (fn) => fn({}).pipe(map(({ list: [value], field }) => {
|
|
841
|
-
const isThen = isBoolean(schema$1.if)
|
|
842
|
-
? schema$1.if
|
|
843
|
-
: v.safeParse(ifVSchema, value).success;
|
|
844
|
-
field.form.parent.activateIndex$.set(isThen ? 1 : 2);
|
|
845
|
-
useThen$.next(isThen);
|
|
846
|
-
return true;
|
|
847
|
-
})),
|
|
848
|
-
}));
|
|
849
831
|
/** 仅为验证项,非显示用 */
|
|
850
832
|
let ifVSchema;
|
|
851
833
|
if (isBoolean(schema$1.if)) {
|
|
852
834
|
ifVSchema = v.pipe(v.any(), v.check(() => !!schema$1.if));
|
|
853
835
|
}
|
|
854
836
|
else {
|
|
855
|
-
const ifSchema = this
|
|
856
|
-
ifVSchema = v.pipe(this.#jsonSchemaBase(ifSchema
|
|
837
|
+
const ifSchema = this.resolveSchema2(schema$1.if);
|
|
838
|
+
ifVSchema = v.pipe(this.#jsonSchemaBase(ifSchema, () => this.getValidationActionList(ifSchema)));
|
|
857
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* 当前设计中if/then/else是采用的分离显示
|
|
842
|
+
* 也就是then/else都会合并base,然后按条件展示,
|
|
843
|
+
*/
|
|
844
|
+
const useThen$ = new BehaviorSubject(undefined);
|
|
845
|
+
const baseSchema = this.#jsonSchemaBase(schema$1, () => [
|
|
846
|
+
...this.getValidationActionList(schema$1),
|
|
847
|
+
jsonActions.valueChange((fn) => {
|
|
848
|
+
fn().subscribe(({ list: [value], field }) => {
|
|
849
|
+
const isThen = isBoolean(schema$1.if)
|
|
850
|
+
? schema$1.if
|
|
851
|
+
: v.safeParse(ifVSchema, value).success;
|
|
852
|
+
field.form.parent.activateIndex$.set(isThen ? 1 : 2);
|
|
853
|
+
useThen$.next(isThen);
|
|
854
|
+
});
|
|
855
|
+
}),
|
|
856
|
+
]);
|
|
858
857
|
function hideAction(isThen) {
|
|
859
858
|
return [
|
|
860
859
|
jsonActions.renderConfig({ hidden: true }),
|
|
@@ -868,43 +867,54 @@ class CommonTypeService extends BaseTypeService {
|
|
|
868
867
|
}
|
|
869
868
|
let thenSchema;
|
|
870
869
|
if (schema$1.then && !isBoolean(schema$1.then)) {
|
|
871
|
-
const subSchema = this
|
|
872
|
-
thenSchema = v.pipe(this.#jsonSchemaBase(subSchema
|
|
873
|
-
...subSchema
|
|
870
|
+
const subSchema = this.resolveSchema2(schema$1.then);
|
|
871
|
+
thenSchema = v.pipe(this.#jsonSchemaBase(subSchema, () => [
|
|
872
|
+
...this.getValidationActionList(subSchema),
|
|
873
|
+
...hideAction(true),
|
|
874
874
|
]));
|
|
875
|
+
if (!subSchema.__resolved.type.types.includes('object')) {
|
|
876
|
+
thenSchema = v.pipe(thenSchema, jsonActions.setComponent(''), jsonActions.renderConfig({ hidden: true }));
|
|
877
|
+
}
|
|
875
878
|
}
|
|
876
879
|
else {
|
|
877
|
-
thenSchema =
|
|
880
|
+
thenSchema = EMPTY_DEFINE;
|
|
878
881
|
}
|
|
879
|
-
thenSchema = v.pipe(thenSchema, ...hideAction(true));
|
|
880
882
|
let elseSchema;
|
|
881
883
|
if (schema$1.else && !isBoolean(schema$1.else)) {
|
|
882
|
-
const subSchema = this
|
|
883
|
-
elseSchema = v.pipe(this.#jsonSchemaBase(subSchema
|
|
884
|
-
...subSchema
|
|
884
|
+
const subSchema = this.resolveSchema2(schema$1.else);
|
|
885
|
+
elseSchema = v.pipe(this.#jsonSchemaBase(subSchema, () => [
|
|
886
|
+
...this.getValidationActionList(subSchema),
|
|
887
|
+
...hideAction(false),
|
|
885
888
|
]));
|
|
889
|
+
if (!subSchema.__resolved.type.types.includes('object')) {
|
|
890
|
+
elseSchema = v.pipe(elseSchema, jsonActions.setComponent(''), jsonActions.renderConfig({ hidden: true }));
|
|
891
|
+
}
|
|
886
892
|
}
|
|
887
893
|
else {
|
|
888
|
-
elseSchema =
|
|
894
|
+
elseSchema = EMPTY_DEFINE;
|
|
889
895
|
}
|
|
890
|
-
elseSchema = v.pipe(elseSchema, ...hideAction(false));
|
|
891
896
|
// 这种逻辑没问题,因为jsonschema验证中,也会出现base和子级架构一起验证
|
|
892
897
|
vSchema = v.pipe(v.union([baseSchema, thenSchema, elseSchema]), jsonActions.formConfig({ disableOrUpdateActivate: true }), v.rawCheck(({ dataset, addIssue }) => {
|
|
893
898
|
if (dataset.issues) {
|
|
894
899
|
return;
|
|
895
900
|
}
|
|
901
|
+
const result = v.safeParse(baseSchema, dataset.value);
|
|
902
|
+
if (!result.success) {
|
|
903
|
+
addIssue({ label: `if:default` });
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
896
906
|
const status = useThen$.value;
|
|
897
907
|
if (status && thenSchema) {
|
|
898
908
|
const result = v.safeParse(thenSchema, dataset.value);
|
|
899
909
|
if (!result.success) {
|
|
900
|
-
addIssue();
|
|
910
|
+
addIssue({ label: `if:then` });
|
|
901
911
|
return;
|
|
902
912
|
}
|
|
903
913
|
}
|
|
904
914
|
if (!status && elseSchema) {
|
|
905
915
|
const result = v.safeParse(elseSchema, dataset.value);
|
|
906
916
|
if (!result.success) {
|
|
907
|
-
addIssue();
|
|
917
|
+
addIssue({ label: `if:else` });
|
|
908
918
|
return;
|
|
909
919
|
}
|
|
910
920
|
}
|
|
@@ -1038,7 +1048,7 @@ class CommonTypeService extends BaseTypeService {
|
|
|
1038
1048
|
}
|
|
1039
1049
|
conditionResult.conditionKeyList = excludeFixedConditionList;
|
|
1040
1050
|
}
|
|
1041
|
-
const checkAction = jsonActions.
|
|
1051
|
+
const checkAction = jsonActions.mergeHooks({
|
|
1042
1052
|
allFieldsResolved: (field) => {
|
|
1043
1053
|
const displayName = ['..', 2];
|
|
1044
1054
|
const list = [];
|