Add title for prompt

Added title for prompt

The title will simplify the search in the list of prompts
This commit is contained in:
Erritis
2023-03-28 18:41:01 +03:00
committed by Sergey Shekhovtsov
parent 2374c81edb
commit cf0053a060
4 changed files with 66 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
const menu = ref(false)
const prompts = ref([])
const editingPrompt = ref(null)
const newTitlePrompt = ref(null)
const newPrompt = ref('')
const submittingNewPrompt = ref(false)
const promptInputErrorMessage = ref('')
@@ -24,11 +25,13 @@ const addPrompt = async () => {
const { data, error } = await useAuthFetch('/api/chat/prompts/', {
method: 'POST',
body: JSON.stringify({
title: newTitlePrompt.value,
prompt: newPrompt.value
})
})
if (!error.value) {
prompts.value.push(data.value)
newTitlePrompt.value = null
newPrompt.value = ''
}
submittingNewPrompt.value = false
@@ -43,6 +46,7 @@ const updatePrompt = async (index) => {
const { data, error } = await useAuthFetch(`/api/chat/prompts/${editingPrompt.value.id}/`, {
method: 'PUT',
body: JSON.stringify({
title: editingPrompt.value.title,
prompt: editingPrompt.value.prompt
})
})
@@ -127,18 +131,30 @@ onMounted( () => {
>
<v-list-item
active-color="primary"
rounded="xl"
v-if="editingPrompt && editingPrompt.id === prompt.id"
>
<div class="d-flex flex-row" :style="{ marginTop: '5px' }">
<div class="flex-grow-1">
<v-text-field
v-model="editingPrompt.title"
:loading="editingPrompt.updating"
:label="$t('titlePrompt')"
variant="underlined"
density="compact"
hide-details
>
</v-text-field>
<v-textarea
rows="2"
v-model="editingPrompt.prompt"
:loading="editingPrompt.updating"
variant="underlined"
hide-details
density="compact"
hide-details
>
<template v-slot:append>
</v-textarea>
</div>
<div>
<div class="d-flex flex-column">
<v-btn
icon="done"
@@ -154,8 +170,8 @@ onMounted( () => {
>
</v-btn>
</div>
</template>
</v-textarea>
</div>
</div>
</v-list-item>
<v-list-item
v-if="!editingPrompt || editingPrompt.id !== prompt.id"
@@ -163,7 +179,7 @@ onMounted( () => {
active-color="primary"
@click="selectPrompt(prompt)"
>
<v-list-item-title>{{ prompt.prompt }}</v-list-item-title>
<v-list-item-title>{{ prompt.title ? prompt.title : prompt.prompt }}</v-list-item-title>
<template v-slot:append>
<v-btn
icon="edit"
@@ -184,6 +200,25 @@ onMounted( () => {
</v-list-item>
</template>
<v-list-item
active-color="primary"
>
<div
class="pt-3"
>
<v-text-field
rows="1"
v-model="newTitlePrompt"
:label="$t('titlePrompt')"
variant="outlined"
density="compact"
hide-details
clearable
>
</v-text-field>
</div>
</v-list-item>
<v-list-item
active-color="primary"
>

View File

@@ -12,6 +12,7 @@
"writeAMessage": "Write a message",
"frequentlyPrompts": "Frequently prompts",
"addPrompt": "Add prompt",
"titlePrompt": "Title",
"addNewPrompt": "Add a new prompt",
"pressEnterToSendYourMessageOrShiftEnterToAddANewLine": "Press Enter to send your message or Shift+Enter to add a new line",
"lightMode": "Light Mode",

View File

@@ -12,6 +12,7 @@
"writeAMessage": "Напишите сообщение",
"frequentlyPrompts": "Список подсказок",
"addPrompt": "Добавить подсказку",
"titlePrompt": "Заголовок",
"addNewPrompt": "Добавитьте новую подсказку",
"pressEnterToSendYourMessageOrShiftEnterToAddANewLine": "Нажмите Enter, чтобы отправить сообщение, или Shift+Enter, чтобы добавить новую строку.",
"lightMode": "Светлая",

View File

@@ -12,6 +12,7 @@
"writeAMessage": "输入信息",
"frequentlyPrompts": "Frequently prompts",
"addPrompt": "Add prompt",
"titlePrompt": "Title",
"addNewPrompt": "Add a new prompt",
"pressEnterToSendYourMessageOrShiftEnterToAddANewLine": "按回车键发送您的信息或按Shift+Enter键添加新行",
"lightMode": "明亮模式",