Skip to content

Commit 5ceb8a7

Browse files
feat: Internal function can modify names
1 parent e7e4570 commit 5ceb8a7

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

ui/src/locales/lang/en-US/views/function-lib.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
form: {
3434
functionName: {
3535
label: 'Name',
36+
name: 'Function Name',
3637
placeholder: 'Please enter the function name',
3738
requiredMessage: 'Please enter the function name'
3839
},

ui/src/locales/lang/zh-CN/views/function-lib.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default {
3131
form: {
3232
functionName: {
3333
label: '名称',
34+
name: '函数名称',
3435
placeholder: '请输入函数名称',
3536
requiredMessage: '请输入函数名称'
3637
},
@@ -63,7 +64,7 @@ export default {
6364
paramInfo2: '使用函数时不显示',
6465
code: '函数内容(Python)',
6566
selectPlaceholder: '请选择参数',
66-
inputPlaceholder: '请输入参数值',
67+
inputPlaceholder: '请输入参数值'
6768
},
6869
debug: {
6970
run: '运行',

ui/src/locales/lang/zh-Hant/views/function-lib.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default {
3131
form: {
3232
functionName: {
3333
label: '名稱',
34+
name: '函數名稱',
3435
placeholder: '請輸入函數名稱',
3536
requiredMessage: '請輸入函數名稱'
3637
},
@@ -63,7 +64,7 @@ export default {
6364
paramInfo2: '使用函數時不顯示',
6465
code: '函数内容(Python)',
6566
selectPlaceholder: '請选择參數',
66-
inputPlaceholder: '請輸入參數值',
67+
inputPlaceholder: '請輸入參數值'
6768
},
6869
debug: {
6970
run: '運行',

ui/src/views/function-lib/component/AddInternalFunctionDialog.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<el-dialog
3-
:title="$t('views.functionLib.functionForm.form.functionName.placeholder')"
3+
:title="$t('views.functionLib.functionForm.form.functionName.name')"
44
v-model="dialogVisible"
55
:close-on-click-modal="false"
66
:close-on-press-escape="false"
@@ -23,7 +23,7 @@
2323
<span class="dialog-footer">
2424
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
2525
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
26-
{{ $t('common.add') }}
26+
{{ isEdit ? $t('common.save') : $t('common.add') }}
2727
</el-button>
2828
</span>
2929
</template>
@@ -39,6 +39,7 @@ const emit = defineEmits(['refresh'])
3939
4040
const fieldFormRef = ref()
4141
const loading = ref<boolean>(false)
42+
const isEdit = ref<boolean>(false)
4243
4344
const form = ref<any>({
4445
name: ''
@@ -64,19 +65,19 @@ watch(dialogVisible, (bool) => {
6465
}
6566
})
6667
67-
const open = (row: any) => {
68+
const open = (row: any, edit: boolean) => {
6869
if (row) {
6970
form.value = cloneDeep(row)
7071
}
71-
72+
isEdit.value = edit || false
7273
dialogVisible.value = true
7374
}
7475
7576
const submit = async (formEl: FormInstance | undefined) => {
7677
if (!formEl) return
7778
await formEl.validate((valid) => {
7879
if (valid) {
79-
emit('refresh', form.value)
80+
emit('refresh', form.value, isEdit.value)
8081
dialogVisible.value = false
8182
}
8283
})

ui/src/views/function-lib/index.vue

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<template>
22
<div class="function-lib-list-container p-24" style="padding-top: 16px">
3-
<el-tabs
4-
v-model="functionType"
5-
@tab-change="
6-
tabChangeHandle
7-
8-
"
9-
>
3+
<el-tabs v-model="functionType" @tab-change="tabChangeHandle">
104
<el-tab-pane :label="$t('views.functionLib.title')" name="PUBLIC"></el-tab-pane>
115
<el-tab-pane :label="$t('views.functionLib.internalTitle')" name="INTERNAL"></el-tab-pane>
126
</el-tabs>
@@ -165,6 +159,14 @@
165159
</el-button>
166160
<template #dropdown>
167161
<el-dropdown-menu>
162+
<el-dropdown-item
163+
v-if="item.template_id"
164+
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
165+
@click.stop="addInternalFunction(item, true)"
166+
>
167+
<el-icon><EditPen /></el-icon>
168+
{{ $t('common.edit') }}
169+
</el-dropdown-item>
168170
<el-dropdown-item
169171
v-if="!item.template_id"
170172
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
@@ -366,17 +368,24 @@ async function openDescDrawer(row: any) {
366368
InternalDescDrawerRef.value.open(content, row)
367369
}
368370
369-
function addInternalFunction(data?: any) {
370-
AddInternalFunctionDialogRef.value.open(data)
371+
function addInternalFunction(data?: any, isEdit?: boolean) {
372+
AddInternalFunctionDialogRef.value.open(data, isEdit)
371373
}
372374
373-
function confirmAddInternalFunction(data?: any) {
374-
functionLibApi
375-
.addInternalFunction(data.id, { name: data.name }, changeStateloading)
376-
.then((res) => {
377-
MsgSuccess(t('common.submitSuccess'))
375+
function confirmAddInternalFunction(data?: any, isEdit?: boolean) {
376+
if (isEdit) {
377+
functionLibApi.putFunctionLib(data?.id as string, data, loading).then((res) => {
378+
MsgSuccess(t('common.saveSuccess'))
378379
searchHandle()
379380
})
381+
} else {
382+
functionLibApi
383+
.addInternalFunction(data.id, { name: data.name }, changeStateloading)
384+
.then((res) => {
385+
MsgSuccess(t('common.addSuccess'))
386+
searchHandle()
387+
})
388+
}
380389
}
381390
382391
function searchHandle() {

0 commit comments

Comments
 (0)