diff --git a/app/src/Lib/Traits/SearchFilterTrait.php b/app/src/Lib/Traits/SearchFilterTrait.php index e0d9b2e95..70ffd5e18 100644 --- a/app/src/Lib/Traits/SearchFilterTrait.php +++ b/app/src/Lib/Traits/SearchFilterTrait.php @@ -68,7 +68,8 @@ public function getSearchableAttributes(string $controller, string $vv_tz=null): 'type' => 'string', // XXX for now - this needs to be looked up. 'label' => \App\Lib\Util\StringUtilities::columnKey($fieldName, $field, $vv_tz, true), 'active' => isset($f['active']) ? $f['active'] : true, - 'model' => $f['model'] + 'model' => $f['model'], + 'order' => $f['order'] ]; } } @@ -93,7 +94,8 @@ public function getSearchableAttributes(string $controller, string $vv_tz=null): $this->searchFilters[$column] = [ 'type' => $type, 'label' => \App\Lib\Util\StringUtilities::columnKey($modelname, $column, $vv_tz, true), - 'active' => $fieldIsActive + 'active' => $fieldIsActive, + 'order' => 99 // this is the default ]; // For the date fields we search ranges diff --git a/app/src/Lib/Util/StringUtilities.php b/app/src/Lib/Util/StringUtilities.php index 0b3e47aca..945456eb9 100644 --- a/app/src/Lib/Util/StringUtilities.php +++ b/app/src/Lib/Util/StringUtilities.php @@ -57,10 +57,16 @@ public static function classNameToForeignKey(string $className): string { public static function columnKey($modelsName, $c, $tz=null, $useCustomClMdlLabel=false): string { if(strpos($c, "_id", strlen($c)-3)) { + $postfix = ""; + if($c == "parent_id") { + // This means we are working with a model that implements a Tree behavior + $postfix = " ({$modelsName})"; + } + // Key is of the form field_id, use .ct label instead $k = self::foreignKeyToClassName($c); - return __d('controller', $k, [1]); + return __d('controller', $k, [1]) . $postfix; } // Look for a model specific key first diff --git a/app/src/Model/Table/PeopleTable.php b/app/src/Model/Table/PeopleTable.php index 36c338a26..513c489ec 100644 --- a/app/src/Model/Table/PeopleTable.php +++ b/app/src/Model/Table/PeopleTable.php @@ -160,26 +160,31 @@ public function initialize(array $config): void { 'family' => [ 'type' => 'relatedModel', 'model' => 'Name', - 'active' => true + 'active' => true, + 'order' => 2 ], 'given' => [ 'type' => 'relatedModel', 'model' => 'Name', - 'active' => true + 'active' => true, + 'order' => 1 ], 'mail' => [ 'type' => 'relatedModel', 'model' => 'EmailAddress', - 'active' => true + 'active' => true, + 'order' => 3 ], 'identifier' => [ 'type' => 'relatedModel', 'model' => 'Identifier', - 'active' => true + 'active' => true, + 'order' => 4 ], 'timezone' => [ 'type' => 'field', - 'active' => false + 'active' => false, + 'order' => 99 ] ]); @@ -437,9 +442,9 @@ public function marshalProvisioningData(int $id): array { $identifiers = []; - foreach($ret['data']->identifiers as $id) { - if($id->status == SuspendableStatusEnum::Active) { - $identifiers[] = $id; + foreach($ret['data']->identifiers as $ident) { + if($ident->status == SuspendableStatusEnum::Active) { + $identifiers[] = $ident; } } @@ -462,9 +467,9 @@ public function marshalProvisioningData(int $id): array { $identifiers = []; - foreach($ret['data']->identifiers as $id) { - if($id->status == SuspendableStatusEnum::Active) { - $identifiers[] = $id; + foreach($ret['data']->identifiers as $ident) { + if($ident->status == SuspendableStatusEnum::Active) { + $identifiers[] = $ident; } } diff --git a/app/templates/element/filter.php b/app/templates/element/filter.php index 5ee4f8b92..359c7f749 100644 --- a/app/templates/element/filter.php +++ b/app/templates/element/filter.php @@ -121,7 +121,7 @@