return
}
+ // Check for duplicate tag names
+ tags, ok := content["tags"].([]any)
+ if ok {
+ for _, tagInterface := range tags {
+ tag, ok := tagInterface.(map[string]any)
+ if !ok {
+ continue
+ }
+
+ if encName, ok := tag["name"].(string); ok {
+ decryptedName, err := utils.DecryptText(encName, encKey)
+ if err != nil {
+ http.Error(w, fmt.Sprintf("Error decrypting tag name: %v", err), http.StatusInternalServerError)
+ return
+ }
+ if decryptedName == req.Name {
+ http.Error(w, "Tag name already exists", http.StatusBadRequest)
+ return
+ }
+ }
+ }
+ }
+
// Encrypt tag data
encIcon, err := utils.EncryptText(req.Icon, encKey)
if err != nil {
}
// Add tag to tags array
- tags, ok := content["tags"].([]any)
+ tags, ok = content["tags"].([]any)
if !ok {
tags = []any{}
}
});
</script>
-<span class="badge rounded-pill" style="background-color: {tag.color}; color: {fontColor}">
+<span class="shadow badge rounded-pill" style="background-color: {tag.color}; color: {fontColor}">
<div class="d-flex flex-row">
<div>{tag.icon} #{tag.name}</div>
{#if isEditable}
toast.show();
}
})
+ .catch((error) => {
+ console.error(error.response);
+ if (error.response.status == 400) {
+ // name already exists
+ // toast
+ const toast = new bootstrap.Toast(
+ document.getElementById('toastErrorSavingNewTagExists')
+ );
+ toast.show();
+ } else {
+ // toast
+ const toast = new bootstrap.Toast(document.getElementById('toastErrorSavingNewTag'));
+ toast.show();
+ }
+ })
.finally(() => {
// close modal
isSavingNewTag = false;
</div>
</div>
+ <div
+ id="toastErrorSavingNewTagExists"
+ class="toast align-items-center text-bg-danger"
+ role="alert"
+ aria-live="assertive"
+ aria-atomic="true"
+ >
+ <div class="d-flex">
+ <div class="toast-body">
+ {$t('tags.toast.error_saving_exists')}
+ </div>
+ <button
+ type="button"
+ class="btn-close me-2 m-auto"
+ data-bs-dismiss="toast"
+ aria-label="Close"
+ ></button>
+ </div>
+ </div>
+
<div
id="toastErrorSavingLog"
class="toast align-items-center text-bg-danger"