Skip to content

Commit

Permalink
opening and closing tag editing
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Snowden committed Jan 2, 2019
1 parent 211aee1 commit 41ec405
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
15 changes: 13 additions & 2 deletions app/Libs/Elements/Traits/Formats/TabsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
trait TabsBootstrap
{

protected $name = 'tab';

/**
* @return mixed
*/
public function render()
{
$this->name .= substr( sha1( microtime( true ) ), 0, 5 );
return $this->headerWrapper(
$this->headers()
) .
Expand All @@ -24,7 +27,11 @@ public function render()
*/
protected function headerWrapper( $content )
{
return sprintf( '<ul class="nav nav-tabs" id="myTab" role="tablist">%s</ul>', $content );
return sprintf(
'<ul class="nav nav-tabs" id="%s" role="tablist">%s</ul>',
$this->name,
$content
);
}

/**
Expand All @@ -33,7 +40,11 @@ protected function headerWrapper( $content )
*/
protected function bodyWrapper( $content )
{
return sprintf( '<div class="tab-content" id="myTabContent">%s</div>', $content );
return sprintf(
'<div class="tab-content" id="%sContent">%s</div>',
$this->name,
$content
);
}

/**
Expand Down
20 changes: 20 additions & 0 deletions app/Libs/Layouts/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ protected function body()
$this->valueKeyName(),
$this->valueKeyName(),
$this->valueKeyName(),
$this->valueKeyName(),
$this->valueKeyName(),
$this->valueKeyName()
);
}
Expand Down Expand Up @@ -222,6 +224,24 @@ public function noRowsMessage()
return $this->noResultsMessage;
}

/**
* @param $row
* @return string
*/
public function openingRowTag( $row )
{
return '<tr>';
}

/**
* @param $row
* @return string
*/
public function closingRowTag( $row )
{
return '</tr>';
}

/**
* @param $model
* @param $request
Expand Down
18 changes: 18 additions & 0 deletions app/Libs/Layouts/Table/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,22 @@ public function attributesAsHtml()
return trim( $attributes );
}

/**
* @param $row
* @return string
*/
public function openingTag( $row )
{
return '<td>';
}

/**
* @param $row
* @return string
*/
public function closingTag( $row )
{
return '</td>';
}

}
8 changes: 5 additions & 3 deletions stubs/partials/table_body.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
</tr>
@else
@foreach( $%s->rows() as $row )
<tr>
{!! $%s->openingRowTag( $row ) !!}
@foreach( $%s->columns() as $column )
<td>{!! $column->render( $row ) !!}</td>
{!! $column->openingTag( $row ) !!}
{!! $column->render( $row ) !!}
{!! $column->closingTag( $row ) !!}
@endforeach
</tr>
{!! $%s->closingRowTag( $row ) !!}
@endforeach
@endif

0 comments on commit 41ec405

Please sign in to comment.