diff --git a/app/src/Lib/Traits/SearchFilterTrait.php b/app/src/Lib/Traits/SearchFilterTrait.php index c6a55b714..77b1452c5 100644 --- a/app/src/Lib/Traits/SearchFilterTrait.php +++ b/app/src/Lib/Traits/SearchFilterTrait.php @@ -30,6 +30,7 @@ namespace App\Lib\Traits; use Cake\Utility\Inflector; +use Cake\I18n\FrozenTime; trait SearchFilterTrait { // Array (and configuration) of permitted search filters @@ -93,19 +94,19 @@ public function whereFilter(\Cake\ORM\Query $query, string $attribute, string|ar if(!empty($search[0]) && !empty($search[1])) { return $query->where(function (\Cake\Database\Expression\QueryExpression $exp, \Cake\ORM\Query $query) use ($attribute, $search) { - return $exp->between($attribute, $search[0], $search[1]); + return $exp->between($attribute, "'" . $search[0] . "'", "'" . $search[1] . "'"); }); // The starts at is non empty. So the data should be greater than the starts_at date } elseif(!empty($search[0]) && empty($search[1])) { return $query->where(function (\Cake\Database\Expression\QueryExpression $exp, \Cake\ORM\Query $query) use ($attribute, $search) { - return $exp->gte($attribute, $search[0]); + return $exp->gte("'" . FrozenTime::parse($search[0]) . "'", $attribute); }); // The ends at is non-empty. So the data should be less than the ends at date } elseif(!empty($search[1]) && empty($search[0])) { return $query->where(function (\Cake\Database\Expression\QueryExpression $exp, \Cake\ORM\Query $query) use ($attribute, $search) { - return $exp->lte($attribute, $search[1]); + return $exp->lte("'" . FrozenTime::parse($search[1]) . "'", $attribute); }); } else { // We return everything diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 137b70a26..b96c34afb 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -47,7 +47,7 @@ class FieldHelper extends Helper { // The current entity, if edit or view protected $entity = null; - + /** * Emit an informational banner. * diff --git a/app/templates/element/filter.php b/app/templates/element/filter.php index f40fcad5b..ece0da3e2 100644 --- a/app/templates/element/filter.php +++ b/app/templates/element/filter.php @@ -167,14 +167,35 @@ } ?> + +
+
On-Off
+
+ $options): ?> +
+ Form->label($key); + print $this->Form->checkbox($key, [ + 'id' => $key, + 'class' => 'form-check-input', + 'checked' => $query[$key] ?? 0, + 'hiddenField' => false, + 'required' => false + ]); + ?> +
+ +
+
+ - $options): ?> -
-
-
+ $options): ?> +
+
+
-
+
- -
-
On-Off
-
- $options): ?> -
- Form->label($key); - print $this->Form->checkbox($key, [ - 'class' => 'form-check-input', - 'checked' => $query[$key] ?? 0, - 'hiddenField' => false, - 'required' => false - ]); - ?> -
- -
-
-
> { - e.preventDefault(); let dateWidgetInputs = document.querySelectorAll('duet-date-picker input'); - Array.prototype.slice.call(dateWidgetInputs).forEach( - function(element) { - element.parentNode.removeChild(element); - } - ); - curForm.submit(); + // Remove all the Vue related fields + Array.prototype.slice.call(dateWidgetInputs).forEach( (el) => { + el.parentNode.removeChild(el); + }); + // For the GET request send using the default flow + if (curForm.getAttribute('method') != 'get') { + e.preventDefault(); + curForm.submit(); + } }); }, template: `