summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/systemtags/src/components/SystemTags.vue39
1 files changed, 17 insertions, 22 deletions
diff --git a/apps/systemtags/src/components/SystemTags.vue b/apps/systemtags/src/components/SystemTags.vue
index 9315d0eb6c0..9bd9619d773 100644
--- a/apps/systemtags/src/components/SystemTags.vue
+++ b/apps/systemtags/src/components/SystemTags.vue
@@ -59,22 +59,16 @@ import NcSelectTags from '@nextcloud/vue/dist/Components/NcSelectTags.js'
import { translate as t } from '@nextcloud/l10n'
import { showError } from '@nextcloud/dialogs'
+import { defaultBaseTag } from '../utils.js'
+import { fetchLastUsedTagIds, fetchTags } from '../services/api.js'
import {
- createTag,
- deleteTag,
- fetchLastUsedTagIds,
- fetchSelectedTags,
- fetchTags,
- selectTag,
-} from '../services/api.js'
-
-import type { BaseTag, Tag, TagWithId } from '../types.js'
-
-const defaultBaseTag: BaseTag = {
- userVisible: true,
- userAssignable: true,
- canAssign: true,
-}
+ createTagForFile,
+ deleteTagForFile,
+ fetchTagsForFile,
+ setTagForFile,
+} from '../services/files.js'
+
+import type { Tag, TagWithId } from '../types.js'
export default Vue.extend({
name: 'SystemTags',
@@ -133,7 +127,7 @@ export default Vue.extend({
async handler() {
this.loadingTags = true
try {
- this.selectedTags = await fetchSelectedTags(this.fileId)
+ this.selectedTags = await fetchTagsForFile(this.fileId)
this.$emit('has-tags', this.selectedTags.length > 0)
} catch (error) {
showError(t('systemtags', 'Failed to load selected tags'))
@@ -175,14 +169,15 @@ export default Vue.extend({
},
async handleSelect(tags: Tag[]) {
- const selectedTag = tags[tags.length - 1]
- if (!selectedTag.id) {
+ const lastTag = tags[tags.length - 1]
+ if (!lastTag.id) {
// Ignore created tags handled by `handleCreate()`
return
}
+ const selectedTag = lastTag as TagWithId
this.loading = true
try {
- await selectTag(this.fileId, selectedTag)
+ await setTagForFile(selectedTag, this.fileId)
const sortToFront = (a: TagWithId, b: TagWithId) => {
if (a.id === selectedTag.id) {
return -1
@@ -201,7 +196,7 @@ export default Vue.extend({
async handleCreate(tag: Tag) {
this.loading = true
try {
- const id = await createTag(this.fileId, tag)
+ const id = await createTagForFile(tag, this.fileId)
const createdTag = { ...tag, id }
this.sortedTags.unshift(createdTag)
this.selectedTags.push(createdTag)
@@ -211,10 +206,10 @@ export default Vue.extend({
this.loading = false
},
- async handleDeselect(tag: Tag) {
+ async handleDeselect(tag: TagWithId) {
this.loading = true
try {
- await deleteTag(this.fileId, tag)
+ await deleteTagForFile(tag, this.fileId)
} catch (error) {
showError(t('systemtags', 'Failed to delete tag'))
}