Skip to content

Commit

Permalink
ajout de la description dans une colonne du table
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Houvion committed Jul 7, 2016
1 parent fb46d40 commit cd2a2b0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
51 changes: 51 additions & 0 deletions src/Table/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ abstract class Column
protected $visible = true;


/**
* Description de la colonne
*
* @var
*/
protected $description;


/**
* Setter for $width attribute
*
Expand Down Expand Up @@ -460,4 +468,47 @@ public function isVisible($row = null)
$callable = !is_bool($this->visible) && !is_string($this->visible) && is_callable($this->visible);
return (bool) ($callable ? call_user_func($this->visible, $this, $row) : $this->visible);
}



/**
* Setter for $description
*
* @param $description
*/
public function setDescription($description)
{
$this->description = $description;
}

/**
* getter for $description
*
* @return mixed
*/
public function getDescription()
{
return $this->description;
}

/**
* Return TRUE is $description is set
*
* @return bool
*/
public function hasDescription()
{
return isset($this->description);
}

/**
* Unset $description
*
* @return $this
*/
public function removeDescription()
{
unset($this->description);
return $this;
}
}
6 changes: 5 additions & 1 deletion src/Table/Renderer/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public function table(Table\Table $table)
$hasStrainer = false;
foreach($table->getColumns() as $column) {
/** @var Column\Column $column */
$head .= html('th', ['class' => 'text-center'], $column->getLabel());
$label = $column->getLabel();
if ($column->hasDescription()) {
$label .= ' <i class="fa fa-question-circle" data-toggle="tooltip" title="'.$column->getDescription().'"></i>';
}
$head .= html('th', ['class' => 'text-center'], $label);
$headers[] = $column->getName();
$hasStrainer = $hasStrainer || $column->hasStrainer();
}
Expand Down

0 comments on commit cd2a2b0

Please sign in to comment.