Skip to content

Commit

Permalink
Columns: Added a class editable if cell is editable [Closes #230]
Browse files Browse the repository at this point in the history
  • Loading branch information
o5 committed Nov 1, 2015
1 parent e2e053e commit c92a2ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/Components/Columns/Editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public function getCellPrototype($row = NULL)
$td = parent::getCellPrototype($row);

if ($this->isEditable() && $row !== NULL) {
if (!in_array('editable', $td->class)) {
$td->class[] = 'editable';
}

$td->data['grido-editable-value'] = $this->editableValueCallback === NULL
? parent::getValue($row)
: callback($this->editableValueCallback)->invokeArgs(array($row, $this));
Expand Down
2 changes: 1 addition & 1 deletion tests/Components/Column.Editable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class EditableTest extends \Tester\TestCase
return $item['name'] . '-TEST';
});

Assert::same('<td class="grid-cell-name" data-grido-editable-value="Lucy-TEST"></td>', (string) $column->getCellPrototype($row));
Assert::same('<td class="grid-cell-name editable" data-grido-editable-value="Lucy-TEST"></td>', (string) $column->getCellPrototype($row));

})->run();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/DataSources/files/render.expect
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</tfoot>
<tbody>
<tr class="grid-row-628">
<td class="grid-cell-firstname" data-grido-editable-value="Luwam">
<td class="grid-cell-firstname editable" data-grido-editable-value="Luwam">
Luwam
</td>
<td class="grid-cell-surname">
Expand All @@ -89,7 +89,7 @@
</td>
</tr>
<tr class="grid-row-818">
<td class="grid-cell-firstname" data-grido-editable-value="Ronald">
<td class="grid-cell-firstname editable" data-grido-editable-value="Ronald">
Ronald
</td>
<td class="grid-cell-surname">
Expand All @@ -106,7 +106,7 @@
</td>
</tr>
<tr class="grid-row-837">
<td class="grid-cell-firstname" data-grido-editable-value="Dame">
<td class="grid-cell-firstname editable" data-grido-editable-value="Dame">
Dame
</td>
<td class="grid-cell-surname">
Expand Down
16 changes: 8 additions & 8 deletions tests/Grid/files/render.editable.expect
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<td class="checker">
<label for="frm-grid-form-operations-1"><input type="checkbox" name="operations[1]" title="1" id="frm-grid-form-operations-1"></label>
</td>
<td class="grid-cell-firstname" data-grido-editable-value="Trommler">
<td class="grid-cell-firstname editable" data-grido-editable-value="Trommler">
Trommler
</td>
<td class="grid-cell-surname">
Expand All @@ -92,7 +92,7 @@
<td class="grid-cell-gender">
Martina
</td>
<td class="grid-cell-birthday" data-grido-editable-value="1964-10-25">
<td class="grid-cell-birthday editable" data-grido-editable-value="1964-10-25">
25.10.1964
</td>
<td class="actions center">
Expand All @@ -102,7 +102,7 @@
<td class="checker">
<label for="frm-grid-form-operations-20"><input type="checkbox" name="operations[20]" title="20" id="frm-grid-form-operations-20"></label>
</td>
<td class="grid-cell-firstname" data-grido-editable-value="Marij">
<td class="grid-cell-firstname editable" data-grido-editable-value="Marij">
Marij
</td>
<td class="grid-cell-surname">
Expand All @@ -112,7 +112,7 @@ and newline &quot;test&quot;;
<td class="grid-cell-gender">
male
</td>
<td class="grid-cell-birthday" data-grido-editable-value="1972-12-16">
<td class="grid-cell-birthday editable" data-grido-editable-value="1972-12-16">
16.12.1972
</td>
<td class="actions center">
Expand All @@ -122,7 +122,7 @@ and newline &quot;test&quot;;
<td class="checker">
<label for="frm-grid-form-operations-39"><input type="checkbox" name="operations[39]" title="39" id="frm-grid-form-operations-39"></label>
</td>
<td class="grid-cell-firstname" data-grido-editable-value="Lyyli">
<td class="grid-cell-firstname editable" data-grido-editable-value="Lyyli">
Lyyli
</td>
<td class="grid-cell-surname">
Expand All @@ -131,7 +131,7 @@ and newline &quot;test&quot;;
<td class="grid-cell-gender">
female
</td>
<td class="grid-cell-birthday" data-grido-editable-value="1963-5-5">
<td class="grid-cell-birthday editable" data-grido-editable-value="1963-5-5">
05.05.1963
</td>
<td class="actions center">
Expand All @@ -141,7 +141,7 @@ and newline &quot;test&quot;;
<td class="checker">
<label for="frm-grid-form-operations-58"><input type="checkbox" name="operations[58]" title="58" id="frm-grid-form-operations-58"></label>
</td>
<td class="grid-cell-firstname" data-grido-editable-value="Dýrleif">
<td class="grid-cell-firstname editable" data-grido-editable-value="Dýrleif">
Dýrleif
</td>
<td class="grid-cell-surname">
Expand All @@ -150,7 +150,7 @@ and newline &quot;test&quot;;
<td class="grid-cell-gender">
female
</td>
<td class="grid-cell-birthday" data-grido-editable-value="1972-11-24">
<td class="grid-cell-birthday editable" data-grido-editable-value="1972-11-24">
24.11.1972
</td>
<td class="actions center">
Expand Down

0 comments on commit c92a2ef

Please sign in to comment.