-
Improvement
-
Resolution: Fixed
-
Major
-
4.3
-
MOODLE_403_STABLE
-
MOODLE_403_STABLE
-
MDL-78324-master-7 -
The way in which the core/modal module works and that we must separately register modals, before instantiating them from the factory is, to be frank, batshit crazy.
Right now it looks like:
// mymodal.js
|
import Modal from 'core/modal';
|
import * as ModalRegistry from 'core/modal_registry';
|
|
export default class MyModal extends Modal {
|
static TYPE = 'local_example/mymodal';
|
// ...
|
}
|
|
ModalRegistry.register(
|
MyModal.TYPE,
|
MyModal,
|
'local_example/mymodal', // Template name.
|
);
|
And then to instantiate it looks like:
// mycode.js
|
import MyModal from './mymodal';
|
import * as ModalFactory from 'core/modal_factory';
|
|
// ...
|
const myModal = await ModalFactory.create(MyModal.TYPE, {
|
// ...
|
large: true,
|
body: 'Hello world!',
|
});
|
myModal.show();
|
To be quite frank, this is nuts. There is so much boilerplate here, and it's so easy to reduce and remove most of it.
,
I'd like to get us to to the point where the definition is as simple as:
// mymodal.js
|
import Modal from 'core/modal';
|
|
export default class MyModal extends Modal {
|
static TYPE = 'local_example/mymodal';
|
static TEMPLATE = 'local_example/mymodal';
|
// ...
|
}
|
And then the instantiation is:
// mycode.js
|
import MyModal from './mymodal';
|
|
const myModal = MyModal.create({
|
// ...
|
large: true,
|
body: 'Hello world!',
|
show: true,
|
});
|
I believe that we should be able to entirely get rid of:
- the modal_registry (after deprecating)
- the modal_factory (moving existing functionality to core/modal as new static methods and depreating)
- the need to register modals at all
We also do a ridiculous amount of configuration in the factory instead of the modal itself - again why!?
This issue is about taking some ideas originally put into MDL-78306, and enacting them here.
- caused a regression
-
MDL-81339 Modal factory no longer respects template defined in registry
- Development in progress
-
MDL-79384 Modals broken in mod_lti, analytics
- Closed
-
MDL-79340 Various rubric behat failures
- Closed
-
MDL-79356 Share to MoodleNet modal stops working
- Closed
-
MDL-79584 Unable to select payment gateway during payment-based enrolment
- Closed
-
MDL-79400 Calendar: Undefined fail() function
- Closed
-
MDL-79451 An 'Undefined string' error occurs when attempting to cancel the publish or unpublish action for BigBlueButton (BBB) recordings.
- Closed
-
MDL-80673 View Grades modal is missing the Grading Guide criteria and feedback from professors
- Closed
-
MDL-79521 Error while exporting the model configuration on analytics model
- Closed
-
MDL-79693 Copy to clipboard modal no longer shows toast message upon success
- Closed
-
MDL-79762 Modal forms no longer support alternative form type.
- Closed
-
MDL-82045 Category autocomplete disappears when copy course form invalid
- Closed
- has to be done before
-
MDL-79182 Deprecate core/modal_factory and core/modal_registry
- Open
- is blocked by
-
MDL-79248 Behat failures following MDL-72321
- Closed
-
MDL-78306 Convert core/modal and remaining legacy uses to ESM
- Closed
- Testing discovered
-
MDL-79246 Behat gradingform_rubric steps use Node->click
- Closed
- links to