Skip to content

Commit

Permalink
Removed redundancies, directly using Propel models and queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sitilge committed Jul 9, 2016
1 parent 8f60340 commit fe7e140
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Templates/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<?php $segment = $url->getSegment(); ?>
<?php foreach ($tables as $name => $phpName) : ?>
<li class="<?php echo $segment === $name ? 'active' : ''; ?>"><a href="<?php echo $url->main($name); ?>"><?php echo $phpName; ?></a></li>
<?php endforeach; ?>
Expand Down
9 changes: 5 additions & 4 deletions src/Templates/Row.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<link rel="stylesheet" href="<?php echo $url->main(); ?>css/dist/row.css">
<script src="<?php echo $url->main(); ?>js/dist/row.js"></script>
<h1 class="page-header">
<span><?php echo $map->getPhpName(); ?></span>
<span><?php echo $query->getTableMap()->getPhpName(); ?></span>
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST') : ?>
<div class="pull-right">
<a class="create-row-button btn btn-success" data-url="<?php echo $url->main($map->getName(), $key); ?>" data-id="<?php echo $key; ?>">Create</a>
<a class="create-row-button btn btn-success" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>" data-id="<?php echo $key; ?>">Create</a>
</div>
<?php elseif ($_SERVER['REQUEST_METHOD'] === 'GET') : ?>
<div class="pull-right">
<?php if (!empty($query->getPropellerTableDelete())) : ?>
<a class="delete-row-button btn btn-danger" data-url="<?php echo $url->main($map->getName(), $key); ?>" data-id="<?php echo $key; ?>">Delete</a>
<a class="delete-row-button btn btn-danger" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>" data-id="<?php echo $key; ?>">Delete</a>
<?php endif; ?>
<?php if (!empty($query->getPropellerTableUpdate())) : ?>
<a class="update-row-button btn btn-primary" data-url="<?php echo $url->main($map->getName(), $key); ?>" data-id="<?php echo $key; ?>">Update</a>
<a class="update-row-button btn btn-primary" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>" data-id="<?php echo $key; ?>">Update</a>
<?php endif; ?>
</div>
<?php endif; ?>
</h1>
<form id="form" action="" method="post" enctype="multipart/form-data">
<?php $columns = $query->getTableMap()->getColumns(); ?>
<?php foreach ($columns as $column) : ?>
<?php $attributes = ''; ?>
<?php if (!empty($properties = $query->getPropellerRowColumnAttributes($column->getName()))) : ?>
Expand Down
14 changes: 8 additions & 6 deletions src/Templates/Table.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<link rel="stylesheet" href="<?php echo $url->main(); ?>css/dist/table.css">
<script src="<?php echo $url->main(); ?>js/dist/table.js"></script>
<h1 class="page-header">
<span><?php echo $map->getPhpName(); ?></span>
<span><?php echo $query->getTableMap()->getPhpName(); ?></span>
<?php if (!empty($query->getPropellerTableCreate())) : ?>
<div class="pull-right">
<a class="create-row-button btn btn-success" data-url="<?php echo $url->main($map->getName()); ?>">Create</a>
<a class="create-row-button btn btn-success" data-url="<?php echo $url->main($query->getTableMap()->getName()); ?>">Create</a>
</div>
<?php endif; ?>
</h1>
Expand All @@ -15,6 +15,7 @@
<table class="table table-striped">
<thead>
<tr class="head">
<?php $columns = $query->getTableMap()->getColumns(); ?>
<?php foreach ($columns as $column) : ?>
<?php if (empty($query->getPropellerTableColumnShow($column->getName()))) : ?>
<?php continue; ?>
Expand All @@ -28,12 +29,13 @@
</thead>
<tbody class="searchable">
<?php foreach ($rows as $index => $row) : ?>
<tr data-id="<?php echo $keys[$index]; ?>">
<?php $key = is_array($row->getPrimaryKey()) ? implode('-', $row->getPrimaryKey()) : $row->getPrimaryKey(); ?>
<tr data-id="<?php echo $key; ?>">
<?php foreach ($columns as $column) : ?>
<?php if (empty($query->getPropellerTableColumnShow($column->getName()))) : ?>
<?php continue; ?>
<?php endif; ?>
<td class="update-row" data-url="<?php echo $url->main($map->getName(), $keys[$index]); ?>">
<td class="update-row" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>">
<?php if ($row->getByName($column->getPhpName()) instanceof DateTime) : ?>
<?php echo htmlentities($row->getByName($column->getPhpName())->format('Y-m-d H:i:s'), ENT_QUOTES); ?>
<?php else : ?>
Expand All @@ -44,10 +46,10 @@
<?php if (!empty($query->getPropellerTableUpdate()) || !empty($query->getPropellerTableDelete())) : ?>
<td class="text-right">
<?php if (!empty($query->getPropellerTableUpdate())) : ?>
<a class="update-row-button glyphicon glyphicon-pencil" data-url="<?php echo $url->main($map->getName(), $keys[$index]); ?>"></a>
<a class="update-row-button glyphicon glyphicon-pencil" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>"></a>
<?php endif; ?>
<?php if (!empty($query->getPropellerTableDelete())) : ?>
<a class="delete-row-button glyphicon glyphicon-remove" data-url="<?php echo $url->main($map->getName(), $keys[$index]); ?>" data-id="<?php echo $keys[$index]; ?>"></a>
<a class="delete-row-button glyphicon glyphicon-remove" data-url="<?php echo $url->main($query->getTableMap()->getName(), $key); ?>" data-id="<?php echo $key; ?>"></a>
<?php endif; ?>
</td>
<?php endif; ?>
Expand Down

0 comments on commit fe7e140

Please sign in to comment.