Compare commits
24 Commits
dev
...
plugin-inf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3540becf6f | ||
|
|
63099eda8b | ||
|
|
65d89b0462 | ||
|
|
c6ded099fa | ||
|
|
c072233593 | ||
|
|
4e296c1555 | ||
| 016fcaab29 | |||
|
|
bebc1ec9fa | ||
|
|
f71c3d2123 | ||
|
|
d79ce8d06b | ||
|
|
fc9c3a5e81 | ||
|
|
6df72a1ae3 | ||
|
|
372dbe50f7 | ||
|
|
68fde6d490 | ||
|
|
c398dee21e | ||
|
|
f2ab310b6d | ||
|
|
ca0f24465b | ||
|
|
3cc4b65460 | ||
|
|
a6cf95b76d | ||
|
|
484ab9fdae | ||
|
|
78bba2502f | ||
|
|
c78b3cb5c0 | ||
|
|
b25c17ab53 | ||
|
|
a7078b54c5 |
File diff suppressed because one or more lines are too long
152
frontend/src/components/AppFieldSelectBox.vue
Normal file
152
frontend/src/components/AppFieldSelectBox.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
|
||||
<div class="q-mx-md q-mb-lg">
|
||||
<div class="q-mb-xs q-ml-md text-primary">アプリ選択</div>
|
||||
|
||||
<div class="q-pa-md row" style="border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 4px;">
|
||||
<div v-if="selField?.app && !showSelectApp">{{ selField.app?.name }}</div>
|
||||
<q-space />
|
||||
<div>
|
||||
<q-btn outline dense label="選 択" padding="none sm" color="primary" @click="() => {
|
||||
showSelectApp = true;
|
||||
}"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!showSelectApp && selField.app?.name">
|
||||
<div>
|
||||
<div class="row q-mb-md">
|
||||
<!-- <div class="col"> -->
|
||||
<div class="q-mb-xs q-ml-md text-primary">フィールド選択</div>
|
||||
<!-- </div> -->
|
||||
<q-space />
|
||||
<!-- <div class="col"> -->
|
||||
<div class="q-mr-md">
|
||||
<q-input dense debounce="300" v-model="fieldFilter" placeholder="フィールド検索" clearable>
|
||||
<template v-slot:before>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<field-select ref="fieldDlg" name="フィールド" :type="selectType" :updateSelects="updateItems"
|
||||
:appId="selField.app?.id" not_page :filter="fieldFilter"
|
||||
:selFields="selField.fields"></field-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="min-width: 45vw;" v-else>
|
||||
</div>
|
||||
|
||||
|
||||
<show-dialog v-model:visible="showSelectApp" name="アプリ選択" @close="closeAppDlg">
|
||||
<template v-slot:toolbar>
|
||||
<q-input dense debounce="300" v-model="filter" placeholder="検索" clearable>
|
||||
<template v-slot:before>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
|
||||
<AppSelectBox ref="appDlg" name="アプリ" type="single" :filter="filter"
|
||||
:updateExternalSelectAppInfo="updateExternalSelectAppInfo"></AppSelectBox>
|
||||
</show-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, watchEffect, computed ,reactive} from 'vue';
|
||||
import ShowDialog from './ShowDialog.vue';
|
||||
import FieldSelect from './FieldSelect.vue';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import AppSelectBox from './AppSelectBox.vue';
|
||||
interface IApp {
|
||||
id: string,
|
||||
name: string
|
||||
}
|
||||
interface IField {
|
||||
name: string,
|
||||
code: string,
|
||||
type: string
|
||||
}
|
||||
|
||||
interface IAppFields {
|
||||
app?: IApp,
|
||||
fields: IField[]
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
name: 'AppFieldSelectBox',
|
||||
components: {
|
||||
ShowDialog,
|
||||
FieldSelect,
|
||||
AppSelectBox,
|
||||
},
|
||||
props: {
|
||||
selectedField: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
selectType: {
|
||||
type: String,
|
||||
default: 'single'
|
||||
},
|
||||
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const appDlg = ref();
|
||||
const fieldDlg = ref();
|
||||
const showSelectApp = ref(false);
|
||||
const selField = reactive(props.selectedField);
|
||||
console.log(props.selectedField);
|
||||
|
||||
const store = useFlowEditorStore();
|
||||
|
||||
const isSelected = computed(() => {
|
||||
return selField !== null && typeof selField === 'object' && ('app' in selField)
|
||||
});
|
||||
|
||||
|
||||
const closeAppDlg = (val: string) => {
|
||||
if (val == 'OK') {
|
||||
selField.app = appDlg.value.selected[0];
|
||||
selField.fields = [];
|
||||
showSelectApp.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const closeFieldDialog = (val: string) => {
|
||||
if (val == 'OK') {
|
||||
selField.fields = fieldDlg.value.selected;
|
||||
}
|
||||
};
|
||||
const updateExternalSelectAppInfo = (newAppinfo: IApp) => {
|
||||
selField.app = newAppinfo
|
||||
}
|
||||
|
||||
const updateItems = (newFields: IField[]) => {
|
||||
selField.fields = newFields
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
emit('update:modelValue', selField);
|
||||
});
|
||||
|
||||
return {
|
||||
appDlg,
|
||||
fieldDlg,
|
||||
closeAppDlg,
|
||||
closeFieldDialog,
|
||||
showSelectApp,
|
||||
isSelected,
|
||||
updateExternalSelectAppInfo,
|
||||
filter: ref(),
|
||||
updateItems,
|
||||
fieldFilter: ref(),
|
||||
selField
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -21,7 +21,7 @@ import { ref, onMounted, reactive, watchEffect } from 'vue'
|
||||
import { api } from 'boot/axios';
|
||||
|
||||
export default {
|
||||
name: 'AppSelect',
|
||||
name: 'AppSelectBox',
|
||||
props: {
|
||||
name: String,
|
||||
type: String,
|
||||
@@ -113,7 +113,7 @@ import { finished } from 'stream';
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent,ref,reactive, computed } from 'vue';
|
||||
import { defineComponent,ref,reactive, computed, inject } from 'vue';
|
||||
import { INode,ConditionTree,GroupNode,ConditionNode, LogicalOperator,Operator,NodeType } from '../../types/Conditions';
|
||||
import ConditionObject from './ConditionObject.vue';
|
||||
export default defineComponent( {
|
||||
@@ -143,12 +143,9 @@ export default defineComponent( {
|
||||
return opts;
|
||||
});
|
||||
|
||||
const operator = inject('Operator')
|
||||
const operators =computed(()=>{
|
||||
const opts=[];
|
||||
for(const op in Operator){
|
||||
opts.push(Operator[op as keyof typeof Operator]);
|
||||
}
|
||||
return opts;
|
||||
return operator ? operator : Object.values(Operator);
|
||||
});
|
||||
const tree = reactive(props.conditionTree);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
<AppSelect ref="appDg" name="アプリ" type="single" :filter="filter"></AppSelect>
|
||||
<AppSelectBox ref="appDg" name="アプリ" type="single" :filter="filter"></AppSelectBox>
|
||||
</ShowDialog>
|
||||
</template>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
import { defineComponent,ref } from 'vue';
|
||||
import {AppInfo} from '../../types/ActionTypes'
|
||||
import ShowDialog from '../../components/ShowDialog.vue';
|
||||
import AppSelect from '../../components/AppSelect.vue';
|
||||
import AppSelectBox from '../../components/AppSelectBox.vue';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import { useAuthStore } from 'src/stores/useAuthStore';
|
||||
export default defineComponent({
|
||||
@@ -47,7 +47,7 @@ export default defineComponent({
|
||||
"appSelected"
|
||||
],
|
||||
components:{
|
||||
AppSelect,
|
||||
AppSelectBox,
|
||||
ShowDialog
|
||||
},
|
||||
setup(props, context) {
|
||||
|
||||
@@ -1,48 +1,55 @@
|
||||
<template>
|
||||
<!-- <div class="q-pa-md q-gutter-sm"> -->
|
||||
<q-tree
|
||||
:nodes="store.eventTree.screens"
|
||||
node-key="eventId"
|
||||
children-key="events"
|
||||
no-connectors
|
||||
v-model:expanded="store.expandedScreen"
|
||||
:dense="true"
|
||||
:ref="tree"
|
||||
>
|
||||
<q-tree :nodes="store.eventTree.screens" node-key="eventId" children-key="events" no-connectors
|
||||
v-model:expanded="store.expandedScreen" :dense="true" :ref="tree">
|
||||
<template v-slot:header-EVENT="prop">
|
||||
<div class="row col items-start no-wrap event-node" @click="onSelected(prop.node)">
|
||||
<q-icon v-if="prop.node.eventId"
|
||||
name="play_circle"
|
||||
:color="prop.node.hasFlow?'green':'grey'"
|
||||
size="16px" class="q-mr-sm">
|
||||
<div :ref="prop.node.eventId" class="row col items-center no-wrap event-node">
|
||||
<q-icon v-if="prop.node.eventId" name="play_circle" :color="prop.node.hasFlow ? 'green' : 'grey'" size="16px"
|
||||
class="q-mr-sm">
|
||||
</q-icon>
|
||||
<div class="no-wrap" :class="selectedEvent && prop.node.eventId===selectedEvent.eventId?'selected-node':''">{{ prop.node.label }}</div>
|
||||
<div class="no-wrap" @click="onSelected(prop.node)"
|
||||
:class="selectedEvent && prop.node.eventId === selectedEvent.eventId ? 'selected-node' : ''">{{
|
||||
prop.node.label }}</div>
|
||||
<q-space></q-space>
|
||||
<!-- <q-icon v-if="prop.node.hasFlow" name="delete" color="negative" size="16px" class="q-mr-sm"></q-icon> -->
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:header-CHANGE="prop">
|
||||
<div class="row col items-start no-wrap event-node" >
|
||||
<div class="row col items-center no-wrap event-node">
|
||||
<div class="no-wrap">{{ prop.node.label }}</div>
|
||||
<q-space></q-space>
|
||||
<q-icon name="add_circle" color="primary" size="16px" class="q-mr-sm" @click="addChangeEvent(prop.node)"></q-icon>
|
||||
<q-icon name="add_circle" color="primary" size="16px" class="q-mr-sm"
|
||||
@click="addChangeEvent(prop.node)"></q-icon>
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:header-DELETABLE="prop">
|
||||
<div class="row col items-center event-node">
|
||||
<div class="row col items-center" @click="onSelected(prop.node)">
|
||||
<q-icon v-if="prop.node.eventId" name="play_circle" :color="prop.node.hasFlow ? 'green' : 'grey'" size="16px"
|
||||
class="q-mr-sm">
|
||||
</q-icon>
|
||||
<div>{{ prop.node.label }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<q-btn class="q-mr-sm delete-btn" flat fab-mini icon="delete_forever" padding="none" color="negative"
|
||||
@click="deleteEvent(prop.node)"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</q-tree>
|
||||
<show-dialog v-model:visible="showDialog" name="フィールド選択" @close="closeDg" widht="400px">
|
||||
<show-dialog v-model:visible="showDialog" name="フィールド選択" @close="closeDg">
|
||||
<field-select ref="appDg" name="フィールド" type="single" :appId="store.appInfo?.appId"></field-select>
|
||||
</show-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed, ref } from 'vue';
|
||||
import { IKintoneEvent ,IKintoneEventGroup, IKintoneEventNode, kintoneEvent} from '../../types/KintoneEvents';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { QTree, useQuasar } from 'quasar';
|
||||
import { ActionFlow, RootAction } from 'src/types/ActionTypes';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import { ActionFlow, ActionNode, RootAction } from 'src/types/ActionTypes';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { IKintoneEvent, IKintoneEventGroup, IKintoneEventNode } from '../../types/KintoneEvents';
|
||||
import FieldSelect from '../FieldSelect.vue';
|
||||
import { QTree } from 'quasar';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
export default defineComponent({
|
||||
name: 'EventTree',
|
||||
components: {
|
||||
@@ -50,6 +57,7 @@ export default defineComponent({
|
||||
FieldSelect,
|
||||
},
|
||||
setup(props, context) {
|
||||
const $q = useQuasar();
|
||||
const appDg = ref();
|
||||
const store = useFlowEditorStore();
|
||||
const showDialog = ref(false);
|
||||
@@ -72,12 +80,12 @@ export default defineComponent({
|
||||
if (store.eventTree.findEventById(eventid)) {
|
||||
return;
|
||||
}
|
||||
selectedChangeEvent.value?.events.push(
|
||||
new kintoneEvent(
|
||||
field.label,
|
||||
eventid,
|
||||
selectedChangeEvent.value.eventId)
|
||||
);
|
||||
selectedChangeEvent.value?.events.push({
|
||||
eventId: eventid,
|
||||
label: field.name,
|
||||
parentId: selectedChangeEvent.value.eventId,
|
||||
header: 'DELETABLE'
|
||||
});
|
||||
tree.value?.expanded?.push(selectedChangeEvent.value.eventId);
|
||||
tree.value?.expandAll();
|
||||
}
|
||||
@@ -89,6 +97,21 @@ export default defineComponent({
|
||||
selectedChangeEvent.value = node;
|
||||
showDialog.value = true;
|
||||
}
|
||||
|
||||
const deleteEvent = (node: IKintoneEvent) => {
|
||||
if (!node.eventId) {
|
||||
return;
|
||||
}
|
||||
store.deleteEvent(node);
|
||||
store.selectFlow(undefined)
|
||||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
caption: "通知",
|
||||
message: `イベント ${node.label} 削除`
|
||||
})
|
||||
}
|
||||
|
||||
const onSelected = (node: IKintoneEvent) => {
|
||||
if (!node.eventId) {
|
||||
return;
|
||||
@@ -98,6 +121,7 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
const screen = store.eventTree.findEventById(node.parentId);
|
||||
|
||||
let flow = store.findFlowByEventId(node.eventId);
|
||||
let screenName = screen !== null ? screen.label : "";
|
||||
let nodeLabel = node.label;
|
||||
@@ -105,6 +129,7 @@ export default defineComponent({
|
||||
// screenName=nodeLabel;
|
||||
// nodeLabel=`${node.label}の値を変更したとき`;
|
||||
// }
|
||||
|
||||
if (flow !== undefined && flow !== null) {
|
||||
store.selectFlow(flow);
|
||||
} else {
|
||||
@@ -125,6 +150,7 @@ export default defineComponent({
|
||||
onSelected,
|
||||
selectedEvent,
|
||||
addChangeEvent,
|
||||
deleteEvent,
|
||||
closeDg,
|
||||
store
|
||||
}
|
||||
@@ -136,16 +162,21 @@ export default defineComponent({
|
||||
flex-wrap: nowarp;
|
||||
text-wrap: nowarp;
|
||||
}
|
||||
|
||||
.event-node {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.selected-node {
|
||||
color: $primary;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.event-node:hover {
|
||||
background-color: $light-blue-1;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
<div style="">
|
||||
<div v-if="selectedField.fields && selectedField.fields.length > 0">
|
||||
<q-list bordered>
|
||||
<q-virtual-scroll style="max-height: 160px;" :items="selectedField.fields" separator v-slot="{ item, index }">
|
||||
<q-virtual-scroll style="max-height: 160px;" :items="selectedField.fields" separator
|
||||
v-slot="{ item, index }">
|
||||
<q-item :key="index" dense clickable>
|
||||
<q-item-section>
|
||||
<q-item-label>
|
||||
@@ -47,81 +48,28 @@
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<show-dialog v-model:visible="show" name="フィールド一覧" @close="closeFieldDialog" ref="fieldDlg">
|
||||
|
||||
<div class="q-mx-md q-mb-lg">
|
||||
<div class="q-mb-xs q-ml-md text-primary">アプリ選択</div>
|
||||
|
||||
<div class="q-pa-md row" style="border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 4px;">
|
||||
<div v-if="!showSelectApp && selectedField.app">{{ selectedField.app?.name }}</div>
|
||||
<q-space />
|
||||
<div>
|
||||
<q-btn outline dense label="選 択" padding="none sm" color="primary" @click="() => {
|
||||
showSelectApp = true;
|
||||
}"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!showSelectApp && selectedField.app?.name">
|
||||
<div>
|
||||
<div class="row q-mb-md">
|
||||
<!-- <div class="col"> -->
|
||||
<div class="q-mb-xs q-ml-md text-primary">フィールド選択</div>
|
||||
<!-- </div> -->
|
||||
<q-space />
|
||||
<!-- <div class="col"> -->
|
||||
<div class="q-mr-md">
|
||||
<q-input dense debounce="300" v-model="fieldFilter" placeholder="フィールド検索" clearable>
|
||||
<template v-slot:before>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<field-select ref="fieldDlg" name="フィールド" :type="selectType" :updateSelects="updateItems"
|
||||
:appId="selectedField.app?.id" not_page :filter="fieldFilter" :selectedFields="selectedField.fields"></field-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="min-width: 45vw;" v-else>
|
||||
</div>
|
||||
|
||||
</show-dialog>
|
||||
|
||||
<show-dialog v-model:visible="showSelectApp" name="アプリ選択" @close="closeAppDlg">
|
||||
<template v-slot:toolbar>
|
||||
<q-input dense debounce="300" v-model="filter" placeholder="検索" clearable>
|
||||
<template v-slot:before>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
|
||||
<AppSelect ref="appDlg" name="アプリ" type="single" :filter="filter"
|
||||
:updateExternalSelectAppInfo="updateExternalSelectAppInfo"></AppSelect>
|
||||
<AppFieldSelectBox v-model:selectedField="selectedField" :selectType="selectType" />
|
||||
</show-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, watchEffect, computed } from 'vue';
|
||||
import { defineComponent, ref, watchEffect } from 'vue';
|
||||
import AppFieldSelectBox from '../AppFieldSelectBox.vue';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
import FieldSelect from '../FieldSelect.vue';
|
||||
import { useFlowEditorStore } from 'stores/flowEditor';
|
||||
import AppSelect from '../AppSelect.vue';
|
||||
interface IApp{
|
||||
|
||||
export interface IApp {
|
||||
id: string,
|
||||
name: string
|
||||
}
|
||||
interface IField {
|
||||
export interface IField {
|
||||
name: string,
|
||||
code: string,
|
||||
type: string
|
||||
}
|
||||
|
||||
interface IAppFields{
|
||||
export interface IAppFields {
|
||||
app?: IApp,
|
||||
fields: IField[]
|
||||
}
|
||||
@@ -131,8 +79,7 @@ export default defineComponent({
|
||||
name: 'AppFieldSelect',
|
||||
components: {
|
||||
ShowDialog,
|
||||
FieldSelect,
|
||||
AppSelect,
|
||||
AppFieldSelectBox
|
||||
},
|
||||
props: {
|
||||
displayName: {
|
||||
@@ -157,10 +104,7 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const appDlg = ref();
|
||||
const fieldDlg = ref();
|
||||
const show = ref(false);
|
||||
const showSelectApp = ref(false);
|
||||
const selectedField = ref<IAppFields>({
|
||||
app: undefined,
|
||||
fields: []
|
||||
@@ -170,41 +114,12 @@ export default defineComponent({
|
||||
}
|
||||
const store = useFlowEditorStore();
|
||||
|
||||
const isSelected = computed(() => {
|
||||
return selectedField.value !== null && typeof selectedField.value === 'object' && ('app' in selectedField.value)
|
||||
});
|
||||
|
||||
const showDg = () => {
|
||||
show.value = true;
|
||||
};
|
||||
|
||||
const clear = () => {
|
||||
selectedField.value = {
|
||||
fields: []
|
||||
};
|
||||
}
|
||||
|
||||
const closeAppDlg = (val: string) => {
|
||||
if (val == 'OK') {
|
||||
selectedField.value.app = appDlg.value.selected[0];
|
||||
selectedField.value.fields=[];
|
||||
showSelectApp.value=false;
|
||||
}
|
||||
};
|
||||
|
||||
const closeFieldDialog=(val:string)=>{
|
||||
if (val == 'OK') {
|
||||
selectedField.value.fields = fieldDlg.value.selected;
|
||||
}
|
||||
};
|
||||
const updateExternalSelectAppInfo = (newAppinfo:IApp) => {
|
||||
// selectedField.value.app = newAppinfo
|
||||
}
|
||||
|
||||
const updateItems = (newFields:IField[]) => {
|
||||
// selectedField.value.fields = newFields
|
||||
}
|
||||
|
||||
const removeField = (index: number) => {
|
||||
selectedField.value.fields.splice(index, 1);
|
||||
}
|
||||
@@ -214,21 +129,11 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
store,
|
||||
appDlg,
|
||||
fieldDlg,
|
||||
show,
|
||||
showDg,
|
||||
closeAppDlg,
|
||||
closeFieldDialog,
|
||||
showDg: () => { show.value = true },
|
||||
selectedField,
|
||||
showSelectApp,
|
||||
isSelected,
|
||||
updateExternalSelectAppInfo,
|
||||
filter: ref(),
|
||||
updateItems,
|
||||
clear,
|
||||
fieldFilter: ref(),
|
||||
removeField
|
||||
removeField,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
93
frontend/src/components/right/AppSelect.vue
Normal file
93
frontend/src/components/right/AppSelect.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-field :label="displayName" labelColor="primary" stack-label>
|
||||
<template v-slot:control>
|
||||
<q-card flat class="full-width">
|
||||
<q-card-actions vertical>
|
||||
<q-btn color="grey-3" text-color="black" @click="() => { dgIsShow = true }">アプリ選択</q-btn>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-caption">
|
||||
<div v-if="selectedField.app.name">
|
||||
{{ selectedField.app.name }}
|
||||
</div>
|
||||
<div v-else>{{ placeholder }}</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</template>
|
||||
</q-field>
|
||||
</div>
|
||||
|
||||
<ShowDialog v-model:visible="dgIsShow" name="アプリ選択" @close="closeDg" min-width="50vw" min-height="50vh">
|
||||
<template v-slot:toolbar>
|
||||
<q-input dense debounce="300" v-model="filter" placeholder="検索" clearable>
|
||||
<template v-slot:before>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
<AppSelectBox ref="appDg" name="アプリ" type="single" :filter="filter"></AppSelectBox>
|
||||
</ShowDialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, reactive, ref, watchEffect } from 'vue';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
import AppSelectBox from '../AppSelectBox.vue';
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
name: 'AppSelect',
|
||||
components: {
|
||||
ShowDialog,
|
||||
AppSelectBox
|
||||
},
|
||||
props: {
|
||||
context: {
|
||||
type: Array<Props>,
|
||||
default: '',
|
||||
},
|
||||
displayName: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const appDg = ref()
|
||||
const dgIsShow = ref(false)
|
||||
const selectedField = props.modelValue && props.modelValue.app ? props.modelValue : reactive({app:{}});
|
||||
const closeDg = (state: string) => {
|
||||
dgIsShow.value = false;
|
||||
if (state == 'OK') {
|
||||
selectedField.app = appDg.value.selected[0];
|
||||
}
|
||||
};
|
||||
|
||||
console.log(selectedField);
|
||||
|
||||
watchEffect(() => {
|
||||
emit('update:modelValue', selectedField);
|
||||
});
|
||||
|
||||
return {
|
||||
filter: ref(''),
|
||||
dgIsShow,
|
||||
appDg,
|
||||
closeDg,
|
||||
selectedField
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -4,7 +4,8 @@
|
||||
<template v-slot:control>
|
||||
<q-card flat class="full-width">
|
||||
<q-card-actions vertical>
|
||||
<q-btn color="grey-3" text-color="black" @click="showDg()">クリックで設定:{{ isSetted ? '設定済み' : '未設定' }}</q-btn>
|
||||
<q-btn color="grey-3" text-color="black" :disable="btnDisable" @click="showDg()">クリックで設定:{{ isSetted ?
|
||||
'設定済み' : '未設定' }}</q-btn>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-caption">
|
||||
<div v-if="!isSetted">{{ placeholder }}</div>
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
|
||||
<script lang="ts">
|
||||
import { ConditionNode, ConditionTree, Operator } from 'app/src/types/Conditions';
|
||||
import { ConditionNode, ConditionTree, Operator, OperatorListItem } from 'app/src/types/Conditions';
|
||||
import { computed, defineComponent, provide, reactive, ref, watchEffect } from 'vue';
|
||||
import ConditionEditor from '../ConditionEditor/ConditionEditor.vue';
|
||||
|
||||
@@ -28,6 +29,10 @@ type Props = {
|
||||
props?: {
|
||||
name: string;
|
||||
modelValue?: {
|
||||
app: {
|
||||
id: string;
|
||||
name: string;
|
||||
},
|
||||
fields: {
|
||||
type: string;
|
||||
label: string;
|
||||
@@ -72,6 +77,13 @@ export default defineComponent({
|
||||
sourceType: {
|
||||
type: String,
|
||||
default: 'field'
|
||||
},
|
||||
onlySourceSelect: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
operatorList: {
|
||||
type: Array,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -82,18 +94,34 @@ export default defineComponent({
|
||||
if (props.sourceType === 'field') {
|
||||
provide('sourceFields', computed(() => source.props?.modelValue?.fields ?? []));
|
||||
} else if (props.sourceType === 'app') {
|
||||
console.log('sourceApp', source.props?.modelValue);
|
||||
provide('sourceApp', computed(() => source.props?.modelValue?.app?.id));
|
||||
}
|
||||
}
|
||||
|
||||
provide('Operator', props.operatorList);
|
||||
|
||||
const btnDisable = computed(() => {
|
||||
const onlySourceSelect = props.onlySourceSelect;
|
||||
|
||||
if (!onlySourceSelect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (props.sourceType === 'field') {
|
||||
return source?.props?.modelValue?.fields?.length ?? 0 > 0;
|
||||
} else if (props.sourceType === 'app') {
|
||||
return source?.props?.modelValue?.app?.id ? false : true
|
||||
}
|
||||
return true;
|
||||
})
|
||||
|
||||
const appDg = ref();
|
||||
const show = ref(false);
|
||||
const tree = reactive(new ConditionTree());
|
||||
if (props.modelValue && props.modelValue !== '') {
|
||||
tree.fromJson(props.modelValue);
|
||||
} else {
|
||||
const newNode = new ConditionNode({}, Operator.Equal, '', tree.root);
|
||||
const newNode = new ConditionNode({}, (props.operatorList && props.operatorList.length > 0) ? props.operatorList[0] as OperatorListItem : Operator.Equal, '', tree.root);
|
||||
tree.addNode(tree.root, newNode);
|
||||
}
|
||||
|
||||
@@ -109,13 +137,15 @@ export default defineComponent({
|
||||
|
||||
const onClosed = (val: string) => {
|
||||
if (val == 'OK') {
|
||||
const conditionJson = tree.toJson();
|
||||
isSetted.value = true;
|
||||
tree.setQuery(tree.buildConditionQueryString(tree.root));
|
||||
const conditionJson = tree.toJson();
|
||||
emit('update:modelValue', conditionJson);
|
||||
}
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
tree.setQuery(tree.buildConditionQueryString(tree.root));
|
||||
const conditionJson = tree.toJson();
|
||||
emit('update:modelValue', conditionJson);
|
||||
});
|
||||
@@ -127,7 +157,8 @@ export default defineComponent({
|
||||
showDg,
|
||||
onClosed,
|
||||
tree,
|
||||
conditionString
|
||||
conditionString,
|
||||
btnDisable
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
202
frontend/src/components/right/DataMapping.vue
Normal file
202
frontend/src/components/right/DataMapping.vue
Normal file
@@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-field :label="displayName" labelColor="primary" stack-label>
|
||||
<template v-slot:control>
|
||||
<q-card flat class="full-width">
|
||||
<q-card-actions vertical>
|
||||
<q-btn color="grey-3" text-color="black" :disable="btnDisable"
|
||||
@click="() => { dgIsShow = true }">クリックで設定</q-btn>
|
||||
</q-card-actions>
|
||||
<q-card-section class="text-caption">
|
||||
<div v-if="mappingObjectsInputDisplay && mappingObjectsInputDisplay.length > 0">
|
||||
<div v-for="(item) in mappingObjectsInputDisplay" :key="item">{{ item }}</div>
|
||||
</div>
|
||||
<div v-else>{{ placeholder }}</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</template>
|
||||
</q-field>
|
||||
<show-dialog v-model:visible="dgIsShow" name="データマッピング" @close="closeDg" min-width="50vw" min-height="60vh">
|
||||
|
||||
<div class="q-mx-md">
|
||||
<div class="row q-col-gutter-x-xs flex-center">
|
||||
<div class="col-5">
|
||||
<div class="q-mx-xs">From</div>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="q-mx-xs">To</div>
|
||||
</div>
|
||||
<div class="col-1"><q-btn flat round dense icon="add" size="sm" @click="addMappingObject" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="q-my-sm" v-for="(item, index) in mappingProps" :key="item.id">
|
||||
<div class="row q-col-gutter-x-xs flex-center">
|
||||
<div class="col-5">
|
||||
<ConditionObject v-model="item.from" />
|
||||
</div>
|
||||
<div class="col-1">
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<q-field v-model="item.vName" type="text" outlined dense>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" class="cursor-pointer"
|
||||
@click="() => { mappingProps[index].to.isDialogVisible = true }" />
|
||||
</template>
|
||||
<template v-slot:control>
|
||||
<div class="self-center full-width no-outline" tabindex="0"
|
||||
v-if="item.to.app?.name && item.to.fields?.length > 0 && item.to.fields[0].label">
|
||||
{{ `${item.to.app?.name} : ${item.to.fields[0].label}` }}
|
||||
</div>
|
||||
</template>
|
||||
</q-field>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<q-btn flat round dense icon="delete" size="sm" @click="() => deleteMappingObject(index)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<show-dialog v-model:visible="mappingProps[index].to.isDialogVisible" name="フィールド一覧"
|
||||
@close="closeToDg" ref="fieldDlg">
|
||||
<FieldSelect v-if="onlySourceSelect" ref="fieldDlg" name="フィールド" :appId="sourceAppId" not_page
|
||||
:selectedFields="mappingProps[index].to.fields"
|
||||
:updateSelects="(fields) => { mappingProps[index].to.fields = fields; mappingProps[index].to.app = sourceApp }">
|
||||
</FieldSelect>
|
||||
<AppFieldSelectBox v-else v-model:selectedField="mappingProps[index].to" />
|
||||
</show-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</show-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { computed, defineComponent, reactive, ref, watchEffect } from 'vue';
|
||||
import ConditionObject from '../ConditionEditor/ConditionObject.vue';
|
||||
import ShowDialog from '../ShowDialog.vue';
|
||||
import AppFieldSelectBox from '../AppFieldSelectBox.vue';
|
||||
import FieldSelect from '../FieldSelect.vue';
|
||||
import IAppFields from './AppFieldSelect.vue';
|
||||
|
||||
type Props = {
|
||||
props?: {
|
||||
name: string;
|
||||
modelValue?: {
|
||||
app: {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
type ValueType = {
|
||||
id: string;
|
||||
from: object;
|
||||
to: typeof IAppFields & {
|
||||
isDialogVisible: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
const defaultMappingProp = () => ({ id: uuidv4(), to: { app: {}, fields: [], isDialogVisible: false } });
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DataMapping',
|
||||
inheritAttrs: false,
|
||||
components: {
|
||||
ShowDialog,
|
||||
ConditionObject,
|
||||
AppFieldSelectBox,
|
||||
FieldSelect
|
||||
},
|
||||
props: {
|
||||
context: {
|
||||
type: Array<Props>,
|
||||
default: '',
|
||||
},
|
||||
displayName: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
modelValue: {
|
||||
type: Object as () => ValueType[],
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
onlySourceSelect: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const closeDg = () => {
|
||||
emit('update:modelValue', mappingProps
|
||||
);
|
||||
}
|
||||
|
||||
const closeToDg = () => {
|
||||
emit('update:modelValue', mappingProps
|
||||
);
|
||||
}
|
||||
|
||||
const mappingProps: ValueType[] = props.modelValue
|
||||
? props.modelValue
|
||||
: reactive([defaultMappingProp()]);
|
||||
|
||||
|
||||
const deleteMappingObject = (index: number) => mappingProps.length === 1
|
||||
? mappingProps.splice(0, mappingProps.length, defaultMappingProp())
|
||||
: mappingProps.splice(index, 1);
|
||||
|
||||
const mappingObjectsInputDisplay = computed(() =>
|
||||
mappingProps ?
|
||||
mappingProps
|
||||
.filter(item => item.from?.name && item.to.fields?.length > 0)
|
||||
.map(item => {
|
||||
const name = typeof item.from?.name === 'string'
|
||||
? item.from.name
|
||||
: item.from?.name.name;
|
||||
return `[${name}] - (${item.to.app?.name} : ${item.to.fields[0].label})`;
|
||||
})
|
||||
: []
|
||||
);
|
||||
|
||||
const source = props.context.find(element => element?.props?.name === 'sources')
|
||||
|
||||
const sourceApp = computed(() => source?.props?.modelValue?.app);
|
||||
|
||||
const sourceAppId = computed(() => sourceApp.value?.id);
|
||||
|
||||
const btnDisable = computed(() => props.onlySourceSelect ? !(source?.props?.modelValue?.app?.id) : false);
|
||||
|
||||
//集計処理方法
|
||||
|
||||
watchEffect(() => {
|
||||
emit('update:modelValue', mappingProps);
|
||||
});
|
||||
return {
|
||||
uuidv4,
|
||||
dgIsShow: ref(false),
|
||||
closeDg,
|
||||
toDgIsShow: ref(false),
|
||||
closeToDg,
|
||||
mappingProps,
|
||||
addMappingObject: () => mappingProps.push(defaultMappingProp()),
|
||||
deleteMappingObject,
|
||||
mappingObjectsInputDisplay,
|
||||
sourceApp,
|
||||
sourceAppId,
|
||||
btnDisable
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style lang="scss"></style>
|
||||
@@ -22,6 +22,8 @@ import EventSetter from '../right/EventSetter.vue';
|
||||
import ColorPicker from './ColorPicker.vue';
|
||||
import NumInput from './NumInput.vue';
|
||||
import DataProcessing from './DataProcessing.vue';
|
||||
import DataMapping from './DataMapping.vue';
|
||||
import AppSelect from './AppSelect.vue';
|
||||
import { IActionNode,IActionProperty,IProp } from 'src/types/ActionTypes';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -37,7 +39,9 @@ export default defineComponent({
|
||||
EventSetter,
|
||||
ColorPicker,
|
||||
NumInput,
|
||||
DataProcessing
|
||||
DataProcessing,
|
||||
DataMapping,
|
||||
AppSelect
|
||||
},
|
||||
props: {
|
||||
nodeProps: {
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { api } from 'boot/axios';
|
||||
import { ActionFlow } from 'src/types/ActionTypes';
|
||||
|
||||
export class FlowCtrl
|
||||
{
|
||||
|
||||
async getFlows(appId:string):Promise<ActionFlow[]>
|
||||
{
|
||||
export class FlowCtrl {
|
||||
async getFlows(appId: string): Promise<ActionFlow[]> {
|
||||
const flows: ActionFlow[] = [];
|
||||
try {
|
||||
const result = await api.get(`api/flows/${appId}`);
|
||||
@@ -24,10 +21,9 @@ export class FlowCtrl
|
||||
}
|
||||
}
|
||||
|
||||
async SaveFlow(jsonData:any):Promise<boolean>
|
||||
{
|
||||
async SaveFlow(jsonData: any): Promise<boolean> {
|
||||
const result = await api.post('api/flow', jsonData);
|
||||
console.info(result.data)
|
||||
console.info(result.data);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@@ -35,10 +31,19 @@ export class FlowCtrl
|
||||
* @param jsonData
|
||||
* @returns
|
||||
*/
|
||||
async UpdateFlow(jsonData:any):Promise<boolean>
|
||||
{
|
||||
async UpdateFlow(jsonData: any): Promise<boolean> {
|
||||
const result = await api.put('api/flow/' + jsonData.flowid, jsonData);
|
||||
console.info(result.data)
|
||||
console.info(result.data);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* フローを消去する
|
||||
* @param flowId
|
||||
* @returns
|
||||
*/
|
||||
async DeleteFlow(flowId: string): Promise<boolean> {
|
||||
const result = await api.delete('api/flow/' + flowId);
|
||||
console.info(result.data);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@@ -46,12 +51,9 @@ export class FlowCtrl
|
||||
* @param appid
|
||||
* @returns
|
||||
*/
|
||||
async depoly(appid:string):Promise<boolean>
|
||||
{
|
||||
async depoly(appid: string): Promise<boolean> {
|
||||
const result = await api.post(`api/v1/createjstokintone?app=${appid}`);
|
||||
console.info(result.data);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<q-btn :label="model+'選択'" color="primary" @click="showDg()" />
|
||||
<show-dialog v-model:visible="show" :name="model" @close="closeDg" width="400px">
|
||||
<template v-if="model=='アプリ'">
|
||||
<app-select ref="appDg" :name="model" type="single"></app-select>
|
||||
<app-select-box ref="appDg" :name="model" type="single"></app-select-box>
|
||||
</template>
|
||||
<template v-if="model=='フィールド'">
|
||||
<field-select ref="appDg" :name="model" type="multiple" :appId="1"></field-select>
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ShowDialog from 'components/ShowDialog.vue';
|
||||
import AppSelect from 'components/AppSelect.vue';
|
||||
import AppSelectBox from 'components/AppSelectBox.vue';
|
||||
import FieldSelect from 'components/FieldSelect.vue';
|
||||
import ActionSelect from 'components/ActionSelect.vue';
|
||||
import { ref } from 'vue'
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface FlowEditorState{
|
||||
}
|
||||
const flowCtrl = new FlowCtrl();
|
||||
const eventTree = new KintoneEventManager();
|
||||
export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
export const useFlowEditorStore = defineStore('flowEditor', {
|
||||
state: (): FlowEditorState => ({
|
||||
flowNames1: '',
|
||||
appInfo: undefined,
|
||||
@@ -24,7 +24,7 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
activeNode: undefined,
|
||||
eventTree: eventTree,
|
||||
selectedEvent: undefined,
|
||||
expandedScreen:[]
|
||||
expandedScreen: [],
|
||||
}),
|
||||
getters: {
|
||||
/**
|
||||
@@ -43,17 +43,24 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
return (eventId: string) => {
|
||||
return state.flows?.find((flow) => {
|
||||
const root = flow.getRoot();
|
||||
return root?.name===eventId
|
||||
return root?.name === eventId;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
findEventById(state) {
|
||||
return (eventId: string) => {
|
||||
return state.eventTree.findEventById(eventId);
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
actions: {
|
||||
setFlows(flows: IActionFlow[]) {
|
||||
this.flows = flows;
|
||||
},
|
||||
selectFlow(flow:IActionFlow){
|
||||
selectFlow(flow: IActionFlow | undefined) {
|
||||
this.selectedFlow = flow;
|
||||
},
|
||||
setActiveNode(node: IActionNode) {
|
||||
@@ -80,7 +87,7 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
if (actionFlows && actionFlows.length > 0) {
|
||||
this.selectFlow(actionFlows[0]);
|
||||
}
|
||||
const expandNames = actionFlows.map(flow=>flow.getRoot()?.title);
|
||||
const expandNames = actionFlows.map((flow) => flow.getRoot()?.title);
|
||||
// const expandName =actionFlows[0].getRoot()?.title;
|
||||
this.expandedScreen = expandNames;
|
||||
},
|
||||
@@ -95,8 +102,8 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
appid: this.appInfo?.appId,
|
||||
eventid: root?.name,
|
||||
name: root?.subTitle,
|
||||
content: JSON.stringify(flow)
|
||||
}
|
||||
content: JSON.stringify(flow),
|
||||
};
|
||||
|
||||
if (isNew) {
|
||||
return await flowCtrl.SaveFlow(jsonData);
|
||||
@@ -104,6 +111,24 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
return await flowCtrl.UpdateFlow(jsonData);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
deleteEvent(event: IKintoneEvent) {
|
||||
const store = useFlowEditorStore();
|
||||
if (event.flowData) {
|
||||
const flow = event.flowData;
|
||||
if (flow.id === '') {
|
||||
return;
|
||||
}
|
||||
flowCtrl.DeleteFlow(flow.id)
|
||||
eventTree.deleteEvent(event, store);
|
||||
if(this.flows){
|
||||
this.flows = this.flows.filter((f) => f.id !== flow.id);
|
||||
}
|
||||
} else {
|
||||
eventTree.deleteEvent(event, store);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* デプロイする
|
||||
*/
|
||||
@@ -112,7 +137,6 @@ export const useFlowEditorStore = defineStore("flowEditor",{
|
||||
return false;
|
||||
}
|
||||
return await flowCtrl.depoly(this.appInfo?.appId);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -74,6 +74,11 @@ export class GroupNode implements INode {
|
||||
|
||||
}
|
||||
|
||||
export type OperatorListItem = {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
// 条件式ノード
|
||||
export class ConditionNode implements INode {
|
||||
index: number;
|
||||
@@ -83,13 +88,13 @@ export class ConditionNode implements INode {
|
||||
return this.parent.logicalOperator;
|
||||
};
|
||||
object: any; // 比較元
|
||||
operator: Operator; // 比較子
|
||||
operator: Operator | OperatorListItem; // 比較子
|
||||
value: any;
|
||||
get header():string{
|
||||
return 'generic';
|
||||
}
|
||||
|
||||
constructor(object: any, operator: Operator, value: any, parent: GroupNode) {
|
||||
constructor(object: any, operator: Operator | OperatorListItem, value: any, parent: GroupNode) {
|
||||
this.index=0;
|
||||
this.type = NodeType.Condition;
|
||||
this.object = object;
|
||||
@@ -113,10 +118,12 @@ export class ConditionNode implements INode {
|
||||
export class ConditionTree {
|
||||
root: GroupNode;
|
||||
maxIndex:number;
|
||||
queryString:string;
|
||||
|
||||
constructor() {
|
||||
this.maxIndex=0;
|
||||
this.root = new GroupNode(LogicalOperator.AND, null);
|
||||
this.queryString='';
|
||||
}
|
||||
|
||||
// ノード追加
|
||||
@@ -198,12 +205,49 @@ export class ConditionTree {
|
||||
if(value && typeof value ==='object' && ('label' in value)){
|
||||
value =condNode.value.label;
|
||||
}
|
||||
return `${typeof condNode.object.name === 'object' ? condNode.object.name.name : condNode.object.name} ${condNode.operator} '${value}'`;
|
||||
return `${typeof condNode.object.name === 'object' ? condNode.object.name.name : condNode.object.name} ${typeof condNode.operator === 'object' ? condNode.operator.label : condNode.operator} '${value}'`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildConditionQueryString(node:INode){
|
||||
if (node.type !== NodeType.Condition) {
|
||||
let conditionString = '';
|
||||
if(node.type !== NodeType.Root){
|
||||
conditionString = '(';
|
||||
}
|
||||
|
||||
const groupNode = node as GroupNode;
|
||||
for (let i = 0; i < groupNode.children.length; i++) {
|
||||
const childConditionString = this.buildConditionQueryString(groupNode.children[i]);
|
||||
if (childConditionString !== '') {
|
||||
conditionString += childConditionString;
|
||||
if (i < groupNode.children.length - 1) {
|
||||
conditionString += ` ${groupNode.logicalOperator.toLowerCase()} `;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(node.type !== NodeType.Root){
|
||||
conditionString += ')';
|
||||
}
|
||||
return conditionString;
|
||||
} else {
|
||||
const condNode=node as ConditionNode;
|
||||
if (condNode.object && condNode.operator ) {
|
||||
let value=condNode.value;
|
||||
if(value && typeof value ==='object' && ('label' in value)){
|
||||
value =condNode.value.label;
|
||||
}
|
||||
return `${condNode.object.code} ${typeof condNode.operator === 'object' ? condNode.operator.value : condNode.operator} "${value}"`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param node ノード移動
|
||||
@@ -325,7 +369,7 @@ export class ConditionTree {
|
||||
}
|
||||
|
||||
toJson():string{
|
||||
return JSON.stringify(this.root, (key, value) => {
|
||||
return JSON.stringify({queryString :this.queryString, ...this.root}, (key, value) => {
|
||||
if (key === 'parent') {
|
||||
return value ? value.type : null;
|
||||
}
|
||||
@@ -333,4 +377,7 @@ export class ConditionTree {
|
||||
});
|
||||
}
|
||||
|
||||
setQuery(queryString:string){
|
||||
this.queryString=queryString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useFlowEditorStore } from 'src/stores/flowEditor';
|
||||
import { IActionFlow } from './ActionTypes';
|
||||
export interface IKintoneEventNode {
|
||||
label: string;
|
||||
@@ -15,18 +16,15 @@ export interface IKintoneEventGroup extends IKintoneEventNode {
|
||||
events: IKintoneEventNode[];
|
||||
}
|
||||
|
||||
|
||||
export class kintoneEvent implements IKintoneEvent {
|
||||
eventId: string;
|
||||
parentId: string;
|
||||
get hasFlow(): boolean {
|
||||
return this.flowData!==undefined && this.flowData.actionNodes.length>1
|
||||
};
|
||||
return this.flowData !== undefined && this.flowData.actionNodes.length > 1;
|
||||
}
|
||||
flowData?: IActionFlow | undefined;
|
||||
label: string;
|
||||
get header():string{
|
||||
return "EVENT";
|
||||
}
|
||||
header = 'EVENT';
|
||||
constructor(label: string, eventId: string, parentId: string) {
|
||||
this.eventId = eventId;
|
||||
this.label = label;
|
||||
@@ -40,9 +38,14 @@ export class kintoneEventGroup implements IKintoneEventGroup{
|
||||
label: string;
|
||||
events: IKintoneEventNode[];
|
||||
get header(): string {
|
||||
return "EVENTGROUP";
|
||||
return 'EVENTGROUP';
|
||||
}
|
||||
constructor(eventId:string,label:string,events:IKintoneEventNode[],parentId:string){
|
||||
constructor(
|
||||
eventId: string,
|
||||
label: string,
|
||||
events: IKintoneEventNode[],
|
||||
parentId: string
|
||||
) {
|
||||
this.eventId = eventId;
|
||||
this.label = label;
|
||||
this.events = events;
|
||||
@@ -50,16 +53,20 @@ export class kintoneEventGroup implements IKintoneEventGroup{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class kintoneEventForChange implements IKintoneEventGroup {
|
||||
eventId: string;
|
||||
parentId: string;
|
||||
label: string;
|
||||
events: IKintoneEventNode[];
|
||||
get header(): string {
|
||||
return "CHANGE";
|
||||
return 'CHANGE';
|
||||
}
|
||||
constructor(eventId:string,label:string,events:IKintoneEventNode[],parentId:string){
|
||||
constructor(
|
||||
eventId: string,
|
||||
label: string,
|
||||
events: IKintoneEventNode[],
|
||||
parentId: string
|
||||
) {
|
||||
this.eventId = eventId;
|
||||
this.label = label;
|
||||
this.events = events;
|
||||
@@ -67,8 +74,6 @@ export class kintoneEventForChange implements IKintoneEventGroup{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class KintoneEventManager {
|
||||
public screens: IKintoneEventGroup[];
|
||||
|
||||
@@ -82,22 +87,29 @@ export class KintoneEventManager {
|
||||
const eventId = flow.getRoot()?.name;
|
||||
if (eventId !== undefined) {
|
||||
const eventNode = this.findEventById(eventId);
|
||||
if(eventNode!==null && eventNode.header==="EVENT"){
|
||||
if (eventNode !== null && eventNode.header === 'EVENT') {
|
||||
const event = eventNode as kintoneEvent;
|
||||
event.flowData = flow;
|
||||
} else {
|
||||
//EventGroupのIDを取得
|
||||
const lastIndex = eventId.lastIndexOf(".");
|
||||
const lastIndex = eventId.lastIndexOf('.');
|
||||
const groupId = eventId.substring(0, lastIndex);
|
||||
const eventNode = this.findEventById(groupId);
|
||||
if(eventNode && (eventNode.header==="EVENTGROUP" || eventNode.header==="CHANGE")){
|
||||
if (
|
||||
eventNode &&
|
||||
(eventNode.header === 'EVENTGROUP' || eventNode.header === 'CHANGE')
|
||||
) {
|
||||
const groupEvent = eventNode as kintoneEventGroup;
|
||||
const newEvent =new kintoneEvent(
|
||||
flow.getRoot()?.subTitle || "",
|
||||
eventId,
|
||||
groupEvent.parentId
|
||||
);
|
||||
newEvent.flowData=flow;
|
||||
|
||||
const newEvent = {
|
||||
label: flow.getRoot()?.subTitle || '',
|
||||
eventId: eventId,
|
||||
parentId: groupId,
|
||||
header: 'DELETABLE',
|
||||
hasFlow: true,
|
||||
flowData: flow,
|
||||
};
|
||||
|
||||
groupEvent.events.push(newEvent);
|
||||
}
|
||||
}
|
||||
@@ -107,17 +119,19 @@ export class KintoneEventManager {
|
||||
|
||||
public findEventById(eventId: string): IKintoneEventNode | null {
|
||||
const screen = this.findScreen(eventId);
|
||||
if(screen) {return screen;}
|
||||
if (screen) {
|
||||
return screen;
|
||||
}
|
||||
for (const screen of this.screens) {
|
||||
for (const event of screen.events) {
|
||||
if (event.eventId === eventId) {
|
||||
return event;
|
||||
}
|
||||
if(event.header==="EVENTGROUP"||event.header==="CHANGE"){
|
||||
if (event.header === 'EVENTGROUP' || event.header === 'CHANGE') {
|
||||
const eventGroup = event as IKintoneEventGroup;
|
||||
const targetEvent = eventGroup.events.find((ev) => {
|
||||
return ev.eventId === eventId;
|
||||
})
|
||||
});
|
||||
if (targetEvent) {
|
||||
return targetEvent;
|
||||
}
|
||||
@@ -128,39 +142,169 @@ export class KintoneEventManager {
|
||||
}
|
||||
|
||||
public findScreen(eventId: string): IKintoneEventGroup | undefined {
|
||||
return this.screens.find(screen=>screen.eventId==eventId);
|
||||
return this.screens.find((screen) => screen.eventId == eventId);
|
||||
}
|
||||
|
||||
public deleteEvent(
|
||||
event: kintoneEvent,
|
||||
store: ReturnType<typeof useFlowEditorStore>
|
||||
) {
|
||||
if (event.header !== 'DELETABLE') {
|
||||
return;
|
||||
}
|
||||
|
||||
const parent = store.findEventById(event.parentId);
|
||||
if (parent?.header !== 'CHANGE' && parent?.header !== 'EVENTGROUP') {
|
||||
return;
|
||||
}
|
||||
const realParent = parent as kintoneEventForChange;
|
||||
|
||||
const index = realParent.events.findIndex(
|
||||
(e) => e.eventId === event.eventId
|
||||
);
|
||||
|
||||
if (index !== -1) {
|
||||
realParent.events.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public getKintoneEvents(): IKintoneEventGroup[] {
|
||||
return [
|
||||
new kintoneEventGroup("app.record.create","レコード追加画面",[
|
||||
new kintoneEvent('レコード追加画面を表示した後','app.record.create.show',"app.record.create"),
|
||||
new kintoneEvent('保存をクリックしたとき','app.record.create.submit',"app.record.create"),
|
||||
new kintoneEvent('保存が成功したとき','app.record.create.submit.success',"app.record.create"),
|
||||
new kintoneEventForChange('app.record.create.change','フィールドの値を変更したとき',[],"app.record.create"),
|
||||
new kintoneEventGroup('app.record.create.show.customButtonClick','ボタンをクリックした時',[],"app.record.create")
|
||||
],""),
|
||||
new kintoneEventGroup("app.record.detail","レコード詳細画面",[
|
||||
new kintoneEvent('レコード詳細画面を表示した後','app.record.detail.show',"app.record.detail"),
|
||||
new kintoneEvent('レコードを削除するとき','app.record.detail.delete.submit',"app.record.detail"),
|
||||
new kintoneEvent('プロセス管理のアクションを実行したとき','app.record.detail.process.proceed',"app.record.detail"),
|
||||
new kintoneEventGroup('app.record.detail.show.customButtonClick','ボタンをクリックした時',[],"app.record.detail"),
|
||||
],""),
|
||||
new kintoneEventGroup("app.record.edit","レコード編集画面",[
|
||||
new kintoneEvent('レコード編集画面を表示した後','app.record.edit.show',"app.record.edit"),
|
||||
new kintoneEvent('保存をクリックしたとき','app.record.edit.submit',"app.record.edit"),
|
||||
new kintoneEvent('保存が成功したとき','app.record.edit.submit.success',"app.record.edit"),
|
||||
new kintoneEventForChange('app.record.edit.change','フィールドの値を変更したとき',[],"app.record.edit"),
|
||||
new kintoneEventGroup('app.record.edit.show.customButtonClick','ボタンをクリックした時',[],"app.record.edit"),
|
||||
],""),
|
||||
new kintoneEventGroup("app.record.index","レコード一覧画面",[
|
||||
new kintoneEvent('一覧画面を表示した後', 'app.record.index.show',"app.record.index"),
|
||||
new kintoneEvent('インライン編集を開始したとき','app.record.index.edit.show',"app.record.index"),
|
||||
new kintoneEvent('インライン編集の【保存】をクリックしたとき','app.record.index.edit.submit',"app.record.index"),
|
||||
new kintoneEvent('インライン編集の保存が成功したとき', 'app.record.index.edit.submit.success',"app.record.index"),
|
||||
new kintoneEventForChange('app.record.index.edit.change','インライン編集のフィールド値を変更したとき' ,[],"app.record.index"),
|
||||
new kintoneEventGroup('app.record.detail.show.customButtonClick','ボタンをクリックした時',[],"app.record.index"),
|
||||
],"")
|
||||
new kintoneEventGroup(
|
||||
'app.record.create',
|
||||
'レコード追加画面',
|
||||
[
|
||||
new kintoneEvent(
|
||||
'レコード追加画面を表示した後',
|
||||
'app.record.create.show',
|
||||
'app.record.create'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'保存をクリックしたとき',
|
||||
'app.record.create.submit',
|
||||
'app.record.create'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'保存が成功したとき',
|
||||
'app.record.create.submit.success',
|
||||
'app.record.create'
|
||||
),
|
||||
new kintoneEventForChange(
|
||||
'app.record.create.change',
|
||||
'フィールドの値を変更したとき',
|
||||
[],
|
||||
'app.record.create'
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.create.show.customButtonClick',
|
||||
'ボタンをクリックした時',
|
||||
[],
|
||||
'app.record.create'
|
||||
),
|
||||
],
|
||||
''
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.detail',
|
||||
'レコード詳細画面',
|
||||
[
|
||||
new kintoneEvent(
|
||||
'レコード詳細画面を表示した後',
|
||||
'app.record.detail.show',
|
||||
'app.record.detail'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'レコードを削除するとき',
|
||||
'app.record.detail.delete.submit',
|
||||
'app.record.detail'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'プロセス管理のアクションを実行したとき',
|
||||
'app.record.detail.process.proceed',
|
||||
'app.record.detail'
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.detail.show.customButtonClick',
|
||||
'ボタンをクリックした時',
|
||||
[],
|
||||
'app.record.detail'
|
||||
),
|
||||
],
|
||||
''
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.edit',
|
||||
'レコード編集画面',
|
||||
[
|
||||
new kintoneEvent(
|
||||
'レコード編集画面を表示した後',
|
||||
'app.record.edit.show',
|
||||
'app.record.edit'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'保存をクリックしたとき',
|
||||
'app.record.edit.submit',
|
||||
'app.record.edit'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'保存が成功したとき',
|
||||
'app.record.edit.submit.success',
|
||||
'app.record.edit'
|
||||
),
|
||||
new kintoneEventForChange(
|
||||
'app.record.edit.change',
|
||||
'フィールドの値を変更したとき',
|
||||
[],
|
||||
'app.record.edit'
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.edit.show.customButtonClick',
|
||||
'ボタンをクリックした時',
|
||||
[],
|
||||
'app.record.edit'
|
||||
),
|
||||
],
|
||||
''
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.index',
|
||||
'レコード一覧画面',
|
||||
[
|
||||
new kintoneEvent(
|
||||
'一覧画面を表示した後',
|
||||
'app.record.index.show',
|
||||
'app.record.index'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'インライン編集を開始したとき',
|
||||
'app.record.index.edit.show',
|
||||
'app.record.index'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'インライン編集の【保存】をクリックしたとき',
|
||||
'app.record.index.edit.submit',
|
||||
'app.record.index'
|
||||
),
|
||||
new kintoneEvent(
|
||||
'インライン編集の保存が成功したとき',
|
||||
'app.record.index.edit.submit.success',
|
||||
'app.record.index'
|
||||
),
|
||||
new kintoneEventForChange(
|
||||
'app.record.index.edit.change',
|
||||
'インライン編集のフィールド値を変更したとき',
|
||||
[],
|
||||
'app.record.index'
|
||||
),
|
||||
new kintoneEventGroup(
|
||||
'app.record.detail.show.customButtonClick',
|
||||
'ボタンをクリックした時',
|
||||
[],
|
||||
'app.record.index'
|
||||
),
|
||||
],
|
||||
''
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
2
plugin/kintone-addins/.env.dev
Normal file
2
plugin/kintone-addins/.env.dev
Normal file
@@ -0,0 +1,2 @@
|
||||
VITE_SOURCE_MAP = inline
|
||||
VITE_PORT = 4173
|
||||
2
plugin/kintone-addins/.env.production
Normal file
2
plugin/kintone-addins/.env.production
Normal file
@@ -0,0 +1,2 @@
|
||||
VITE_SOURCE_MAP = false
|
||||
VITE_PORT = 4173
|
||||
@@ -4,19 +4,28 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsc && set \"SOURCE_MAP=true\" && vite build && vite preview",
|
||||
"build": "tsc && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y",
|
||||
"build:dev":"tsc && set \"SOURCE_MAP=true\" && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y",
|
||||
"preview": "vite preview",
|
||||
"ngrok":"ngrok http http://localhost:4173/",
|
||||
"vite":"vite dev"
|
||||
"dev": "run-p watch server ngrok",
|
||||
"watch": "vite build --watch --mode dev",
|
||||
"server": "vite dev --mode dev",
|
||||
"ngrok": "ngrok http 4173",
|
||||
"build": "run-s b:production copy:windows",
|
||||
"build:dev": "run-s b:dev copy:windows",
|
||||
"build:linux": "run-s b:production copy:linux",
|
||||
"build:linux-dev": "run-s b:dev copy:linux",
|
||||
"b:production": "vite build --mode production",
|
||||
"b:dev": "vite build --mode dev",
|
||||
"copy:windows": "xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y",
|
||||
"copy:linux": "cp -ur dist/*.js ../../backend/Temp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jquery": "^3.5.24",
|
||||
"@types/node": "^20.8.9",
|
||||
"npm-run-all2": "^6.2.0",
|
||||
"sass": "^1.69.5",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.4.5"
|
||||
"vite": "^4.4.5",
|
||||
"vite-plugin-checker": "^0.6.4",
|
||||
"vite-plugin-lib-inject-css": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"jquery": "^3.7.1"
|
||||
|
||||
24
plugin/kintone-addins/src/actions/auto-numbering.css
Normal file
24
plugin/kintone-addins/src/actions/auto-numbering.css
Normal file
@@ -0,0 +1,24 @@
|
||||
.alc-button-normal {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
padding: 0 16px;
|
||||
margin-left: 16px;
|
||||
margin-top: 8px;
|
||||
min-width: 100px;
|
||||
outline: none;
|
||||
border: 1px solid #e3e7e8;
|
||||
background-color: #f7f9fa;
|
||||
box-shadow: 1px 1px 1px #fff inset;
|
||||
color: #3498db;
|
||||
text-align: center;
|
||||
line-height: 32px;
|
||||
}
|
||||
.alc-button-normal:hover {
|
||||
background-color: #c8d6dd;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.alc-button-normal:active {
|
||||
color: #f7f9fa;
|
||||
background-color: #54b8eb;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IField, IAction,IActionResult, IActionNode, IActionProperty, IContext } from "../types/ActionTypes";
|
||||
import { Formatter } from "../util/format";
|
||||
import "./auto-numbering.css";
|
||||
|
||||
declare global {
|
||||
interface Window { $format: any; }
|
||||
@@ -84,6 +85,7 @@ export class AutoNumbering implements IAction{
|
||||
|
||||
execEval(match:string,expr:string):string{
|
||||
console.log(match);
|
||||
// @ts-ignore
|
||||
return eval(expr);
|
||||
}
|
||||
|
||||
|
||||
0
plugin/kintone-addins/src/actions/button-add.css
Normal file
0
plugin/kintone-addins/src/actions/button-add.css
Normal file
@@ -2,6 +2,8 @@
|
||||
import { actionAddins } from ".";
|
||||
import $ from 'jquery';
|
||||
import { IAction, IActionProperty, IActionNode, IActionResult } from "../types/ActionTypes";
|
||||
import "./button-add.css";
|
||||
|
||||
/**
|
||||
* ボタン配置属性定義
|
||||
*/
|
||||
@@ -51,30 +53,7 @@ export class ButtonAddAction implements IAction {
|
||||
if(!menuSpace) return result;
|
||||
if($("style#alc-button-add").length===0){
|
||||
const css=`
|
||||
.alc-button-normal {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
padding: 0 16px;
|
||||
margin-left: 16px;
|
||||
margin-top: 8px;
|
||||
min-width: 100px;
|
||||
outline: none;
|
||||
border: 1px solid #e3e7e8;
|
||||
background-color: #f7f9fa;
|
||||
box-shadow: 1px 1px 1px #fff inset;
|
||||
color: #3498db;
|
||||
text-align: center;
|
||||
line-height: 32px;
|
||||
}
|
||||
.alc-button-normal:hover {
|
||||
background-color: #c8d6dd;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.alc-button-normal:active {
|
||||
color: #f7f9fa;
|
||||
background-color: #54b8eb;
|
||||
}`;
|
||||
`;
|
||||
const style = $("<style id='alc-button-add'>/<style>");
|
||||
style.text(css);
|
||||
$("head").append(style);
|
||||
|
||||
182
plugin/kintone-addins/src/actions/data-mapping.ts
Normal file
182
plugin/kintone-addins/src/actions/data-mapping.ts
Normal file
@@ -0,0 +1,182 @@
|
||||
import {
|
||||
IAction,
|
||||
IActionResult,
|
||||
IActionNode,
|
||||
IActionProperty,
|
||||
IContext,
|
||||
} from "../types/ActionTypes";
|
||||
import { actionAddins } from ".";
|
||||
|
||||
export type IApp = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
export type IField = {
|
||||
name: string;
|
||||
code: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type IAppFields = {
|
||||
app?: IApp;
|
||||
fields: IField[];
|
||||
};
|
||||
|
||||
type ValueType = {
|
||||
id: string;
|
||||
from: {
|
||||
objectType: "variable" | "field";
|
||||
name: { name: string };
|
||||
code: string;
|
||||
};
|
||||
to: IAppFields & {
|
||||
isDialogVisible: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
type Props = { app: IApp; field: ValueType[] };
|
||||
|
||||
export class DataMappingAction implements IAction {
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
dataMappingProps: Props;
|
||||
constructor() {
|
||||
this.name = "DataMapping";
|
||||
this.actionProps = [];
|
||||
this.dataMappingProps = {} as Props;
|
||||
this.register();
|
||||
}
|
||||
|
||||
async process(
|
||||
prop: IActionNode,
|
||||
event: any,
|
||||
context: IContext
|
||||
): Promise<IActionResult> {
|
||||
this.initActionProps(prop);
|
||||
this.initTypedActionProps();
|
||||
let result = {
|
||||
canNext: true,
|
||||
result: "",
|
||||
} as IActionResult;
|
||||
try {
|
||||
for (const item of this.dataMappingProps.field) {
|
||||
if (item.from.objectType === "variable") {
|
||||
if (
|
||||
item.from.name.name &&
|
||||
item.to.app &&
|
||||
item.to.fields &&
|
||||
item.to.fields.length > 0
|
||||
) {
|
||||
const value = getValueByPath(
|
||||
context.variables,
|
||||
item.from.name.name
|
||||
);
|
||||
if (value) {
|
||||
await kintone.api(
|
||||
kintone.api.url("/k/v1/record.json", true),
|
||||
"POST",
|
||||
{
|
||||
app: item.to.app.id,
|
||||
record: {
|
||||
[item.to.fields[0].code]: {
|
||||
value: value,
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (item.from.objectType === "field") {
|
||||
if (
|
||||
item.from.code &&
|
||||
item.to.app &&
|
||||
item.to.fields &&
|
||||
item.to.fields.length > 0
|
||||
) {
|
||||
const value = await selectData(
|
||||
item.to.app.id,
|
||||
item.to.fields[0].code
|
||||
);
|
||||
if (value && value.type === context.record[item.from.code].type) {
|
||||
await kintone.api(
|
||||
kintone.api.url("/k/v1/records.json", true),
|
||||
"POST",
|
||||
{
|
||||
app: item.to.app.id,
|
||||
records: value.value.map((v) => ({
|
||||
[item.to.fields[0].code]: {
|
||||
value: v,
|
||||
},
|
||||
})),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("DataMappingAction error", error);
|
||||
result.canNext = false;
|
||||
}
|
||||
console.log("dataMappingProps", this.dataMappingProps);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private initActionProps(nodes: IActionNode) {
|
||||
this.actionProps = nodes.actionProps;
|
||||
}
|
||||
private initTypedActionProps() {
|
||||
for (const action of this.actionProps) {
|
||||
if (action.component === "DataMapping") {
|
||||
this.dataMappingProps.field = action.props.modelValue as ValueType[];
|
||||
} else if (action.component === "AppSelect") {
|
||||
this.dataMappingProps.app = action.props.modelValue.app as IApp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register(): void {
|
||||
actionAddins[this.name] = this;
|
||||
}
|
||||
}
|
||||
|
||||
new DataMappingAction();
|
||||
|
||||
const getValueByPath = (obj: any, path: string) => {
|
||||
return path.split(".").reduce((o, k) => (o || {})[k], obj);
|
||||
};
|
||||
|
||||
type Resp = { records: RespRecordType[] };
|
||||
|
||||
type RespRecordType = {
|
||||
[key: string]: {
|
||||
type: string;
|
||||
value: any;
|
||||
};
|
||||
};
|
||||
|
||||
type Result = {
|
||||
type: string;
|
||||
value: any[];
|
||||
};
|
||||
|
||||
const selectData = async (appid: string, field: string): Promise<Result> => {
|
||||
return kintone
|
||||
.api(kintone.api.url("/k/v1/records", true), "GET", {
|
||||
app: appid ?? kintone.app.getId(),
|
||||
fields: [field],
|
||||
})
|
||||
.then((resp: Resp) => {
|
||||
const result: Result = { type: "", value: [] };
|
||||
resp.records.forEach((element) => {
|
||||
for (const [key, value] of Object.entries(element)) {
|
||||
if (result.type === "") {
|
||||
result.type = value.type;
|
||||
}
|
||||
result.value.push(value.value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
};
|
||||
280
plugin/kintone-addins/src/actions/data-processing.ts
Normal file
280
plugin/kintone-addins/src/actions/data-processing.ts
Normal file
@@ -0,0 +1,280 @@
|
||||
import {
|
||||
IAction,
|
||||
IActionResult,
|
||||
IActionNode,
|
||||
IActionProperty,
|
||||
IContext,
|
||||
} from "../types/ActionTypes";
|
||||
import { actionAddins } from ".";
|
||||
|
||||
|
||||
type DataProcessingProps = {
|
||||
app: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
conditionsQuery: string;
|
||||
propcessing: {
|
||||
varRootName: string;
|
||||
fields: Field[];
|
||||
};
|
||||
};
|
||||
|
||||
type Field = {
|
||||
name: string;
|
||||
code: string;
|
||||
type: string;
|
||||
varName: string;
|
||||
operator: string;
|
||||
};
|
||||
|
||||
export class DataProcessingAction implements IAction {
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
dataProcessingProps: DataProcessingProps | null;
|
||||
constructor() {
|
||||
this.name = "データ処理";
|
||||
this.actionProps = [];
|
||||
this.dataProcessingProps = null;
|
||||
this.register();
|
||||
}
|
||||
|
||||
async process(
|
||||
nodes: IActionNode,event: any,context: IContext
|
||||
): Promise<IActionResult> {
|
||||
this.initActionProps(nodes);
|
||||
this.initTypedActionProps();
|
||||
let result = {
|
||||
canNext: true,
|
||||
result: "",
|
||||
} as IActionResult;
|
||||
try {
|
||||
if (!this.dataProcessingProps) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const data = await selectData(this.dataProcessingProps.conditionsQuery);
|
||||
console.log("data ", data);
|
||||
|
||||
context.variables[this.dataProcessingProps.propcessing.varRootName] =
|
||||
this.dataProcessingProps.propcessing.fields.reduce((acc, f) => {
|
||||
const v = calc(f, data);
|
||||
if (v) {
|
||||
acc[f.varName] = calc(f, data);
|
||||
}
|
||||
return acc;
|
||||
}, {} as Var);
|
||||
|
||||
console.log("context ", context);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
event.error=error;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
register(): void {
|
||||
actionAddins[this.name] = this;
|
||||
}
|
||||
|
||||
private initActionProps(nodes: IActionNode) {
|
||||
this.actionProps = nodes.actionProps;
|
||||
}
|
||||
|
||||
private initTypedActionProps() {
|
||||
this.dataProcessingProps = {
|
||||
app: {
|
||||
id: "",
|
||||
name: "",
|
||||
},
|
||||
conditionsQuery: "",
|
||||
propcessing: {
|
||||
varRootName: "",
|
||||
fields: [],
|
||||
},
|
||||
};
|
||||
for (const action of this.actionProps) {
|
||||
if (action.component === "AppFieldSelect") {
|
||||
this.dataProcessingProps.app.id = action.props.modelValue.app.id;
|
||||
this.dataProcessingProps.app.name = action.props.modelValue.app.name;
|
||||
} else if (action.component === "DataProcessing") {
|
||||
this.dataProcessingProps.propcessing.varRootName =
|
||||
action.props.modelValue.name;
|
||||
for (const f of action.props.modelValue.vars) {
|
||||
this.dataProcessingProps.propcessing.fields.push({
|
||||
name: f.field.name,
|
||||
code: f.field.code,
|
||||
type: f.field.type,
|
||||
varName: f.vName,
|
||||
operator: f.logicalOperator.operator,
|
||||
});
|
||||
}
|
||||
} else if (action.component === "ConditionInput") {
|
||||
this.dataProcessingProps.conditionsQuery = JSON.parse(
|
||||
action.props.modelValue
|
||||
).queryString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new DataProcessingAction();
|
||||
|
||||
const selectData = async (query?: string) => {
|
||||
return kintone
|
||||
.api(kintone.api.url("/k/v1/records", true), "GET", {
|
||||
app: kintone.app.getId(),
|
||||
query: query,
|
||||
})
|
||||
.then((resp: Resp) => {
|
||||
const result: Result = {};
|
||||
resp.records.forEach((element) => {
|
||||
for (const [key, value] of Object.entries(element)) {
|
||||
if (!result[key]) {
|
||||
result[key] = { type: value.type, value: [] };
|
||||
}
|
||||
result[key].value.push(value.value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
};
|
||||
|
||||
type Resp = { records: RespRecordType[] };
|
||||
|
||||
type RespRecordType = {
|
||||
[key: string]: {
|
||||
type: string;
|
||||
value: any;
|
||||
};
|
||||
};
|
||||
|
||||
type Result = {
|
||||
[key: string]: {
|
||||
type: string;
|
||||
value: any[];
|
||||
};
|
||||
};
|
||||
|
||||
type Var = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
const ERROR_TYPE = "ERROR_TYPE";
|
||||
|
||||
const calc = (field: Field, result: Result) => {
|
||||
const type = typeCheck(field.type);
|
||||
if (!type) {
|
||||
return ERROR_TYPE;
|
||||
}
|
||||
|
||||
const fun =
|
||||
calcFunc[`${type}_${Operator[field.operator as keyof typeof Operator]}`];
|
||||
if (!fun) {
|
||||
return ERROR_TYPE;
|
||||
}
|
||||
const values = result[field.code].value;
|
||||
if (!values) {
|
||||
return null;
|
||||
}
|
||||
return fun(values);
|
||||
};
|
||||
|
||||
const typeCheck = (type: string) => {
|
||||
switch (type) {
|
||||
case "RECORD_NUMBER":
|
||||
case "NUMBER":
|
||||
return CalcType.NUMBER;
|
||||
case "SINGLE_LINE_TEXT":
|
||||
case "MULTI_LINE_TEXT":
|
||||
case "RICH_TEXT":
|
||||
return CalcType.STRING;
|
||||
case "DATE":
|
||||
return CalcType.DATE;
|
||||
case "TIME":
|
||||
return CalcType.TIME;
|
||||
case "DATETIME":
|
||||
case "UPDATED_TIME":
|
||||
return CalcType.DATETIME;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
enum Operator {
|
||||
SUM = "SUM",
|
||||
AVG = "AVG",
|
||||
MAX = "MAX",
|
||||
MIN = "MIN",
|
||||
COUNT = "COUNT",
|
||||
FIRST = "FIRST"
|
||||
}
|
||||
|
||||
enum CalcType {
|
||||
NUMBER = "number",
|
||||
STRING = "string",
|
||||
DATE = "date",
|
||||
TIME = "time",
|
||||
DATETIME = "datetime",
|
||||
}
|
||||
|
||||
const calcFunc: Record<string, (value: string[]) => string | null> = {
|
||||
[`${CalcType.NUMBER}_${Operator.COUNT}`]: (value: string[]) =>
|
||||
value.length.toString(),
|
||||
[`${CalcType.STRING}_${Operator.COUNT}`]: (value: string[]) =>
|
||||
value.length.toString(),
|
||||
[`${CalcType.DATE}_${Operator.COUNT}`]: (value: string[]) =>
|
||||
value.length.toString(),
|
||||
[`${CalcType.TIME}_${Operator.COUNT}`]: (value: string[]) =>
|
||||
value.length.toString(),
|
||||
[`${CalcType.DATETIME}_${Operator.COUNT}`]: (value: string[]) =>
|
||||
value.length.toString(),
|
||||
|
||||
[`${CalcType.NUMBER}_${Operator.SUM}`]: (value: string[]) =>
|
||||
value.reduce((acc, v) => acc + Number(v), 0).toString(),
|
||||
[`${CalcType.NUMBER}_${Operator.AVG}`]: (value: string[]) =>
|
||||
(value.reduce((acc, v) => acc + Number(v), 0) / value.length).toString(),
|
||||
[`${CalcType.NUMBER}_${Operator.MAX}`]: (value: string[]) =>
|
||||
Math.max(...value.map(Number)).toString(),
|
||||
[`${CalcType.NUMBER}_${Operator.MIN}`]: (value: string[]) =>
|
||||
Math.min(...value.map(Number)).toString(),
|
||||
|
||||
[`${CalcType.STRING}_${Operator.SUM}`]: (value: string[]) => value.join(" "),
|
||||
|
||||
[`${CalcType.DATE}_${Operator.MAX}`]: (value: string[]) =>
|
||||
value.reduce((maxDate, currentDate) =>
|
||||
maxDate > currentDate ? maxDate : currentDate
|
||||
),
|
||||
|
||||
[`${CalcType.DATE}_${Operator.MIN}`]: (value: string[]) =>
|
||||
value.reduce((minDate, currentDate) =>
|
||||
minDate < currentDate ? minDate : currentDate
|
||||
),
|
||||
|
||||
[`${CalcType.TIME}_${Operator.MAX}`]: (value: string[]) =>
|
||||
value.reduce((maxTime, currentTime) =>
|
||||
maxTime > currentTime ? maxTime : currentTime
|
||||
),
|
||||
[`${CalcType.TIME}_${Operator.MIN}`]: (value: string[]) =>
|
||||
value.reduce((minTime, currentTime) =>
|
||||
minTime < currentTime ? minTime : currentTime
|
||||
),
|
||||
|
||||
[`${CalcType.DATETIME}_${Operator.MAX}`]: (value: string[]) =>
|
||||
value.reduce((maxDateTime, currentDateTime) =>
|
||||
new Date(maxDateTime) > new Date(currentDateTime)
|
||||
? maxDateTime
|
||||
: currentDateTime
|
||||
),
|
||||
|
||||
[`${CalcType.DATETIME}_${Operator.MIN}`]: (value: string[]) =>
|
||||
value.reduce((minDateTime, currentDateTime) =>
|
||||
new Date(minDateTime) < new Date(currentDateTime)
|
||||
? minDateTime
|
||||
: currentDateTime
|
||||
),
|
||||
[`${CalcType.STRING}_${Operator.FIRST}`]:(value: string[])=>{
|
||||
return value[0];
|
||||
}
|
||||
};
|
||||
@@ -6,6 +6,8 @@ import '../actions/field-shown';
|
||||
import '../actions/error-show';
|
||||
import '../actions/button-add';
|
||||
import '../actions/condition-action';
|
||||
import '../actions/data-processing';
|
||||
import '../actions/data-mapping';
|
||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||
|
||||
export class ActionProcess{
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
// vite.config.js
|
||||
import { defineConfig } from 'vite'
|
||||
const sourcemap = process.env.SOURCE_MAP==='true';
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import checker from "vite-plugin-checker";
|
||||
import { libInjectCss } from 'vite-plugin-lib-inject-css';
|
||||
|
||||
export default defineConfig({
|
||||
export default ({ mode }) => {
|
||||
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
|
||||
|
||||
return defineConfig({
|
||||
plugins: [
|
||||
checker({
|
||||
typescript: true,
|
||||
}),
|
||||
libInjectCss(),
|
||||
],
|
||||
build: {
|
||||
cssCodeSplit: false,
|
||||
rollupOptions: {
|
||||
input: 'src/index.ts', // entry file
|
||||
input: "src/index.ts", // entry file
|
||||
output: {
|
||||
entryFileNames:'alc_runtime.js',
|
||||
entryFileNames: "alc_runtime.js",
|
||||
// assetFileNames:'alc_kintone_style.css'
|
||||
}
|
||||
},
|
||||
sourcemap:sourcemap
|
||||
}
|
||||
})
|
||||
},
|
||||
sourcemap: process.env.VITE_SOURCE_MAP,
|
||||
},
|
||||
server: {
|
||||
port: process.env.VITE_PORT,
|
||||
// open: "/dist/alc_runtime.js",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user