Merge branch 'master' of https://dev.azure.com/alicorn-dev/deta-fetch-plugin/_git/deta-fetch-plugin
This commit is contained in:
@@ -28,7 +28,7 @@ const props = defineProps<{ pluginId: string }>();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const data: SavedData = reactive({
|
const data: SavedData = reactive({
|
||||||
buttonName: '',
|
buttonName: '',
|
||||||
joinTables: [] as JoinTable[],
|
joinTables: [createEmptyJoinTable()],
|
||||||
});
|
});
|
||||||
|
|
||||||
const cachedData: CachedData = reactive({
|
const cachedData: CachedData = reactive({
|
||||||
@@ -43,15 +43,16 @@ const mainArea = shallowRef<HTMLElement | null>(null);
|
|||||||
const spinner = shallowRef<Spinner | null>(null);
|
const spinner = shallowRef<Spinner | null>(null);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
spinner.value?.close(); // 修复不自动挂载到节点的 bug
|
|
||||||
const savedData = kintone.plugin.app.getConfig(props.pluginId);
|
|
||||||
// TODO
|
|
||||||
data.buttonName = savedData?.buttonName || '集約';
|
|
||||||
data.joinTables = savedData?.joinTables ? JSON.parse(savedData.joinTables) : [createEmptyJoinTable()];
|
|
||||||
nextTick(async () => {
|
nextTick(async () => {
|
||||||
|
spinner.value?.close(); // fix bug: kuc-spinner will not auto amount to target HTML element when init loading
|
||||||
|
const savedData = kintone.plugin.app.getConfig(props.pluginId);
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
cachedData.apps = await loadApps();
|
cachedData.apps = await loadApps();
|
||||||
cachedData.currentAppFields = await loadAppFieldsAndLayout();
|
cachedData.currentAppFields = await loadAppFieldsAndLayout();
|
||||||
|
if (savedData?.joinTables) {
|
||||||
|
data.joinTables = JSON.parse(savedData.joinTables); //TODO JSON;
|
||||||
|
}
|
||||||
|
data.buttonName = savedData?.buttonName || '集約';
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<plugin-row class="table-area flex-row border">
|
<plugin-row class="table-area flex-row border">
|
||||||
<div class="table-main-area">
|
<div class="table-main-area">
|
||||||
<plugin-row>
|
<plugin-row>
|
||||||
<plugin-dropdown :disabled="false" label="取得元アプリ" :items="apps" v-model="table.app" @change="selectApp" />
|
<plugin-dropdown :disabled="false" label="取得元アプリ" :items="apps" v-model="table.app" />
|
||||||
</plugin-row>
|
</plugin-row>
|
||||||
<plugin-row>
|
<plugin-row>
|
||||||
<plugin-dropdown
|
<plugin-dropdown
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
:items="tableOptions"
|
:items="tableOptions"
|
||||||
v-model="table.table"
|
v-model="table.table"
|
||||||
@change="selectTable"
|
@change="selectTable"
|
||||||
|
:key="componentKey"
|
||||||
/>
|
/>
|
||||||
</plugin-row>
|
</plugin-row>
|
||||||
<plugin-row class="flex-row" v-if="isJoinConditionShown(table)">
|
<plugin-row class="flex-row" v-if="isJoinConditionShown(table)">
|
||||||
@@ -48,10 +49,12 @@ import { computed, inject, provide, reactive, ref, watch } from 'vue';
|
|||||||
const savedData = inject<SavedData>('savedData') as SavedData;
|
const savedData = inject<SavedData>('savedData') as SavedData;
|
||||||
const cachedData = inject<CachedData>('cachedData') as CachedData;
|
const cachedData = inject<CachedData>('cachedData') as CachedData;
|
||||||
|
|
||||||
const props = defineProps<{ table: JoinTable }>();
|
const props = defineProps<{
|
||||||
|
table: JoinTable;
|
||||||
|
}>();
|
||||||
const apps = computed(() => cachedData.apps);
|
const apps = computed(() => cachedData.apps);
|
||||||
const tableOptions = ref([EMPTY_OPTION]);
|
const tableOptions = ref([EMPTY_OPTION]);
|
||||||
const loading = ref(true);
|
const loading = ref(false);
|
||||||
|
|
||||||
const selectedAppData: CachedSelectedAppData = reactive({
|
const selectedAppData: CachedSelectedAppData = reactive({
|
||||||
appFields: { fields: {}, layout: [] } as FieldsInfo,
|
appFields: { fields: {}, layout: [] } as FieldsInfo,
|
||||||
@@ -60,14 +63,35 @@ const selectedAppData: CachedSelectedAppData = reactive({
|
|||||||
});
|
});
|
||||||
provide('selectedAppData', selectedAppData);
|
provide('selectedAppData', selectedAppData);
|
||||||
|
|
||||||
const selectApp = async (e: KucEvent) => {
|
const componentKey = ref(0);
|
||||||
loading.value = true;
|
// fix-bug: force select saved data when load config
|
||||||
const fields = await loadAppFieldsAndLayout(e.detail.value);
|
watch(
|
||||||
tableOptions.value = getTableFieldsDropdownItems(fields, types.SUBTABLE);
|
() => tableOptions.value,
|
||||||
resetTable(props.table);
|
() => {
|
||||||
selectedAppData.appFields = fields;
|
if (!props.table.table) return;
|
||||||
loading.value = false;
|
debugger
|
||||||
};
|
componentKey.value += 1;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
once: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.table.app,
|
||||||
|
async (newVal, oldVal) => {
|
||||||
|
if (!newVal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
const fields = await loadAppFieldsAndLayout(newVal);
|
||||||
|
tableOptions.value = getTableFieldsDropdownItems(fields, types.SUBTABLE);
|
||||||
|
selectedAppData.appFields = fields;
|
||||||
|
!!oldVal && resetTable(props.table);
|
||||||
|
loading.value = false;
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
const selectTable = (e: KucEvent) => {
|
const selectTable = (e: KucEvent) => {
|
||||||
resetConditions(props.table);
|
resetConditions(props.table);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CachedData, CachedSelectedAppData, SavedData, WhereCondition } from '@/types/model';
|
import type { CachedData, CachedSelectedAppData, SavedData, WhereCondition } from '@/types/model';
|
||||||
import { defineProps, defineEmits, inject, computed, ref, reactive, render, h, watch, onMounted } from 'vue';
|
import { defineProps, inject, computed, render, h } from 'vue';
|
||||||
import TableCombobox from './TableCombobox.vue';
|
import TableCombobox from './TableCombobox.vue';
|
||||||
import { getFieldsDropdownItems } from '@/js/helper';
|
import { getFieldsDropdownItems } from '@/js/helper';
|
||||||
import type { ConditionValue } from '@/js/conditions';
|
import type { ConditionValue } from '@/js/conditions';
|
||||||
@@ -27,11 +27,11 @@ const columns = [
|
|||||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const vnode = h(TableCombobox, {
|
const vnode = h(TableCombobox, {
|
||||||
items: getFieldsDropdownItems(selectedAppData.appFields, {
|
items: computed(() => getFieldsDropdownItems(selectedAppData.appFields, {
|
||||||
subTableCode: table.value,
|
subTableCode: table.value,
|
||||||
defaultLabel: 'すべてのレコード',
|
defaultLabel: 'すべてのレコード',
|
||||||
}),
|
})),
|
||||||
modelValue: '',
|
modelValue: props.modelValue[rowIndex].field,
|
||||||
selectedAppData,
|
selectedAppData,
|
||||||
'onUpdate:modelValue': (newValue: string) => {
|
'onUpdate:modelValue': (newValue: string) => {
|
||||||
props.modelValue[rowIndex].field = newValue;
|
props.modelValue[rowIndex].field = newValue;
|
||||||
@@ -49,7 +49,7 @@ const columns = [
|
|||||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const vnode = h(TableCondition, {
|
const vnode = h(TableCondition, {
|
||||||
modelValue: '',
|
modelValue: props.modelValue[rowIndex].condition,
|
||||||
index: rowIndex,
|
index: rowIndex,
|
||||||
selectedAppData,
|
selectedAppData,
|
||||||
whereConditions: props.modelValue,
|
whereConditions: props.modelValue,
|
||||||
@@ -68,7 +68,7 @@ const columns = [
|
|||||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const vnode = h(TableConditionValue, {
|
const vnode = h(TableConditionValue, {
|
||||||
modelValue: '',
|
modelValue: props.modelValue[rowIndex].data,
|
||||||
index: rowIndex,
|
index: rowIndex,
|
||||||
selectedAppData,
|
selectedAppData,
|
||||||
whereConditions: props.modelValue,
|
whereConditions: props.modelValue,
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ const columns = reactive([
|
|||||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const vnode = h(TableCombobox, {
|
const vnode = h(TableCombobox, {
|
||||||
items: getFieldsDropdownItems(selectedAppData.appFields, { subTableCode: table.value, filterType: undefined }),
|
items: computed(() => getFieldsDropdownItems(selectedAppData.appFields, { subTableCode: table.value, filterType: undefined })),
|
||||||
modelValue: '',
|
modelValue: props.modelValue[rowIndex].leftField,
|
||||||
selectedAppData,
|
selectedAppData,
|
||||||
'onUpdate:modelValue': (newValue: string) => {
|
'onUpdate:modelValue': (newValue: string) => {
|
||||||
props.modelValue[rowIndex].leftField = newValue;
|
props.modelValue[rowIndex].leftField = newValue;
|
||||||
@@ -48,8 +48,8 @@ const columns = reactive([
|
|||||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
const vnode = h(TableCombobox, {
|
const vnode = h(TableCombobox, {
|
||||||
items: getFieldsDropdownItems(cachedData.currentAppFields, { filterType: undefined }),
|
items: computed(()=>getFieldsDropdownItems(cachedData.currentAppFields, { filterType: undefined })),
|
||||||
modelValue: '',
|
modelValue: props.modelValue[rowIndex].rightField,
|
||||||
selectedAppData,
|
selectedAppData,
|
||||||
'onUpdate:modelValue': (newValue: string) => {
|
'onUpdate:modelValue': (newValue: string) => {
|
||||||
props.modelValue[rowIndex].rightField = newValue;
|
props.modelValue[rowIndex].rightField = newValue;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<kuc-combobox
|
<kuc-combobox
|
||||||
:items="items"
|
:items="items.value"
|
||||||
:value="modelValue"
|
:value="modelValue"
|
||||||
@change="updateValue"
|
@change="updateValue"
|
||||||
|
:key="componentKey"
|
||||||
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
|
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -11,14 +12,27 @@
|
|||||||
import type { CachedSelectedAppData } from '@/types/model';
|
import type { CachedSelectedAppData } from '@/types/model';
|
||||||
import type { KucEvent } from '@/types/my-kintone';
|
import type { KucEvent } from '@/types/my-kintone';
|
||||||
import type { DropdownItem } from 'kintone-ui-component';
|
import type { DropdownItem } from 'kintone-ui-component';
|
||||||
import { defineProps, defineEmits } from 'vue';
|
import { defineProps, defineEmits, type Ref, watch, ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
items: DropdownItem[];
|
items: Ref<DropdownItem[]>;
|
||||||
modelValue: string;
|
modelValue: string;
|
||||||
selectedAppData: CachedSelectedAppData;
|
selectedAppData: CachedSelectedAppData;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const componentKey = ref(0);
|
||||||
|
// fix-bug: force select saved data when load config
|
||||||
|
watch(
|
||||||
|
() => props.items.value,
|
||||||
|
() => {
|
||||||
|
if (!props.modelValue) return;
|
||||||
|
componentKey.value += 1;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
once: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:modelValue', value: string): void;
|
(e: 'update:modelValue', value: string): void;
|
||||||
}>();
|
}>();
|
||||||
|
|||||||
Reference in New Issue
Block a user