Commit 463509d3 authored by 金昶's avatar 金昶
Browse files

feat: add hasDefaultValue property

No related merge requests found
Showing with 19 additions and 4 deletions
+19 -4
......@@ -26,8 +26,6 @@ const InternalField: React.FC = (props) => {
};
const ctx = useFormBlockContext();
console.log('InternalField', fieldSchema, collectionField, ctx);
useEffect(() => {
if (ctx?.field) {
ctx.field.added = ctx.field.added || new Set();
......
......@@ -22,7 +22,7 @@ const getSchema = (schema: IField, record: any, compile): ISchema => {
const properties = cloneDeep(schema.properties) as any;
if (!['systemInfo', 'relation', 'advanced'].includes(schema.group)) {
if (schema.hasDefaultValue === true) {
properties['defaultValue'] = cloneDeep(schema.default.uiSchema);
properties['defaultValue']['title'] = compile('{{ t("Default value") }}');
properties['defaultValue']['x-decorator'] = 'FormItem';
......
......@@ -20,7 +20,7 @@ const getSchema = (schema: IField, record: any, compile): ISchema => {
const properties = cloneDeep(schema.properties) as any;
properties.name['x-disabled'] = true;
if (!['systemInfo', 'relation', 'advanced'].includes(schema.group)) {
if (schema.hasDefaultValue === true) {
properties['defaultValue'] = cloneDeep(schema.default.uiSchema);
properties['defaultValue']['title'] = compile('{{ t("Default value") }}');
properties['defaultValue']['x-decorator'] = 'FormItem';
......
......@@ -15,6 +15,7 @@ export const checkbox: IField = {
'x-component': 'Checkbox',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -17,6 +17,7 @@ export const checkboxGroup: IField = {
'x-component': 'Checkbox.Group',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.enum': dataSource,
......
......@@ -20,6 +20,7 @@ export const datetime: IField = {
},
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
...dateTimeProps,
......
......@@ -18,6 +18,7 @@ export const email: IField = {
'x-validator': 'email',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -16,6 +16,7 @@ export const icon: IField = {
'x-component': 'IconPicker',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -18,6 +18,7 @@ export const input: IField = {
'x-component': 'Input',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -30,6 +30,7 @@ export const integer: IField = {
'x-validator': 'integer',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -17,6 +17,7 @@ export const markdown: IField = {
'x-component': 'Markdown',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -21,6 +21,7 @@ export const multipleSelect: IField = {
enum: [],
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.enum': dataSource,
......
......@@ -24,6 +24,7 @@ export const number: IField = {
},
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.x-component-props.step': {
......
......@@ -18,6 +18,7 @@ export const password: IField = {
'x-component': 'Password',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -68,6 +68,7 @@ export const percent: IField = {
},
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.x-component-props.step': {
......
......@@ -21,6 +21,7 @@ export const phone: IField = {
// 'x-validator': 'phone',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -17,6 +17,7 @@ export const radioGroup: IField = {
'x-component': 'Radio.Group',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.enum': dataSource,
......
......@@ -18,6 +18,7 @@ export const richText: IField = {
'x-component': 'RichText',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
......@@ -18,6 +18,7 @@ export const select: IField = {
enum: [],
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
'uiSchema.enum': dataSource,
......
......@@ -18,6 +18,7 @@ export const textarea: IField = {
'x-component': 'Input.TextArea',
},
},
hasDefaultValue: true,
properties: {
...defaultProps,
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment