From f1a2bbb673f0d9c5ebe031c961ec4f8a2c56d7a6 Mon Sep 17 00:00:00 2001 From: trendschau Date: Sat, 29 Oct 2022 10:16:25 +0200 Subject: [PATCH] V2 vue forms --- composer.lock | 92 +++++----- .../typemill/Controllers/ControllerSystem.php | 6 + system/typemill/author/js/vue-system.js | 169 +++++++++++++++++- .../typemill/author/layouts/layoutSystem.twig | 7 +- system/typemill/settings/system.yaml | 60 +++++-- 5 files changed, 271 insertions(+), 63 deletions(-) diff --git a/composer.lock b/composer.lock index b7e9a5a..cbf3ebf 100644 --- a/composer.lock +++ b/composer.lock @@ -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": [], diff --git a/system/typemill/Controllers/ControllerSystem.php b/system/typemill/Controllers/ControllerSystem.php index 7965eb4..140268b 100644 --- a/system/typemill/Controllers/ControllerSystem.php +++ b/system/typemill/Controllers/ControllerSystem.php @@ -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 diff --git a/system/typemill/author/js/vue-system.js b/system/typemill/author/js/vue-system.js index 59597cd..0797004 100644 --- a/system/typemill/author/js/vue-system.js +++ b/system/typemill/author/js/vue-system.js @@ -1,20 +1,44 @@ const { createApp } = Vue createApp({ - delimiters: ['${', '}'], + template: `
MyForm Here message +
+ {{ legend }} +
{{field.legend}} + + +
+ + +
+
`, 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: '
' + + '
' + + '' + + '
{{ slugerror }}
' + + '
' + + '
' + + '
{{field.legend}}' + + '' + + '' + + '
' + + '' + + '' + + '
' + + '
{{ \'Saved successfully\'|translate }}
' + + '
{{ \'Please correct the errors above\'|translate }}
' + + '
' + + '
', + 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; + } + }); + } + } + } +}) + + + /* diff --git a/system/typemill/author/layouts/layoutSystem.twig b/system/typemill/author/layouts/layoutSystem.twig index da151af..07dfd8f 100644 --- a/system/typemill/author/layouts/layoutSystem.twig +++ b/system/typemill/author/layouts/layoutSystem.twig @@ -54,7 +54,8 @@ var data = {{ jsdata | json_encode() | raw }} - var eventBus = false; +/* var eventBus = false; */ + console.info(data.settings); @@ -66,8 +67,12 @@ +