1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-06 14:16:46 +02:00

V2 vue forms

This commit is contained in:
trendschau
2022-10-29 10:16:25 +02:00
parent 0b9af2a61f
commit f1a2bbb673
5 changed files with 271 additions and 63 deletions

92
composer.lock generated
View File

@@ -346,36 +346,35 @@
},
{
"name": "laminas/laminas-permissions-acl",
"version": "2.10.x-dev",
"version": "2.12.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-permissions-acl.git",
"reference": "43e137e9984550f36dc9cbfe5aa62089a79a0ae8"
"reference": "0d88f430953fbcbce382f09090db28905b90d60f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-permissions-acl/zipball/43e137e9984550f36dc9cbfe5aa62089a79a0ae8",
"reference": "43e137e9984550f36dc9cbfe5aa62089a79a0ae8",
"url": "https://api.github.com/repos/laminas/laminas-permissions-acl/zipball/0d88f430953fbcbce382f09090db28905b90d60f",
"reference": "0d88f430953fbcbce382f09090db28905b90d60f",
"shasum": ""
},
"require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0"
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"laminas/laminas-servicemanager": "<3.0",
"zendframework/zend-permissions-acl": "*"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-servicemanager": "^3.0.3",
"phpunit/phpunit": "^9.5.0",
"psalm/plugin-phpunit": "^0.15.1",
"vimeo/psalm": "^4.7"
"laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-servicemanager": "^3.19",
"phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.17.0",
"vimeo/psalm": "^4.29"
},
"suggest": {
"laminas/laminas-servicemanager": "To support Laminas\\Permissions\\Acl\\Assertion\\AssertionManager plugin manager usage"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@@ -406,29 +405,30 @@
"type": "community_bridge"
}
],
"time": "2022-03-08T15:56:59+00:00"
"time": "2022-10-17T04:26:35+00:00"
},
{
"name": "laravel/serializable-closure",
"version": "v1.2.0",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "09f0e9fb61829f628205b7c94906c28740ff9540"
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/09f0e9fb61829f628205b7c94906c28740ff9540",
"reference": "09f0e9fb61829f628205b7c94906c28740ff9540",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae",
"reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae",
"shasum": ""
},
"require": {
"php": "^7.3|^8.0"
},
"require-dev": {
"pestphp/pest": "^1.18",
"phpstan/phpstan": "^0.12.98",
"symfony/var-dumper": "^5.3"
"nesbot/carbon": "^2.61",
"pestphp/pest": "^1.21.3",
"phpstan/phpstan": "^1.8.2",
"symfony/var-dumper": "^5.4.11"
},
"type": "library",
"extra": {
@@ -465,7 +465,7 @@
"issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure"
},
"time": "2022-05-16T17:09:47+00:00"
"time": "2022-09-08T13:45:54+00:00"
},
{
"name": "nikic/fast-route",
@@ -1602,7 +1602,7 @@
},
{
"name": "symfony/event-dispatcher-contracts",
"version": "v3.0.1",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
@@ -1661,7 +1661,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.1"
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.2"
},
"funding": [
{
@@ -1681,16 +1681,16 @@
},
{
"name": "symfony/finder",
"version": "v6.0.8",
"version": "v6.0.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "af7edab28d17caecd1f40a9219fc646ae751c21f"
"reference": "09cb683ba5720385ea6966e5e06be2a34f2568b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/af7edab28d17caecd1f40a9219fc646ae751c21f",
"reference": "af7edab28d17caecd1f40a9219fc646ae751c21f",
"url": "https://api.github.com/repos/symfony/finder/zipball/09cb683ba5720385ea6966e5e06be2a34f2568b1",
"reference": "09cb683ba5720385ea6966e5e06be2a34f2568b1",
"shasum": ""
},
"require": {
@@ -1722,7 +1722,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.0.8"
"source": "https://github.com/symfony/finder/tree/v6.0.11"
},
"funding": [
{
@@ -1738,7 +1738,7 @@
"type": "tidelift"
}
],
"time": "2022-04-15T08:07:58+00:00"
"time": "2022-07-29T07:39:48+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -2069,16 +2069,16 @@
},
{
"name": "symfony/yaml",
"version": "v6.0.3",
"version": "v6.0.14",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5"
"reference": "e65020d137ad54beb85a67ffe6435e980f35ccf3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/e77f3ea0b21141d771d4a5655faa54f692b34af5",
"reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5",
"url": "https://api.github.com/repos/symfony/yaml/zipball/e65020d137ad54beb85a67ffe6435e980f35ccf3",
"reference": "e65020d137ad54beb85a67ffe6435e980f35ccf3",
"shasum": ""
},
"require": {
@@ -2123,7 +2123,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v6.0.3"
"source": "https://github.com/symfony/yaml/tree/v6.0.14"
},
"funding": [
{
@@ -2139,20 +2139,20 @@
"type": "tidelift"
}
],
"time": "2022-01-26T17:23:29+00:00"
"time": "2022-10-07T08:02:12+00:00"
},
{
"name": "twig/twig",
"version": "v3.4.1",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "e939eae92386b69b49cfa4599dd9bead6bf4a342"
"reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e939eae92386b69b49cfa4599dd9bead6bf4a342",
"reference": "e939eae92386b69b49cfa4599dd9bead6bf4a342",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/c38fd6b0b7f370c198db91ffd02e23b517426b58",
"reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58",
"shasum": ""
},
"require": {
@@ -2203,7 +2203,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.4.1"
"source": "https://github.com/twigphp/Twig/tree/v3.4.3"
},
"funding": [
{
@@ -2215,20 +2215,20 @@
"type": "tidelift"
}
],
"time": "2022-05-17T05:48:52+00:00"
"time": "2022-09-28T08:42:51+00:00"
},
{
"name": "vlucas/valitron",
"version": "v1.4.10",
"version": "v1.4.11",
"source": {
"type": "git",
"url": "https://github.com/vlucas/valitron.git",
"reference": "5ebd5d7af82cc0a9d798e816a2ecad63f1b59ceb"
"reference": "fadce39f5f235755bb9794b2573af2d5bfcba85f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/valitron/zipball/5ebd5d7af82cc0a9d798e816a2ecad63f1b59ceb",
"reference": "5ebd5d7af82cc0a9d798e816a2ecad63f1b59ceb",
"url": "https://api.github.com/repos/vlucas/valitron/zipball/fadce39f5f235755bb9794b2573af2d5bfcba85f",
"reference": "fadce39f5f235755bb9794b2573af2d5bfcba85f",
"shasum": ""
},
"require": {
@@ -2266,7 +2266,7 @@
],
"support": {
"issues": "https://github.com/vlucas/valitron/issues",
"source": "https://github.com/vlucas/valitron/tree/v1.4.10"
"source": "https://github.com/vlucas/valitron/tree/v1.4.11"
},
"funding": [
{
@@ -2274,7 +2274,7 @@
"type": "tidelift"
}
],
"time": "2021-07-08T16:18:03+00:00"
"time": "2022-10-14T11:54:24+00:00"
}
],
"packages-dev": [],

View File

@@ -3,6 +3,8 @@
namespace Typemill\Controllers;
use Typemill\Models\User;
use Typemill\Models\Yaml;
# use \Symfony\Component\Yaml\Yaml;
# use Typemill\Models\Write;
@@ -60,6 +62,9 @@ class ControllerSystem extends ControllerData
$user->setUser($_SESSION['username']);
$userdata = $user->getUserData();
$yaml = new Yaml('\Typemill\Models\Storage');
$system = $yaml->getYaml('system/typemill/settings', 'system.yaml');
return $this->c->get('view')->render($response, 'system/system.twig', [
'basicauth' => $user->getBasicAuth(),
'settings' => $this->settings,
@@ -67,6 +72,7 @@ class ControllerSystem extends ControllerData
'systemnavi' => $this->getSystemNavigation($userdata['userrole']),
'jsdata' => [
'settings' => $this->settings,
'system' => $system,
]
# main navigation

View File

@@ -1,20 +1,44 @@
const { createApp } = Vue
createApp({
delimiters: ['${', '}'],
template: `<div><form>MyForm Here message
<div v-for="(field, legend) in formDefinitions">
{{ legend }}
<fieldset v-if="field.type == 'fieldset'" class="fs-formbuilder"><legend>{{field.legend}}</legend>
<component v-for="(subfield, index) in field.fields "
:key="index"
:is="selectComponent(subfield)"
:errors="errors"
:name="index"
:userroles="userroles"
v-model="formdata[index]"
v-bind="subfield">
</component>
</fieldset>
<component v-else
:key="index"
:is="selectComponent(field)"
:errors="errors"
:name="index"
:userroles="userroles"
v-model="formData[index]"
v-bind="field">
</component>
</div>
</form></div>`,
data() {
return {
message: 'Add system forms with vue here',
root: document.getElementById("main").dataset.url,
currentTab: 'System',
tabs: ['System', 'Media', 'Editor', 'Access', 'Password Recovery', 'Advanced'],
formDefinitions: [],
formData: [],
tabs: [],
formDefinitions: data.system.fields,
formData: data.settings,
formErrors: {},
formErrorsReset: {},
item: false,
userroles: false,
saved: false,
saved: false,
}
},
computed: {
@@ -31,10 +55,145 @@ createApp({
return 'tab-' + this.currentTab.toLowerCase()
}
}
},
mounted() {
for (var key in this.formDefinitions)
{
if (this.formDefinitions.hasOwnProperty(key))
{
this.tabs.push(key);
this.formErrors[key] = false;
}
}
this.formErrorsReset = this.formErrors;
},
methods: {
selectComponent: function(field)
{
return 'component-'+field.type;
},
},
}).mount('#systemsettings')
/*
Vue.component('tab-meta', {
props: ['saved', 'errors', 'formdata', 'schema', 'userroles'],
data: function () {
return {
slug: false,
originalSlug: false,
slugerror: false,
disabled: "disabled",
}
},
template: '<section><form>' +
'<div v-if="slug !== false"><div class="large relative">' +
'<label>Slug / Name in URL</label><input type="text" v-model="slug" pattern="[a-z0-9\- ]" @input="changeSlug()"><button @click.prevent="storeSlug()" :disabled="disabled" class="button slugbutton bn br2 bg-tm-green white absolute">change slug</button>' +
'<div v-if="slugerror" class="f6 tm-red mt1">{{ slugerror }}</div>' +
'</div></div>' +
'<div v-for="(field, index) in schema.fields">' +
'<fieldset v-if="field.type == \'fieldset\'" class="fs-formbuilder"><legend>{{field.legend}}</legend>' +
'<component v-for="(subfield, index) in field.fields "' +
' :key="index"' +
' :is="selectComponent(subfield)"' +
' :errors="errors"' +
' :name="index"' +
' :userroles="userroles"' +
' v-model="formdata[index]"' +
' v-bind="subfield">' +
'</component>' +
'</fieldset>' +
'<component v-else' +
' :key="index"' +
' :is="selectComponent(field)"' +
' :errors="errors"' +
' :name="index"' +
' :userroles="userroles"' +
' v-model="formdata[index]"' +
' v-bind="field">' +
'</component>' +
'</div>' +
'<div v-if="saved" class="metasubmit"><div class="metaSuccess">{{ \'Saved successfully\'|translate }}</div></div>' +
'<div v-if="errors" class="metasubmit"><div class="metaErrors">{{ \'Please correct the errors above\'|translate }}</div></div>' +
'<div class="metasubmit"><input type="submit" @click.prevent="saveInput" :value="\'save\'|translate"></input></div>' +
'</form></section>',
mounted: function()
{
if(this.$parent.item.slug != '')
{
this.slug = this.$parent.item.slug;
this.originalSlug = this.slug;
}
},
methods: {
selectComponent: function(field)
{
return 'component-'+field.type;
},
saveInput: function()
{
this.$emit('saveform');
},
changeSlug: function()
{
if(this.slug == this.originalSlug)
{
this.slugerror = false;
this.disabled = "disabled";
return;
}
if(this.slug == '')
{
this.slugerror = 'empty slugs are not allowed';
this.disabled = "disabled";
return;
}
this.slug = this.slug.replace(/ /g, '-');
if(this.slug.match(/^[a-z0-9\-]*$/))
{
this.slugerror = false;
this.disabled = false;
}
else
{
this.slugerror = 'Only lowercase a-z and 0-9 and "-" is allowed for slugs.';
this.disabled = "disabled";
}
},
storeSlug: function()
{
if(this.slug.match(/^[a-z0-9\-]*$/) && this.slug != this.originalSlug)
{
var self = this;
myaxios.post('/api/v1/article/rename',{
'url': document.getElementById("path").value,
'csrf_name': document.getElementById("csrf_name").value,
'csrf_value': document.getElementById("csrf_value").value,
'slug': this.slug,
})
.then(function (response)
{
window.location.replace(response.data.url);
})
.catch(function (error)
{
if(error.response.data.errors.message)
{
publishController.errors.message = error.response.data.errors.message;
}
});
}
}
}
})
/*

View File

@@ -54,7 +54,8 @@
var data = {{ jsdata | json_encode() | raw }}
var eventBus = false;
/* var eventBus = false; */
console.info(data.settings);
</script>
<script src="{{ base_url() }}/system/typemill/author/js/axios.min.js?v={{ settings.version }}"></script>
@@ -66,8 +67,12 @@
</script>
<!-- <script src="{{ base_url() }}/system/typemill/author/js/autosize.min.js?v={{ settings.version }}"></script> -->
<script src="{{ base_url() }}/system/typemill/author/js/vue.js?v={{ settings.version }}"></script>
<script>
const { eventBus } = Vue;
</script>
<!--
<script>
var eventBus = false;
const FormBus = new Vue();
</script>
<script src="{{ base_url() }}/system/author/js/vue-shared.js?v={{ settings.version }}"></script>

View File

@@ -1,12 +1,50 @@
basics:
system:
fields:
media:
fields:
writing:
fields:
access:
fields:
password:
fields:
developer:
fields:
fieldsetsystem:
type: fieldset
legend: System
fields:
title:
type: text
label: Website Title
class: medium
maxlength: 60
author:
type: text
label: Author
class: medium
maxlength: 60
copyright:
type: text
label: Copyright
class: medium
maxlength: 60
year:
type: text
label: Year
class: medium
maxlength: 60
fieldsetmedia:
type: fieldset
legend: Media
fields:
title:
type: text
label: Website Title
class: medium
maxlength: 60
author:
type: text
label: Author
class: medium
maxlength: 60
copyright:
type: text
label: Copyright
class: medium
maxlength: 60
year:
type: text
label: Year
class: medium
maxlength: 60