Work in progress - db ui
This commit is contained in:
parent
9745f54035
commit
c3ae5c3621
|
@ -2,7 +2,7 @@
|
|||
data-service="database.getCollection"
|
||||
data-param-collection-id="{{router.params.id}}"
|
||||
data-scope="sdk"
|
||||
data-event="load,database.updateCollection"
|
||||
data-event="load,database.updateCollection,database.createAttribute,database.deleteAttribute,database.createIndex,database.deleteIndex"
|
||||
data-name="project-collection">
|
||||
|
||||
<div class="cover">
|
||||
|
@ -50,7 +50,7 @@
|
|||
<input name="search" id="searchDocuments" type="search" autocomplete="off" placeholder="Search" class="margin-bottom-no" data-ls-bind="{{router.params.search}}">
|
||||
</div>
|
||||
<div class="col span-2 desktops-only">
|
||||
<button class="fill" title="Search" aria-label="Search"><i class="icon-search"></i></button>
|
||||
<button class="fill" title="Search" aria-label="Search">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -129,49 +129,213 @@
|
|||
</div>
|
||||
</li>
|
||||
<li data-state="/console/database/collection/attributes?id={{router.params.id}}&project={{router.params.project}}">
|
||||
<h2>Attributes x</h2>
|
||||
<h2>Attributes</h2>
|
||||
|
||||
<span data-ls-bind="{{project-collection.attributes.length}}"></span>
|
||||
<span data-ls-bind="{{project-collection.attributes}}"></span>
|
||||
<span data-ls-bind="{{project-collection}}"></span>
|
||||
<span data-ls-bind="{{project-collection}}">xxx</span>
|
||||
|
||||
<div class="clear">
|
||||
<div data-ls-if="0 == {{project-collection.attributes.length}}" class="box margin-bottom">
|
||||
<div class="clear box margin-bottom">
|
||||
<div data-ls-if="0 == {{project-collection.attributes.length}}">
|
||||
<h3 class="margin-bottom-small text-bold">No Attributes Found</h3>
|
||||
|
||||
<p class="margin-bottom-no">Create your first attribute to get started</p>
|
||||
</div>
|
||||
|
||||
<div class="drop-list pull-start" data-ls-ui-open="" data-button-aria="Choose Platform" data-button-text="Create Attribute" data-button-class="button" data-blur="1">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="link new-attribute-string"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New String Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-integer"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Integer Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-float"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Float Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-boolean"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Boolean Attribute</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<table class="vertical" data-ls-if="0 < {{project-collection.attributes.length}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="100"></th>
|
||||
<th width="140">Attribute ID</th>
|
||||
<th width="100">Type</th>
|
||||
<th width="180">Default</th>
|
||||
<th></th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-ls-loop="project-collection.attributes" data-ls-as="attribute">
|
||||
<tr>
|
||||
<td data-title="Status">
|
||||
<span class="text-size-small text-success"><i class="icon-ok-circled"></i> Ready </span>
|
||||
</td>
|
||||
|
||||
<td data-title="Attribute ID: ">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.$id}}"></span><span class="text-size-small" data-ls-if="{{attribute.size}}" data-ls-bind="({{attribute.size}})"></span>
|
||||
</td>
|
||||
|
||||
<td data-title="Type:">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.type}}"></span>
|
||||
<span class="text-size-small" data-ls-if="{{attribute.array}}">[]</span>
|
||||
</td>
|
||||
|
||||
<td data-title="Default:">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.default}}" data-ls-attr="title={{attribute.default}}"></span>
|
||||
<span class="text-fade text-size-small" data-ls-if="!({{attribute.default}})">n/a</span>
|
||||
</td>
|
||||
|
||||
<td data-title="">
|
||||
<span class="text-size-small text-danger" data-ls-if="{{attribute.required}}">Required *</span>
|
||||
</td>
|
||||
|
||||
<td data-title="">
|
||||
<form class="pull-end"
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Delete Collection Attribute"
|
||||
data-service="database.deleteAttribute"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-confirm="Are you sure you want to delete this attribute?"
|
||||
data-success="alert,trigger"
|
||||
data-success-param-alert-text="Deleted attribute successfully"
|
||||
data-success-param-trigger-events="database.deleteAttribute"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to delete attribute"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="collectionId" data-ls-bind="{{project-collection.$id}}" />
|
||||
<input type="hidden" name="attributeId" data-ls-bind="{{attribute.$id}}" />
|
||||
|
||||
<button class="danger small">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr data-ls-if="0 < {{project-collection.attributesInQueue.length}}" />
|
||||
|
||||
<table class="vertical" data-ls-if="0 < {{project-collection.attributesInQueue.length}}">
|
||||
<tbody data-ls-loop="project-collection.attributesInQueue" data-ls-as="attribute">
|
||||
<tr>
|
||||
<td width="100" data-title="Status">
|
||||
<span class="text-size-small text-info"><i class="icon-cog"></i> Creating </span>
|
||||
</td>
|
||||
|
||||
<td width="140" data-title="Attribute ID: ">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.$id}}"></span><span class="text-size-small" data-ls-if="{{attribute.size}}" data-ls-bind="({{attribute.size}})"></span>
|
||||
</td>
|
||||
|
||||
<td width="100" data-title="Type:">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.type}}"></span>
|
||||
<span class="text-size-small" data-ls-if="{{attribute.array}}">[]</span>
|
||||
</td>
|
||||
|
||||
<td width="180" data-title="Default:">
|
||||
<span class="text-size-small" data-ls-bind="{{attribute.default}}" data-ls-attr="title={{attribute.default}}"></span>
|
||||
<span class="text-fade text-size-small" data-ls-if="!({{attribute.default}})">n/a</span>
|
||||
</td>
|
||||
|
||||
<td data-title="">
|
||||
<span class="text-size-small text-danger" data-ls-if="{{attribute.required}}">Required *</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="drop-list pull-start" data-ls-ui-open="" data-button-aria="Choose Platform" data-button-text="Create Attribute" data-button-class="button" data-blur="1">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="link new-attribute-string"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New String Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-integer"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Integer Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-float"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Float Attribute</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="link new-attribute-boolean"><img src="/images/clients/web.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="String Attribute Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Boolean Attribute</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li data-state="/console/database/collection/indexes?id={{router.params.id}}&project={{router.params.project}}">
|
||||
<h2>Indexes</h2>
|
||||
</li>
|
||||
<li data-state="/console/database/collection/indexes?id={{router.params.id}}&project={{router.params.project}}">
|
||||
<h2>Queue</h2>
|
||||
|
||||
<div data-ls-if="0 == {{project-documents.sum}}" class="box margin-bottom">
|
||||
<h3 class="margin-bottom-small text-bold">No Attributes Found in the Queue</h3>
|
||||
<div class="clear box margin-bottom">
|
||||
<div data-ls-if="0 == {{project-collection.indexes.length}}">
|
||||
<h3 class="margin-bottom-small text-bold">No Indexes Found</h3>
|
||||
|
||||
<p class="margin-bottom-no">Create your first index to get started</p>
|
||||
</div>
|
||||
|
||||
<p class="margin-bottom-no">Create your first attribute to get started</p>
|
||||
<table class="vertical" data-ls-if="0 < {{project-collection.indexes.length}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="100"></th>
|
||||
<th width="140">Index ID</th>
|
||||
<th width="100">Type</th>
|
||||
<th width="180">Default</th>
|
||||
<th></th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-ls-loop="project-collection.indexes" data-ls-as="index">
|
||||
<tr>
|
||||
<td data-title="Status">
|
||||
<span class="text-size-small text-success"><i class="icon-ok-circled"></i> Ready </span>
|
||||
</td>
|
||||
|
||||
<td data-title="Index ID: ">
|
||||
<span class="text-size-small" data-ls-bind="{{index.$id}}"></span><span class="text-size-small" data-ls-if="{{index.size}}" data-ls-bind="({{index.size}})"></span>
|
||||
</td>
|
||||
|
||||
<td data-title="Type:">
|
||||
<span class="text-size-small" data-ls-bind="{{index.type}}"></span>
|
||||
<span class="text-size-small" data-ls-if="{{index.array}}">[]</span>
|
||||
</td>
|
||||
|
||||
<td data-title="Default:">
|
||||
<span class="text-size-small" data-ls-bind="{{index.default}}" data-ls-attr="title={{index.default}}"></span>
|
||||
<span class="text-fade text-size-small" data-ls-if="!({{index.default}})">n/a</span>
|
||||
</td>
|
||||
|
||||
<td data-title="">
|
||||
<span class="text-size-small text-danger" data-ls-if="{{index.required}}">Required *</span>
|
||||
</td>
|
||||
|
||||
<td data-title="">
|
||||
<form class="pull-end"
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Delete Collection Index"
|
||||
data-service="database.deleteIndex"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-confirm="Are you sure you want to delete this index?"
|
||||
data-success="alert,trigger"
|
||||
data-success-param-alert-text="Deleted index successfully"
|
||||
data-success-param-trigger-events="database.deleteIndex"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to delete index"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="collectionId" data-ls-bind="{{project-collection.$id}}" />
|
||||
<input type="hidden" name="attributeId" data-ls-bind="{{attribute.$id}}" />
|
||||
|
||||
<button class="danger small">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr data-ls-if="0 < {{project-collection.indexesInQueue.length}}" />
|
||||
|
||||
<table class="vertical" data-ls-if="0 < {{project-collection.indexesInQueue.length}}">
|
||||
<tbody data-ls-loop="project-collection.indexesInQueue" data-ls-as="index">
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="new-index">New Index</button>
|
||||
</li>
|
||||
<li data-state="/console/database/collection/settings?id={{router.params.id}}&project={{router.params.project}}">
|
||||
<h2>Settings</h2>
|
||||
|
@ -258,6 +422,116 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div data-ui-modal class="modal box close sticky-footer" data-button-alias=".new-attribute-string">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Create a String Attribute</h1>
|
||||
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Create Collection Attribute (string)"
|
||||
data-service="database.createStringAttribute"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Created new attribute successfully"
|
||||
data-success-param-trigger-events="database.createAttribute"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to create attribute"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="collectionId" data-ls-bind="{{router.params.id}}" />
|
||||
|
||||
<label for="string-attributeId">Attribute ID</label>
|
||||
<input type="text" class="full-width" name="attributeId" required autocomplete="off" maxlength="128" />
|
||||
|
||||
<label for="string-length">Size</label>
|
||||
<input id="string-length" name="size" type="number" class="margin-bottom" autocomplete="off" required value="255" data-cast-to="integer" />
|
||||
|
||||
<div class="margin-bottom">
|
||||
<input name="required" type="hidden" data-forms-switch data-cast-to="boolean" /> Required <span class="tooltip" data-tooltip="Mark whether this is a required attribute"><i class="icon-info-circled"></i></span>
|
||||
</div>
|
||||
|
||||
<div class="margin-bottom">
|
||||
<input name="array" type="hidden" data-forms-switch data-cast-to="boolean" /> Array <span class="tooltip" data-tooltip="Mark whether this attribute should act as an array"><i class="icon-info-circled"></i></span>
|
||||
</div>
|
||||
|
||||
<label for="string-default">Default Value</label>
|
||||
<input id="string-default" name="default" type="number" class="margin-bottom-large" autocomplete="off">
|
||||
|
||||
<footer>
|
||||
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Back</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div data-ui-modal class="modal box close sticky-footer" data-button-alias=".new-index">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Create Index</h1>
|
||||
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Create Collection Index"
|
||||
data-service="database.createIndex"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Created new index successfully"
|
||||
data-success-param-trigger-events="database.createIndex"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to create index"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="collectionId" data-ls-bind="{{router.params.id}}" />
|
||||
|
||||
<label for="index-indexId">Index ID</label>
|
||||
<input id="index-indexId" type="text" class="full-width" name="indexId" required autocomplete="off" maxlength="128" />
|
||||
|
||||
<label for="index-type">Type</label>
|
||||
<select id="index-type" name="type">
|
||||
<option value="key">Key</option>
|
||||
<option value="unique">Unique</option>
|
||||
<option value="fulltext">Fulltext</option>
|
||||
</select>
|
||||
|
||||
<label>Attributes</label>
|
||||
|
||||
<div class="margin-bottom">
|
||||
<div data-forms-clone="" data-label="Add Attribute" data-first="1">
|
||||
<div class="row responsive thin margin-bottom-tiny">
|
||||
<div class="col span-7 margin-bottom-small">
|
||||
<select data-duplications data-ls-attrs="name=attributes" data-ls-loop="project-collection.attributes" data-ls-as="option" data-cast-to="array" class="margin-bottom-no">
|
||||
<option data-ls-attrs="value={{option.$id}}" data-ls-bind="{{option.$id}}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col span-4 margin-bottom-small">
|
||||
<select name="orders" data-cast-to="array" class="margin-bottom-no">
|
||||
<option value="ASC">ASC</option>
|
||||
<option value="DESC">DESC</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col span-1 margin-bottom-small">
|
||||
<button type="button" data-remove class="dark danger small round pull-end" style="margin-top: 10px;"><i class="icon-cancel"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Back</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="margin-top"
|
||||
|
@ -265,53 +539,4 @@
|
|||
data-event="load,database.createCollection,database.updateCollection,database.deleteCollection"
|
||||
data-scope="sdk"
|
||||
data-name="project-collections">
|
||||
</div>
|
||||
|
||||
|
||||
<div data-ui-modal class="modal box close sticky-footer" data-button-alias=".new-attribute-string">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Create a String Attribute</h1>
|
||||
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Create Collection Attribute (string)"
|
||||
data-service="database.createStringAttribute"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Created new attribute successfully"
|
||||
data-success-param-trigger-events="database.createStringAttribute"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to create attribute"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="collectionId" data-ls-bind="{{router.params.id}}" />
|
||||
<input type="hidden" name="type" data-ls-bind="web" />
|
||||
|
||||
<label for="string-attributeId">Attribute ID</label>
|
||||
<input type="text" class="full-width" name="attributeId" required autocomplete="off" maxlength="128" />
|
||||
|
||||
<label for="string-length">Size</label>
|
||||
<input id="string-length" name="size" type="number" class="margin-bottom" autocomplete="off" required value="255" data-cast-to="integer" />
|
||||
|
||||
<div class="margin-bottom">
|
||||
<input name="required" type="hidden" data-forms-switch data-cast-to="boolean" /> Required <span class="tooltip" data-tooltip="Mark whether this is a required attribute"><i class="icon-info-circled"></i></span>
|
||||
</div>
|
||||
|
||||
<div class="margin-bottom">
|
||||
<input name="array" type="hidden" data-forms-switch data-cast-to="boolean" /> Array <span class="tooltip" data-tooltip="Mark whether this attribute should act as an array"><i class="icon-info-circled"></i></span>
|
||||
</div>
|
||||
|
||||
<label for="string-default">Default Value</label>
|
||||
<input id="string-default" name="default" type="number" class="margin-bottom-large" autocomplete="off">
|
||||
|
||||
<footer>
|
||||
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Back</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
|
@ -1,253 +1,70 @@
|
|||
<?php
|
||||
|
||||
use Appwrite\Database\Database;
|
||||
use Utopia\View;
|
||||
use Appwrite\Database\Validator\Authorization;
|
||||
|
||||
$collection = $this->getParam('collection', null);
|
||||
$searchFiles = $this->getParam('searchFiles', null);
|
||||
$searchDocuments = $this->getParam('searchDocuments', null);
|
||||
$name = $collection->getAttribute('name', '');
|
||||
$db = $this->getParam('db', null);
|
||||
$rules = $collection->getAttribute('rules', []);
|
||||
$namespace = 'project-document';
|
||||
$collections = [];
|
||||
?>
|
||||
|
||||
<?php echo $searchFiles->render(); ?>
|
||||
|
||||
<?php foreach($rules as $rule): // Form to append child document
|
||||
$key = $rule['key'] ?? '';
|
||||
$label = $rule['label'] ?? '';
|
||||
$type = $rule['type'] ?? '';
|
||||
$list = $rule['list'] ?? [];
|
||||
?>
|
||||
<?php foreach($list as $item):
|
||||
if($item === $collection->getId()) {
|
||||
continue; // Do not allow rec recrusion
|
||||
}
|
||||
|
||||
if(!isset($collections[$item])) {
|
||||
Authorization::disable(); //TODO Try and avoid calling the DB from the template
|
||||
$collections[$item] = $db->getDocument($item, false);
|
||||
Authorization::reset();
|
||||
}
|
||||
|
||||
$childCollection = $collections[$item];
|
||||
|
||||
if(!$childCollection->getId() || $childCollection->getCollection() !== Database::SYSTEM_COLLECTION_COLLECTIONS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$searchDocuments
|
||||
->setParam('collection', $childCollection)
|
||||
;
|
||||
|
||||
echo $searchDocuments->render(); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach($rules as $rule): // Form to append child document
|
||||
$key = $rule['key'] ?? '';
|
||||
$label = $rule['label'] ?? '';
|
||||
$type = $rule['type'] ?? '';
|
||||
$list = $rule['list'] ?? [];
|
||||
$array = $rule['array'] ?? false;
|
||||
?>
|
||||
|
||||
<?php if($type !== 'document' && $array): ?>
|
||||
|
||||
<form class="margin-bottom-no"
|
||||
data-service="container.path"
|
||||
data-event="collection-child-<?php echo $this->escape($namespace.'.'.$key); ?>"
|
||||
data-scope="window.ls"
|
||||
data-success="reset">
|
||||
|
||||
<input type="hidden" name="path" value="<?php echo $this->escape($namespace.'.'.$key); ?>" />
|
||||
<input type="hidden" name="type" value="append" />
|
||||
<input type="hidden" name="value" value="" />
|
||||
</form>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($type !== 'document'): ?>
|
||||
<?php continue; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach($list as $item):
|
||||
if($item === $collection->getId()) {
|
||||
continue; // Do not allow rec recrusion
|
||||
}
|
||||
|
||||
if(!isset($collections[$item])) {
|
||||
Authorization::disable(); //TODO Try and avoid calling the DB from the template
|
||||
$collections[$item] = $db->getDocument($item, false);
|
||||
Authorization::reset();
|
||||
}
|
||||
|
||||
$childCollection = $collections[$item];
|
||||
|
||||
if(!$childCollection->getId() || $childCollection->getCollection() !== Database::SYSTEM_COLLECTION_COLLECTIONS) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<form class="margin-bottom-no"
|
||||
data-service="container.path"
|
||||
data-event="collection-child-<?php echo $this->escape($namespace.'.'.$key); ?>-<?php echo $this->escape($childCollection->getId()); ?>"
|
||||
data-scope="window.ls"
|
||||
data-success="reset">
|
||||
|
||||
<input type="hidden" name="path" value="<?php echo $this->escape($namespace.'.'.$key); ?>" />
|
||||
<input type="hidden" name="type" value="append" />
|
||||
|
||||
<fieldset name="value" data-cast-to="object">
|
||||
<input name="$id" type="hidden" value="" />
|
||||
<input name="$collection" type="hidden" value="<?php echo $this->escape($childCollection->getId()); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<script type="text/html" id="collection-<?php echo ($array) ? 'array-' : ''; ?><?php echo $this->escape($childCollection->getId()); ?>">
|
||||
<?php
|
||||
|
||||
$comp = new View(__DIR__.'/form.phtml');
|
||||
|
||||
$comp
|
||||
->setParam('collection', $childCollection)
|
||||
->setParam('namespace', ($array) ? 'node' : $namespace.'.'.$key)
|
||||
->setParam('key', $key)
|
||||
->setParam('array', $array)
|
||||
->setParam('parent', 0)
|
||||
;
|
||||
|
||||
echo $comp->render();
|
||||
?>
|
||||
</script>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach($rules as $rule): // Form to remove array $index key
|
||||
$key = $rule['key'] ?? '';
|
||||
$label = $rule['label'] ?? '';
|
||||
$type = $rule['type'] ?? '';
|
||||
$list = $rule['list'] ?? false;
|
||||
$array = $rule['array'] ?? false;
|
||||
|
||||
if(!$array) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<ul data-ls-loop="<?php echo $this->escape($namespace.'.'.$key); ?>" data-ls-as="xxx">
|
||||
<li>
|
||||
<form
|
||||
data-service="container.path"
|
||||
data-event="splice-<?php echo $this->escape($namespace.'.'.$key); ?>-{{$index}}"
|
||||
data-scope="window.ls"
|
||||
data-success="reset">
|
||||
|
||||
<input type="hidden" name="path" value="<?php echo $this->escape($namespace.'.'.$key); ?>" />
|
||||
<input type="hidden" name="type" value="splice" />
|
||||
<input type="hidden" name="value" data-ls-bind="{{$index}}" />
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div
|
||||
data-service="database.getDocument"
|
||||
data-service="database.getCollection"
|
||||
data-param-collection-id="{{router.params.collection}}"
|
||||
data-param-document-id="{{router.params.id}}"
|
||||
data-scope="sdk"
|
||||
data-event="load,database.updateDocument"
|
||||
data-name="project-document"
|
||||
data-success="default">
|
||||
data-event="load,database.updateCollection"
|
||||
data-name="project-collection">
|
||||
|
||||
<div
|
||||
data-service="database.getDocument"
|
||||
data-param-collection-id="{{router.params.collection}}"
|
||||
data-param-document-id="{{router.params.id}}"
|
||||
data-scope="sdk"
|
||||
data-event="load,database.updateDocument"
|
||||
data-name="project-document"
|
||||
data-success="default">
|
||||
|
||||
<div class="cover">
|
||||
<h1 class="zone xl margin-bottom-large">
|
||||
<a data-ls-attrs="href=/console/database/collection?id={{router.params.collection}}&project={{router.params.project}}" class="back text-size-small link-return-animation--start"><i class="icon-left-open"></i> <?php echo $this->escape($name); ?></a>
|
||||
<div class="cover">
|
||||
<h1 class="zone xl margin-bottom-large">
|
||||
<a data-ls-attrs="href=/console/database/collection?id={{router.params.collection}}&project={{router.params.project}}" class="back text-size-small link-return-animation--start"><i class="icon-left-open"></i> <span data-ls-bind="{{project-collection.name}}"></span></a>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<span data-ls-if="({{project-document.$id}})" data-ls-bind="Document"> </span>
|
||||
<span data-ls-if="(!{{project-document.$id}})" data-ls-bind="Document"> </span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div data-ui-modal class="modal width-large box close" data-button-hide="on" data-open-event="open-json">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h2>JSON View</h2>
|
||||
|
||||
<div class="margin-bottom">
|
||||
<input type="hidden" data-ls-bind="{{project-document}}" data-forms-code />
|
||||
<span data-ls-if="({{project-document.$id}})" data-ls-bind="Document"> </span>
|
||||
<span data-ls-if="(!{{project-document.$id}})" data-ls-bind="Document"> </span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
||||
</div>
|
||||
<div data-ui-modal class="modal width-large box close" data-button-hide="on" data-open-event="open-json">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h2>JSON View</h2>
|
||||
|
||||
<div class="zone xl margin-bottom-no">
|
||||
<ul class="phases clear" data-ui-phases data-selected="{{router.params.tab}}">
|
||||
<li data-state="/console/database/document?id={{router.params.id}}&collection={{router.params.collection}}&project={{router.params.project}}">
|
||||
<h2>Update</h2>
|
||||
<div class="margin-bottom">
|
||||
<input type="hidden" data-ls-bind="{{project-document}}" data-forms-code />
|
||||
</div>
|
||||
|
||||
<div class="row responsive margin-top-negative">
|
||||
<div class="col span-8 margin-bottom">
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Update Database Document"
|
||||
data-service="{{|documentAction}}"
|
||||
data-name="project-document"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger{{|documentSuccess}}"
|
||||
data-success-param-alert-text="Updated document successfully"
|
||||
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">
|
||||
<button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
||||
</div>
|
||||
|
||||
<label> </label>
|
||||
<div class="zone xl margin-bottom-no">
|
||||
<ul class="phases clear" data-ui-phases data-selected="{{router.params.tab}}">
|
||||
<li data-state="/console/database/document?id={{router.params.id}}&collection={{router.params.collection}}&project={{router.params.project}}">
|
||||
<h2>Update</h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="row responsive margin-top-negative">
|
||||
<div class="col span-8 margin-bottom">
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Update Database Document"
|
||||
data-service="{{|documentAction}}"
|
||||
data-name="project-document"
|
||||
data-scope="sdk"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger{{|documentSuccess}}"
|
||||
data-success-param-alert-text="Updated document successfully"
|
||||
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">
|
||||
|
||||
<!-- <div class="document-nav" data-forms-nav>
|
||||
<ul class="text-align-end margin-end-small">
|
||||
<?php foreach($rules as $rule): // Form to append child document
|
||||
$key = $rule['key'] ?? '';
|
||||
$label = $rule['label'] ?? '';
|
||||
$type = $rule['type'] ?? '';
|
||||
$list = $rule['list'] ?? [];
|
||||
?>
|
||||
<li class="text-size-small">
|
||||
<span class="link text-fade" data-forms-nav-link="<?php echo $this->escape($key); ?>"><?php echo $this->escape($label); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div> -->
|
||||
|
||||
<?php if(empty($rules)): ?>
|
||||
<div class="margin-bottom-xl margin-top-xl margin-end margin-start text-align-center">
|
||||
<h4 class="text-fade text-size-small">No attribute rules added yet.<br /><br /><a data-ls-attrs="href=/console/database/collection/settings?id={{router.params.collection}}&project={{router.params.project}}">Update Collection</a></h4>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
|
||||
$comp = new View(__DIR__.'/form.phtml');
|
||||
|
||||
$comp
|
||||
->setParam('collection', $collection)
|
||||
->setParam('collections', $collections)
|
||||
->setParam('namespace', $namespace)
|
||||
->setParam('key', 'data')
|
||||
->setParam('parent', 1)
|
||||
;
|
||||
|
||||
echo $comp->render();
|
||||
?>
|
||||
<label> </label>
|
||||
|
||||
<div class="box">
|
||||
<div class="toggle margin-bottom" data-ls-ui-open data-button-aria="Open Permissions">
|
||||
<i class="icon-plus pull-end margin-top-tiny"></i>
|
||||
<i class="icon-minus pull-end margin-top-tiny"></i>
|
||||
|
@ -265,58 +82,58 @@ $collections = [];
|
|||
|
||||
<button data-ls-if="({{project-document.$id}})">Update</button>
|
||||
<button data-ls-if="(!{{project-document.$id}})">Create</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="col span-4 sticky-top">
|
||||
|
||||
<div data-ls-if="({{project-document.$id}})">
|
||||
<label>Document ID</label>
|
||||
<div class="input-copy margin-bottom">
|
||||
<input type="text" autocomplete="off" placeholder="" data-ls-bind="{{project-document.$id}}" disabled data-forms-copy class="margin-bottom-no" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Collection ID</label>
|
||||
<div class="input-copy margin-bottom">
|
||||
<input type="text" autocomplete="off" placeholder="" data-ls-bind="{{router.params.collection}}" disabled data-forms-copy class="margin-bottom-no" />
|
||||
</div>
|
||||
|
||||
<ul class="margin-bottom-large text-fade text-size-small" data-ls-if="({{project-document.$id}})">
|
||||
<li class="margin-bottom-small"><i class="icon-angle-circled-right margin-start-tiny margin-end-tiny"></i> <button data-ls-ui-trigger="open-json" class="link text-size-small">View as JSON</button></li>
|
||||
</ul>
|
||||
|
||||
<div data-ls-if="({{project-document.$id}})">
|
||||
<form name="database.deleteDocument" class="margin-bottom"
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Delete Collection Document"
|
||||
data-service="database.deleteDocument"
|
||||
data-event="submit"
|
||||
data-param-collection-id="{{router.params.collection}}"
|
||||
data-param-document-id="{{project-document.$id}}"
|
||||
data-confirm="Are you sure you want to delete this document?"
|
||||
data-success="alert,trigger,redirect"
|
||||
data-success-param-alert-text="Document deleted successfully"
|
||||
data-success-param-trigger-events="database.deleteDocument"
|
||||
data-success-param-redirect-url="/console/database/collection?id={{router.params.collection}}&project={{router.params.project}}"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to delete collection"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<button type="submit" class="danger fill">Delete Document</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col span-4 sticky-top">
|
||||
|
||||
<div data-ls-if="({{project-document.$id}})">
|
||||
<label>Document ID</label>
|
||||
<div class="input-copy margin-bottom">
|
||||
<input type="text" autocomplete="off" placeholder="" data-ls-bind="{{project-document.$id}}" disabled data-forms-copy class="margin-bottom-no" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Collection ID</label>
|
||||
<div class="input-copy margin-bottom">
|
||||
<input type="text" autocomplete="off" placeholder="" data-ls-bind="{{router.params.collection}}" disabled data-forms-copy class="margin-bottom-no" />
|
||||
</div>
|
||||
|
||||
<ul class="margin-bottom-large text-fade text-size-small" data-ls-if="({{project-document.$id}})">
|
||||
<li class="margin-bottom-small"><i class="icon-angle-circled-right margin-start-tiny margin-end-tiny"></i> <button data-ls-ui-trigger="open-json" class="link text-size-small">View as JSON</button></li>
|
||||
</ul>
|
||||
|
||||
<div data-ls-if="({{project-document.$id}})">
|
||||
<form name="database.deleteDocument" class="margin-bottom"
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Delete Collection Document"
|
||||
data-service="database.deleteDocument"
|
||||
data-event="submit"
|
||||
data-param-collection-id="{{router.params.collection}}"
|
||||
data-param-document-id="{{project-document.$id}}"
|
||||
data-confirm="Are you sure you want to delete this document?"
|
||||
data-success="alert,trigger,redirect"
|
||||
data-success-param-alert-text="Document deleted successfully"
|
||||
data-success-param-trigger-events="database.deleteDocument"
|
||||
data-success-param-redirect-url="/console/database/collection?id={{router.params.collection}}&project={{router.params.project}}"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to delete collection"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<button type="submit" class="danger fill">Delete Document</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<!-- <li data-ls-if="{{project-document.$id}}" data-state="/console/database/document/activity?id={{router.params.id}}&collection={{router.params.collection}}&project={{router.params.project}}">
|
||||
<h2>Activity</h2>
|
||||
</li> -->
|
||||
</ul>
|
||||
</li>
|
||||
<!-- <li data-ls-if="{{project-document.$id}}" data-state="/console/database/document/activity?id={{router.params.id}}&collection={{router.params.collection}}&project={{router.params.project}}">
|
||||
<h2>Activity</h2>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue