Skip to content

Commit 8afcd67

Browse files
authored
Merge pull request #1 from alxpez/master
feat: Add possibility of having global fields
2 parents 3b0a1b5 + a6ee461 commit 8afcd67

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

readme.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,29 @@ Once you have setup your `type` field, you need to name your fields like the abo
2525
| block | image | picture |
2626
| block | image | alt |
2727

28+
> Also you can include `global` fields, that will be visible for any type
29+
30+
| collection | type | field |
31+
|------------|-----------|---------|
32+
| block | global | title |
33+
| block | global | slug |
34+
2835
So the fields in the database should be like
2936
```
3037
block_editorial_text
3138
block_editorial_intro
3239
block_image_picture
3340
block_image_alt
41+
block_global_title
42+
block_global_slug
3443
```
3544

36-
With that config, if you select the type `editorial` in the dropdown, only the `text` and `intro` fields will appear on the screen.
45+
With that config, if you select the type `editorial` in the dropdown, only the `title`, `slug`, `text` and `intro` fields will appear on the screen.
3746

3847
### Import conditional-fields into the collection
3948
Once you have setup your fields, you can then just add the `conditional-fields` field so the javascript can do his job on the administration page.
40-
*NOTE*: you will have to name the field `conditional-fields`
49+
50+
*NOTE*: you will have to name the field `conditional_interface`
4151

4252
And that's it !
4353

src/input.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
mixins: [mixin],
1010
mounted() {
1111
// Fetch block options
12-
const { values, fields } = this._props
12+
const { values } = this._props
1313
const fieldsNode = document.querySelectorAll('[data-field]');
1414
const conditionalInterface = document.querySelector('[data-field="conditional_interface"]');
1515
const typeField = document.querySelector('[data-field=type]');
@@ -47,12 +47,12 @@
4747
}
4848
},
4949
hideAll(fieldsNode) {
50-
// Hide everything except the status bar, title and type
50+
// Hide everything except the status bar, type and global fields
5151
for (let i = 0; i < fieldsNode.length; i++) {
5252
let field = fieldsNode[i].dataset.field
5353
if (field !== 'status' &&
5454
field !== 'type' &&
55-
field !== 'title' )
55+
field.split("_")[1] !== 'global' )
5656
fieldsNode[i].style.display = 'none'
5757
}
5858
},

0 commit comments

Comments
 (0)