Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/components/TagItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@
</template>

<script>
import { showInfo } from '@nextcloud/dialogs'
import { showError, showInfo } from '@nextcloud/dialogs'
import { NcActionInput as ActionInput, NcActions as Actions, NcActionText as ActionText, NcLoadingIcon as IconLoading, NcActionButton, NcColorPicker } from '@nextcloud/vue'
import { mapStores } from 'pinia'
import IconEdit from 'vue-material-design-icons/PencilOutline.vue'
import DeleteIcon from 'vue-material-design-icons/TrashCanOutline.vue'
import logger from '../logger.js'
import useMainStore from '../store/mainStore.js'
import { translateTagDisplayName } from '../util/tag.js'
import { hiddenTags } from './tags.js'

export default {
name: 'TagItem',
Expand Down Expand Up @@ -151,19 +152,29 @@ export default {
},

async renameTag(tag, event) {
this.renameTagInput = false
this.showSaving = false
const displayName = event.target.querySelector('input[type=text]').value
if (displayName.toLowerCase() in hiddenTags) {
showError(this.t('mail', 'Tag name is a hidden system tag'))
return
}
if (this.mainStore.getTags.some((tag) => tag.displayName === displayName)) {
showError(this.t('mail', 'Tag already exists'))
return
}
if (displayName.trim() === '') {
showError(this.t('mail', 'Tag name cannot be empty'))
return
}

this.showSaving = false

try {
await this.mainStore.updateTag({
tag,
displayName,
color: this.tag.color,
})
this.renameTagLabel = true
this.renameTagInput = false
this.showSaving = false
this.closeEditTag()
} catch (error) {
showInfo(t('mail', 'An error occurred, unable to rename the tag.'))
logger.error('could not rename tag', { error })
Expand Down
45 changes: 0 additions & 45 deletions src/components/TagModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export default {
tagLabel: true,
tagInput: false,
showSaving: false,
renameTagLabel: true,
renameTagInput: false,
deleteTagModal: false,
tagToDelete: null,
color: randomColor(),
Expand Down Expand Up @@ -188,49 +186,6 @@ export default {
}
},

convertHex(color, opacity) {
if (color.length === 4) {
const r = parseInt(color.substring(1, 2), 16)
const g = parseInt(color.substring(2, 3), 16)
const b = parseInt(color.substring(3, 4), 16)
return `rgba(${r}, ${g}, ${b}, ${opacity})`
} else {
const r = parseInt(color.substring(1, 3), 16)
const g = parseInt(color.substring(3, 5), 16)
const b = parseInt(color.substring(5, 7), 16)
return `rgba(${r}, ${g}, ${b}, ${opacity})`
}
},

openEditTag() {
this.renameTagLabel = false
this.renameTagInput = true
this.showSaving = false
},

async renameTag(tag, event) {
this.renameTagInput = false
this.showSaving = false
const displayName = event.target.querySelector('input[type=text]').value

try {
await this.mainStore.updateTag({
tag,
displayName,
color: tag.color,
})
this.renameTagLabel = true
this.renameTagInput = false
this.showSaving = false
} catch (error) {
showInfo(t('mail', 'An error occurred, unable to rename the tag.'))
logger.error('could not rename tag', { error })
this.renameTagLabel = false
this.renameTagInput = false
this.showSaving = true
}
},

deleteTag(tag) {
this.tagToDelete = tag
this.deleteTagModal = true
Expand Down
Loading