Skip to content
Snippets Groups Projects
Verified Commit 19fed8d8 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: tidy and stylings

parent dd8967a8
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,8 @@
<main>
<div id="error-message" data-monster-error="this is the error">This control has an error</div>
<monster-context-error>error1</monster-context-error>
<monster-context-error></monster-context-error>
<monster-context-error>error1</monster-context-error> das ist ein test
<monster-context-error></monster-context-error> dieser hat keine fehlermeldung und damit keinen fehler.
</main>
</body>
......
......@@ -15,11 +15,6 @@ if (!filename.endsWith(".pcss")) {
process.exit(1);
}
if (existsSync(`${projectRoot}/dist`) === false) {
console.error("Creating dist directory");
process.exit(1);
}
buildCSS(filename, createScriptFilenameFromStyleFilename(filename)).then(() => {
}).catch((e) => {
console.error(e.message);
......
......@@ -142,7 +142,7 @@ class DataSet extends CustomElement {
* @type {boolean}
*/
refreshOnMutation: {
selector: "input, select, textarea"
selector: "input, select, textarea",
},
data: {},
......@@ -268,10 +268,12 @@ class DataSet extends CustomElement {
}),
);
if (this.getOption("features.refreshOnMutation")&&this.getOption("refreshOnMutation.selector")) {
if (
this.getOption("features.refreshOnMutation") &&
this.getOption("refreshOnMutation.selector")
) {
initMutationObserver.call(this);
}
}
/**
......@@ -316,21 +318,21 @@ function updateOptionsFromArguments(options) {
* @private
*/
function initMutationObserver() {
const config = { attributes: false, childList: true, subtree: true };
const callback = (mutationList, observer) => {
if (mutationList.length === 0) {
return;
}
let doneFlag = false;
for (const mutation of mutationList) {
if (mutation.type === "childList") {
for (const node of mutation.addedNodes) {
if(node instanceof HTMLElement && node.matches(this.getOption("refreshOnMutation.selector"))) {
if (
node instanceof HTMLElement &&
node.matches(this.getOption("refreshOnMutation.selector"))
) {
doneFlag = true;
break;
}
......@@ -349,10 +351,8 @@ function initMutationObserver() {
const observer = new MutationObserver(callback);
observer.observe(this, config);
}
/**
* @private
* @return {string}
......
......@@ -482,7 +482,6 @@ function handleIntersectionObserver(json, response, filterControl) {
* @private
*/
function initAutoInit() {
const autoInit = this.getOption("features.autoInit");
validateBoolean(autoInit);
......@@ -494,8 +493,7 @@ function initAutoInit() {
}
setTimeout(() => {
this.fetch().catch(() => {
});
this.fetch().catch(() => {});
}, 0);
}
......
......@@ -238,7 +238,6 @@ class Filter extends CustomElement {
},
},
labels: {
search: "Search",
reset: "Reset",
save: "Save",
......
......@@ -12,50 +12,17 @@
* SPDX-License-Identifier: AGPL-3.0
*/
import {instanceSymbol} from "../../constants.mjs";
import {internalSymbol} from "../../constants.mjs";
import {TokenList} from "../../types/tokenlist.mjs";
import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
import { DataSet } from "../datatable/dataset.mjs";
//import { Datasource } from "../../data/datasource.mjs";
import {RestAPI} from "../../data/datasource/server/restapi.mjs";
import {WebConnect} from "../../data/datasource/server/webconnect.mjs";
import {WriteError} from "../../data/datasource/server/restapi/writeerror.mjs";
import {LocalStorage} from "../../data/datasource/storage/localstorage.mjs";
import {SessionStorage} from "../../data/datasource/storage/sessionstorage.mjs";
import {
ATTRIBUTE_DISABLED,
ATTRIBUTE_ERRORMESSAGE,
ATTRIBUTE_PREFIX,
ATTRIBUTE_UPDATER_ATTRIBUTES,
ATTRIBUTE_UPDATER_INSERT,
ATTRIBUTE_UPDATER_REMOVE,
ATTRIBUTE_UPDATER_REPLACE,
} from "../../dom/constants.mjs";
import {
assembleMethodSymbol,
CustomElement,
registerCustomElement,
getSlottedElements,
} from "../../dom/customelement.mjs";
import {addObjectWithUpdaterToElement} from "../../dom/updater.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import {isFunction, isString} from "../../types/is.mjs";
import {Observer} from "../../types/observer.mjs";
import {ProxyObserver} from "../../types/proxyobserver.mjs";
import {Processing} from "../../util/processing.mjs";
import {datasourceLinkedElementSymbol, handleDataSourceChanges} from "../datatable/util.mjs";
import {MessageStateButton} from "./message-state-button.mjs";
import {
ATTRIBUTE_FORM_DATASOURCE,
ATTRIBUTE_FORM_DATASOURCE_ARGUMENTS,
} from "./constants.mjs";
import {StateButton} from "./state-button.mjs";
import { FormStyleSheet } from "./stylesheet/form.mjs";
export { Form };
/**
* @private
* @type {symbol}
......@@ -63,16 +30,12 @@ export {Form};
const debounceCallbackSymbol = Symbol("timerCallback");
class Form extends DataSet {
/**
*
* @returns {{shadowMode: string, templates: {main: *}, display: string, disabled: boolean, delegatesFocus: boolean, templateMapping: {}} & {templates: {main: string}, classes: {form: string}}}
*/
get defaults() {
const obj = Object.assign(
{},
super.defaults,
{
const obj = Object.assign({}, super.defaults, {
templates: {
main: getTemplate(),
},
......@@ -82,24 +45,20 @@ class Form extends DataSet {
},
writeBack: {
events: ["change", "input", "keyup"]
events: ["change", "input", "keyup"],
},
reportValidity: {
selector: "input,select,textarea",
}
}
);
},
});
obj['features']['mutationObserver'] = false;
obj['features']['writeBack'] = true;
obj["features"]["mutationObserver"] = false;
obj["features"]["writeBack"] = true;
return obj;
}
/**
*
* @return {string}
......@@ -124,7 +83,6 @@ class Form extends DataSet {
initControlReferences.call(this);
initEventHandler.call(this);
initDataSourceHandler.call(this);
}
/**
......@@ -160,31 +118,24 @@ class Form extends DataSet {
return valid;
}
}
function initDataSourceHandler() {
}
function initDataSourceHandler() {}
/**
* @private
* @returns {initEventHandler}
*/
function initEventHandler() {
if (this.getOption("features.writeBack") === true) {
const events = this.getOption("writeBack.events");
for (const event of events) {
this.addEventListener(event, (e) => {
if (!this.reportValidity()) {
this.classList.add("invalid");
setTimeout(() => {
this.classList.remove("invalid");
}, 1000)
}, 1000);
return;
}
......@@ -206,7 +157,6 @@ function initEventHandler() {
this.write();
}, 0);
});
});
}
}
......
......@@ -698,7 +698,7 @@ class Select extends CustomControl {
const selection = this.getOption("selection");
let newValue = [];
if (selection) {
newValue = selection
newValue = selection;
} else if (this.hasAttribute("value")) {
newValue = this.getAttribute("value");
}
......@@ -710,7 +710,7 @@ class Select extends CustomControl {
resolve(result);
}, 10);
return
return;
}
setStatusOrRemoveBadges.call(this, "error");
......@@ -1866,7 +1866,6 @@ function areOptionsAvailableAndInit() {
* @throws {Error} no shadow-root is defined
*/
function checkOptionState() {
if (!this.shadowRoot) {
throw new Error("no shadow-root is defined");
}
......@@ -1891,8 +1890,6 @@ function checkOptionState() {
if (e.checked !== false) e.checked = false;
}
}
}
/**
......@@ -1976,7 +1973,7 @@ function setSelection(selection) {
selection = [];
}
validateArray(selection)
validateArray(selection);
for (let i = 0; i < selection.length; i++) {
selection[i] = {
......@@ -2114,9 +2111,11 @@ function show() {
setStatusOrRemoveBadges.call(this, "loading");
new Processing(200, () => {
this.fetch().then(() => {
this.fetch()
.then(() => {
checkOptionState.call(this);
}).catch((e) => {
})
.catch((e) => {
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
setStatusOrRemoveBadges.call(this, "error");
});
......
......@@ -21,7 +21,6 @@ import {Pipe} from "../pipe.mjs";
export { Server };
/**
* @private
* @type {symbol}
......@@ -96,7 +95,10 @@ class Server extends Datasource {
* @returns {*}
*/
function doDiff(obj) {
if (this[serverVersionSymbol] === null || this[serverVersionSymbol] === undefined) {
if (
this[serverVersionSymbol] === null ||
this[serverVersionSymbol] === undefined
) {
return obj;
}
......
......@@ -31,7 +31,6 @@ const rawDataSymbol = Symbol.for(
"@schukai/monster/data/datasource/server/restapi/rawdata",
);
/**
* The RestAPI is a class that enables a REST API server.
*
......@@ -114,7 +113,7 @@ class RestAPI extends Server {
partial: {
callback: null,
}
},
},
read: {
init: {
......@@ -198,7 +197,9 @@ function fetchData(init, key, callback) {
.then((resp) => {
response = resp;
const acceptedStatus = this.getOption(`${key}.acceptedStatus`, [200]).map(Number);
const acceptedStatus = this.getOption(`${key}.acceptedStatus`, [200]).map(
Number,
);
if (acceptedStatus.indexOf(resp.status) === -1) {
throw new DataFetchError(
......@@ -232,7 +233,8 @@ function fetchData(init, key, callback) {
}
return response;
}).catch((e) => {
})
.catch((e) => {
throw e;
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment