Skip to content

Commit

Permalink
Fixed lint issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
gushil committed Jan 3, 2025
1 parent 1f63692 commit 0189901
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/enketo-core/src/widget/text-print/text-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ class TextPrintWidget extends Widget {
const className = 'print-input-text';
const printElement = document.createElement('div');
printElement.classList.add(className, 'widget');

printElement.innerHTML = this.element.value.replace(/\n/g, '<br>');
this.element.after(printElement);
this.element.classList.add('print-hide');

this.widget = printElement;
}

_removeWidget() {
this.element.classList.remove('print-hide');

const previousElement = this.element.previousElementSibling;
const isDateWidget = previousElement?.classList.contains('date');

// If previous element is a date widget, change its value to actual value
if (isDateWidget) {
const dateInputElement = previousElement.querySelector('input');
Expand Down
25 changes: 13 additions & 12 deletions packages/enketo-express/public/js/src/module/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ function printOcForm() {

return new Promise((resolve, reject) => {
const cleanup = () => {
textPrints.forEach(textPrint => {
textPrints.forEach((textPrint) => {
textPrint.dispatchEvent(events.DePrintify());
});
if (historyAdded) {
return new Promise(resolveCleanup => {
return new Promise((resolveCleanup) => {
setTimeout(() => {
dns.forEach(dn => {
dns.forEach((dn) => {
dn.dispatchEvent(events.DePrintify());
});
resolveCleanup();
Expand All @@ -580,44 +580,45 @@ function printOcForm() {

if (format.queries === 'yes') {
historyAdded = true;
dns.forEach(dn => {
dns.forEach((dn) => {
dn.dispatchEvent(events.Printify());
});
}

textPrints.forEach(textPrint => {
textPrints.forEach((textPrint) => {
textPrint.dispatchEvent(events.Printify());
});

if (formTheme === 'grid' || (!formTheme && printHelper.isGrid())) {
return printGrid(format)
.then(() => cleanup())
.then(resolve)
.catch(error => {
.catch((error) => {
cleanup().then(() => reject(error));
});
}

return new Promise(resolvePrint => {
return new Promise((resolvePrint) => {
setTimeout(() => {
window.print();
resolvePrint();
}, 100);
})
.then(() => cleanup())
.then(resolve)
.catch(error => {
.catch((error) => {
cleanup().then(() => reject(error));
});
};

const promptInputs = (formTheme === 'grid' || (!formTheme && printHelper.isGrid()))
? gridInputs
: regularInputs;
const promptInputs =
formTheme === 'grid' || (!formTheme && printHelper.isGrid())
? gridInputs
: regularInputs;

prompt(texts, options, promptInputs)
.then(handlePrint)
.catch(error => {
.catch((error) => {
cleanup().then(() => reject(error));
});
});
Expand Down

0 comments on commit 0189901

Please sign in to comment.