Skip to content

Commit

Permalink
weekdays filter has been added to the demo page (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
semteacher committed Feb 1, 2025
1 parent 0cb3c4c commit 2df0be8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions classes/demo_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
*/
class demo_table extends wunderbyte_table {

/**
* Decodes the Unix Timestamp
*
* @param stdClass $values
* @return void
*/
public function col_timecreated($values) {
return userdate($values->timecreated);
}

/**
* Decodes the Unix Timestamp
*
Expand Down
12 changes: 10 additions & 2 deletions classes/output/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use local_wunderbyte_table\filters\types\hourlist;
use local_wunderbyte_table\filters\types\intrange;
use local_wunderbyte_table\filters\types\standardfilter;
use local_wunderbyte_table\filters\types\weekdays;
use local_wunderbyte_table\wunderbyte_table;
use renderable;
use renderer_base;
Expand Down Expand Up @@ -617,8 +618,8 @@ private function render_table_4() {
// It is recommended to avoid of usage of simple single words like "table" to reduce chance of affecting by Moodle`s core CSS
$table = new demo_table('demotable_4');

$table->define_headers(['id', 'username', 'firstname', 'lastname', 'email', 'action']);
$table->define_columns(['id', 'username', 'firstname', 'lastname', 'email', 'action']);
$table->define_headers(['id', 'username', 'firstname', 'lastname', 'email', 'action', 'timecreated', 'timemodified']);
$table->define_columns(['id', 'username', 'firstname', 'lastname', 'email', 'action', 'timecreated', 'timemodified']);

$standardfilter = new standardfilter('firstname', get_string('firstname'));
$table->add_filter($standardfilter);
Expand All @@ -628,6 +629,13 @@ private function render_table_4() {
$table->add_filter($standardfilter);
$intrangefilter = new intrange('username', "Range of numbers given in Username");
$table->add_filter($intrangefilter);
$weekdaysfilter = new weekdays(
'timecreated',
get_string('timecreated'),
'timemodified',
get_string('modified')
);
$table->add_filter($weekdaysfilter);

//$table->define_fulltextsearchcolumns(['username', 'firstname', 'lastname']);
$table->define_sortablecolumns(['id', 'username', 'firstname', 'lastname']);
Expand Down

0 comments on commit 2df0be8

Please sign in to comment.