Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from rasteiner/feat/controls
Browse files Browse the repository at this point in the history
Feat/controls
  • Loading branch information
rasteiner authored Apr 30, 2022
2 parents 435a29d + ce9528c commit b8d9525
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
33 changes: 28 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
panel.plugin("rasteiner/k3-pagesdisplay-section", {
components: {
"k-pagesdisplay-section": {
extends: "k-pages-section",
},
},
use: [(Vue) => {
const o = Vue.component("k-pages-section").options;
Vue.component("k-pagesdisplay-section", {
extends: o,
props: {
controls: {
type: [Boolean, String],
default: true,
},
},
methods: {
items(data) {
if(this.controls === false) return data;

data = o.methods.items.call(this, data);

if(this.controls === "flag") {
for(const item of data) {
delete item.flag.click
delete item.options
}
}

return data;
},
},
});
}],
});
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,27 @@ sections:
type: pagesdisplay
query: page.siblings(false)
```
### Disable Controls
In addition to leaving the controls (the status flag and the options dropdown) visible - the default, it's possible to either hide them completely or show only the status flag.
To completely hide the controls:
```yaml
sections:
mysection:
headline: Siblings
type: pagesdisplay
query: page.siblings(false)
controls: false
```
To show only the status flag:
```yaml
sections:
mysection:
headline: Siblings
type: pagesdisplay
query: page.siblings(false)
controls: flag
```
9 changes: 8 additions & 1 deletion src/PagesDisplaySection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
},
'query' => function (string $query = 'page.children') {
return $query;
}
},
'controls' => function ($controls = true) {
if(!is_bool($controls) && $controls !== 'flag') {
throw new InvalidArgumentException('Invalid value for "controls" option. It must be either true, false or "flag"');
}

return $controls;
},
],
'computed' => [
'pages' => function () {
Expand Down

0 comments on commit b8d9525

Please sign in to comment.