Skip to content
Draft
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
9 changes: 9 additions & 0 deletions blocks/fieldsblock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'props' => [
'hiddenByDefault' => function () {
return true;
}
]
];
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<?php

Kirby::plugin('jg/fields-block', []);
Kirby::plugin('jg/fields-block', [
'options' => [
'hiddenByDefault' => true,
],
'blocks' => [
'fields' => require __DIR__ . '/blocks/fieldsblock.php',
]
]);
15 changes: 13 additions & 2 deletions src/FieldsBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@

<script>
export default {
props: {
hiddenByDefault: Boolean
},
data () {
return {
isHidden: JSON.parse(sessionStorage.getItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`))
isHidden: null
}
},
created() {
//this value should come from (global) config
this.hiddenByDefault = true;

// Get Value of Hidden from LS and check if Value is set in LS, otherwise set to hiddenByDefault
const hiddenBySession = JSON.parse(sessionStorage.getItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`));
this.isHidden = (hiddenBySession !== null) ? hiddenBySession : this.hiddenByDefault;
},
methods: {
toggle () {
this.isHidden = !this.isHidden
Expand Down Expand Up @@ -80,4 +91,4 @@ export default {
.k-block-fields-preview .k-empty[data-layout="list"] .k-icon {
border-right: 1px solid rgba(0,0,0,.05) !important;
}
</style>
</style>