This commit is contained in:
Ilya Tregubov 2023-06-22 10:33:45 +08:00 committed by Sara Arjona
commit b2dce5d60c
7 changed files with 71 additions and 3 deletions

View File

@ -155,6 +155,7 @@ class acceptances_table extends \table_sql {
$this->columns[$key] = count($this->columns);
$this->column_style[$key] = array();
$this->column_class[$key] = $columnclass;
$this->columnsticky[$key] = '';
$this->column_suppress[$key] = false;
$this->headers[] = $label;
}

View File

@ -79,6 +79,12 @@ class flexible_table {
var $column_suppress = array();
var $column_nosort = array('userpic');
private $column_textsort = array();
/**
* @var array The sticky attribute of each table column.
*/
protected $columnsticky = [];
/** @var boolean Stores if setup has already been called on this flixible table. */
var $setup = false;
var $baseurl = NULL;
@ -430,6 +436,17 @@ class flexible_table {
}
}
/**
* Sets a sticky attribute to a column.
* @param string $column Column name
* @param bool $sticky
*/
public function column_sticky(string $column, bool $sticky = true): void {
if (isset($this->columnsticky[$column])) {
$this->columnsticky[$column] = $sticky == true ? ' sticky-column' : '';
}
}
/**
* Sets the given $attributes to $this->columnsattributes.
* Column attributes will be added to every cell in the column.
@ -468,6 +485,7 @@ class flexible_table {
$this->columns = array();
$this->column_style = array();
$this->column_class = array();
$this->columnsticky = [];
$this->columnsattributes = [];
$colnum = 0;
@ -475,6 +493,7 @@ class flexible_table {
$this->columns[$column] = $colnum++;
$this->column_style[$column] = array();
$this->column_class[$column] = '';
$this->columnsticky[$column] = '';
$this->columnsattributes[$column] = [];
$this->column_suppress[$column] = false;
}
@ -1150,7 +1169,7 @@ class flexible_table {
}
$attributes = [
'class' => "cell c{$index}" . $this->column_class[$column],
'class' => "cell c{$index}" . $this->column_class[$column] . $this->columnsticky[$column],
'id' => "{$rowid}_c{$index}",
'style' => $this->make_styles_string($this->column_style[$column]),
];
@ -1332,7 +1351,7 @@ class flexible_table {
}
$attributes = array(
'class' => 'header c' . $index . $this->column_class[$column],
'class' => 'header c' . $index . $this->column_class[$column] . $this->columnsticky[$column],
'scope' => 'col',
);
if ($this->headers[$index] === NULL) {

View File

@ -238,6 +238,8 @@ abstract class attempts_report extends report_base {
$table->column_class('lastname', 'bold');
$table->column_class('firstname', 'bold');
$table->column_class('fullname', 'bold');
$table->column_sticky('fullname');
}
/**

View File

@ -306,7 +306,8 @@ table.quizattemptsummary .noreviewmessage {
}
body.path-mod-quiz .gradedattempt,
body.path-mod-quiz table tbody tr.gradedattempt > td {
body.path-mod-quiz table tbody tr.gradedattempt > td,
body.path-mod-quiz table tbody tr.gradedattempt > td.sticky-column {
border-color: #bce8f1;
background-color: #d9edf7;
}

View File

@ -24,6 +24,13 @@
tbody tr:nth-of-type(#{$table-striped-order}) {
background-color: $table-accent-bg;
}
thead .sticky-column,
tbody tr:nth-of-type(even) {
background-color: $white;
}
tbody tr:nth-of-type(#{$table-striped-order}) .sticky-column {
background-color: #f7f7f7;
}
&.table-sm {
th,
td {
@ -39,6 +46,9 @@
color: $table-hover-color;
}
}
td.sticky-column {
background-color: #ececec;
}
}
}
}
@ -51,6 +61,11 @@ table {
text-align: left;
caption-side: top;
}
.sticky-column {
position: sticky;
left: 0;
background-color: inherit;
}
}
.table-dynamic .loading-icon {

View File

@ -34458,6 +34458,13 @@ img.userpicture {
.generaltable tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.03);
}
.generaltable thead .sticky-column,
.generaltable tbody tr:nth-of-type(even) {
background-color: #fff;
}
.generaltable tbody tr:nth-of-type(odd) .sticky-column {
background-color: #f7f7f7;
}
.generaltable.table-sm th,
.generaltable.table-sm td {
padding: 0.3rem;
@ -34469,6 +34476,9 @@ img.userpicture {
.generaltable tbody tr:hover.dimmed_text a:not(.menu-action) {
color: #1d2125;
}
.generaltable tbody tr:hover td.sticky-column {
background-color: #ececec;
}
table caption {
font-size: 24px;
@ -34477,6 +34487,11 @@ table caption {
text-align: left;
caption-side: top;
}
table .sticky-column {
position: sticky;
left: 0;
background-color: inherit;
}
.table-dynamic .loading-icon {
position: absolute;

View File

@ -34458,6 +34458,13 @@ img.userpicture {
.generaltable tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.03);
}
.generaltable thead .sticky-column,
.generaltable tbody tr:nth-of-type(even) {
background-color: #fff;
}
.generaltable tbody tr:nth-of-type(odd) .sticky-column {
background-color: #f7f7f7;
}
.generaltable.table-sm th,
.generaltable.table-sm td {
padding: 0.3rem;
@ -34469,6 +34476,9 @@ img.userpicture {
.generaltable tbody tr:hover.dimmed_text a:not(.menu-action) {
color: #1d2125;
}
.generaltable tbody tr:hover td.sticky-column {
background-color: #ececec;
}
table caption {
font-size: 24px;
@ -34477,6 +34487,11 @@ table caption {
text-align: left;
caption-side: top;
}
table .sticky-column {
position: sticky;
left: 0;
background-color: inherit;
}
.table-dynamic .loading-icon {
position: absolute;