Skip to content

Commit

Permalink
start implementing list of text
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jul 10, 2024
1 parent 0ba20a0 commit a17b0ce
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 173 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/Service/AssistantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\TaskProcessing\TaskTypes\ContextWrite;
use OCP\TaskProcessing\TaskTypes\TextToImage;
use OCP\TaskProcessing\TaskTypes\TextToText;
use OCP\TaskProcessing\TaskTypes\TextToTextChat;
use OCP\TaskProcessing\TaskTypes\TextToTextHeadline;
use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
use OCP\TaskProcessing\TaskTypes\TextToTextTopics;
Expand Down Expand Up @@ -162,6 +163,10 @@ public function getAvailableTaskTypes(): array {
}
/** @var string $typeId */
foreach ($availableTaskTypes as $typeId => $taskTypeArray) {
// skip chat task type (not directly useful to the end user)
// if ($typeId === TextToTextChat::ID) {
// continue;
// }
$taskTypeArray['id'] = $typeId;
$taskTypeArray['priority'] = self::TASK_TYPE_PRIORITIES[$typeId] ?? 1000;

Expand Down
4 changes: 1 addition & 3 deletions src/components/fields/AudioDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export default {
},
},
emits: [
'delete',
],
emits: [],
data() {
return {
Expand Down
4 changes: 1 addition & 3 deletions src/components/fields/FileDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export default {
},
},
emits: [
'delete',
],
emits: [],
data() {
return {
Expand Down
4 changes: 1 addition & 3 deletions src/components/fields/ImageDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export default {
},
},
emits: [
'delete',
],
emits: [],
data() {
return {
Expand Down
121 changes: 121 additions & 0 deletions src/components/fields/ListOfTextsField.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<template>
<div class="text-list-field">
<h3 :title="field.description">
{{ field.name }}
</h3>
<div v-for="(v, i) in arrayValue"
:key="fieldKey + '-' + i"
class="text-list--item">
<TextInput
class="text-input"
:value="v ?? ''"
:is-output="isOutput"
:label="field.name"
:placeholder="field.description"
:title="field.description"
@update:value="onItemValueChanged(i, $event)" />
<NcButton v-if="!isOutput"
class="delete-button"
type="secondary"
@click="onDeleteItem(i)">
<template #icon>
<DeleteIcon />
</template>
</NcButton>
</div>
<NcButton v-if="!isOutput"
class="more-button"
type="secondary"
@click="onAddItem">
<template #icon>
<PlusIcon />
</template>
</NcButton>
</div>
</template>
<script>
import PlusIcon from 'vue-material-design-icons/Plus.vue'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import TextInput from './TextInput.vue'
export default {
name: 'ListOfTextsField',
components: {
TextInput,
NcButton,
PlusIcon,
DeleteIcon,
},
props: {
fieldKey: {
type: String,
required: true,
},
value: {
type: [Array, null],
default: null,
},
field: {
type: Object,
required: true,
},
isOutput: {
type: Boolean,
default: false,
},
},
emits: [
'update:value',
],
data() {
return {
}
},
computed: {
arrayValue() {
return this.value ?? []
},
},
watch: {
},
mounted() {
},
methods: {
onItemValueChanged(i, itemValue) {
const newValue = this.arrayValue.slice()
newValue[i] = itemValue
this.$emit('update:value', newValue)
console.debug('onvaluechanggeeee', i, itemValue, newValue)
},
onDeleteItem(i) {
if (this.arrayValue.length === 1 && i === 0) {
this.$emit('update:value', [])
return
}
const newValue = this.arrayValue.slice().splice(i - 1, 1)
this.$emit('update:value', newValue)
console.debug('delete', i)
},
onAddItem() {
const newValue = [...this.arrayValue, '']
this.$emit('update:value', newValue)
},
},
}
</script>
<style lang="scss">
// nothing yet
</style>
3 changes: 3 additions & 0 deletions src/components/fields/TaskTypeField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TextField from './TextField.vue'
import NumberField from './NumberField.vue'
import MediaField from './MediaField.vue'
import ListOfMediaField from './ListOfMediaField.vue'
import ListOfTextsField from './ListOfTextsField.vue'
import { SHAPE_TYPE_NAMES } from '../../constants.js'
Expand Down Expand Up @@ -76,6 +77,8 @@ export default {
return MediaField
} else if (this.isListOfMedia) {
return ListOfMediaField
} else if (this.field.type === SHAPE_TYPE_NAMES.ListOfTexts) {
return ListOfTextsField
}
return TextField
},
Expand Down
Loading

0 comments on commit a17b0ce

Please sign in to comment.