merge to kintone exec
This commit is contained in:
@@ -23,22 +23,16 @@ type ConditionItem = {
|
||||
};
|
||||
|
||||
export const conditionList: ConditionItem[] = [
|
||||
{ value: '=', label: '=(等しい)', type: 'input' },
|
||||
{ value: '!=', label: '≠ (等しくない)', type: 'input' },
|
||||
{ value: '<=', label: (field) => isDateTimeType(field) ? '≦ (以前)' : '≦ (以下)', type: 'input' },
|
||||
{ value: '<', label: '< (より前)', type: 'input' },
|
||||
{ value: '>', label: '> (より後)', type: 'input' },
|
||||
{ value: '>=', label: (field) => isDateTimeType(field) ? '≧ (以降)' : '≧ (以上)', type: 'input' },
|
||||
{ value: 'like', label: '次のキーワードを含む', type: 'input' },
|
||||
{ value: 'not like', label:'次のキーワードを含まない', type: 'input' },
|
||||
{ value: 'in', label: '次のいずれかを含む', type: 'input' },
|
||||
{ value: 'not in', label: '次のいずれも含まない', type: 'input' },
|
||||
{ value: 'eq', label: '=(等しい)', type: 'input' },
|
||||
{ value: 'ne', label: '≠ (等しくない)', type: 'input' },
|
||||
{ value: 'le', label: (field) => isDateTimeType(field) ? '≦ (以前)' : '≦ (以下)', type: 'input' },
|
||||
{ value: 'lt', label: '< (より前)', type: 'input' },
|
||||
{ value: 'gt', label: '> (より後)', type: 'input' },
|
||||
{ value: 'ge', label: (field) => isDateTimeType(field) ? '≧ (以降)' : '≧ (以上)', type: 'input' },
|
||||
{ value: 'contains', label: '次のいずれかを含む', type: 'input' },
|
||||
{ value: 'not_contain', label: '次のいずれも含まない', type: 'input' },
|
||||
];
|
||||
|
||||
export const isDateTimeType = (field: OneOf) => {
|
||||
return isType.DATETIME(field) || isType.TIME(field) || isType.DATE(field) || isType.CREATED_TIME(field) || isType.UPDATED_TIME(field);
|
||||
}
|
||||
|
||||
// search from conditionList
|
||||
// conditionItem = conditionMap[conditionValue]
|
||||
export const conditionMap: Record<ConditionValue, ConditionItem> = conditionList.reduce(
|
||||
@@ -50,7 +44,6 @@ export const conditionMap: Record<ConditionValue, ConditionItem> = conditionList
|
||||
);
|
||||
|
||||
type FieldConditions = Partial<Record<FieldType, ConditionValue[]>>;
|
||||
|
||||
const textCondition: ConditionValue[] = ['=', '!=', 'in', 'like','not like'];
|
||||
const numberCondition: ConditionValue[] = ['=', '!=', '<=', '>='];
|
||||
const timeCondition: ConditionValue[] = ['=', '!=', '<=', '>=', '<', '>'];
|
||||
@@ -98,11 +91,15 @@ export const getAvailableCondition = (fieldCode: string, fieldsInfo: FieldsInfo,
|
||||
const component = {
|
||||
input: 'kuc-text',
|
||||
select: 'kuc-combobox',
|
||||
time: 'time',
|
||||
time: 'kuc-time',
|
||||
date: 'date',
|
||||
datetime: 'datetime',
|
||||
};
|
||||
|
||||
export const isDateTimeType = (field: OneOf) => {
|
||||
return field.type in dateTimeComponent;
|
||||
}
|
||||
|
||||
const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
TIME: 'time',
|
||||
DATE: 'date',
|
||||
@@ -112,7 +109,8 @@ const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
}
|
||||
|
||||
export type ComponentType = keyof typeof component;
|
||||
export const getComponent = (value: ConditionValue) => {
|
||||
export const getComponent = (value: ConditionValue, fieldObj: OneOf) => {
|
||||
if (!value) return;
|
||||
return component[conditionMap[value].type];
|
||||
const condition = conditionMap[value].type;
|
||||
return component[typeof condition === 'function' ? condition(fieldObj) : condition];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user