From 807936d8ab3cf30565dc2e8b5e6079a721649348 Mon Sep 17 00:00:00 2001 From: Steffen Giers Date: Wed, 22 Jan 2020 20:37:15 +0100 Subject: [PATCH] feat: show empty state when no pages where found Closes #6 --- index.js | 2 +- index.php | 2 ++ src/components/EnhancedToolbarLinkDialog.vue | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5be38a9..343da67 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function () {var a={props:{pages:Array,text:String},data:function(){return{tabs:[{name:"external",label:this.$t("gearsdigital.enhanced-toolbar-link-dialog.external")},{name:"internal",label:this.$t("gearsdigital.enhanced-toolbar-link-dialog.internal")}],search:null,currentPage:{},currentTab:{},value:{url:null,text:null},pagination:{page:1,total:0},externalFields:{url:{label:this.$t("link"),type:"text",placeholder:this.$t("url.placeholder"),icon:"url"},text:{label:this.$t("link.text"),type:"text"}}}},watch:{search:b(function(){this.pagination.page=0,this.fetch()},200)},computed:{kirbytext:function(){return this.$store.state.system.info.kirbytext}},methods:{open:function(t,e){this.value.text=e,this.currentTab=this.tabs[0],this.$refs.dialog.open()},resetForm:function(){this.value={url:null,text:null},this.value.text=null,this.search=null,this.pagination.page=1},selectTab:function(t){this.currentTab=t},selectPage:function(t){this.value={url:t.url,text:this.value.text||t.title},this.isCurrentPage(t)?(this.currentPage={},this.value={url:null,text:null}):this.currentPage=t},isCurrentPage:function(t){return this.currentPage===t},paginate:function(t){this.pagination.page=t.page,this.fetch()},createKirbytext:function(){return this.value.text.length>0?"(link: ".concat(this.value.url," text: ").concat(this.value.text,")"):"(link: ".concat(this.value.url,")")},createMarkdown:function(){return this.value.text.length>0?"[".concat(this.value.text,"](").concat(this.value.url,")"):"<".concat(this.value.url,">")},fetch:function(){var t=this,e={page:this.pagination.page,search:this.search};this.$api.get("enhanced-toolbar-link-dialog/pages",e).then(function(e){t.pages=e.data,t.pagination=e.pagination})},submit:function(){this.$emit("submit",this.kirbytext?this.createKirbytext():this.createMarkdown()),this.$refs.dialog.close()}}};function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,a=null;return function(){var n=this,i=arguments;clearTimeout(a),a=setTimeout(function(){t.apply(n,i)},e)}}if(typeof a==="function"){a=a.options}Object.assign(a,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-dialog",{ref:"dialog",staticClass:"k-pages-dialog",attrs:{"size":"medium","button":_vm.$t("insert")},on:{"submit":_vm.submit,"open":_vm.fetch,"close":_vm.resetForm}},[_vm.tabs&&_vm.tabs.length>1?_c("div",{staticClass:"k-header-tabs"},[_c("nav",_vm._l(_vm.tabs,function(tab){return _c("k-button",{staticClass:"k-tab-button",attrs:{"link":"#"+tab.name,"current":_vm.currentTab&&_vm.currentTab.name===tab.name},on:{"click":function($event){return _vm.selectTab(tab)}}},[_vm._v(" "+_vm._s(tab.label)+" ")])}),1)]):_vm._e(),_vm._v(" "),_vm.currentTab.name==="external"?_c("div",{staticClass:"k-tab"},[_c("k-form",{ref:"form",attrs:{"fields":_vm.externalFields},on:{"submit":_vm.submit},model:{value:_vm.value,callback:function($$v){_vm.value=$$v},expression:"value"}})],1):_vm._e(),_vm._v(" "),_vm.currentTab.name==="internal"?_c("div",{staticClass:"k-tab"},[_c("k-input",{staticClass:"k-dialog-search",attrs:{"autofocus":"","placeholder":_vm.$t("search")+" \u2026","type":"text","icon":"search"},model:{value:_vm.search,callback:function($$v){_vm.search=$$v},expression:"search"}}),_vm._v(" "),_c("k-list",_vm._l(_vm.pages,function(page){return _c("k-list-item",{key:page.id,attrs:{"text":page.title},on:{"click":function($event){return _vm.selectPage(page)}}},[_c("template",{slot:"options"},[_vm.isCurrentPage(page)?_c("k-button",{attrs:{"slot":"options","autofocus":"","icon":"check","theme":"positive","tooltip":_vm.$t("remove")},slot:"options"}):_c("k-button",{attrs:{"slot":"options","autofocus":"","icon":"circle-outline","tooltip":_vm.$t("select")},slot:"options"})],1)],2)}),1),_vm._v(" "),_c("k-pagination",_vm._b({staticClass:"k-dialog-pagination",attrs:{"details":true,"dropdown":false,"align":"center"},on:{"paginate":_vm.paginate}},"k-pagination",_vm.pagination,false))],1):_vm._e()])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("gearsdigital/enhanced-toolbar-link-dialog",{components:{"k-toolbar-link-dialog":{extends:a}}});})(); \ No newline at end of file +(function () {var a={props:{pages:Array,text:String},data:function(){return{tabs:[{name:"external",label:this.$t("gearsdigital.enhanced-toolbar-link-dialog.external")},{name:"internal",label:this.$t("gearsdigital.enhanced-toolbar-link-dialog.internal")}],search:null,currentPage:{},currentTab:{},value:{url:null,text:null},pagination:{page:1,total:0},externalFields:{url:{label:this.$t("link"),type:"text",placeholder:this.$t("url.placeholder"),icon:"url"},text:{label:this.$t("link.text"),type:"text"}}}},watch:{search:b(function(){this.pagination.page=0,this.fetch()},200)},computed:{kirbytext:function(){return this.$store.state.system.info.kirbytext}},methods:{open:function(t,e){this.value.text=e,this.currentTab=this.tabs[0],this.$refs.dialog.open()},resetForm:function(){this.value={url:null,text:null},this.value.text=null,this.search=null,this.pagination.page=1},selectTab:function(t){this.currentTab=t},selectPage:function(t){this.value={url:t.url,text:this.value.text||t.title},this.isCurrentPage(t)?(this.currentPage={},this.value={url:null,text:null}):this.currentPage=t},isCurrentPage:function(t){return this.currentPage===t},paginate:function(t){this.pagination.page=t.page,this.fetch()},createKirbytext:function(){return this.value.text.length>0?"(link: ".concat(this.value.url," text: ").concat(this.value.text,")"):"(link: ".concat(this.value.url,")")},createMarkdown:function(){return this.value.text.length>0?"[".concat(this.value.text,"](").concat(this.value.url,")"):"<".concat(this.value.url,">")},fetch:function(){var t=this,e={page:this.pagination.page,search:this.search};this.$api.get("enhanced-toolbar-link-dialog/pages",e).then(function(e){t.pages=e.data,t.pagination=e.pagination})},submit:function(){this.$emit("submit",this.kirbytext?this.createKirbytext():this.createMarkdown()),this.$refs.dialog.close()}}};function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,a=null;return function(){var n=this,i=arguments;clearTimeout(a),a=setTimeout(function(){t.apply(n,i)},e)}}if(typeof a==="function"){a=a.options}Object.assign(a,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-dialog",{ref:"dialog",staticClass:"k-pages-dialog",attrs:{"size":"medium","button":_vm.$t("insert")},on:{"submit":_vm.submit,"open":_vm.fetch,"close":_vm.resetForm}},[_vm.tabs&&_vm.tabs.length>1?_c("div",{staticClass:"k-header-tabs"},[_c("nav",_vm._l(_vm.tabs,function(tab){return _c("k-button",{staticClass:"k-tab-button",attrs:{"link":"#"+tab.name,"current":_vm.currentTab&&_vm.currentTab.name===tab.name},on:{"click":function($event){return _vm.selectTab(tab)}}},[_vm._v(" "+_vm._s(tab.label)+" ")])}),1)]):_vm._e(),_vm._v(" "),_vm.currentTab.name==="external"?_c("div",{staticClass:"k-tab"},[_c("k-form",{ref:"form",attrs:{"fields":_vm.externalFields},on:{"submit":_vm.submit},model:{value:_vm.value,callback:function($$v){_vm.value=$$v},expression:"value"}})],1):_vm._e(),_vm._v(" "),_vm.currentTab.name==="internal"?_c("div",{staticClass:"k-tab"},[_c("k-input",{staticClass:"k-dialog-search",attrs:{"autofocus":"","placeholder":_vm.$t("search")+" \u2026","type":"text","icon":"search"},model:{value:_vm.search,callback:function($$v){_vm.search=$$v},expression:"search"}}),_vm._v(" "),_vm.pages.length>0?_c("k-list",_vm._l(_vm.pages,function(page){return _c("k-list-item",{key:page.id,attrs:{"text":page.title},on:{"click":function($event){return _vm.selectPage(page)}}},[_c("template",{slot:"options"},[_vm.isCurrentPage(page)?_c("k-button",{attrs:{"slot":"options","autofocus":"","icon":"check","theme":"positive","tooltip":_vm.$t("remove")},slot:"options"}):_c("k-button",{attrs:{"slot":"options","autofocus":"","icon":"circle-outline","tooltip":_vm.$t("select")},slot:"options"})],1)],2)}),1):_c("k-text",[_vm._v(" "+_vm._s(_vm.$t("gearsdigital.enhanced-toolbar-link-dialog.empty"))+" ")]),_vm._v(" "),_c("k-pagination",_vm._b({staticClass:"k-dialog-pagination",attrs:{"details":true,"dropdown":false,"align":"center"},on:{"paginate":_vm.paginate}},"k-pagination",_vm.pagination,false))],1):_vm._e()])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("gearsdigital/enhanced-toolbar-link-dialog",{components:{"k-toolbar-link-dialog":{extends:a}}});})(); \ No newline at end of file diff --git a/index.php b/index.php index 485d7c0..358b6f2 100755 --- a/index.php +++ b/index.php @@ -25,10 +25,12 @@ 'en' => [ 'gearsdigital.enhanced-toolbar-link-dialog.internal' => 'Internal Link', 'gearsdigital.enhanced-toolbar-link-dialog.external' => 'External Link', + 'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'No pages found', ], 'de' => [ 'gearsdigital.enhanced-toolbar-link-dialog.internal' => 'Interner Link', 'gearsdigital.enhanced-toolbar-link-dialog.external' => 'Externer Link', + 'gearsdigital.enhanced-toolbar-link-dialog.empty' => 'Keine Seiten gefunden.', ], ], ]); diff --git a/src/components/EnhancedToolbarLinkDialog.vue b/src/components/EnhancedToolbarLinkDialog.vue index a400da0..998e45f 100755 --- a/src/components/EnhancedToolbarLinkDialog.vue +++ b/src/components/EnhancedToolbarLinkDialog.vue @@ -42,7 +42,7 @@ icon="search" /> - + + + {{$t('gearsdigital.enhanced-toolbar-link-dialog.empty')}} +