Created
April 19, 2018 14:06
-
-
Save onefriendaday/a6943a8d4c9dcd6321fd76ddbced3c57 to your computer and use it in GitHub Desktop.
Folder Selector Plugin example
This file contains hidden or 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
| const Fieldtype = { | |
| mixins: [window.Storyblok.plugin], | |
| template: `<div><select class="uk-width-1-1" v-model="model.value"> | |
| <option :key="option.value" v-for="option in options">{{ option.name }}</option> | |
| </select></div>`, | |
| data() { | |
| return { | |
| options: [] | |
| } | |
| }, | |
| methods: { | |
| initWith() { | |
| return { | |
| plugin: 'folder-selector', | |
| value: '' | |
| } | |
| }, | |
| pluginCreated() { | |
| this.options = [] | |
| this.api.get('cdn/links').then((res) => { | |
| for (let key in res.data.links) { | |
| if (res.data.links[key].is_folder) { | |
| this.options.push({name: res.data.links[key].name, value: key}) | |
| } | |
| } | |
| }) | |
| } | |
| }, | |
| watch: { | |
| 'model': { | |
| handler: function (value) { | |
| this.$emit('changed-model', value); | |
| }, | |
| deep: true | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment