From e96311893f081efcb7fe754919838b34f9f8f460 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 26 Jun 2021 14:38:08 +0200 Subject: [PATCH] fix phpstan/phpcs --- UI/Component/Form.js | 18 +++++++++++------- UI/Component/Table.js | 6 +++--- Views/FormView.js | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/UI/Component/Form.js b/UI/Component/Form.js index fd56041..868f429 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -309,7 +309,9 @@ export class Form { action = typeof action !== 'undefined' ? action : null; - if (!form.isValid()) { + const data = form.getData(); + + if (!form.isValid(data)) { this.app.notifyManager.send( new NotificationMessage( NotificationLevel.INFO, @@ -334,7 +336,7 @@ export class Form const request = new Request(), self = this; - request.setData(form.getData()); + request.setData(data); request.setType(RequestType.FORM_DATA); request.setUri(action ? action : form.getAction()); request.setMethod(form.getMethod()); @@ -344,17 +346,19 @@ export class Form if (xhr.getResponseHeader('content-type') === 'application/octet-stream') { const blob = new Blob([xhr.response], { type: 'application/octet-stream' }); - const doc = document.createElement('a'); - doc.style = 'display: none'; + const doc = document.createElement('a'); + doc.style = 'display: none'; document.body.appendChild(doc); + const url = window.URL.createObjectURL(blob); - doc.href = url; + doc.href = url; const disposition = xhr.getResponseHeader('content-disposition'); - let filename = ''; + let filename = ''; if (disposition && disposition.indexOf('attachment') !== -1) { const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; - const matches = filenameRegex.exec(disposition); + const matches = filenameRegex.exec(disposition); + if (matches !== null && matches[1]) { filename = matches[1].replace(/['"]/g, ''); } diff --git a/UI/Component/Table.js b/UI/Component/Table.js index 7781217..e0994d9 100644 --- a/UI/Component/Table.js +++ b/UI/Component/Table.js @@ -373,10 +373,10 @@ export class Table { checkbox.addEventListener('click', function (event) { - const columnId = checkbox.closest('td').cellIndex; - const rows = checkbox.closest('table').querySelectorAll('tbody tr'); + const columnId = checkbox.closest('td').cellIndex; + const rows = checkbox.closest('table').querySelectorAll('tbody tr'); const rowLength = rows.length; - const status = checkbox.checked; + const status = checkbox.checked; for (let i = 0; i < rowLength; ++i) { const box = rows[i].cells[columnId].querySelector('input[type=checkbox]'); diff --git a/Views/FormView.js b/Views/FormView.js index 90a4eae..eebb556 100644 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -482,10 +482,10 @@ export class FormView * * @since 1.0.0 */ - isValid () + isValid (data) { - const elements = this.getFormElements(), - length = elements.length; + const elements = typeof data === 'undefined' ? this.getFormElements() : data; + const length = elements.length; try { for (let i = 0; i < length; ++i) {