diff options
| author | Shyam Sunder | 2020-06-05 18:03:37 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-06-06 08:58:23 -0400 |
| commit | 57193b57157b7a42896c887a2d5930493ac7b290 (patch) | |
| tree | 9555453a944caae64d8a00e4b073482d9e7fb244 /client/js/views/pool_create_view.js | |
| parent | c06aaa63af977e64ef08bfba7829214f0f0ed38e (diff) | |
client+server: implement code autoformatting using prettier and black
Diffstat (limited to 'client/js/views/pool_create_view.js')
| -rw-r--r-- | client/js/views/pool_create_view.js | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/client/js/views/pool_create_view.js b/client/js/views/pool_create_view.js index f22cf71..fc75f45 100644 --- a/client/js/views/pool_create_view.js +++ b/client/js/views/pool_create_view.js @@ -1,41 +1,43 @@ -'use strict'; +"use strict"; -const events = require('../events.js'); -const api = require('../api.js'); -const misc = require('../util/misc.js'); -const views = require('../util/views.js'); -const Pool = require('../models/pool.js') +const events = require("../events.js"); +const api = require("../api.js"); +const misc = require("../util/misc.js"); +const views = require("../util/views.js"); +const Pool = require("../models/pool.js"); -const template = views.getTemplate('pool-create'); +const template = views.getTemplate("pool-create"); class PoolCreateView extends events.EventTarget { constructor(ctx) { super(); - this._hostNode = document.getElementById('content-holder'); + this._hostNode = document.getElementById("content-holder"); views.replaceContent(this._hostNode, template(ctx)); views.decorateValidator(this._formNode); if (this._namesFieldNode) { - this._namesFieldNode.addEventListener( - 'input', e => this._evtNameInput(e)); + this._namesFieldNode.addEventListener("input", (e) => + this._evtNameInput(e) + ); } if (this._postsFieldNode) { - this._postsFieldNode.addEventListener( - 'input', e => this._evtPostsInput(e)); + this._postsFieldNode.addEventListener("input", (e) => + this._evtPostsInput(e) + ); } for (let node of this._formNode.querySelectorAll( - 'input, select, textarea, posts')) { - node.addEventListener( - 'change', e => { - this.dispatchEvent(new CustomEvent('change')); - }); + "input, select, textarea, posts" + )) { + node.addEventListener("change", (e) => { + this.dispatchEvent(new CustomEvent("change")); + }); } - this._formNode.addEventListener('submit', e => this._evtSubmit(e)); + this._formNode.addEventListener("submit", (e) => this._evtSubmit(e)); } clearMessages() { @@ -64,19 +66,21 @@ class PoolCreateView extends events.EventTarget { if (!list.length) { this._namesFieldNode.setCustomValidity( - 'Pools must have at least one name.'); + "Pools must have at least one name." + ); return; } for (let item of list) { if (!regex.test(item)) { this._namesFieldNode.setCustomValidity( - `Pool name "${item}" contains invalid symbols.`); + `Pool name "${item}" contains invalid symbols.` + ); return; } } - this._namesFieldNode.setCustomValidity(''); + this._namesFieldNode.setCustomValidity(""); } _evtPostsInput(e) { @@ -86,46 +90,50 @@ class PoolCreateView extends events.EventTarget { for (let item of list) { if (!regex.test(item)) { this._postsFieldNode.setCustomValidity( - `Pool ID "${item}" is not an integer.`); + `Pool ID "${item}" is not an integer.` + ); return; } } - this._postsFieldNode.setCustomValidity(''); + this._postsFieldNode.setCustomValidity(""); } _evtSubmit(e) { e.preventDefault(); - this.dispatchEvent(new CustomEvent('submit', { - detail: { - names: misc.splitByWhitespace(this._namesFieldNode.value), - category: this._categoryFieldNode.value, - description: this._descriptionFieldNode.value, - posts: misc.splitByWhitespace(this._postsFieldNode.value) - .map(i => parseInt(i)) - }, - })); + this.dispatchEvent( + new CustomEvent("submit", { + detail: { + names: misc.splitByWhitespace(this._namesFieldNode.value), + category: this._categoryFieldNode.value, + description: this._descriptionFieldNode.value, + posts: misc + .splitByWhitespace(this._postsFieldNode.value) + .map((i) => parseInt(i)), + }, + }) + ); } get _formNode() { - return this._hostNode.querySelector('form'); + return this._hostNode.querySelector("form"); } get _namesFieldNode() { - return this._formNode.querySelector('.names input'); + return this._formNode.querySelector(".names input"); } get _categoryFieldNode() { - return this._formNode.querySelector('.category select'); + return this._formNode.querySelector(".category select"); } get _descriptionFieldNode() { - return this._formNode.querySelector('.description textarea'); + return this._formNode.querySelector(".description textarea"); } get _postsFieldNode() { - return this._formNode.querySelector('.posts input'); + return this._formNode.querySelector(".posts input"); } } |