Last active
September 5, 2024 09:52
-
-
Save lukaskleinschmidt/3cc809bdaa84c525bab364857fa6a3e6 to your computer and use it in GitHub Desktop.
Kirby Structure Field Preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel.plugin('lukaskleinschmidt/site', { | |
components: { | |
'k-structure-field-preview': { | |
props: { | |
value: String, | |
column: Object, | |
field: Object | |
}, | |
computed: { | |
text: function() { | |
var result = []; | |
var fields = ['title', 'label']; | |
this.value.forEach(entry => fields.some(field => { | |
var value = entry[field] || null; | |
if (value) { | |
result.push(value); | |
return true; | |
} | |
})); | |
if (result.length) { | |
return result.join(', '); | |
} | |
return '…'; | |
} | |
}, | |
template: '<p class="k-structure-table-text">{{ text }}</p>', | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment