Skip to content

Commit

Permalink
Правки в фильтре
Browse files Browse the repository at this point in the history
  • Loading branch information
Gokujo authored and gitbutler-client committed Feb 14, 2025
1 parent 635c3c3 commit 2e3b165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion upload/engine/inc/maharder/_includes/classes/TwigFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,21 @@ public function createRangeFilter(string $column_name, string $label): array {
$data = (array)$this->getRepository()->select()->columns([$column_name])->orderBy($column_name, SelectQuery::SORT_ASC)->fetchAll();
$firstData = (array) $data[0];
$lastData = (array) $data[count($data) - 1];
$values = [];
$first = $firstData[$column_name] ?: 0;
$last = $lastData[$column_name] ?: 10;

foreach ($data as $d) {
$values[] = $d[$column_name];
}

return [
$column_name => [
'type' => 'range',
'label' => $label,
'from' => $first,
'to' => $last
'to' => $last,
'values'=> $values
]
];
}
Expand Down
11 changes: 9 additions & 2 deletions upload/engine/inc/maharder/admin/templates/_macros/filter.twig
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@

<script>
setTimeout(() => {
let restricted = [];
{% for r in options.values|default(range(options.from, options.to)) %}
restricted.push({{ r }});
{% endfor %}
$('#range-{{ name }}')
.slider({
min: {{ options.from }},
max: {{ options.to }},
step: 1,
showThumbTooltip: true,
restrictedLabels: restricted,
tooltipConfig: {
position: 'bottom center',
variation: 'small visible blue'
Expand Down Expand Up @@ -120,8 +127,8 @@
<script>
setTimeout(() => {
let {{ name }}_settings = calendarSettings('datetime');
{{ name }}_settings.minDate = new Date('{{ options.min }}');
{{ name }}_settings.maxDate = new Date('{{ options.max }}');
{{ name }}_settings.minDate = new Date('{{ options.min|from_dti }}');
{{ name }}_settings.maxDate = new Date('{{ options.max|from_dti }}');
let startCalSettings = {{ name }}_settings;
let endCalSettings = {{ name }}_settings;
Expand Down

0 comments on commit 2e3b165

Please sign in to comment.