From cf6cc974752dc75a237da665c36f45aeeabc0dbd Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Fri, 29 Nov 2024 08:42:36 +0100 Subject: [PATCH] Noten Tab: header/inline edit --- .../api/frontend/v1/stv/Config.php | 5 +- .../Stv/Studentenverwaltung/Details/Noten.js | 8 +- .../Details/Noten/Zeugnis.js | 107 ++++++++++++++---- .../Details/Noten/Zeugnis/Actions.js | 5 +- 4 files changed, 99 insertions(+), 26 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 3c63c0c17..8c06d8bfc 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -94,7 +94,10 @@ class Config extends FHCAPI_Controller $result['grades'] = [ 'title' => $this->p->t('stv', 'tab_grades'), 'component' => './Stv/Studentenverwaltung/Details/Noten.js', - 'showOnlyWithUid' => true + 'showOnlyWithUid' => true, + 'config' => [ + 'edit' => 'both', // Possible values: both|header|inline + ] ]; diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Noten.js b/public/js/components/Stv/Studentenverwaltung/Details/Noten.js index e7aae4c8c..498e8ea6f 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Noten.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Noten.js @@ -10,8 +10,14 @@ export default { NotenTeacher, NotenRepeater }, + provide() { + return { + config: this.config + } + }, props: { - modelValue: Object + modelValue: Object, + config: Object }, data() { return { diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Noten/Zeugnis.js b/public/js/components/Stv/Studentenverwaltung/Details/Noten/Zeugnis.js index ae1a9b6f3..284671b52 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Noten/Zeugnis.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Noten/Zeugnis.js @@ -6,6 +6,9 @@ export default { CoreFilterCmpt, ZeugnisActions }, + inject: [ + 'config' + ], props: { student: Object, allSemester: Boolean @@ -13,11 +16,89 @@ export default { data() { return { tabulatorEvents: [], - stdsem: '' + stdsem: '', + lastGradeList: [] }; }, computed: { tabulatorOptions() { + const listPromise = this.$fhcApi.factory + .stv.grades.list() + .then(res => res.data.map(({bezeichnung: label, note: value}) => ({label, value}))); + + let gradeField = { + field: 'note', + title: 'Note', + formatter: cell => cell.getData().note_bezeichnung, + tooltip: (evt, cell) => cell.getData().note_bezeichnung + }; + if (['both', 'inline'].includes(this.config.edit)) { + gradeField = {...gradeField, ...{ + editor: 'list', + editorParams: { + valuesLookup: (cell, filterTerm) => listPromise, + placeholderLoading: "Loading Remote Data...", // TODO(chris): phrase + }, + cellEdited: cell => { + // get row data + const {lehrveranstaltung_id, uid: student_uid, studiensemester_kurzbz} = cell.getData(); + // get changed value + const note = cell.getValue(); + + listPromise + // get bezeichnung + .then(list => list.find(el => el.value == note)) + .then(found => found ? found.label : Promise.reject({message: 'not found'})) + // prepare data object + .then(note_bezeichnung => ({ + lehrveranstaltung_id, + student_uid, + studiensemester_kurzbz, + note, + note_bezeichnung + })) + // send to backend + .then(this.$fhcApi.factory.stv.grades.updateCertificate) + // get bezeichnung again + .then(() => listPromise) + .then(list => list.find(el => el.value == note)) + .then(found => found ? found.label : Promise.reject({message: 'not found'})) + // update other fields in row + .then(note_bezeichnung => cell.getRow().update({note_bezeichnung})) + .then(() => cell.getRow().reformat()) + // cleanup + .then(cell.clearEdited) + .catch(err => { + cell.restoreOldValue(); + cell.clearEdited(); + this.$fhcAlert.handleFormValidation(err); + }); + } + }}; + } + + const columns = [ + { field: 'zeugnis', title: 'Zeugnis', formatter: 'tickCross' }, + { field: 'lehrveranstaltung_bezeichnung', title: 'Lehrveranstaltung' }, + gradeField, + { field: 'uebernahmedatum', title: 'Übernahmedatum', visible: false }, + { field: 'benotungsdatum', title: 'Benotungsdatum', visible: false }, + { field: 'benotungsdatum-iso', title: 'Benotungsdatum ISO', visible: false }, + { field: 'studiensemester_kurzbz', title: 'Studiensemester', visible: false }, + { field: 'note_number', title: 'Note Numerisch', visible: false, formatter: cell => cell.getData().note, tooltip: (evt, cell) => cell.getData().note }, + { field: 'lehrveranstaltung_id', title: 'Lehrveranstaltung ID', visible: false }, + { field: 'studiengang', title: 'Studiengang', visible: false }, + { field: 'studiengang_kz', title: 'Studiengang Kennzahl', visible: false }, + { field: 'studiengang_lv', title: 'StudiengangLV', visible: false }, + { field: 'studiengang_kz_lv', title: 'Studiengang_kzLV', visible: false }, + { field: 'semester_lv', title: 'SemesterLV', visible: false }, + { field: 'ects_lv', title: 'ECTS', visible: false }, + { field: 'lehrform', title: 'Lehrform', visible: false }, + { field: 'kurzbz', title: 'Kurzbz', visible: false }, + { field: 'punkte', title: 'Punkte', visible: false }, + { field: 'lehrveranstaltung_bezeichnung_english', title: 'Englisch', visible: false } + ]; + return { ajaxURL: 'dummy', ajaxRequestFunc: (url, config, params) => { @@ -32,27 +113,7 @@ export default { ajaxResponse: (url, params, response) => { return response.data || []; }, - columns: [ - { field: 'zeugnis', title: 'Zeugnis', formatter: 'tickCross' }, - { field: 'lehrveranstaltung_bezeichnung', title: 'Lehrveranstaltung' }, - { field: 'note_bezeichnung', title: 'Note' }, - { field: 'uebernahmedatum', title: 'Übernahmedatum', visible: false }, - { field: 'benotungsdatum', title: 'Benotungsdatum', visible: false }, - { field: 'benotungsdatum-iso', title: 'Benotungsdatum ISO', visible: false }, - { field: 'studiensemester_kurzbz', title: 'Studiensemester', visible: false }, - { field: 'note', title: 'Note Numerisch', visible: false }, - { field: 'lehrveranstaltung_id', title: 'Lehrveranstaltung ID', visible: false }, - { field: 'studiengang', title: 'Studiengang', visible: false }, - { field: 'studiengang_kz', title: 'Studiengang Kennzahl', visible: false }, - { field: 'studiengang_lv', title: 'StudiengangLV', visible: false }, - { field: 'studiengang_kz_lv', title: 'Studiengang_kzLV', visible: false }, - { field: 'semester_lv', title: 'SemesterLV', visible: false }, - { field: 'ects_lv', title: 'ECTS', visible: false }, - { field: 'lehrform', title: 'Lehrform', visible: false }, - { field: 'kurzbz', title: 'Kurzbz', visible: false }, - { field: 'punkte', title: 'Punkte', visible: false }, - { field: 'lehrveranstaltung_bezeichnung_english', title: 'Englisch', visible: false } - ], + columns, layout: 'fitDataStretch', height: '100%', selectable: 1, @@ -90,7 +151,7 @@ export default { :side-menu="false" reload > -