Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7e9fb74
1.) Add formatting option to Columns and Buttons
hleumas Jun 26, 2011
13ae5dd
Add NetteModel (using Nette\Database)
hleumas Jun 26, 2011
ddf8fb5
NetteModel bug fixed
hleumas Jun 29, 2011
58f0eb8
Pridany Nette Model
hleumas Jul 1, 2011
4849972
FIX: XSS
hleumas Jul 1, 2011
18451c2
Add property maxlen
hleumas Jul 1, 2011
159d81b
Add property type
hleumas Jul 1, 2011
cd99c43
Add email renderer
hleumas Jul 1, 2011
d3904e7
Fix: forgotten use ...
hleumas Jul 1, 2011
bd53ae7
Add formating
hleumas Jul 1, 2011
2b6e8f3
Merge branch 'testing'
hleumas Jul 1, 2011
7e5f06a
FIX: Posahany merge z testingu
hleumas Jul 1, 2011
6db4922
FIX: delete use Dibi\Fluent from NetteModel
hleumas Jul 1, 2011
efd90ba
Zbavena zavislost aplikovania csska na js kode.
hleumas Jul 2, 2011
9eb53ff
Z nejakeho divneho dovodu count() najskor vsetky data vytiahne z data…
hleumas Jul 7, 2011
6d35f25
Merge branch 'testing'
hleumas Jul 7, 2011
fc78b93
FIX: delete function body after return
hleumas Jul 11, 2011
78ea2ad
Add CheckButton
hleumas Jul 11, 2011
c7cb29c
FIX: missing file
hleumas Jul 12, 2011
4401422
Renderer methods changed to just return rendered result, not actualy …
hleumas Jul 13, 2011
5b5d343
add editable ability
hleumas Jul 13, 2011
7edbbdd
add IsEditable function
hleumas Jul 14, 2011
a199426
fluent interface
hleumas Jul 14, 2011
9f372dd
Handler provided by user should also care about invalidation. It is n…
hleumas Jul 14, 2011
1429a7f
enabled property should exists for all buttons
hleumas Jul 16, 2011
26b9552
css min height for editable
hleumas Jul 16, 2011
5c17a31
fix: css, editable text should be centered
hleumas Jul 16, 2011
1fdf97c
fix: missing row parameter for isEnabled
hleumas Jul 17, 2011
4da542a
advanced column features
hleumas Sep 29, 2011
3b973d4
add antispam protection
hleumas Feb 19, 2012
075345e
use visualpaginator instead of coding own
hleumas Feb 19, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions BaseButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,32 @@ abstract class BaseButton extends \Nette\Application\UI\PresenterComponent

/** @var bool */
private $showText = true;

/** @var string */
private $enabled = true;


/**
* Is button enabled
* @param mixed row
* @return bool
*/
public function isEnabled($row = null)
{
return is_bool($this->enabled) ? $this->enabled : call_user_func($this->enabled, $row);
}

/**
* Set enabled
* @param bool $enabled
* @return CheckButton
*/
public function SetEnabled($enabled = true)
{
$this->enabled = $enabled;
return $this;
}


/**
* Get label
Expand Down Expand Up @@ -239,11 +263,28 @@ public function handleClick($token, $uniqueId = null)
*/
protected function createButton($row = null)
{
return Html::el("a")
->href($this->getLink($row))
->data("gridito-icon", $this->icon)
->class(array("gridito-button", $this->showText ? null : "gridito-hide-text"))
->setText($this->label);
$button = Html::el('a');
if ($this->isEnabled($row)) {
$button->href($this->getLink($row));
} else {
$button->class[] = 'disabled';
}
$button->class[] = 'gridito-button';
if ($this->icon && $this->showText) {
$button->class[] = 'button-icon-text';
} elseif ($this->icon) {
$button->class[] = 'button-icon';
$button->class[] = 'gridito-hide-text';
$button->title($this->label);
} else {
$button->class[] = 'button-text';
}

if ($this->icon) {
$button->create('span')->class(array('gridito-icon', $this->icon));
}
$button->create('span class="gridito-text"')->setText($this->label);
return $button;
}


Expand All @@ -259,4 +300,4 @@ public function render($row = null)
}
}

}
}
4 changes: 2 additions & 2 deletions Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getConfirmationQuestion($row)
if (is_callable($this->confirmationQuestion)) {
return call_user_func($this->confirmationQuestion, $row);
} else {
return $this->confirmationQuestion;
return Grid::formatRecordString($row, $this->confirmationQuestion);
}
}

Expand Down Expand Up @@ -103,4 +103,4 @@ protected function createButton($row = null)
return $el;
}

}
}
99 changes: 99 additions & 0 deletions CheckButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace Gridito;

/**
* Action button
*
* @author Jan Marek
* @license MIT
*/
class CheckButton extends BaseButton
{
/** @var bool */
private $ajax = false;

/** @var string */
private $checked = false;

/**
* Set checked
* @param bool $checked
* @return CheckButton
*/
public function SetChecked($checked = true)
{
$this->checked = $checked;
return $this;
}


/**
* Is button checked
* @param mixed row
* @return bool
*/
public function isChecked($row = null)
{
return is_bool($this->checked) ? $this->checked : call_user_func($this->checked, $row);
}


/**
* Is ajax?
* @return bool
*/
public function isAjax()
{
return $this->ajax;
}



/**
* Set ajax mode
* @param bool ajax
* @return Button
*/
public function setAjax($ajax)
{
$this->ajax = (bool) $ajax;
return $this;
}



/**
* Handle click signal
* @param string security token
* @param mixed primary key
*/
public function handleClick($token, $uniqueId = null)
{
parent::handleClick($token, $uniqueId);

if ($this->getPresenter()->isAjax()) {
$this->getGrid()->invalidateControl();
} else {
$this->getGrid()->redirect("this");
}
}



/**
* Create button element
* @param mixed row
* @return Nette\Web\Html
*/
protected function createButton($row = null)
{
$el = parent::createButton($row);
if ($this->isChecked($row)) {
$el->class[] = 'checked';
}
$el->class[] = $this->isAjax() ? $this->getGrid()->getAjaxClass() : null;
return $el;
}

}
Loading