Initial import of tasks application
This initial import is a heavily modified version of the code I had here, as Arse was modified for other purposes in the meantime and the application no longer worked with it. In addition: * I did not import the user management part yet, * task dependencies are supported in-base, but there is no interface for that yet.
This commit is contained in:
commit
9677ad4dd3
36 changed files with 3919 additions and 0 deletions
includes/t-items
96
includes/t-items/views.inc.php
Normal file
96
includes/t-items/views.inc.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
class View_ItemsTree
|
||||
extends BaseURLAwareView
|
||||
{
|
||||
private $tree;
|
||||
private $minDepth;
|
||||
|
||||
public function __construct( $tree )
|
||||
{
|
||||
$this->tree = $tree;
|
||||
if ( ! empty( $tree ) ) {
|
||||
$this->minDepth = $tree[ 0 ]->depth;
|
||||
} else {
|
||||
$this->minDepth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function render( )
|
||||
{
|
||||
if ( empty( $this->tree ) ) {
|
||||
return HTML::make( 'div' )
|
||||
->setAttribute( 'class' , 'no-table' )
|
||||
->appendText( 'No items have been defined.' );
|
||||
}
|
||||
|
||||
$table = HTML::make( 'table' )
|
||||
->appendElement( HTML::make( 'tr' )
|
||||
->setAttribute( 'class' , 'header' )
|
||||
->appendElement( HTML::make( 'th' )
|
||||
->appendText( 'Item name' ) )
|
||||
->appendElement( HTML::make( 'th' )
|
||||
->setAttribute( 'class' , 'align-right' )
|
||||
->appendText( 'Tasks' ) ) );
|
||||
foreach ( $this->tree as $item ) {
|
||||
$this->renderItem( $table , $item );
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
|
||||
private function renderItem( $table , $item )
|
||||
{
|
||||
$children = Loader::DAO( 'items' )->getAll( $item->children );
|
||||
$padding = 5 + ( $item->depth - $this->minDepth ) * 16;
|
||||
$table->appendElement( HTML::make( 'tr' )
|
||||
->appendElement( HTML::make( 'td' )
|
||||
->setAttribute( 'style' , 'padding-left:' . $padding . 'px' )
|
||||
->appendElement( HTML::make( 'a' )
|
||||
->setAttribute( 'href' , $this->base . '/items/view?id=' . $item->id )
|
||||
->appendText( $item->name ) ) )
|
||||
->appendElement( HTML::make( 'td' )
|
||||
->setAttribute( 'class' , 'align-right' )
|
||||
->appendRaw( (int) $item->activeTasks ) ) );
|
||||
|
||||
foreach ( $children as $child ) {
|
||||
$this->renderItem( $table , $child );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class View_ItemDetails
|
||||
extends BaseURLAwareView
|
||||
{
|
||||
private $item;
|
||||
|
||||
public function __construct( Data_Item $item )
|
||||
{
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
public function render( )
|
||||
{
|
||||
$items = Loader::DAO( 'items' );
|
||||
|
||||
$contents = array( );
|
||||
if ( empty( $this->item->lineage ) ) {
|
||||
array_push( $contents , HTML::make( 'em' ) ->appendText( 'None' ) );
|
||||
} else {
|
||||
foreach ( $items->getAll( $this->item->lineage ) as $ancestor ) {
|
||||
if ( ! empty( $contents ) ) {
|
||||
array_push( $contents , ' » ' );
|
||||
}
|
||||
array_push( $contents , HTML::make( 'a' )
|
||||
->setAttribute( 'href' , $this->base . '/items/view?id=' . $ancestor->id )
|
||||
->appendText( $ancestor->name ) );
|
||||
}
|
||||
}
|
||||
|
||||
return HTML::make( 'dl' )
|
||||
->appendElement( HTML::make( 'dt' )->appendText( 'Path:' ) )
|
||||
->appendElement( HTML::make( 'dd' )
|
||||
->setAttribute( 'style' , 'font-size: 10pt' )
|
||||
->append( $contents ) );
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue