2020-04-21 06:47:26 +12:00
<?php
2021-12-14 22:11:34 +13:00
use Appwrite\Utopia\View;
2020-04-21 06:47:26 +12:00
$collection = $this->getParam('collection', null);
2020-04-28 06:36:21 +12:00
$collections = $this->getParam('collections', []);
2020-04-21 06:47:26 +12:00
$rules = $collection->getAttribute('rules', []);
2020-04-26 08:33:35 +12:00
$key = $this->getParam('key', null);
2020-04-29 20:36:55 +12:00
$type = $this->getParam('type', null);
2020-04-21 06:47:26 +12:00
$parent = $this->getParam('parent', true);
$namespace = $this->getParam('namespace', 'project-document');
2020-04-26 08:33:35 +12:00
$array = $this->getParam('array', false);
2020-04-21 06:47:26 +12:00
?>
<?php if ( $parent ) : ?>
< input name = "documentId" type = "hidden" data-ls-bind = "{{router.params.id}}" / >
< input name = "collectionId" type = "hidden" data-ls-bind = "{{router.params.collection}}" / >
2020-04-22 07:52:32 +12:00
<?php else : ?>
2020-04-26 08:33:35 +12:00
<?php /*< div class = "margin-bottom-small text-size-small" data - ls - if = "({{<?php echo $this->escape ( $namespace ); ?>. $id }})" >
2020-04-22 07:52:32 +12:00
< span data-ls-bind = "Document #{{ <?php echo $this -> escape ( $namespace ); ?> .$id}}" ></ span >
< a data-ls-attrs = "href=/console/database/document?id={{ <?php echo $this -> escape ( $namespace ); ?> .$id}}&collection={{ <?php echo $this -> escape ( $namespace ); ?> .$collection}}&project={{router.params.project}}" class = "pull-end" target = "_blank" > Edit in a new window < i class = "icon-link-ext" ></ i ></ a >
< / div >
< div class = "margin-bottom-small text-size-small" data-ls-if = "(!{{ <?php echo $this -> escape ( $namespace ); ?> .$id}})" >
Create a new child document
2020-04-26 08:33:35 +12:00
< / div > */ ?>
2020-04-21 06:47:26 +12:00
<?php endif ; ?>
2020-04-28 06:36:21 +12:00
< fieldset name = " <?php echo $this -> escape ( $key ); ?> " <?php if ( ! $array ) : ?> data-cast-to = "object" <?php endif ; ?> class = " <?php if ( $type === 'document' ) : ?> info <?php endif ; ?> " >
2020-04-21 06:47:26 +12:00
<?php if ( ! $parent ) : ?>
< input name = "$id" type = "hidden" data-ls-bind = "{{ <?php echo $this -> escape ( $namespace ); ?> .$id}}" />
2020-04-22 07:52:32 +12:00
< input name = "$collection" type = "hidden" data-ls-bind = " <?php echo $this -> escape ( $collection -> getId ()); ?> " />
2020-04-21 06:47:26 +12:00
< input name = "$permissions" type = "hidden" data-ls-bind = "{{ <?php echo $this -> escape ( $namespace ); ?> .$permissions}}" data-cast-to = "json" />
<?php endif ; ?>
2020-04-24 23:24:04 +12:00
2020-04-21 06:47:26 +12:00
< ul >
<?php foreach ( $rules as $rule ) :
2020-10-15 10:34:57 +13:00
$key = $rule['key'] ?? '';
$label = $rule['label'] ?? '';
$type = $rule['type'] ?? '';
$array = $rule['array'] ?? false;
$required = $rule['required'] ?? false;
$list = $rule['list'] ?? false;
2020-04-21 06:47:26 +12:00
$comp = new View(__DIR__.'/rules/'.$type.'.phtml');
$loop = new View(__DIR__.'/rules/array.phtml');
$comp
->setParam('key', $key)
->setParam('array', $array)
->setParam('required', $required)
2020-04-21 20:12:47 +12:00
->setParam('list', $list)
2020-04-21 06:47:26 +12:00
->setParam('namespace', $namespace.'.'.$key)
2020-05-03 07:57:52 +12:00
->setParam('collections', $collections)
2020-04-23 15:25:00 +12:00
;
2020-04-21 06:47:26 +12:00
2020-04-23 15:25:00 +12:00
$loop
2020-04-26 08:33:35 +12:00
->setParam('type', $type)
2020-04-21 06:47:26 +12:00
->setParam('key', $key)
->setParam('array', $array)
->setParam('required', $required)
2020-04-21 20:12:47 +12:00
->setParam('list', $list)
2020-04-21 06:47:26 +12:00
->setParam('namespace', $namespace.'.'.$key)
->setParam('comp', $comp)
2020-04-28 06:36:21 +12:00
->setParam('collections', $collections)
2020-04-21 06:47:26 +12:00
;
?>
< li >
2020-05-04 17:04:30 +12:00
< label class = "margin-bottom-no <?php if ( $type === 'document' ) : ?> margin-top-large <?php endif ; ?> " <?php if ( $parent ) : ?> data-forms-nav-anchor = " <?php echo $this -> escape ( $key ); ?> " <?php endif ; ?> >
2020-04-21 06:47:26 +12:00
<?php echo $this -> escape ( $label ); ?>
<?php if ( $array ) : ?>
2020-04-26 08:33:35 +12:00
< span class = "text-size-small text-fade" > (Array)< / span >
<?php endif ; ?>
<?php if ( $required ) : ?>
2020-04-28 06:36:21 +12:00
< div class = "text-size-xs text-danger text-fade" > required< / div >
2020-04-26 08:33:35 +12:00
<?php endif ; ?>
<?php if ( ! $required ) : ?>
2020-04-28 06:36:21 +12:00
< div class = "text-size-xs text-fade" > optional< / div >
2020-04-21 06:47:26 +12:00
<?php endif ; ?>
< / label >
< div class = "margin-top-small margin-bottom" >
<?php if ( ! $array ) : ?>
<?php echo $comp -> render (); ?>
<?php else : ?>
<?php echo $loop -> render (); ?>
<?php endif ; ?>
< / div >
< / li >
<?php endforeach ; ?>
< / ul >
< / fieldset >