1
0
mirror of https://github.com/typemill/typemill.git synced 2025-10-21 09:37:50 +02:00

Changed test plugin

This commit is contained in:
trendschau
2020-10-31 07:53:14 +01:00
parent 0ef48e831a
commit 649e545945
3 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace Plugins\Customfields;
use Typemill\Plugin;
class Customfields extends Plugin
{
public static function getSubscribedEvents()
{
return array(
'onTwigLoaded' => 'onTwigLoaded',
'onMetaLoaded' => 'onMetaLoaded'
);
}
public function onTwigLoaded()
{
$this->addEditorJS('/customfields/js/customfields.js');
}
public function onMetaLoaded($meta)
{
$meta = $meta->getData();
# do something with the fields:
$myTabInformation = $meta['mytab'];
}
}

View File

@@ -0,0 +1,15 @@
name: Customfields Plugin
version: 1.0.0
description: Plugin to test customfields
author: Sebastian Schürmanns
homepage: http://trendschau.net
licence: No licence
metatabs:
adamhall:
fields:
myfield:
type: customfields
label: Simple Custom Field
description: Please add some custom fields
data: array

View File

@@ -0,0 +1,26 @@
Vue.component('tab-adamhall', {
props: ['saved', 'errors', 'formdata', 'schema'],
template: '<section><form>' +
'<component v-for="(field, index) in schema.fields"' +
':key="index"' +
':is="selectComponent(field)"' +
':errors="errors"' +
':name="index"' +
'v-model="formdata[index]"' +
'v-bind="field">' +
'</component>' +
'<div v-if="saved" class="metaLarge"><div class="metaSuccess">Saved successfully</div></div>' +
'<div v-if="errors" class="metaLarge"><div class="metaErrors">Please correct the errors above</div></div>' +
'<div class="large"><input type="submit" @click.prevent="saveInput" value="save"></input></div>' +
'</form></section>',
methods: {
selectComponent: function(field)
{
return 'component-'+field.type;
},
saveInput: function()
{
this.$emit('saveform');
},
}
})