-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pedro-teixeira/issue-7-pt-improvements
Improvements
- Loading branch information
Showing
8 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace PedroTeixeira\Bundle\GridBundle\Grid\Filter; | ||
|
||
/** | ||
* Filter NumberRange | ||
*/ | ||
class NumberRange extends FilterAbstract | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $operatorType = 'number_range'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $inputSeparator = ' : '; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function render() | ||
{ | ||
$html = '<input class="number-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'from" type="text" placeholder="' . $this->getPlaceholder() . '" value="' . $this->getValue() . '"> '; | ||
$html .= $this->getInputSeparator(); | ||
$html .= '<input class="number-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'to" type="text" placeholder="' . $this->getPlaceholder() . '" value="' . $this->getValue() . '">'; | ||
|
||
return $html; | ||
} | ||
|
||
/** | ||
* @param string $inputSeparator | ||
* | ||
* @return DateRange | ||
*/ | ||
public function setInputSeparator($inputSeparator) | ||
{ | ||
$this->inputSeparator = $inputSeparator; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getInputSeparator() | ||
{ | ||
return $this->inputSeparator; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace PedroTeixeira\Bundle\GridBundle\Grid\Filter\Operator; | ||
|
||
/** | ||
* NumberRange | ||
*/ | ||
class NumberRange extends OperatorAbstract | ||
{ | ||
/** | ||
* @param array $value | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function execute($value) | ||
{ | ||
if (!is_array($value) || count($value) != 2) { | ||
throw new \Exception('Value for number range comparison should have to values'); | ||
} | ||
|
||
$queryBuilder = $this->getQueryBuilder(); | ||
|
||
if (!empty($value[0])) { | ||
$queryBuilder->andWhere( | ||
$queryBuilder->expr()->gte( | ||
$this->getIndex(), | ||
":{$this->getIndexClean()}_1" | ||
)) | ||
->setParameter( | ||
":{$this->getIndexClean()}_1", | ||
(float) $value[0] | ||
); | ||
} | ||
|
||
if (!empty($value[1])) { | ||
|
||
$queryBuilder->andWhere( | ||
$queryBuilder->expr()->lte( | ||
$this->getIndex(), | ||
":{$this->getIndexClean()}_2" | ||
)) | ||
->setParameter( | ||
":{$this->getIndexClean()}_2", | ||
(float) $value[1] | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,10 @@ | |
width: auto; | ||
} | ||
.date-input { | ||
width: 70px; | ||
width: 75px; | ||
} | ||
.number-input { | ||
width: 75px; | ||
} | ||
} | ||
} | ||
|