Skip to content

Commit

Permalink
Operation: Fixed setConfirm client side [Closed #137]
Browse files Browse the repository at this point in the history
  • Loading branch information
o5 committed May 28, 2014
1 parent c7eec65 commit ead9a40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Grido/Components/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function setConfirm($operation, $message)
{
$message = $this->translate($message);
$this->grid->onRender[] = function(Grid $grid) use ($operation, $message) {
$grid['form'][Operation::ID][Operation::ID]->controlPrototype->data["grido-$operation"] = $message;
$grid['form'][Operation::ID][Operation::ID]->controlPrototype->data["grido-confirm-$operation"] = $message;
};

return $this;
Expand Down
2 changes: 1 addition & 1 deletion client-side/grido.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@

onSubmit: function()
{
var hasConfirm = this.getSelect().data('grido-' + this.getSelect().val());
var hasConfirm = this.getSelect().attr('data-grido-confirm-' + this.getSelect().val());
if (hasConfirm) {
if (confirm(hasConfirm.replace(/%i/g, $(this.selector + ':checked', this.grido.$table).length))) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions tests/Grido/Components/Operation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class OperationTest extends \Tester\TestCase
Helper::grid(function(Grid $grid) {
$grid->setModel(array());
$grid->addColumnText('column', 'Column');
$grid->setOperation(array('edit' => 'Edit', 'del' => 'Del'), function() {})
->setConfirm('del', 'Are you sure?');
$grid->setOperation(array('edit' => 'Edit', 'delete' => 'Delete'), function() {})
->setConfirm('delete', 'Are you sure?');
$grid->render();
})->run();

$formControl = Helper::$grid['form'][Operation::ID][Operation::ID];
Assert::same($formControl->controlPrototype->data['grido-del'], 'Are you sure?');
Assert::same($formControl->controlPrototype->data['grido-confirm-delete'], 'Are you sure?');
}

/**********************************************************************************************/
Expand Down

0 comments on commit ead9a40

Please sign in to comment.