e-valuation / EvaP

a university course evaluation system written in Python using Django
Other
96 stars 146 forks source link

Convert sortable-form and its usages to TypeScript #2199

Open PFischbeck opened 1 month ago

PFischbeck commented 1 month ago

This helps (maybe resolves?) #2082. In particular, sortable-form.js is now in TypeScript, and the scripts using it also don't use jQuery anymore. Note that jquery.formset.js still requires jQuery...

Possible future things:

Please test the changed forms to make sure nothing broke :)

PFischbeck commented 2 weeks ago

The commit where you added import { makeFormSortable } ... instead of the script tag has a message starting with "Fix" - I am curious, was the previous version not working anymore?

Correct! Once I added import { selectOrError } from "./utils.js";, it failed. To be honest, I can't remember exactly why, but this has something to do with modules and scripts, where I can't do imports within scripts. Switching to using sortable-form as a module import instead of a script fixed it.

niklasmohrin commented 2 weeks ago

Ah right, it has to itself be a module to import from other modules. Alright!

richardebeling commented 2 weeks ago

On http://localhost:8000/staff/faq/, I also get

Uncaught TypeError: row.querySelector(...) is null rowChanged http://localhost:8000/staff/faq/:815 applyOrdering http://localhost:8000/static/js/sortable-form.js:5 applyOrdering http://localhost:8000/static/js/sortable-form.js:4 makeFormSortable http://localhost:8000/static/js/sortable-form.js:72

failing at

const nameDe = row.querySelector('input[id$=-title_de]').value;

while row is the header row (that doesn't contain any input fields).

PFischbeck commented 2 weeks ago

That's weird, I can't reproduce this error locally, neither in Firefox nor Safari. I open http://localhost:8000/staff/faq/ and am able to drag and reorder the items.

richardebeling commented 2 weeks ago

That's weird, I can't reproduce this error locally, neither in Firefox nor Safari. I open http://localhost:8000/staff/faq/ and am able to drag and reorder the items.

Sorry, I should have added that: Drag+Drop works fine. The error happens when you click the submit button, after reloading the page the order is reset to the initial order.

PFischbeck commented 2 weeks ago

That's weird, I can't reproduce this error locally, neither in Firefox nor Safari. I open http://localhost:8000/staff/faq/ and am able to drag and reorder the items.

Sorry, I should have added that: Drag+Drop works fine. The error happens when you click the submit button, after reloading the page the order is reset to the initial order.

Thanks for the clarification, makes sense! This should be fixed now.