From b3eab7e3e7200362bc37f71c4bd42a9efbb66beb Mon Sep 17 00:00:00 2001 From: dennisb Date: Tue, 20 Sep 2022 12:20:09 +0200 Subject: [PATCH] feat: set status hidden by default value, if not set in local storage --- blocks/fieldsblock.php | 9 +++++++++ index.js | 2 +- index.php | 9 ++++++++- src/FieldsBlock.vue | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 blocks/fieldsblock.php diff --git a/blocks/fieldsblock.php b/blocks/fieldsblock.php new file mode 100644 index 0000000..ac62bc0 --- /dev/null +++ b/blocks/fieldsblock.php @@ -0,0 +1,9 @@ + [ + 'hiddenByDefault' => function () { + return true; + } + ] +]; diff --git a/index.js b/index.js index 436c002..2d192f2 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function () {var a={data:function(){return{isHidden:JSON.parse(sessionStorage.getItem("kirby.fieldsBlock.".concat(this.$attrs.endpoints.field,".").concat(this.$attrs.id)))}},methods:{toggle:function(){this.isHidden=!this.isHidden,sessionStorage.setItem("kirby.fieldsBlock.".concat(this.$attrs.endpoints.field,".").concat(this.$attrs.id),this.isHidden)},preventSelect:function(t){t.detail>1&&(t.target.closest(".k-input")||t.preventDefault())}}};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("div",{staticClass:"k-block-fields-preview",on:{"mousedown":_vm.preventSelect}},[_vm.fieldset.label===null||_vm.fieldset.label?_c("k-block-title",{class:{"with-border":!_vm.isHidden},attrs:{"content":_vm.content,"fieldset":_vm.fieldset},on:{"dblclick":_vm.toggle}}):_vm._e(),_vm._v(" "),!_vm.isHidden?_c("k-form",{ref:"form",attrs:{"autofocus":true,"fields":_vm.fieldset.tabs.content.fields,"value":_vm.$helper.clone(_vm.content)},on:{"input":function($event){return _vm.$emit("update",$event)}}}):_vm._e()],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("jg/fields-block",{blocks:{fields:a}});})(); \ No newline at end of file +(function () {var a={props:{hiddenByDefault:Boolean},data:function(){return{isHidden:null}},created:function(){this.hiddenByDefault=!0;var t=JSON.parse(sessionStorage.getItem("kirby.fieldsBlock.".concat(this.$attrs.endpoints.field,".").concat(this.$attrs.id)));this.isHidden=null!==t?t:this.hiddenByDefault},methods:{toggle:function(){this.isHidden=!this.isHidden,sessionStorage.setItem("kirby.fieldsBlock.".concat(this.$attrs.endpoints.field,".").concat(this.$attrs.id),this.isHidden)},preventSelect:function(t){t.detail>1&&(t.target.closest(".k-input")||t.preventDefault())}}};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("div",{staticClass:"k-block-fields-preview",on:{"mousedown":_vm.preventSelect}},[_vm.fieldset.label===null||_vm.fieldset.label?_c("k-block-title",{class:{"with-border":!_vm.isHidden},attrs:{"content":_vm.content,"fieldset":_vm.fieldset},on:{"dblclick":_vm.toggle}}):_vm._e(),_vm._v(" "),!_vm.isHidden?_c("k-form",{ref:"form",attrs:{"autofocus":true,"fields":_vm.fieldset.tabs.content.fields,"value":_vm.$helper.clone(_vm.content)},on:{"input":function($event){return _vm.$emit("update",$event)}}}):_vm._e()],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("jg/fields-block",{blocks:{fields:a}});})(); \ No newline at end of file diff --git a/index.php b/index.php index fd8f37b..9dc9e28 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,10 @@ [ + 'hiddenByDefault' => true, + ], + 'blocks' => [ + 'fields' => require __DIR__ . '/blocks/fieldsblock.php', + ] +]); diff --git a/src/FieldsBlock.vue b/src/FieldsBlock.vue index e67c457..c09ea60 100644 --- a/src/FieldsBlock.vue +++ b/src/FieldsBlock.vue @@ -20,11 +20,22 @@