fix(input-number): change step to 1 (#2104)
This commit is contained in:
parent
7bd3168422
commit
8b03dfa96b
@ -24,7 +24,7 @@ export const integer: IField = {
|
|||||||
'x-component': 'InputNumber',
|
'x-component': 'InputNumber',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
stringMode: true,
|
stringMode: true,
|
||||||
step: '0',
|
step: '1',
|
||||||
},
|
},
|
||||||
'x-validator': 'integer',
|
'x-validator': 'integer',
|
||||||
},
|
},
|
||||||
|
@ -18,7 +18,7 @@ export const number: IField = {
|
|||||||
'x-component': 'InputNumber',
|
'x-component': 'InputNumber',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
stringMode: true,
|
stringMode: true,
|
||||||
step: '0',
|
step: '1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -32,9 +32,9 @@ export const number: IField = {
|
|||||||
title: '{{t("Precision")}}',
|
title: '{{t("Precision")}}',
|
||||||
'x-component': 'Select',
|
'x-component': 'Select',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
default: '0',
|
default: '1',
|
||||||
enum: [
|
enum: [
|
||||||
{ value: '0', label: '1' },
|
{ value: '1', label: '1' },
|
||||||
{ value: '0.1', label: '1.0' },
|
{ value: '0.1', label: '1.0' },
|
||||||
{ value: '0.01', label: '1.00' },
|
{ value: '0.01', label: '1.00' },
|
||||||
{ value: '0.001', label: '1.000' },
|
{ value: '0.001', label: '1.000' },
|
||||||
|
@ -63,7 +63,7 @@ export const percent: IField = {
|
|||||||
'x-component': 'Percent',
|
'x-component': 'Percent',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
stringMode: true,
|
stringMode: true,
|
||||||
step: '0',
|
step: '1',
|
||||||
addonAfter: '%',
|
addonAfter: '%',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -85,9 +85,9 @@ export const percent: IField = {
|
|||||||
title: '{{t("Precision")}}',
|
title: '{{t("Precision")}}',
|
||||||
'x-component': 'Select',
|
'x-component': 'Select',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
default: '0',
|
default: '1',
|
||||||
enum: [
|
enum: [
|
||||||
{ value: '0', label: '1%' },
|
{ value: '1', label: '1%' },
|
||||||
{ value: '0.1', label: '1.0%' },
|
{ value: '0.1', label: '1.0%' },
|
||||||
{ value: '0.01', label: '1.00%' },
|
{ value: '0.01', label: '1.00%' },
|
||||||
{ value: '0.001', label: '1.000%' },
|
{ value: '0.001', label: '1.000%' },
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
import { Collection } from '@nocobase/database';
|
||||||
|
import { Migration } from '@nocobase/server';
|
||||||
|
import { FieldModel } from '../models';
|
||||||
|
|
||||||
|
export default class extends Migration {
|
||||||
|
async up() {
|
||||||
|
const transaction = await this.db.sequelize.transaction();
|
||||||
|
|
||||||
|
const migrateFieldsSchema = async (collection: Collection) => {
|
||||||
|
this.app.log.info(`Start to migrate ${collection.name} collection's ui schema`);
|
||||||
|
|
||||||
|
const fieldRecords: Array<FieldModel> = await collection.repository.find({
|
||||||
|
transaction,
|
||||||
|
filter: {
|
||||||
|
type: ['bigInt', 'float', 'double'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.app.log.info(`Total ${fieldRecords.length} fields need to be migrated`);
|
||||||
|
|
||||||
|
for (const fieldRecord of fieldRecords) {
|
||||||
|
const uiSchema = fieldRecord.get('uiSchema');
|
||||||
|
if (uiSchema?.['x-component-props']?.step !== '0') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uiSchema['x-component-props']['step'] = '1';
|
||||||
|
fieldRecord.set('uiSchema', uiSchema);
|
||||||
|
await fieldRecord.save({
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
console.log(`changed: ${fieldRecord.get('collectionName')}.${fieldRecord.get('name')}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await migrateFieldsSchema(this.db.getCollection('fields'));
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (error) {
|
||||||
|
await transaction.rollback();
|
||||||
|
this.app.log.error(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user