mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:25:15 +00:00
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-props': {
|
||||
stringMode: true,
|
||||
step: '0',
|
||||
step: '1',
|
||||
},
|
||||
'x-validator': 'integer',
|
||||
},
|
||||
|
@ -18,7 +18,7 @@ export const number: IField = {
|
||||
'x-component': 'InputNumber',
|
||||
'x-component-props': {
|
||||
stringMode: true,
|
||||
step: '0',
|
||||
step: '1',
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -32,9 +32,9 @@ export const number: IField = {
|
||||
title: '{{t("Precision")}}',
|
||||
'x-component': 'Select',
|
||||
'x-decorator': 'FormItem',
|
||||
default: '0',
|
||||
default: '1',
|
||||
enum: [
|
||||
{ value: '0', label: '1' },
|
||||
{ value: '1', label: '1' },
|
||||
{ value: '0.1', label: '1.0' },
|
||||
{ value: '0.01', label: '1.00' },
|
||||
{ value: '0.001', label: '1.000' },
|
||||
|
@ -63,7 +63,7 @@ export const percent: IField = {
|
||||
'x-component': 'Percent',
|
||||
'x-component-props': {
|
||||
stringMode: true,
|
||||
step: '0',
|
||||
step: '1',
|
||||
addonAfter: '%',
|
||||
},
|
||||
},
|
||||
@ -85,9 +85,9 @@ export const percent: IField = {
|
||||
title: '{{t("Precision")}}',
|
||||
'x-component': 'Select',
|
||||
'x-decorator': 'FormItem',
|
||||
default: '0',
|
||||
default: '1',
|
||||
enum: [
|
||||
{ value: '0', label: '1%' },
|
||||
{ value: '1', label: '1%' },
|
||||
{ value: '0.1', label: '1.0%' },
|
||||
{ value: '0.01', label: '1.00%' },
|
||||
{ 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