Refactor code structure for improved readability and maintainability
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
2026-07-08 19:33:23 +02:00
parent 4abf81cd7d
commit 59a2b86c09
23 changed files with 676 additions and 60 deletions
+23 -7
View File
@@ -480,14 +480,22 @@ $inv.cSt = function (data) {
});
};
$inv.eHtml = function (ev) {
let t = $(this), frmct = ev.data instanceof jQuery ? ev.data : ev.data.t, flds = [
{ name: 'txt', label: 'Text', type: 'html', value: frmct.html(), tinymce: true, attr: { style: 'height: 300px' } }
];
let t = $(this), frmct = ev.data instanceof jQuery ? ev.data : ev.data.t;
/* invoiceemail must stay plain text — using the TinyMCE/html editor here used to wrap the
address in <p> tags, which then got posted and persisted verbatim into SendToEmail. */
let isPlainText = ev.data.nme === 'invoiceemail';
let flds = isPlainText
? [{ name: 'txt', label: 'Text', type: 'text', value: frmct.text() }]
: [{ name: 'txt', label: 'Text', type: 'html', value: frmct.html(), tinymce: true, attr: { style: 'height: 300px' } }];
let change = ev.data.change || null;
let sets = {
title: t.data('dialog') || '',
success: function (response) {
frmct.html(response.txt);
if (isPlainText) {
frmct.text(response.txt || '');
} else {
frmct.html(response.txt);
}
if (typeof change === 'function') {
change(response.txt);
}
@@ -962,7 +970,6 @@ $inv.sprev = (change) => {
}
$ocms.postXT({
url: $ocms.url('req/' + (change === true ?'sedit':'sprep')), data: { invc: JSON.stringify($inv.invcPayload(d)), id: d.invid ||'' }, success: (response) => {
l.rC('freeze');
let c = $$.dc('imagecollection pdfpreview'), vhr = Math.round(vh() * 0.88), invid = response.id, invtp = response.total;
if (invtp > 10) {
$$.dc('note warn', c).text($ict.tpe);
@@ -976,15 +983,20 @@ $inv.sprev = (change) => {
$ocms.dlg(c, {
size: [vhr, Math.round(vw() * 0.88)], zindex: 50, form: false, button: $rct.crI, confirm: function (e) {
let ct = $(this);
l.aC('freeze'); /* spinner while the invoice is finalized/emailed on the backend */
$ocms.postXT({
url: $ocms.url('req/sconf'), data: { id: invid }, success: () => {
url: $ocms.url('req/sconf'), data: { id: invid }, success: (cresp) => {
ct.trigger('modal_close');
window.open($ocms.url('req/idoc') + '?id=' + invid, '_blank'); /* open pdf in new tab */
if (cresp.hasFile === true) {
window.open($ocms.url('req/idoc') + '?id=' + invid, '_blank'); /* open pdf in new tab, only if a file was actually created */
}
$ocms.init('req'); /* go back to request list */
$inv.rReload();
}, error: () => {
alert($t.f1);
ct.trigger('modal_close');
}, complete: () => {
l.rC('freeze');
}
});
}, cancel: function (e) {
@@ -999,6 +1011,10 @@ $inv.sprev = (change) => {
$inv.rReload();
}
});
}, error: () => {
alert($ict.eis);
}, complete: () => {
l.rC('freeze');
}
});
};