Skip to content

Commit

Permalink
Enable Filtering in Groups.Improve column_key function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis Igoumenos committed Sep 6, 2022
1 parent e1bf2a1 commit 1e3aa64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/resources/locales/en_US/enumeration.po
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ msgstr "Staff"
msgid "EduPersonAffiliationEnum.student"
msgstr "Student"

msgid "GroupTypeEnum.MA"
msgstr "Active Members"

msgid "GroupTypeEnum.A"
msgstr "Admins"

msgid "GroupTypeEnum.M"
msgstr "All Members"

msgid "GroupTypeEnum.S"
msgstr "Standard"

msgid "LanguageEnum.af"
msgstr "Afrikaans"

Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Traits/SearchFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function whereFilter(\Cake\ORM\Query $query, string $attribute, string|ar
return $query->where(function (\Cake\Database\Expression\QueryExpression $exp, \Cake\ORM\Query $query) use ($attribute, $search) {
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
// 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) {
Expand Down
5 changes: 4 additions & 1 deletion app/src/Lib/Util/StringUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

namespace App\Lib\Util;

use \Cake\Utility\Inflector;

class StringUtilities {
/**
* Construct the Column human-readable key
Expand Down Expand Up @@ -70,7 +72,8 @@ public static function column_key($modelsName, $c, $tz=null, $useCustomClMdlLabe
// Humanize

// Otherwise look for the general key
return __d('field', $c);
$cfield = __d('field', $c);
return ($cfield !== $c) ? $cfield : \Cake\Utility\Inflector::humanize($c);
}

// The following two utilities provide base64 encoding and decoding for
Expand Down
5 changes: 5 additions & 0 deletions app/src/Model/Table/GroupsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GroupsTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\SearchFilterTrait;

/**
* Perform Cake Model initialization.
Expand Down Expand Up @@ -92,6 +93,10 @@ public function initialize(array $config): void {
'statuses' => [
'type' => 'enum',
'class' => 'SuspendableStatusEnum'
],
'group_types' => [
'type' => 'enum',
'class' => 'GroupTypeEnum'
]
]);

Expand Down

0 comments on commit 1e3aa64

Please sign in to comment.