Skip to content

Commit

Permalink
Merge branch 'main' into addMoreConditions
Browse files Browse the repository at this point in the history
  • Loading branch information
andreia authored Aug 5, 2024
2 parents b5c0805 + eec680e commit 35e6cd8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to the "Filament Value Range Filter" will be documented in this file.

## v1.0.1 - 2024-07-31

### What's Changed

* Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in https://github.com/TappNetwork/filament-value-range-filter/pull/3
* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/TappNetwork/filament-value-range-filter/pull/4
* make select placeholder translatable by @buddhaCode in https://github.com/TappNetwork/filament-value-range-filter/pull/5

### New Contributors

* @buddhaCode made their first contribution in https://github.com/TappNetwork/filament-value-range-filter/pull/5

**Full Changelog**: https://github.com/TappNetwork/filament-value-range-filter/compare/v1.0.0...v1.0.1

## v1.0.0 - 2024-06-20

### What's Changed
Expand Down
5 changes: 3 additions & 2 deletions resources/lang/en/filament-value-range-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

return [

'range.placeholder' => 'Select condition',
'range.options.equal' => 'is equal to',
'range.options.not_equal' => 'is not equal to',
'range.options.between' => 'is between',
'range.options.greater_than' => 'is greater than',
'range.options.greater_than_eqal' => 'is greater than or equal to',
'range.options.greater_than_equal' => 'is greater than or equal to',
'range.options.less_than' => 'is less than',
'range.options.less_than_equal' => 'is less than or equal to',
'range.indicator.equal' => ':label is equal to :value',
'range.indicator.not_equal' => ':label is not equal to :value',
'range.indicator.between' => ':label is between :fromValue and :toValue',
'range.indicator.greater_than' => ':label is greater than :value',
'range.indicator.greater_than_eqal' => ':label is greater than or equal to :value',
'range.indicator.greater_than_equal' => ':label is greater than or equal to :value',
'range.indicator.less_than' => ':label is less than :value',
'range.indicator.less_than_equal' => ':label is less than or equal to :value',

Expand Down
23 changes: 18 additions & 5 deletions src/Filters/ValueRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function setUp(): void
->schema([
Forms\Components\Select::make('range_condition')
->hiddenLabel()
->placeholder('Select condition')
->placeholder(__('filament-value-range-filter::filament-value-range-filter.range.placeholder'))
->live()
->options([
'equal' => __('filament-value-range-filter::filament-value-range-filter.range.options.equal'),
Expand Down Expand Up @@ -148,13 +148,20 @@ function (Builder $query, $value) use ($data) {
$indicators = [];

if ($data['range_between_from'] || $data['range_between_to']) {
$indicators[] = Indicator::make($this->getIndicatorBetweenLabel() ?? $this->getLabel().' is between '.$this->getFormattedValue($data['range_between_from']).' and '.$this->getFormattedValue($data['range_between_to']))
$indicators[] = Indicator::make(__('filament-value-range-filter::filament-value-range-filter.range.indicator.between', [
'label' => $this->getIndicatorBetweenLabel() ?? $this->getLabel(),
'fromValue' => $this->getFormattedValue($data['range_between_from']),
'toValue' => $this->getFormattedValue($data['range_between_to']),
]))
->removeField('range_between_from')
->removeField('range_between_to');
}

if ($data['range_equal']) {
$indicators[] = Indicator::make($this->getIndicatorEqualLabel() ?? $this->getLabel().' is equal to '.$this->getFormattedValue($data['range_equal']))
$indicators[] = Indicator::make(__('filament-value-range-filter::filament-value-range-filter.range.indicator.equal', [
'label' => $this->getIndicatorEqualLabel() ?? $this->getLabel(),
'value' => $this->getFormattedValue($data['range_equal']),
]))
->removeField('range_equal');
}

Expand All @@ -167,7 +174,10 @@ function (Builder $query, $value) use ($data) {
}

if ($data['range_greater_than']) {
$indicators[] = Indicator::make($this->getIndicatorGreaterThanLabel() ?? $this->getLabel().' is greater than '.$this->getFormattedValue($data['range_greater_than']))
$indicators[] = Indicator::make(__('filament-value-range-filter::filament-value-range-filter.range.indicator.greater_than', [
'label' => $this->getIndicatorGreaterThanLabel() ?? $this->getLabel(),
'value' => $this->getFormattedValue($data['range_greater_than']),
]))
->removeField('range_greater_than');
}

Expand All @@ -180,7 +190,10 @@ function (Builder $query, $value) use ($data) {
}

if ($data['range_less_than']) {
$indicators[] = Indicator::make($this->getIndicatorLessThanLabel() ?? $this->getLabel().' is less than '.$this->getFormattedValue($data['range_less_than']))
$indicators[] = Indicator::make(__('filament-value-range-filter::filament-value-range-filter.range.indicator.less_than', [
'label' => $this->getIndicatorLessThanLabel() ?? $this->getLabel(),
'value' => $this->getFormattedValue($data['range_less_than']),
]))
->removeField('range_less_than');
}

Expand Down

0 comments on commit 35e6cd8

Please sign in to comment.