mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(users): issue with parsing the user profile form schema (#6635)
This commit is contained in:
parent
773ee94db4
commit
403ff24800
@ -12,16 +12,39 @@ import { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { namespace } from '..';
|
import { namespace } from '..';
|
||||||
import { ValidationError, ValidationErrorItem } from 'sequelize';
|
import { ValidationError, ValidationErrorItem } from 'sequelize';
|
||||||
import PluginSystemSettingsServer from '@nocobase/plugin-system-settings';
|
|
||||||
|
function findNonVoidTypeObjects(obj: any, path = '', results = []): { name: string; props: any }[] {
|
||||||
|
for (const key in obj) {
|
||||||
|
const value = obj[key];
|
||||||
|
|
||||||
|
const currentPath = path ? `${path}.${key}` : key;
|
||||||
|
|
||||||
|
if (value && typeof value === 'object') {
|
||||||
|
if (value.type && value.type !== 'void') {
|
||||||
|
results.push({
|
||||||
|
name: key,
|
||||||
|
props: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.properties) {
|
||||||
|
findNonVoidTypeObjects(value.properties, `${currentPath}.properties`, results);
|
||||||
|
} else {
|
||||||
|
findNonVoidTypeObjects(value, currentPath, results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
function parseProfileFormSchema(schema: any) {
|
function parseProfileFormSchema(schema: any) {
|
||||||
const properties = _.get(schema, 'properties.form.properties.edit.properties.grid.properties') || {};
|
const properties = _.get(schema, 'properties.form.properties.edit.properties.grid.properties') || {};
|
||||||
const fields = [];
|
const fields = [];
|
||||||
const requiredFields = [];
|
const requiredFields = [];
|
||||||
Object.values(properties).forEach((row: any) => {
|
const configs = findNonVoidTypeObjects(properties);
|
||||||
const col = Object.values(row.properties)[0] as any;
|
Object.values(configs).forEach(({ name, props }) => {
|
||||||
const [name, props] = Object.entries(col.properties)[0];
|
if (props['x-read-pretty'] || props['x-disabled']) {
|
||||||
if (props['x-read-pretty'] || props['x-disable']) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (props['required']) {
|
if (props['required']) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user