Skip to content

Commit

Permalink
SAK-50626 Gradebook cell editing when clicked and sections column ren…
Browse files Browse the repository at this point in the history
…dering (#13013)
  • Loading branch information
kunaljaykam authored Nov 12, 2024
1 parent 17039df commit b589efe
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions gradebookng/tool/src/webapp/scripts/gradebook-gbgrade-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ GbGradeTable.renderTable = function (elementId, tableData) {
GbGradeTable._fixedColumns.push({
titleFormatter: GbGradeTable.headerFormatter('studentHeader'),
formatter: GbGradeTable.studentCellFormatter,
field: GbGradeTable.STUDENT_COLUMN_INDEX.toString(),
formatterParams: {
_data_: GbGradeTable.students,
columnType: "studentname",
Expand All @@ -769,7 +768,6 @@ GbGradeTable.renderTable = function (elementId, tableData) {
GbGradeTable._fixedColumns.push({
titleFormatter: GbGradeTable.headerFormatter('courseGradeHeader'),
formatter: GbGradeTable.courseGradeFormatter,
field: GbGradeTable.COURSE_GRADE_COLUMN_INDEX.toString(),
formatterParams: {
_data_: tableData.courseGrades,
columnType: "coursegrade",
Expand Down Expand Up @@ -907,7 +905,9 @@ GbGradeTable.renderTable = function (elementId, tableData) {
})

GbGradeTable.instance.on("cellClick", (e, cell) => {
if (e.target.closest('.gb-editable')) cell.edit();
if (cell.getElement().classList.contains('tabulator-editable') && e.target.closest('.gb-editable')) {
cell.edit();
}
GbGradeTable.deselectCell();
});

Expand Down Expand Up @@ -1739,29 +1739,19 @@ GbGradeTable.redrawTable = function(force) {
GbGradeTable._fixedColumns = [];

GbGradeTable.getFilteredColumns = function() {
const fixedColumns = GbGradeTable._fixedColumns;
let colIndex = fixedColumns.length;
GbGradeTable._fixedColumns.forEach((column, index) => column.field = index.toString());

return fixedColumns.concat(
return GbGradeTable._fixedColumns.concat(
GbGradeTable.columns
.filter(function(col) {
return !col.hidden;
})
.map(function(column) {
const readonly = column.externallyMaintained;
const currentColIndex = colIndex++;

return {
field: currentColIndex.toString(),
formatter: GbGradeTable.cellFormatter,
formatterParams: {
_data_: column,
},
titleFormatter: GbGradeTable.headerFormatter(null, column),
width: 180,
editor: readonly ? false : "GbGradeTableEditor",
};
})
.filter(col => !col.hidden)
.map((column, colIndex) => ({
field: (GbGradeTable._fixedColumns.length + colIndex).toString(),
formatter: GbGradeTable.cellFormatter,
formatterParams: { _data_: column },
titleFormatter: GbGradeTable.headerFormatter(null, column),
width: 180,
editor: column.type === 'category' || column.externallyMaintained ? false : "GbGradeTableEditor",
}))
);
};

Expand Down Expand Up @@ -3047,7 +3037,6 @@ GbGradeTable.setupStudentNumberColumn = function() {

GbGradeTable._fixedColumns.splice(1, 0, {
titleFormatter: GbGradeTable.headerFormatter('studentNumberHeader'),
field: GbGradeTable.STUDENTS_NUMBER_COLUMN_INDEX.toString(),
formatter: GbGradeTable.studentNumberCellFormatter,
formatterParams: {
_data_: GbGradeTable.students.map(function(student) {
Expand Down Expand Up @@ -3098,7 +3087,6 @@ GbGradeTable.setupSectionsColumn = function() {

GbGradeTable._fixedColumns.splice(1, 0, {
titleFormatter: GbGradeTable.headerFormatter('sectionsHeader'),
field: GbGradeTable.SECTIONS_COLUMN_INDEX.toString(),
formatter: GbGradeTable.sectionsCellFormatter,
formatterParams: {
_data_: GbGradeTable.students.map(function(student) {
Expand All @@ -3108,6 +3096,11 @@ GbGradeTable.setupSectionsColumn = function() {
},
width: sectionsColumnWidth,
frozen: true,
sorter: function(a, b) {
const aText = a.sections ? a.sections[0] : "";
const bText = b.sections ? b.sections[0] : "";
return aText.localeCompare(bText);
},
});
};

Expand Down

0 comments on commit b589efe

Please sign in to comment.