Fix code format
This commit is contained in:
@@ -27,29 +27,29 @@
|
||||
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
|
||||
/>
|
||||
<kuc-multi-choice
|
||||
v-else-if="valueType=== 'kuc-multichoice'"
|
||||
:value = "muiltValue"
|
||||
:items = "multiChoiceItems"
|
||||
:requiredIcon = "true"
|
||||
@change="updateMuiltValue"
|
||||
v-else-if="valueType === 'kuc-multichoice'"
|
||||
:value="multiValue"
|
||||
:items="multiChoiceItems"
|
||||
:requiredIcon="true"
|
||||
@change="updateMultiValue"
|
||||
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
|
||||
></kuc-multi-choice>
|
||||
/>
|
||||
<table-condition-value-multi-input
|
||||
v-else-if = "valueType ==='multi-input'"
|
||||
:value="muiltInput"
|
||||
v-else-if="valueType === 'multi-input'"
|
||||
:value="multiInput"
|
||||
@change="updateTableValue"
|
||||
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getComponent } from '@/js/conditions';
|
||||
import { getFieldObj, isStringArray, search } from '@/js/helper';
|
||||
import { isType } from '@/js/kintone-rest-api-client';
|
||||
import { isSelectType } from '@/js/mapping';
|
||||
import type { CachedSelectedAppData, StringValue, WhereCondition } from '@/types/model';
|
||||
import type { KucEvent } from '@/types/my-kintone';
|
||||
import type { ComboboxChangeEventDetail, TextInputEventDetail,MultiChoiceChangeEventDetail, TableChangeEventDetail } from 'kintone-ui-component';
|
||||
import type { ComboboxChangeEventDetail, TextInputEventDetail, MultiChoiceChangeEventDetail } from 'kintone-ui-component';
|
||||
import { defineProps, defineEmits, computed, type Ref, inject, provide, ref, watch, watchEffect } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -64,10 +64,10 @@ provide('canSave', props.canSave);
|
||||
|
||||
const whereCondition = computed(() => search(props.whereConditions, props.id) as WhereCondition | undefined);
|
||||
|
||||
const needPlaceholderWidthClass = computed(() => placeholder.value ? 'kuc-text-input-placeholder-width' : '')
|
||||
const needPlaceholderWidthClass = computed(() => (placeholder.value ? 'kuc-text-input-placeholder-width' : ''));
|
||||
|
||||
const placeholder = computed(() => {
|
||||
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '')
|
||||
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
|
||||
if (isType.GROUP_SELECT(field)) {
|
||||
return 'グループコードをカンマ区切りで指定';
|
||||
} else if (isType.ORGANIZATION_SELECT(field)) {
|
||||
@@ -78,29 +78,28 @@ const placeholder = computed(() => {
|
||||
return '';
|
||||
});
|
||||
|
||||
const multiChoiceItems = computed(()=>{
|
||||
const field = getFieldObj(whereCondition.value ?.field || '', props.selectedAppData.appFields, '');
|
||||
const multiChoiceItems = computed(() => {
|
||||
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
|
||||
const items = [{
|
||||
label:'--',
|
||||
value:''
|
||||
label: '--',
|
||||
value: '',
|
||||
}];
|
||||
if(field && "options" in field){
|
||||
const opts =field.options;
|
||||
const muiltOpts = Object.values(opts).map(opt=>{
|
||||
if (field && isSelectType(field)) {
|
||||
const opts = field.options;
|
||||
const multiOpts = Object.values(opts).map((opt) => {
|
||||
return {
|
||||
label:opt.label,
|
||||
value:opt.label
|
||||
}
|
||||
label: opt.label,
|
||||
value: opt.label,
|
||||
};
|
||||
});
|
||||
items.push(...muiltOpts);
|
||||
items.push(...multiOpts);
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
const valueType = computed(() => {
|
||||
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
|
||||
const vtype = getComponent(whereCondition.value?.condition || '', field)
|
||||
return vtype;
|
||||
return getComponent(whereCondition.value?.condition || '', field);
|
||||
});
|
||||
|
||||
type EmitData = {
|
||||
@@ -116,36 +115,36 @@ const updateValue = (event: KucEvent<ComboboxChangeEventDetail | TextInputEventD
|
||||
emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || '' });
|
||||
};
|
||||
|
||||
const muiltValue = ref(isStringArray(props.modelValue.value) ? props.modelValue.value : []);
|
||||
const multiValue = ref(isStringArray(props.modelValue.value) ? props.modelValue.value : []);
|
||||
|
||||
watch(
|
||||
()=>props.modelValue,
|
||||
()=>{
|
||||
const field = getFieldObj(whereCondition.value ?.field || '', props.selectedAppData.appFields, '');
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
|
||||
const vType = valueType.value;
|
||||
const moduleValue = props.modelValue.value;
|
||||
if (field && isSelectType(field) && vType === 'kuc-multichoice') {
|
||||
multiValue.value = isStringArray(moduleValue) ? moduleValue : [];
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const multiInput = ref(isStringArray(props.modelValue.value) ? (props.modelValue.value as string[]) : ['', '']);
|
||||
watchEffect(() => {
|
||||
const vType = valueType.value;
|
||||
const moduleValue = props.modelValue.value;
|
||||
if(field && "options" in field && (vType==='kuc-multichoice' )){
|
||||
muiltValue.value = isStringArray(moduleValue) ? moduleValue : [];
|
||||
if (vType === 'multi-input') {
|
||||
multiInput.value = isStringArray(moduleValue) ? (moduleValue as string[]) : ['', ''];
|
||||
}
|
||||
});
|
||||
|
||||
const muiltInput = ref(isStringArray(props.modelValue.value) ? props.modelValue.value as string[] : ["",""]);
|
||||
watchEffect(()=>{
|
||||
const field = getFieldObj(whereCondition.value ?.field || '', props.selectedAppData.appFields, '');
|
||||
const vType = valueType.value;
|
||||
const moduleValue = props.modelValue.value;
|
||||
if( vType==='multi-input'){
|
||||
muiltInput.value = isStringArray(moduleValue) ? moduleValue as string[] : ["",""];
|
||||
}
|
||||
});
|
||||
|
||||
const updateMuiltValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => {
|
||||
let value = event.detail.value || [];
|
||||
emit('update:modelValue',{ obj: whereCondition.value, value: event.detail.value ||[] } );
|
||||
const updateMultiValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => {
|
||||
emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || [] });
|
||||
};
|
||||
|
||||
const updateTableValue =(event: KucEvent<string[]>)=>{
|
||||
let value = event.detail || ["",""];
|
||||
muiltInput.value = value;
|
||||
emit('update:modelValue',{ obj: whereCondition.value, value: value } );
|
||||
}
|
||||
const updateTableValue = (event: KucEvent<string[]>) => {
|
||||
let value = event.detail || ['', ''];
|
||||
multiInput.value = value;
|
||||
emit('update:modelValue', { obj: whereCondition.value, value: value });
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -30,8 +30,8 @@ export const conditionList: ConditionItem[] = [
|
||||
{ value: '>', label: '> (より後)', type: (field) => dateTimeComponent[field.type] || 'input' },
|
||||
{ value: 'like', label: '次のキーワードを含む', type: 'input' },
|
||||
{ value: 'not like', label: '次のキーワードを含まない', type: 'input' },
|
||||
{ value: 'in', label: '次のいずれかを含む', type: (field)=>MultiChoiceComponent[field.type] || 'input' },
|
||||
{ value: 'not in', label: '次のいずれも含まない', type: (field)=>MultiChoiceComponent[field.type] || 'input' },
|
||||
{ value: 'in', label: '次のいずれかを含む', type: (field) => MultiChoiceComponent[field.type] || 'input' },
|
||||
{ value: 'not in', label: '次のいずれも含まない', type: (field) => MultiChoiceComponent[field.type] || 'input' },
|
||||
];
|
||||
|
||||
// search from conditionList
|
||||
@@ -95,8 +95,8 @@ const component = {
|
||||
time: 'kuc-time',
|
||||
date: 'date',
|
||||
datetime: 'datetime',
|
||||
multiChoice:'kuc-multichoice',
|
||||
multiInput :"multi-input"
|
||||
multiChoice: 'kuc-multichoice',
|
||||
multiInput: 'multi-input',
|
||||
};
|
||||
|
||||
export const isDateTimeType = (field: OneOf) => {
|
||||
@@ -111,16 +111,15 @@ const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
UPDATED_TIME: 'datetime',
|
||||
};
|
||||
|
||||
const MultiChoiceComponent:Partial<Record<FieldType, ComponentType>> = {
|
||||
const MultiChoiceComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
CHECK_BOX: 'multiChoice',
|
||||
DROP_DOWN: 'multiChoice',
|
||||
RADIO_BUTTON: 'multiChoice',
|
||||
MULTI_SELECT: 'multiChoice',
|
||||
SINGLE_LINE_TEXT : 'multiInput',
|
||||
LINK : 'multiInput'
|
||||
SINGLE_LINE_TEXT: 'multiInput',
|
||||
LINK: 'multiInput',
|
||||
};
|
||||
|
||||
|
||||
export type ComponentType = keyof typeof component;
|
||||
export const getComponent = (value: ConditionValue, fieldObj: OneOf) => {
|
||||
if (!value || !fieldObj) return;
|
||||
|
||||
@@ -181,31 +181,31 @@ export function getFieldObj(fieldCode: string, { fields }: FieldsInfo, subTableC
|
||||
return meta[fieldCode];
|
||||
}
|
||||
|
||||
export function getMeta(fields: Properties, subTableCode?: string ,withNoSubTableField = true) {
|
||||
export function getMeta(fields: Properties, subTableCode?: string, withNoSubTableField = true) {
|
||||
if (!fields || !subTableCode) {
|
||||
return fields;
|
||||
}
|
||||
let meta = fields;
|
||||
const table = meta[subTableCode];
|
||||
if (isType.SUBTABLE(table)) {
|
||||
const subFields = table.fields; ;
|
||||
Object.values(subFields).forEach(field=>{
|
||||
const subFields = table.fields;
|
||||
Object.values(subFields).forEach((field) => {
|
||||
if (typeof field === 'object' && field !== null) {
|
||||
(field as Record<string, any>).subField = true;
|
||||
(field as Record<string, any>).subField = true;
|
||||
}
|
||||
});
|
||||
if(withNoSubTableField){
|
||||
meta={ ...fields, ...subFields };
|
||||
}else{
|
||||
meta=subFields;
|
||||
if (withNoSubTableField) {
|
||||
meta = { ...fields, ...subFields };
|
||||
} else {
|
||||
meta = subFields;
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
export const isStringArray=(value:any)=>{
|
||||
if(Array.isArray(value) && value.every(x=>typeof x ==='string')){
|
||||
export const isStringArray = (value: any) => {
|
||||
if (Array.isArray(value) && value.every((x) => typeof x === 'string')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,5 +10,5 @@ export type LinkProtocolType = 'WEB' | 'CALL' | 'MAIL';
|
||||
export type SelectType =
|
||||
| KintoneFormFieldProperty.CheckBox
|
||||
| KintoneFormFieldProperty.RadioButton
|
||||
| KintoneFormFieldProperty.DropDown
|
||||
| KintoneFormFieldProperty.Dropdown
|
||||
| KintoneFormFieldProperty.MultiSelect;
|
||||
|
||||
@@ -26,8 +26,8 @@ function replaceKucTagsPlugin() {
|
||||
const keyPascal = key.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join('');
|
||||
if(key==='multi-choice'){
|
||||
key='multichoice';
|
||||
if (key === 'multi-choice') {
|
||||
key = 'multichoice';
|
||||
}
|
||||
importScript += `import * as Kuc${keyPascal} from "kintone-ui-component/lib/${key}";`
|
||||
});
|
||||
@@ -83,6 +83,6 @@ export default defineConfig({
|
||||
assetFileNames: 'src/[ext]/[name].[ext]',
|
||||
},
|
||||
},
|
||||
sourcemap: false,
|
||||
sourcemap: 'inline',
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user