diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 97bb2e474..f64fea205 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -209,43 +209,13 @@ $utopia->get('/console/database/document') $page = new View(__DIR__.'/../../views/console/database/document.phtml'); - $page->setParam('collection', $collection); - - $layout - ->setParam('title', APP_NAME.' - Database Document') - ->setParam('body', $page); - }); - -$utopia->get('/console/database/form') - ->desc('Platform console project database form') - ->label('permission', 'public') - ->label('scope', 'console') - ->param('collection', '', function () { return new UID(); }, 'Collection unique ID.') - ->param('namespace', 'project-document', function () { return new Text(256); }, 'Namespace for vars.', true) - ->param('key', 'data', function () { return new Text(256); }, 'Object main key.', true) - ->param('parent', 1, function () { return new Range(0, 1); }, 'Is parent?.', true) - ->action(function ($collection, $namespace, $key, $parent) use ($layout, $projectDB) { - - Authorization::disable(); - $collection = $projectDB->getDocument($collection, false); - Authorization::reset(); - - if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { - throw new Exception('Collection not found', 404); - } - - $page = new View(__DIR__.'/../../views/console/database/form.phtml'); - $page + ->setParam('db', $projectDB) ->setParam('collection', $collection) - ->setParam('namespace', $namespace) - ->setParam('key', $key) - ->setParam('parent', $parent) ; $layout - ->setPath(__DIR__.'/../../views/layouts/strip.phtml') - ->setParam('title', APP_NAME.' - Database Form') + ->setParam('title', APP_NAME.' - Database Document') ->setParam('body', $page); }); diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 63d8103ad..1ac1454f5 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -180,9 +180,9 @@

+ -
@@ -383,7 +383,6 @@ -
Required
diff --git a/app/views/console/database/document.phtml b/app/views/console/database/document.phtml index 8ef661606..614af7195 100644 --- a/app/views/console/database/document.phtml +++ b/app/views/console/database/document.phtml @@ -1,8 +1,12 @@ getParam('collection', null); +$db = $this->getParam('db', null); $rules = $collection->getAttribute('rules', []); +$namespace = 'project-document'; ?>
getAttribute('rules', []); data-param-collection-id="{{router.params.collection}}" data-param-document-id="{{router.params.id}}" data-scope="sdk" - data-event="load" + data-event="load,database.updateDocument" data-name="project-document" data-success="default"> @@ -58,9 +62,10 @@ $rules = $collection->getAttribute('rules', []); data-name="project-document" data-scope="sdk" data-event="submit" - data-success="alert,trigger" + data-success="alert,trigger{{|documentSuccess}}" data-success-param-alert-text="Updated document successfully" - data-success-param-trigger-events="database.xupdateDocument" + data-success-param-trigger-events="database.updateDocument" + data-success-param-redirect-url="/console/database/document?id={{serviceData.$id}}&collection={{router.params.collection}}&project={{router.params.project}}" data-failure="alert" data-failure-param-alert-text="Failed to update document" data-failure-param-alert-classname="error"> @@ -70,7 +75,7 @@ $rules = $collection->getAttribute('rules', []);
-

No attribute rules added yet.

Update Collection

+

No attribute rules added yet.

Update Collection

getAttribute('rules', []); $comp ->setParam('collection', $collection) - ->setParam('namespace', 'project-document') + ->setParam('namespace', $namespace) ->setParam('key', 'data') ->setParam('parent', 1) ; @@ -155,4 +160,47 @@ $rules = $collection->getAttribute('rules', []);
- \ No newline at end of file + + + + getId()) { + continue; // Do not allow rec recrusion + } + + Authorization::disable(); //TODO Try and avoid calling the DB from the template + $childCollection = $db->getDocument($item, false); + Authorization::reset(); + + if(!$childCollection->getId()) { + continue; + } + ?> + + + \ No newline at end of file diff --git a/app/views/console/database/form.phtml b/app/views/console/database/form.phtml index b220a068e..64911d203 100644 --- a/app/views/console/database/form.phtml +++ b/app/views/console/database/form.phtml @@ -4,26 +4,27 @@ use Utopia\View; $collection = $this->getParam('collection', null); $rules = $collection->getAttribute('rules', []); -$key = $this->getParam('key', 'data'); +$key = $this->getParam('key', null); $parent = $this->getParam('parent', true); $namespace = $this->getParam('namespace', 'project-document'); +$array = $this->getParam('array', false); + ?> -
+escape($namespace); ?>.$id}})">   Edit in a new window
Create a new child document -
-
+ */ ?> -
+
data-cast-to="object"> @@ -50,6 +51,7 @@ $namespace = $this->getParam('namespace', 'project-document'); ; $loop + ->setParam('type', $type) ->setParam('key', $key) ->setParam('array', $array) ->setParam('required', $required) @@ -63,17 +65,17 @@ $namespace = $this->getParam('namespace', 'project-document'); escape($label); ?> -   (Array) +  (Array) + + + +  required + + + +  optional - - -
required
- - - -
optional
-
diff --git a/app/views/console/database/rules/array.phtml b/app/views/console/database/rules/array.phtml index badd73a84..67cefa716 100644 --- a/app/views/console/database/rules/array.phtml +++ b/app/views/console/database/rules/array.phtml @@ -1,10 +1,16 @@ getParam('key', ''); +$type = $this->getParam('type', ''); $required = $this->getParam('required', ''); $comp = $this->getParam('comp', ''); $namespace = $this->getParam('namespace', ''); +$list = $this->getParam('list', []); -$comp->setParam('namespace', 'node.'); +$comp->setParam('namespace', 'node'); + +if($type === 'document') { + $comp->setParam('key', null); +} ?> required data-cast-to="array-empty"> @@ -31,7 +37,7 @@ $comp->setParam('namespace', 'node.'); render(); ?>
- +
- \ No newline at end of file + diff --git a/app/views/console/database/rules/document.phtml b/app/views/console/database/rules/document.phtml index 669668d79..fbc4e9f8f 100644 --- a/app/views/console/database/rules/document.phtml +++ b/app/views/console/database/rules/document.phtml @@ -1,31 +1,19 @@ getParam('key', ''); -$array = $this->getParam('array', false); -$required = $this->getParam('required', ''); $namespace = $this->getParam('namespace', ''); +$array = $this->getParam('array', false); $list = $this->getParam('list', []); $list = (is_array($list)) ? $list : []; $list = ($array) ? $list : array_shift($list); ?> -
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
- - -
- -
- -
\ No newline at end of file +
+ +
+ +
+
+ \ No newline at end of file diff --git a/app/views/console/storage/index.phtml b/app/views/console/storage/index.phtml index 2de3b588a..73ad61a33 100644 --- a/app/views/console/storage/index.phtml +++ b/app/views/console/storage/index.phtml @@ -108,7 +108,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0); - +