(window.webpackJsonp=window.webpackJsonp||[]).push([[178],{1060:function(t,e,n){"use strict";n.r(e);n(26),n(33),n(27),n(150),n(8),n(147);var o={asyncData:function(t){var e=t.store,n=t.redirect;e.getters["user/getIsAdminOrUp"]||n("/")},data:function(){return{loading:!1,tags:[],editingTag:null,newTagName:""}},watch:{},computed:{},methods:{cancelEditClick:function(){this.newTagName="",this.editingTag=null},removeTagClick:function(t){var e=this,n={message:'Are you sure you want to remove tag "'.concat(t,'" from all items?'),callback:function(n){n&&e.removeTag(t)},type:"yesNo"};this.$store.commit("globals/setConfirmPrompt",n)},saveTagClick:function(){var t=this;if(this.newTagName=this.newTagName.trim(),this.newTagName)if(this.editingTag!==this.newTagName){var e=this.tags.find((function(e){return e!==t.editingTag&&e===t.newTagName})),n=e?null:this.tags.find((function(e){return e!==t.editingTag&&e.toLowerCase()===t.newTagName.toLowerCase()})),o=this.$getString("MessageConfirmRenameTag",[this.editingTag,this.newTagName]);e?o+=" ".concat(this.$strings.MessageConfirmRenameTagMergeNote):n&&(o+=" ".concat(this.$getString("MessageConfirmRenameTagWarning",[n])));var r={message:o,callback:function(e){e&&t.renameTag()},type:"yesNo"};this.$store.commit("globals/setConfirmPrompt",r)}else this.cancelEditClick()},renameTag:function(){var t=this;this.loading=!0;var e=this.newTagName,n=this.editingTag,o={tag:n,newTag:e};this.$axios.$post("/api/tags/rename",o).then((function(o){t.$toast.success(t.$getString("MessageItemsUpdated",[o.numItemsUpdated])),o.tagMerged&&(t.tags=t.tags.filter((function(t){return t!==e}))),t.tags=t.tags.map((function(t){return t===n?e:t})),t.cancelEditClick()})).catch((function(e){console.error("Failed to rename tag",e),t.$toast.error(t.$strings.ToastRenameFailed)})).finally((function(){t.loading=!1}))},removeTag:function(t){var e=this;this.loading=!0,this.$axios.$delete("/api/tags/".concat(this.$encode(t))).then((function(n){e.$toast.success(e.$getString("MessageItemsUpdated",[n.numItemsUpdated])),e.tags=e.tags.filter((function(e){return e!==t}))})).catch((function(t){console.error("Failed to remove tag",t),e.$toast.error(e.$strings.ToastRemoveFailed)})).finally((function(){e.loading=!1}))},editTagClick:function(t){this.newTagName=t,this.editingTag=t},init:function(){var t=this;this.loading=!0,this.$axios.$get("/api/tags").then((function(data){t.tags=(data.tags||[]).sort((function(a,b){return a.localeCompare(b,void 0,{sensitivity:"base"})}))})).catch((function(t){console.error("Failed to load tags",t)})).finally((function(){t.loading=!1}))}},mounted:function(){this.init()},beforeDestroy:function(){}},r=n(4),component=Object(r.a)(o,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"bg-bg rounded-md shadow-lg border border-white/5 p-4 mb-8 relative",staticStyle:{"min-height":"200px"}},[e("div",{staticClass:"flex items-center mb-4"},[e("nuxt-link",{staticClass:"w-8 h-8 flex items-center justify-center rounded-full cursor-pointer hover:bg-white/10 text-center",attrs:{to:"/config/item-metadata-utils"}},[e("span",{staticClass:"material-symbols text-2xl"},[t._v("arrow_back")])]),t._v(" "),e("h1",{staticClass:"text-xl mx-2"},[t._v(t._s(t.$strings.HeaderManageTags))])],1),t._v(" "),t.tags.length||t.loading?t._e():e("p",{staticClass:"text-center py-8 text-lg"},[t._v(t._s(t.$strings.MessageNoTags))]),t._v(" "),e("div",{staticClass:"border border-white/10"},[t._l(t.tags,(function(n,o){return[e("div",{key:n,staticClass:"w-full p-2 flex items-center text-gray-400 hover:text-white",class:{"bg-primary/20":o%2==0}},[t.editingTag!==n?e("p",{staticClass:"text-sm md:text-base text-gray-100"},[t._v(t._s(n))]):e("ui-text-input",{model:{value:t.newTagName,callback:function(e){t.newTagName=e},expression:"newTagName"}}),t._v(" "),e("div",{staticClass:"grow"}),t._v(" "),t.editingTag!==n?[e("ui-icon-btn",{staticClass:"mx-1",attrs:{icon:"edit",borderless:"",size:8,"icon-font-size":"1.1rem"},on:{click:function(e){return t.editTagClick(n)}}}),t._v(" "),e("ui-icon-btn",{attrs:{icon:"delete",borderless:"",size:8,"icon-font-size":"1.1rem"},on:{click:function(e){return t.removeTagClick(n)}}})]:[e("ui-btn",{staticClass:"mx-2",attrs:{color:"bg-success",small:""},on:{click:function(e){return e.stopPropagation(),t.saveTagClick.apply(null,arguments)}}},[t._v(t._s(t.$strings.ButtonSave))]),t._v(" "),e("ui-btn",{attrs:{small:""},on:{click:function(e){return e.stopPropagation(),t.cancelEditClick.apply(null,arguments)}}},[t._v(t._s(t.$strings.ButtonCancel))])]],2)]}))],2),t._v(" "),t.loading?e("div",{staticClass:"absolute top-0 left-0 w-full h-full bg-black/25 rounded-md"},[e("div",{staticClass:"sticky top-0 left-0 w-full h-full flex items-center justify-center",staticStyle:{"max-height":"80vh"}},[e("ui-loading-indicator")],1)]):t._e()])}),[],!1,null,null,null);e.default=component.exports;installComponents(component,{UiTextInput:n(68).default,UiIconBtn:n(148).default,UiBtn:n(42).default,UiLoadingIndicator:n(348).default})}}]);