mirror of
https://github.com/johndoe6345789/AutoMetabuilder.git
synced 2026-04-24 13:54:59 +00:00
Add WorkflowToggle and FormValidator plugins:
- Introduce `workflow_toggle.js` for toggling workflow visibility. - Implement `form_validator.js` for form validation on submission. - Register plugins with `AMBPlugins` for initialization.
This commit is contained in:
21
src/autometabuilder/web/static/js/plugins/form_validator.js
Normal file
21
src/autometabuilder/web/static/js/plugins/form_validator.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* AutoMetabuilder - Form Validator
|
||||
*/
|
||||
(() => {
|
||||
const FormValidator = {
|
||||
init() {
|
||||
document.querySelectorAll('form[data-validate]').forEach(form => {
|
||||
form.addEventListener('submit', event => {
|
||||
if (!form.checkValidity()) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
form.classList.add('was-validated');
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.FormValidator = FormValidator;
|
||||
window.AMBPlugins?.register('form_validator', async () => FormValidator.init());
|
||||
})();
|
||||
25
src/autometabuilder/web/static/js/plugins/workflow_toggle.js
Normal file
25
src/autometabuilder/web/static/js/plugins/workflow_toggle.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* AutoMetabuilder - Workflow Toggle
|
||||
*/
|
||||
(() => {
|
||||
const WorkflowToggle = {
|
||||
init() {
|
||||
document.querySelectorAll('[data-workflow-toggle]').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const builder = window.WorkflowBuilder;
|
||||
if (builder && builder.textarea && typeof builder.toggleRaw === 'function') {
|
||||
builder.toggleRaw();
|
||||
return;
|
||||
}
|
||||
const textarea = document.getElementById('workflow-content');
|
||||
if (textarea) {
|
||||
textarea.classList.toggle('d-none');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.WorkflowToggle = WorkflowToggle;
|
||||
window.AMBPlugins?.register('workflow_toggle', async () => WorkflowToggle.init());
|
||||
})();
|
||||
Reference in New Issue
Block a user