From 0a976fa35fde44a51f66a358a83e24d190e81d38 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 29 Jul 2024 10:45:50 -0500 Subject: [PATCH 1/5] Codemirror: disable change flag on submit, avoids spurious 'navigate away?' --- relate/static/js/codemirror.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/relate/static/js/codemirror.js b/relate/static/js/codemirror.js index b246e524b..45bf70f24 100644 --- a/relate/static/js/codemirror.js +++ b/relate/static/js/codemirror.js @@ -134,6 +134,9 @@ export function setListener(view, fn) { } Vim.defineEx('write', 'w', () => { + // assume we're submitting the changes, reset the change flag + anyEditorChangedFlag = false; + const textarea = document.querySelector('textarea.rl-managed-by-codemirror'); if (textarea.form) { const { form } = textarea; From 97c7f3f4d39d304bc70cb04150a570ae7b92c284 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 29 Jul 2024 13:33:34 -0500 Subject: [PATCH 2/5] Export global JS identifiers by setting to globalThis --- course/templates/course/course-base-with-markup.html | 8 -------- course/templates/course/course-datatables.html | 3 --- relate/static/js/base-with-markup.js | 4 ---- relate/static/js/base.js | 4 ++-- relate/static/js/datatables.js | 5 ----- relate/templates/base.html | 4 ---- rollup.config.js | 2 -- 7 files changed, 2 insertions(+), 28 deletions(-) diff --git a/course/templates/course/course-base-with-markup.html b/course/templates/course/course-base-with-markup.html index 391728f6d..165eb325a 100644 --- a/course/templates/course/course-base-with-markup.html +++ b/course/templates/course/course-base-with-markup.html @@ -4,13 +4,5 @@ {% block bundle_loads %} {# contains mathjax config #} - - - - {% endblock %} diff --git a/course/templates/course/course-datatables.html b/course/templates/course/course-datatables.html index 845523a84..9c48be2d4 100644 --- a/course/templates/course/course-datatables.html +++ b/course/templates/course/course-datatables.html @@ -3,7 +3,4 @@ {% block bundle_loads %} - {% endblock %} diff --git a/relate/static/js/base-with-markup.js b/relate/static/js/base-with-markup.js index 242573f13..372689184 100644 --- a/relate/static/js/base-with-markup.js +++ b/relate/static/js/base-with-markup.js @@ -2,8 +2,6 @@ import tmpl from 'blueimp-tmpl'; import './base'; -import * as bootstrap from 'bootstrap'; -import * as rlUtils from './rlUtils'; import 'jstree'; import 'video.js'; @@ -15,5 +13,3 @@ window.MathJax = { displayMath: [['$$', '$$'], ['\\[', '\\]']], }, }; - -export { rlUtils, tmpl, bootstrap }; diff --git a/relate/static/js/base.js b/relate/static/js/base.js index e69266ef1..d9565d732 100644 --- a/relate/static/js/base.js +++ b/relate/static/js/base.js @@ -9,5 +9,5 @@ import '../css/base.scss'; select2(jQuery); -/* eslint-disable-next-line import/prefer-default-export */ -export { rlUtils, bootstrap }; +globalThis.rlUtils = rlUtils; +globalThis.bootstrap = bootstrap; diff --git a/relate/static/js/datatables.js b/relate/static/js/datatables.js index b4bce67ef..9c3427d82 100644 --- a/relate/static/js/datatables.js +++ b/relate/static/js/datatables.js @@ -12,8 +12,6 @@ import datatablesFixedColumns from 'datatables.net-fixedcolumns/js/dataTables.fi import 'datatables.net-fixedcolumns-bs5/css/fixedColumns.bootstrap5.css'; import 'datatables.net-fixedcolumns-bs5/js/fixedColumns.bootstrap5'; -import * as rlUtils from './rlUtils'; - datatables(window, jQuery); datatablesBs(window, jQuery); datatablesFixedColumns(window, jQuery); @@ -36,7 +34,4 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, { // }}} -/* eslint-disable-next-line import/prefer-default-export */ -export { rlUtils }; - // vim: foldmethod=marker diff --git a/relate/templates/base.html b/relate/templates/base.html index ce670cb2c..bc074e313 100644 --- a/relate/templates/base.html +++ b/relate/templates/base.html @@ -13,10 +13,6 @@ {% block bundle_loads %} - {% endblock %} {% block head_assets_form_media %} diff --git a/rollup.config.js b/rollup.config.js index 9f0b446a1..fdc371ac4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -38,7 +38,6 @@ export default [ file: 'frontend-dist/bundle-base.js', format: 'iife', sourcemap: true, - name: 'rlBase', }, plugins: defaultPlugins, }, @@ -48,7 +47,6 @@ export default [ file: 'frontend-dist/bundle-base-with-markup.js', format: 'iife', sourcemap: true, - name: 'rlBase', }, plugins: defaultPlugins, }, From a82f2dd08ace5d49ee69db0bc667c67c9c530274 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 29 Jul 2024 13:29:40 -0500 Subject: [PATCH 3/5] Offer Bootstrap toast as a global utility function --- course/templates/course/grade-flow-page.html | 16 +--------------- relate/static/js/base.js | 2 ++ relate/static/js/bsUtils.js | 12 ++++++++++++ relate/templates/base.html | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 relate/static/js/bsUtils.js diff --git a/course/templates/course/grade-flow-page.html b/course/templates/course/grade-flow-page.html index ee2aea81a..21315aeb9 100644 --- a/course/templates/course/grade-flow-page.html +++ b/course/templates/course/grade-flow-page.html @@ -219,17 +219,6 @@

{% trans "Grading" %}: {{ flow_identifier}} - {{ page_data.group_id }}/ {# {{{ grade ui #} -
- -
- - - {# https://github.com/blueimp/JavaScript-Templates #} - - {% endif %} - {{ block.super }} -{% endblock %} {# vim: set foldmethod=marker: #} diff --git a/course/templates/course/grade-flow-page.html b/course/templates/course/grade-flow-page.html index 9f463d644..d66d15ab3 100644 --- a/course/templates/course/grade-flow-page.html +++ b/course/templates/course/grade-flow-page.html @@ -111,12 +111,18 @@

{% trans "Grading" %}: {{ flow_identifier}} - {{ page_data.group_id }}/ {% if expects_answer %}