Sanity-check decaffeinate app.views.DocPicker

pull/1441/head
Simon Legner 1 year ago
parent b201fb269f
commit 49dbba3de3

@ -1,23 +1,10 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
* DS206: Consider reworking classes to avoid initClass
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
app.views.DocPicker = class DocPicker extends app.View { app.views.DocPicker = class DocPicker extends app.View {
static initClass() { static className = "_list _list-picker";
this.className = "_list _list-picker";
this.events = { static events = {
mousedown: "onMouseDown", mousedown: "onMouseDown",
mouseup: "onMouseUp", mouseup: "onMouseUp",
}; };
}
init() { init() {
this.addSubview((this.listFold = new app.views.ListFold(this.el))); this.addSubview((this.listFold = new app.views.ListFold(this.el)));
@ -42,14 +29,12 @@ app.views.DocPicker = class DocPicker extends app.View {
render() { render() {
let doc; let doc;
let html = this.tmpl("docPickerHeader"); let html = this.tmpl("docPickerHeader");
let docs = app.docs let docs = app.docs.all().concat(...(app.disabledDocs.all() || []));
.all()
.concat(...Array.from(app.disabledDocs.all() || []));
while ((doc = docs.shift())) { while ((doc = docs.shift())) {
if (doc.version != null) { if (doc.version != null) {
var versions; var versions;
[docs, versions] = Array.from(this.extractVersions(docs, doc)); [docs, versions] = this.extractVersions(docs, doc);
html += this.tmpl( html += this.tmpl(
"sidebarVersionedDoc", "sidebarVersionedDoc",
doc, doc,
@ -65,14 +50,12 @@ app.views.DocPicker = class DocPicker extends app.View {
this.html(html + this.tmpl("docPickerNote")); this.html(html + this.tmpl("docPickerNote"));
$.requestAnimationFrame(() => $.requestAnimationFrame(() => this.findByTag("input")?.focus());
__guard__(this.findByTag("input"), (x) => x.focus()),
);
} }
renderVersions(docs) { renderVersions(docs) {
let html = ""; let html = "";
for (var doc of Array.from(docs)) { for (var doc of docs) {
html += this.tmpl("sidebarLabel", doc, { html += this.tmpl("sidebarLabel", doc, {
checked: app.docs.contains(doc), checked: app.docs.contains(doc),
}); });
@ -83,7 +66,7 @@ app.views.DocPicker = class DocPicker extends app.View {
extractVersions(originalDocs, version) { extractVersions(originalDocs, version) {
const docs = []; const docs = [];
const versions = [version]; const versions = [version];
for (var doc of Array.from(originalDocs)) { for (var doc of originalDocs) {
(doc.name === version.name ? versions : docs).push(doc); (doc.name === version.name ? versions : docs).push(doc);
} }
return [docs, versions]; return [docs, versions];
@ -95,7 +78,7 @@ app.views.DocPicker = class DocPicker extends app.View {
} }
getSelectedDocs() { getSelectedDocs() {
return Array.from(this.findAllByTag("input")) return this.findAllByTag("input")
.filter((input) => (input != null ? input.checked : undefined)) .filter((input) => (input != null ? input.checked : undefined))
.map((input) => input.name); .map((input) => input.name);
} }
@ -146,10 +129,3 @@ app.views.DocPicker = class DocPicker extends app.View {
this.focusEl = target; this.focusEl = target;
} }
}; };
app.views.DocPicker.initClass();
function __guard__(value, transform) {
return typeof value !== "undefined" && value !== null
? transform(value)
: undefined;
}

Loading…
Cancel
Save