From e1fc2cee0f9612bd62b0dfb4c545a24c0f03929d Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 14:26:41 +0800 Subject: [PATCH 01/13] cleaning a comma --- profile/schema/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile/schema/profile.php b/profile/schema/profile.php index 6c0db52..75a7604 100644 --- a/profile/schema/profile.php +++ b/profile/schema/profile.php @@ -136,7 +136,7 @@ 'searchable' => 0, 'filterable' => 0, 'sortable' => 1 - ], + ] ], 'relations' => [] ]; From 367a966ea0fbff861de1b4208343d6dbe4ae0368 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 14:32:32 +0800 Subject: [PATCH 02/13] removing asset routes in api --- api/developer/assets/script.js | 29 ----------------------- api/developer/assets/style.css | 1 - api/developer/controller/assets.php | 36 ----------------------------- 3 files changed, 66 deletions(-) delete mode 100644 api/developer/assets/script.js delete mode 100644 api/developer/assets/style.css diff --git a/api/developer/assets/script.js b/api/developer/assets/script.js deleted file mode 100644 index b31db04..0000000 --- a/api/developer/assets/script.js +++ /dev/null @@ -1,29 +0,0 @@ -jQuery(function($) { - $(window).on('bootstrap-validator-init', function (e, target) { - target = $(target); - - if(!target.hasClass('app-form')) { - return; - } - - target.on('submit', function(e) { - if ($('.has-error', target).length) { - return false; - } - - //ajax up - - const method = target.attr('method') || 'post'; - const action = target.attr('action') || window.location.href; - - const trigger = $('') - .data('method', method) - .data('href', action) - .data('form', target); - - $(window).trigger('panel-mobile-rest-reload-click', trigger); - - return false; - }); - }); -}); diff --git a/api/developer/assets/style.css b/api/developer/assets/style.css deleted file mode 100644 index 9d6f459..0000000 --- a/api/developer/assets/style.css +++ /dev/null @@ -1 +0,0 @@ -/**/ diff --git a/api/developer/controller/assets.php b/api/developer/controller/assets.php index 5e0a114..f5bf98e 100644 --- a/api/developer/controller/assets.php +++ b/api/developer/controller/assets.php @@ -9,42 +9,6 @@ use UGComponents\IO\Request\RequestInterface; use UGComponents\IO\Response\ResponseInterface; -/** - * Forwards the supplier script to the DMZ - * - * @param RequestInterface $request - * @param ResponseInterface $response - */ -$this('http')->get('/scripts/app.js', function( - RequestInterface $request, - ResponseInterface $response -) { - //get the asset path - $assetPath = dirname(__DIR__) . '/assets'; - //set content type - $response->addHeader('Content-Type', 'text/javascript'); - //get the file and set to content - $response->setContent(file_get_contents($assetPath . '/script.js')); -}); - -/** - * Forwards the supplier styles to the DMZ - * - * @param RequestInterface $request - * @param ResponseInterface $response - */ -$this('http')->get('/styles/app.css', function( - RequestInterface $request, - ResponseInterface $response -) { - //get the asset path - $assetPath = dirname(__DIR__) . '/assets'; - //set content type - $response->addHeader('Content-Type', 'text/css'); - //get the file and set to content - $response->setContent(file_get_contents($assetPath . '/style.css')); -}); - /** * Forwards the supplier styles to the DMZ * From 99978637c61504d23c3a6e16023d89e629efe415 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 15:00:47 +0800 Subject: [PATCH 03/13] fixed admin role form not loading --- role/controller.php | 74 +++++++++++++++++++----------- role/schema/role.php | 14 +++--- role/template/form.html | 76 ------------------------------- role/template/form/_body.html | 39 ++++++++++++++++ role/template/form/_fieldset.html | 15 ------ 5 files changed, 94 insertions(+), 124 deletions(-) delete mode 100644 role/template/form.html create mode 100644 role/template/form/_body.html delete mode 100644 role/template/form/_fieldset.html diff --git a/role/controller.php b/role/controller.php index 8a7706b..00cc178 100644 --- a/role/controller.php +++ b/role/controller.php @@ -35,24 +35,35 @@ RequestInterface $request, ResponseInterface $response ) { - //we want to change the links up to use the role routes - if (!$response->exists('page', 'template_root')) { - $response->set('page', 'template_root', __DIR__ . '/template'); - } - $this('handlebars') + ->registerPartialFromFile('form_body', sprintf( + '/%s/template/form/_body.html', + __DIR__ + ), true) + ->registerPartialFromFile('form_tabs', sprintf( + '/%s/template/form/_tabs.html', + __DIR__ + ), true) + ->registerPartialFromFile('form_information', sprintf( + '/%s/template/form/_information.html', + __DIR__ + ), true) ->registerPartialFromFile('form_permissions', sprintf( - '/%s/template/form/_permissions.html', __DIR__ - )) + '/%s/template/form/_permissions.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu', sprintf( - '/%s/template/form/_menu.html', __DIR__ - )) + '/%s/template/form/_menu.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu_item', sprintf( - '/%s/template/form/menu/_item.html', __DIR__ - )) + '/%s/template/form/menu/_item.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu_input', sprintf( - '/%s/template/form/menu/_input.html', __DIR__ - )); + '/%s/template/form/menu/_input.html', + __DIR__ + ), true); }, 10); /** @@ -65,24 +76,35 @@ RequestInterface $request, ResponseInterface $response ) { - //we want to change the links up to use the role routes - if (!$response->exists('page', 'template_root')) { - $response->set('page', 'template_root', __DIR__ . '/template'); - } - $this('handlebars') + ->registerPartialFromFile('form_body', sprintf( + '/%s/template/form/_body.html', + __DIR__ + ), true) + ->registerPartialFromFile('form_tabs', sprintf( + '/%s/template/form/_tabs.html', + __DIR__ + ), true) + ->registerPartialFromFile('form_information', sprintf( + '/%s/template/form/_information.html', + __DIR__ + ), true) ->registerPartialFromFile('form_permissions', sprintf( - '/%s/template/form/_permissions.html', __DIR__ - )) + '/%s/template/form/_permissions.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu', sprintf( - '/%s/template/form/_menu.html', __DIR__ - )) + '/%s/template/form/_menu.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu_item', sprintf( - '/%s/template/form/menu/_item.html', __DIR__ - )) + '/%s/template/form/menu/_item.html', + __DIR__ + ), true) ->registerPartialFromFile('form_menu_input', sprintf( - '/%s/template/form/menu/_input.html', __DIR__ - )); + '/%s/template/form/menu/_input.html', + __DIR__ + ), true); }, 10); /** diff --git a/role/schema/role.php b/role/schema/role.php index 590b3e3..46d7ab7 100644 --- a/role/schema/role.php +++ b/role/schema/role.php @@ -147,12 +147,12 @@ 'role_admin_menu' => json_encode([ [ 'label' => 'Dashboard', - 'icon' => 'fa-tachometer-alt', + 'icon' => 'fas fa-tachometer-alt', 'path' => '/admin' ], [ 'label' => 'Admin', - 'icon' => 'fa-coffee', + 'icon' => 'fas fa-coffee', 'path' => 'menu-admin', 'submenu' => [ [ @@ -171,7 +171,7 @@ ], [ 'label' => 'System', - 'icon' => 'fa-server', + 'icon' => 'fas fa-server', 'path' => 'menu-system', 'submenu' => [ [ @@ -186,7 +186,7 @@ ], [ 'label' => 'Configuration', - 'icon' => 'fa-cogs', + 'icon' => 'fas fa-cogs', 'path' => 'menu-configuration', 'submenu' => [ [ @@ -236,12 +236,12 @@ 'role_admin_menu' => json_encode([ [ 'label' => 'Dashboard', - 'icon' => 'fa-tachometer-alt', + 'icon' => 'fas fa-tachometer-alt', 'path' => '/admin' ], [ 'label' => 'Admin', - 'icon' => 'fa-coffee', + 'icon' => 'fas fa-coffee', 'path' => 'menu-admin', 'submenu' => [ [ @@ -260,7 +260,7 @@ ], [ 'label' => 'Configuration', - 'icon' => 'fa-cogs', + 'icon' => 'fas fa-cogs', 'path' => 'menu-configuration', 'submenu' => [ [ diff --git a/role/template/form.html b/role/template/form.html deleted file mode 100644 index 67442f2..0000000 --- a/role/template/form.html +++ /dev/null @@ -1,76 +0,0 @@ -
- -
- -
- - {{title}} -
-
- - -
- - {{> form_tabs}} - - -
- -
- {{> form_information}} -
- - -
- {{> form_permissions}} -
- - -
- {{> form_menu}} -
- - {{#each schema.fieldsets}} - {{> form_fieldset}} - {{/each}} -
- -
- - -
- -
- - {{#each ids}} - - {{/each}} -
diff --git a/role/template/form/_body.html b/role/template/form/_body.html new file mode 100644 index 0000000..0b22452 --- /dev/null +++ b/role/template/form/_body.html @@ -0,0 +1,39 @@ +
+ + {{> form_tabs}} + + +
+ +
+ {{> form_information}} +
+ + +
+ {{> form_permissions}} +
+ + +
+ {{> form_menu}} +
+ + {{#each schema.fieldsets}} + {{> form_fieldset}} + {{/each}} +
+ +
diff --git a/role/template/form/_fieldset.html b/role/template/form/_fieldset.html deleted file mode 100644 index ec6d5df..0000000 --- a/role/template/form/_fieldset.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- {{#field name=@key row=../item schema=../schema.name}} -
-
- {{{control}}} -
-
- {{/field}} -
- From 56e387c766136de3408d8eabaff32a4edc162e9a Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 16:08:03 +0800 Subject: [PATCH 04/13] adding api menu on install --- api/package.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/api/package.php b/api/package.php index 98b0b61..6d079dc 100644 --- a/api/package.php +++ b/api/package.php @@ -147,6 +147,8 @@ RequestInterface $request, ResponseInterface $response ) { + //get emitter + $emitter = $this('event'); //scan through each file foreach (scandir(__DIR__ . '/schema') as $file) { //if it's not a php file @@ -166,8 +168,6 @@ continue; } - //get emitter - $emitter = $this('event'); foreach($data['fixtures'] as $fixture) { $payload = $request ->clone(true) @@ -177,4 +177,63 @@ $emitter->call('system-object-create', $payload); } } + + if ($this->isPackage('inceptphp/packages/role')) { + $role = $emitter->call('system-object-role-detail', [ + 'role_slug' => 'developer' + ]); + + if (isset($role['role_admin_menu'])) { + $exists = false; + foreach ($role['role_admin_menu'] as $item) { + if ($item['path'] === 'menu-api') { + $exists = true; + break; + } + } + + if (!$exists) { + $menu = []; + foreach ($role['role_admin_menu'] as $item) { + $menu[] = $item; + if ($item['path'] !== 'menu-admin') { + continue; + }echo 'pass'; + + $menu[] = [ + 'icon' => 'fas fa-code', + 'path' => 'menu-api', + 'label' => 'API', + 'submenu' => [ + [ + 'path' => '/admin/system/object/app/search', + 'label' => 'Applications' + ], + [ + 'path' => '/admin/system/object/session/search', + 'label' => 'Sessions' + ], + [ + 'path' => '/admin/system/object/scope/search', + 'label' => 'Scopes' + ], + [ + 'path' => '/admin/system/object/rest/search', + 'label' => 'REST Calls' + ], + [ + 'path' => '/admin/system/object/webhook/search', + 'label' => 'Webhooks' + ] + ] + ]; + } + + $emitter->call('system-object-role-update', [ + 'role_id' => $role['role_id'], + 'role_admin_menu' => json_encode($menu, JSON_PRETTY_PRINT) + ]); + } + } + } }); From 3cf6cfa824ecb0e8f534ef7b6f7ef6423243253b Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 16:11:43 +0800 Subject: [PATCH 05/13] fixing admin left side menu overflow --- admin/assets/style/_layout.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/admin/assets/style/_layout.css b/admin/assets/style/_layout.css index 0d975ad..889fd38 100644 --- a/admin/assets/style/_layout.css +++ b/admin/assets/style/_layout.css @@ -94,6 +94,13 @@ margin-top: -3px; } +.layout-panel .panel-sidebar-left .nav { + display: block; + height: 100%; + overflow: auto; + width: 100%; +} + .layout-panel .panel-sidebar-left .nav-link .nav-right { color: #FFFFFF; float: right; From e088306e11b95dd7c66e6731391b4e3e34c656e1 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 16:29:03 +0800 Subject: [PATCH 06/13] lower case keyword fields in schema and fieldset builder --- admin/template/field/form.html | 2 +- admin/template/fieldset/field.html | 2 +- admin/template/fieldset/form/_content.html | 2 +- admin/template/schema/field.html | 2 +- admin/template/schema/form/_content.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/template/field/form.html b/admin/template/field/form.html index 150e9b5..cda6676 100644 --- a/admin/template/field/form.html +++ b/admin/template/field/form.html @@ -54,7 +54,7 @@
class="field-name form-control required" data-do="slugger" data-source="input[name='label']" - data-upper="0" + data-lower="1" data-space="_" name="name" placeholder="{{_ 'Enter a unique keyword'}}" diff --git a/admin/template/fieldset/field.html b/admin/template/fieldset/field.html index 66c8dbd..c210dff 100644 --- a/admin/template/fieldset/field.html +++ b/admin/template/fieldset/field.html @@ -54,7 +54,7 @@
class="field-name form-control required" data-do="slugger" data-source="input[name='label']" - data-upper="0" + data-lower="1" data-space="_" name="name" placeholder="{{_ 'Enter a unique keyword'}}" diff --git a/admin/template/fieldset/form/_content.html b/admin/template/fieldset/form/_content.html index 85bcf5c..31f98fc 100644 --- a/admin/template/fieldset/form/_content.html +++ b/admin/template/fieldset/form/_content.html @@ -51,7 +51,7 @@ class="form-control fieldset-name" data-do="slugger" data-source="input.fieldset-singular" - data-upper="0" + data-lower="1" data-space="_" name="name" value="{{item.name}}" diff --git a/admin/template/schema/field.html b/admin/template/schema/field.html index 136e692..dfc971f 100644 --- a/admin/template/schema/field.html +++ b/admin/template/schema/field.html @@ -54,7 +54,7 @@
class="field-name form-control required" data-do="slugger" data-source="input[name='label']" - data-upper="0" + data-lower="1" data-space="_" name="name" placeholder="{{_ 'Enter a unique keyword'}}" diff --git a/admin/template/schema/form/_content.html b/admin/template/schema/form/_content.html index 6472799..5d18bff 100644 --- a/admin/template/schema/form/_content.html +++ b/admin/template/schema/form/_content.html @@ -51,7 +51,7 @@ class="form-control fieldset-name" data-do="slugger" data-source="input.schema-singular" - data-upper="0" + data-lower="1" data-space="_" name="name" value="{{item.name}}" From edce65bba773fc0d53b18859873a17cafce72ad8 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 16:52:19 +0800 Subject: [PATCH 07/13] fixing row template use when adding a field to a schema in the admin --- admin/controller/schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/controller/schema.php b/admin/controller/schema.php index eb6b5cc..8f0d256 100644 --- a/admin/controller/schema.php +++ b/admin/controller/schema.php @@ -322,7 +322,7 @@ //----------------------------// // 2. Process Data - $template = dirname(__DIR__) . '/template/fieldset'; + $template = dirname(__DIR__) . '/template/schema'; if (is_dir($response->get('page', 'template_root'))) { $template = $response->get('page', 'template_root'); } From 7a184fbab3047e86c1c40c238259e3debba13e71 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Thu, 13 May 2021 20:25:17 +0800 Subject: [PATCH 08/13] patched chrome bug showing options on hidden optgroups --- admin/template/field/assets/_script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/template/field/assets/_script.js b/admin/template/field/assets/_script.js index 8f254d9..0b807c4 100644 --- a/admin/template/field/assets/_script.js +++ b/admin/template/field/assets/_script.js @@ -50,11 +50,13 @@ jQuery(($) => { ['string', 'number', 'date', 'html', 'json', 'custom'].forEach(function(type) { if(formats.indexOf(type) === -1) { var list = $('select.field-list optgroup.filter-group-' + type, form).hide(); + $('option', list).hide(); if($('option:selected', list).length) { list.parent().val('none').trigger('change'); } var detail = $('select.field-detail optgroup.filter-group-' + type, form).hide(); + $('option', detail).hide(); if($('option:selected', detail).length) { detail.parent().val('none').trigger('change'); } @@ -240,8 +242,8 @@ jQuery(($) => { }; target.resetFormState = function () { - $('select.field-list optgroup', target).show(); - $('select.field-detail optgroup', target).show(); + $('select.field-list optgroup', target).show().find('option').show(); + $('select.field-detail optgroup', target).show().find('option').show(); $('input.field-searchable', target).attr('disabled', false); $('input.field-filterable', target).attr('disabled', false); $('input.field-sortable', target).attr('disabled', false); From 02e4a2783aef7c45f3d6e90e6c80aeffeae9b70e Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Fri, 14 May 2021 02:31:09 +0800 Subject: [PATCH 09/13] fixed m >= d on storm when creating a schema --- storm/StormPackage.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storm/StormPackage.php b/storm/StormPackage.php index 55ad0a2..11e6bf1 100644 --- a/storm/StormPackage.php +++ b/storm/StormPackage.php @@ -140,11 +140,11 @@ public function getFieldSchema(array $field): array && is_numeric($field['field']['attributes'][$attribute]) ) { $numbers = explode('.', (string) $field['field']['attributes'][$attribute]); - if (strlen($numbers[0]) > $length[0]) { + if (isset($numbers[0]) && strlen($numbers[0]) > $length[0]) { $length[0] = strlen($numbers[0]); } - if (strlen($numbers[1]) > $length[1]) { + if (isset($numbers[1]) && strlen($numbers[1]) > $length[1]) { $length[1] = strlen($numbers[1]); } } @@ -162,6 +162,11 @@ public function getFieldSchema(array $field): array } } + //SQL Requirement: M must be >= D + if (isset($length[1]) && $length[1] > $length[0]) { + $length[0] = $length[1]; + } + if (count($length) == 2) { $schema = ['type' => 'FLOAT', 'length' => implode(',', $length)]; } else { From e356138bf01e6ca41554022a3234f4e93c49f5fe Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Fri, 14 May 2021 02:32:36 +0800 Subject: [PATCH 10/13] removing echo --- api/package.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/api/package.php b/api/package.php index 6d079dc..ba06829 100644 --- a/api/package.php +++ b/api/package.php @@ -198,33 +198,33 @@ $menu[] = $item; if ($item['path'] !== 'menu-admin') { continue; - }echo 'pass'; + } $menu[] = [ 'icon' => 'fas fa-code', 'path' => 'menu-api', 'label' => 'API', 'submenu' => [ - [ - 'path' => '/admin/system/object/app/search', - 'label' => 'Applications' - ], - [ - 'path' => '/admin/system/object/session/search', - 'label' => 'Sessions' - ], - [ - 'path' => '/admin/system/object/scope/search', - 'label' => 'Scopes' - ], - [ - 'path' => '/admin/system/object/rest/search', - 'label' => 'REST Calls' - ], - [ - 'path' => '/admin/system/object/webhook/search', - 'label' => 'Webhooks' - ] + [ + 'path' => '/admin/system/object/app/search', + 'label' => 'Applications' + ], + [ + 'path' => '/admin/system/object/session/search', + 'label' => 'Sessions' + ], + [ + 'path' => '/admin/system/object/scope/search', + 'label' => 'Scopes' + ], + [ + 'path' => '/admin/system/object/rest/search', + 'label' => 'REST Calls' + ], + [ + 'path' => '/admin/system/object/webhook/search', + 'label' => 'Webhooks' + ] ] ]; } From b7cf262acadaec1e2bcadefc611f436a6bd07678 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Fri, 14 May 2021 16:16:19 +0800 Subject: [PATCH 11/13] fixed error debugging for spa screens, fixed coloring for code editors --- admin/AdminPackage.php | 33 ++++++- admin/assets/script/_fields.js | 57 ++++++----- admin/assets/style/_form.css | 11 ++- admin/assets/style/_theme.css | 12 +++ admin/template/debug/page.html | 168 +++++++++++++++++++++++++++++++++ admin/template/debug/spa.html | 41 ++++++++ 6 files changed, 287 insertions(+), 35 deletions(-) create mode 100644 admin/template/debug/page.html create mode 100644 admin/template/debug/spa.html diff --git a/admin/AdminPackage.php b/admin/AdminPackage.php index 7cf68cf..2d5b0f9 100644 --- a/admin/AdminPackage.php +++ b/admin/AdminPackage.php @@ -98,6 +98,11 @@ public function error( return; } + //if there's already content + if ($response->hasContent()) { + return; + } + //get the path $path = $request->getPath('string'); //if not an admin path @@ -105,6 +110,8 @@ public function error( return; } + $debug = strpos($path, '/admin/spa/') === false ? 'page': 'spa'; + //if it was a call for an actual file if (preg_match('/\.[a-zA-Z0-9]{1,4}$/', $path)) { return; @@ -114,7 +121,7 @@ public function error( $type = $response->getHeaders('Content-Type'); if (strpos($type, 'html') === false) { //don't make it pretty - return $this->errorDebug($request, $response, $error); + return $this->errorDebug($request, $response, $error, $debug); } //get the code @@ -135,7 +142,7 @@ public function error( || $code !== 500 ) { //don't make it pretty - return $this->errorDebug($request, $response, $error); + return $this->errorDebug($request, $response, $error, $debug); } //okay make it pretty... @@ -290,14 +297,16 @@ protected function errorEmail( * * @param *RequestInterface $request * @param *ResponseInterface $response - * @param *Throwable $error + * @param *Throwable $error + * @param *string $mode * * @return bool */ protected function errorDebug( RequestInterface $request, ResponseInterface $response, - Throwable $error + Throwable $error, + string $mode = 'page' ) { //load some packages $host = $this->handler->package('host'); @@ -435,12 +444,22 @@ protected function errorDebug( $data['stack'][] = $trace; } + $handlebars->registerHelper('plus', function($x, $y) { + return $x + $y; + }); + + $handlebars->registerHelper('nolines', function($string) { + $string = preg_replace('/\s+/is', ' ', $string); + $string = str_replace('Array ( ', 'Array(', $string); + return str_replace(' ', ' ', $string); + }); + //set the template root $template = __DIR__ . '/template'; $body = $handlebars ->setTemplateFolder($template) - ->renderFromFolder('error', $data); + ->renderFromFolder('debug/' . $mode, $data); //set content $response @@ -448,6 +467,10 @@ protected function errorDebug( ->set('page', 'class', 'page-error') ->setContent($body); + if ($mode === 'spa') { + return; + } + //render page $this->render($request, $response, 'blank'); return true; diff --git a/admin/assets/script/_fields.js b/admin/assets/script/_fields.js index 9d70193..3597cb7 100644 --- a/admin/assets/script/_fields.js +++ b/admin/assets/script/_fields.js @@ -1342,44 +1342,43 @@ * Code Editor - Ace */ $(window).on('code-editor-init', function(e, target) { - $.require.load( - 'components/ace-editor-builds/src/ace.js', - function() { - target = $(target); + $.require.load('components/ace-editor-builds/src/ace.js', function() { + target = $(target); - var mode = target.attr('data-mode'); - var width = target.attr('data-height') || 0; - var height = target.attr('data-height') || 500; + var mode = target.attr('data-mode'); + var width = target.attr('data-height') || 0; + var height = target.attr('data-height') || 500; - var container = $('
') - .addClass('form-control') - .addClass('code-editor-container'); + var container = $('
') + .addClass('form-control') + .addClass('code-editor-container'); - if(width) { - container.width(width); - } + if(width) { + container.width(width); + } - if(height) { - container.height(height); - } + if(height) { + container.height(height); + } - target.after(container); + target.after(container); - var editor = ace.edit(container[0]); + var editor = ace.edit(container[0]); - if(mode) { - // set mode - editor.getSession().setMode('ace/mode/' + mode); - } + if(mode) { + // set mode + editor.getSession().setMode('ace/mode/' + mode); + } - // set editor default value - editor.setValue(target.val()); + // set editor default value + editor.setValue(target.val()); - target.closest('form').submit(function() { - target.val(editor.getValue()); - }); - } - ); + target.closest('form').submit(function() { + target.val(editor.getValue()); + }); + + target.hide(); + }); }); /** diff --git a/admin/assets/style/_form.css b/admin/assets/style/_form.css index aeb4dfd..20f2d95 100644 --- a/admin/assets/style/_form.css +++ b/admin/assets/style/_form.css @@ -13,6 +13,10 @@ .form-mobile .form-group-textarea, .form-mobile .form-group-markdown, .form-mobile .form-group-wysiwyg, +.form-mobile .form-group-image, +.form-mobile .form-group-file, +.form-mobile .form-group-imagelist, +.form-mobile .form-group-filelist, .form-mobile .form-group-fieldset, .form-mobile .form-group.no-flex { border-width: 0; @@ -24,6 +28,10 @@ .form-mobile .form-group-textarea .control-label, .form-mobile .form-group-markdown .control-label, .form-mobile .form-group-wysiwyg .control-label, +.form-mobile .form-group-image .control-label, +.form-mobile .form-group-file .control-label, +.form-mobile .form-group-imagelist .control-label, +.form-mobile .form-group-filelist .control-label, .form-mobile .form-group-fieldset .control-label, .form-mobile .form-group.no-flex .control-label { margin-bottom: 5px; @@ -231,7 +239,8 @@ width: 100% !important; } -.form-mobile .select2-container--default .select2-selection--single, .form-mobile .select2-container--default .select2-selection--multiple { +.form-mobile .select2-container--default .select2-selection--single, +.form-mobile .select2-container--default .select2-selection--multiple { border-width: 0 !important; } diff --git a/admin/assets/style/_theme.css b/admin/assets/style/_theme.css index 7865aff..441195e 100644 --- a/admin/assets/style/_theme.css +++ b/admin/assets/style/_theme.css @@ -500,3 +500,15 @@ a:visited { .form-mobile .ace-tm .ace_gutter-active-line { background-color: #000000; } + +.form-mobile .ace-tm .ace_meta.ace_tag { + color: #F43A80; +} + +.form-mobile .ace-tm .ace_cursor { + color: #929AAD; +} + +.form-mobile .ace_content { + background-color: #000000; +} diff --git a/admin/template/debug/page.html b/admin/template/debug/page.html new file mode 100644 index 0000000..dae3b77 --- /dev/null +++ b/admin/template/debug/page.html @@ -0,0 +1,168 @@ + +
+
+ +
+
+
+ {{date 'now' 'F d, Y g:ia'}} +
+

{{_ 'Oh No! Error Found'}}

+

{{class}} {{message}}

+

{{file}}:{{line}}

+
+
+
+
+ {{#request}} +
Stage Data
+ {{#if stage.length}} + + {{else}} + {{_ 'No Data Found'}} + {{/if}} +
Session Data
+ {{#if session.length}} + + {{else}} + {{_ 'No Data Found'}} + {{/if}} +
POST Data
+ {{#if post.length}} + + {{else}} + {{_ 'No Data Found'}} + {{/if}} +
GET Data
+ {{#if get.length}} + + {{else}} + {{_ 'No Data Found'}} + {{/if}} + {{/request}} +
+ {{#each stack}} +
+
+ #{{step}} + + {{#if class}} + {{class}}{{#if function}}->{{function}}{{/if}} + {{else}} + {{#if function}} + {{function}} + {{/if}} + {{/if}} + +
+ + {{#if class}} + {{class~}}{{#if function}}->{{function}}{{/if~}} + {{else}} + {{#if function}} + {{function~}} + {{/if~}} + {{/if~}} + ( + {{~#if args.length}} + {{~#each args~}} + {{~#if @last}}{{this}}{{else}}{{this}}, {{/if~}} + {{~/each~}} + {{~/if~}} + ); + +
{{_ 'Snippet'}}
+
+ {{file}}:{{line}} +
+ {{#if snippet.length}} +
+{{~#each snippet}}
+{{~#when @key '==' ../line}}{{this}}{{else}}{{this}}{{/when~}}
+{{/each~}}
+              
+ {{/if}} +
+ {{/each}} +
+
+
+
diff --git a/admin/template/debug/spa.html b/admin/template/debug/spa.html new file mode 100644 index 0000000..65b47ad --- /dev/null +++ b/admin/template/debug/spa.html @@ -0,0 +1,41 @@ +{{_ 'Oh No! Error Found'}} + +{{class}}: {{{message}}} +{{file}}:{{line}} +{{#request}} +Stage Data: +{{{jsonify stage 1}}} + +SESSION Data: +{{{jsonify session 1}}} + +POST Data: +{{{jsonify post 1}}} + +GET Data: +{{{jsonify get 1}}} +{{/request}} +Stack Trace: +{{~#each stack}} +#{{step}} - {{file}}:{{line}} +{{#if class~}} + {{~class~}}{{#if function}}->{{function}}{{/if~}} +{{else}} + {{~#if function}} + {{~function~}} + {{/if~}} +{{/if~}} +( + {{~#if args.length~}} + {{~#each args~}} + {{~#if @last}}{{{nolines this}}}{{else}}{{{nolines this}}}, {{/if~}} + {{~/each~}} + {{~/if~}} +); + +{{#if snippet.length}} +{{~#each snippet}} +{{~plus ../start @index}} {{#when @key '==' ../line}}--> {{{this}}}{{else}}{{{this}}}{{/when}} +{{~/each~}} +{{/if~}} +{{/each}} From 5355a71f4ae99fb74abf0d3717f2e393ae036e48 Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Fri, 14 May 2021 16:16:59 +0800 Subject: [PATCH 12/13] fixed JSON prepare methods so sql will like it --- field/File/File.php | 2 +- field/File/FileList.php | 2 +- field/Json/Fieldset.php | 4 ++++ field/Json/Json.php | 18 ++++++++++++++++++ field/Json/LatLng.php | 4 ++++ field/Json/Meta.php | 4 ++++ field/Json/MultiRange.php | 4 ++++ field/Json/Table.php | 4 ++++ field/Json/TextList.php | 4 ++++ 9 files changed, 44 insertions(+), 2 deletions(-) diff --git a/field/File/File.php b/field/File/File.php index 76583df..8aa07d8 100644 --- a/field/File/File.php +++ b/field/File/File.php @@ -89,7 +89,7 @@ class File extends AbstractField implements FieldInterface */ public function prepare($value = null, string $name = null, array $row = []) { - $file = incept('event')->method('file-upload', [ 'data' => $value ]); + $file = incept('event')->call('file-upload', [ 'data' => $value ]); if (!isset($file['data'])) { return $value; diff --git a/field/File/FileList.php b/field/File/FileList.php index b3e8a07..4e1f25d 100644 --- a/field/File/FileList.php +++ b/field/File/FileList.php @@ -70,7 +70,7 @@ class FileList extends AbstractField implements FieldInterface */ public function prepare($value = null, string $name = null, array $row = []) { - $files = incept('event')->method('file-upload', [ 'data' => $value ]); + $files = incept('event')->call('file-upload', [ 'data' => $value ]); if (!isset($files['data'])) { return json_encode($value); diff --git a/field/Json/Fieldset.php b/field/Json/Fieldset.php index d5fd2ee..5c022bf 100644 --- a/field/Json/Fieldset.php +++ b/field/Json/Fieldset.php @@ -79,6 +79,10 @@ class Fieldset extends AbstractField implements FieldInterface */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value)) { + return null; + } + return json_encode($value); } diff --git a/field/Json/Json.php b/field/Json/Json.php index 99be75d..1b1b877 100644 --- a/field/Json/Json.php +++ b/field/Json/Json.php @@ -59,6 +59,24 @@ class Json extends AbstractField implements FieldInterface FormatTypes::TYPE_CUSTOM ]; + /** + * Prepares the value for some sort of insertion + * + * @param ?mixed $value + * @param ?string $name name of the column in the row + * @param ?array $row the row submitted with the value + * + * @return ?scalar + */ + public function prepare($value = null, string $name = null, array $row = []) + { + if (is_null($value) || (is_string($value) && !strlen($value))) { + return null; + } + + return json_encode($value); + } + /** * Renders the field for object forms * diff --git a/field/Json/LatLng.php b/field/Json/LatLng.php index 921f3b4..e3b6bd1 100644 --- a/field/Json/LatLng.php +++ b/field/Json/LatLng.php @@ -38,6 +38,10 @@ class LatLng extends TextList */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value)) { + return null; + } + if (!is_numeric($value[0])) { $value[0] = 0; } diff --git a/field/Json/Meta.php b/field/Json/Meta.php index 0e64edc..f52f91b 100644 --- a/field/Json/Meta.php +++ b/field/Json/Meta.php @@ -49,6 +49,10 @@ class Meta extends Json */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value)) { + return null; + } + return json_encode($value); } diff --git a/field/Json/MultiRange.php b/field/Json/MultiRange.php index e910deb..ab6d682 100644 --- a/field/Json/MultiRange.php +++ b/field/Json/MultiRange.php @@ -38,6 +38,10 @@ class MultiRange extends TextList */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value) || (is_string($value) && !strlen($value))) { + return null; + } + return json_encode(explode(';', $value)); } diff --git a/field/Json/Table.php b/field/Json/Table.php index 00de875..2eb88d8 100644 --- a/field/Json/Table.php +++ b/field/Json/Table.php @@ -50,6 +50,10 @@ class Table extends Json */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value)) { + return null; + } + return json_encode($value); } diff --git a/field/Json/TextList.php b/field/Json/TextList.php index 58a933e..f54faf3 100644 --- a/field/Json/TextList.php +++ b/field/Json/TextList.php @@ -49,6 +49,10 @@ class TextList extends Json */ public function prepare($value = null, string $name = null, array $row = []) { + if (is_null($value)) { + return null; + } + return json_encode($value); } From 7532cd9ec622c9b0fff19e58576c1b1b33f6780d Mon Sep 17 00:00:00 2001 From: Christian Blanquera Date: Fri, 14 May 2021 16:17:55 +0800 Subject: [PATCH 13/13] we can now upload files --- file/FilePackage.php | 10 +++++----- format/Html/template/image.html | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/file/FilePackage.php b/file/FilePackage.php index 083d7be..627fa23 100644 --- a/file/FilePackage.php +++ b/file/FilePackage.php @@ -89,21 +89,21 @@ public function upload( $file = sprintf('/%s.%s', md5(uniqid()), $extension); //if not folder - if (!is_dir($this->upload . $path)) { + if (!is_dir($this->folder . $path)) { //make one - mkdir($folder, 077); + mkdir($this->folder . $path, 077); } //data:mime;base64,data $base64 = substr($data, strpos($data, ',') + 1); - file_put_contents($this->upload . $path . $file, base64_decode($base64)); + file_put_contents($this->folder . $path . $file, base64_decode($base64)); $host = null; if (isset($_SERVER['HTTP_HOST'])) { - $host = $this('host')->name(); + $host = $this->handler->package('host')->name(); } - return $host . $this->uri . $destination; + return $host . $this->uri . $path . $file; } /** diff --git a/format/Html/template/image.html b/format/Html/template/image.html index f4486ae..46803f4 100644 --- a/format/Html/template/image.html +++ b/format/Html/template/image.html @@ -3,7 +3,7 @@ {{#if parameters.0}} width="{{parameters.0}}" {{/if}} - {{#if config.parameters.1}} + {{#if parameters.1}} height="{{parameters.1}}" {{/if}} />