Playwright Tests / test (push) Canceled after 0s
serializeObject() returns null for an invalid form, but most callers sent
the result anyway. Add $.fn.rejectInvalid (stop the spinner, let the
browser report the offending field) and use it at every call site.
Bugs fixed:
- Password change: on a mismatch the spinner kept running, and the custom
validity on "npw" was never cleared, so the browser blocked every later
submit even after the passwords matched. It is now cleared as soon as
either password field is edited.
- sendForm: options.complete referenced an undefined jqXHR (ReferenceError)
and an invalid form was posted with partial data.
- login.send: an invalid form threw a TypeError on qs.loginaccount.
- postXT({ form }): an invalid form was posted with empty data.
- Form dialogs without required fields had no "Bitte überprüfen Sie Ihre
Eingaben" note, so a rejected submit showed nothing.
Hardening: null guards for the user, user-group, re-login, SMS password,
admin specialties and report-parameter submits.
Add e2e_tests/form-validation.cjs covering each path against the real
scripts; it fails on the previous code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
88 lines
3.8 KiB
JavaScript
88 lines
3.8 KiB
JavaScript
let $ct = {
|
|
mdl: 'Berichte'
|
|
}, $ccol = {
|
|
|
|
};
|
|
function getMonday(d) {
|
|
d = new Date(d);
|
|
var day = d.getDay(),
|
|
diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday
|
|
return new Date(d.setDate(diff));
|
|
}
|
|
let $rep = {
|
|
init2: function (type, options) {
|
|
//console.debug('inv.init2');
|
|
type = type || 'inv';
|
|
options = options || {};
|
|
$ocms.getScript([
|
|
//{ script: 'web/jstree.min.js', css: 'web/jstree.min.css', condition: typeof $.fn.jstree !== 'function' }
|
|
//, { script: 'web/jquery.qtip.min.js', css: 'web/jquery.qtip.min.css', condition: typeof $.fn.qtip !== 'function' }
|
|
//, { script: 'web/typeahead.min.js', css: '', condition: typeof $.fn.typeahead !== 'function' }
|
|
//, { script: 'web/fullcalendar.min.js', module: 'FullCalendar', css: 'web/fullcalendar.min.css', condition: typeof FullCalendar !== 'object' }
|
|
], function () {
|
|
//FullCalendar = $vm.FullCalendar;
|
|
$rep.init3(type, options);
|
|
});
|
|
}, init3: async function (type, options) {
|
|
//console.debug('inv.init3');
|
|
let cf = $('#contentframe').empty(), cf2 = $$.dc('cfrm hd').appendTo(cf), frm = $$.dc('init_frm', cf);
|
|
let tbar = $('#topbar').ocmsmenu([]); //{ lbl: 'home', fnc: $rep.init3 }
|
|
$('#activemodule').text($ct.mdl);
|
|
let repfrm = $$.dc('repfrm', frm);
|
|
let td = new Date();
|
|
let pa = [(async () => {
|
|
if (await $fis.getAuth('fds_reports') > 0) {
|
|
frm.IN(function () { });
|
|
let lf = $('#listframe').empty().aC('fix').rC('hd');
|
|
let scp = function (rx) {
|
|
let itm = $(this);
|
|
if ((rx.params || []).length > 0) {
|
|
let ifrm = $$.dc('ipf', itm).click(function (ev) {
|
|
ev.stopPropagation();
|
|
});
|
|
$.each(rx.params, (pi, px) => {
|
|
let ig = $$.dc('ig', ifrm).append($$.lbl(px.name)), i;
|
|
if ((px.valuelist || '') === '') {
|
|
i = $$.i({ name: px.name, placeholder: px.placeholder }).appendTo(ig);
|
|
if ((px.default || '') !== '') {
|
|
i.val(px.default);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
let scl = function (ev) {
|
|
//console.debug(ev);
|
|
let btn = $(this), rx = ev.data, params = btn.serializeObject();
|
|
if (params === null) { return; }
|
|
$ocms.postXT({
|
|
url: $ocms.url('rep/gct/' + rx.name), data: params, success: (response) => {
|
|
btn.addClass('selected').siblings().removeClass('selected');
|
|
$('#listframe').rC('fix').aC('hd');
|
|
repfrm.html(response);
|
|
}, datatype: 'html'
|
|
});
|
|
};
|
|
$ocms.postXT({
|
|
url: $ocms.url('rep/catalog'), data: {}, success: (response) => {
|
|
$.each(response.reports, (ri, rx) => {
|
|
let i = $$.dc('repitm', lf).text(rx.label).click(rx, scl);
|
|
scp.call(i, rx);
|
|
});
|
|
}
|
|
});
|
|
|
|
}
|
|
})(), new Promise((resolve, reject) => {
|
|
//$rep.123()
|
|
/*
|
|
let tgt = fdt(new Date(td.getFullYear(), (td.getMonth() - 1), 1), 'yy-MM-dd');
|
|
$rep.renderinv.call(invfrm, tgt, 'm');
|
|
*/
|
|
})];
|
|
await Promise.all(pa);
|
|
}
|
|
|
|
}
|
|
let $$rep = { init2: $rep.init2, auth: {} };
|
|
export default $$rep; |