From db8b9edd1675a38621f10e7cbd7855072ac44a18 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos <ioigoume@gmail.com> Date: Tue, 7 May 2024 14:37:23 +0300 Subject: [PATCH] fixes --- app/resources/locales/en_US/error.po | 3 +++ app/src/Controller/StandardController.php | 9 +++++++-- app/templates/element/filter/filter.php | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/resources/locales/en_US/error.po b/app/resources/locales/en_US/error.po index f368492f7..fc6b3686e 100644 --- a/app/resources/locales/en_US/error.po +++ b/app/resources/locales/en_US/error.po @@ -51,6 +51,9 @@ msgstr "API User \"{0}\" is not yet valid" msgid "auth.api.unknown" msgstr "Username \"{0}\" not found in api_users table" +msgid "auto.viewvar.type.unknown" +msgstr "Unknown Auto View Var Type {0}" + msgid "coid" msgstr "CO ID not found" diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 001abdafc..3b9c68abe 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -660,6 +660,12 @@ protected function populateAutoViewVars(object $obj=null) { case 'select': $avvmodel = $avv['model']; $this->$avvmodel = TableRegistry::getTableLocator()->get($avvmodel); + // XXX We should probably move to a more generic approach. + // Models can have various types of parent keys (and sometimes multiple concurrently), + // so it’s better to use PrimaryLinkTrait to handle this. + // if(method_exists($this->$avvmodel, "calculateCoForRecord")) { + // $avv['where']['co_id'] = $this->$avvmodel->calculateCoForRecord($obj) + // } if($this->$avvmodel->getSchema()->hasColumn('co_id')) { $avv['where']['co_id'] = $this->getCOID(); } @@ -742,8 +748,7 @@ protected function populateAutoViewVars(object $obj=null) { break; default: // XXX I18n? and in match? - throw new \LogicException('Unknonwn Auto View Var Type {0}', $avv['type']); - break; + throw new \LogicException(__d('error', 'auto.viewvar.type.unknown', [$avv['type']])); } } } diff --git a/app/templates/element/filter/filter.php b/app/templates/element/filter/filter.php index cff0d99d7..c68288b25 100644 --- a/app/templates/element/filter/filter.php +++ b/app/templates/element/filter/filter.php @@ -36,7 +36,9 @@ filterForm.addEventListener('formdata', (event) => { if(event.formData.has('person_id')) { const personId = $(filterForm).find('#person_id')[0].getAttribute('datapersonid') - event.formData.set('person_id', personId) + if(personId != undefined && personId != '') { + event.formData.set('person_id', personId) + } } }); }); @@ -84,7 +86,8 @@ foreach($field_generic_columns as $key => $options) { $elementArguments = compact('options', 'key'); // Set in SearchfilterTrait.php - if($vv_autocomplete_arguments['fieldName'] === $key) { + if(isset($vv_autocomplete_arguments) + && $vv_autocomplete_arguments['fieldName'] === $key) { // Picker is a custom type. // This is why we calculate it here, and we // only use it to pick the correct element