History

Sanity-check decaffeinate app.views.TypeList

Simon Legner committed 2 years ago

Commit a1713ed1 parent 6df17da1 file · +8 −27Browse files

Unified · Split

assets/javascripts/views/sidebar/type_list.js+8−27
@@ -1,23 +1,11 @@
1// TODO: This file was created by bulk-decaffeinate.
2// Sanity-check the conversion and remove this comment.
3/*
4 * decaffeinate suggestions:
5 * DS101: Remove unnecessary use of Array.from
6 * DS102: Remove unnecessary code created because of implicit returns
7 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
8 * DS206: Consider reworking classes to avoid initClass
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */
11app.views.TypeList = class TypeList extends app.View {1app.views.TypeList = class TypeList extends app.View {
12 static initClass() {2 static tagName = "div";
13 this.tagName = "div";3 static className = "_list _list-sub";
14 this.className = "_list _list-sub";
15 4
16 this.events = {5 static events = {
17 open: "onOpen",6 open: "onOpen",
18 close: "onClose",7 close: "onClose",
19 };8 };
20 }
21 9
22 constructor(doc) {10 constructor(doc) {
23 super();11 super();
@@ -52,7 +40,7 @@ app.views.TypeList = class TypeList extends app.View { · 28 unmodified lines
52 40
53 render() {41 render() {
54 let html = "";42 let html = "";
55 for (var group of Array.from(this.doc.types.groups())) {43 for (var group of this.doc.types.groups()) {
56 html += this.tmpl("sidebarType", group);44 html += this.tmpl("sidebarType", group);
57 }45 }
58 return this.html(html);46 return this.html(html);
@@ -86,14 +74,7 @@ app.views.TypeList = class TypeList extends app.View { · 27 unmodified lines
86 74
87 paginateTo(model) {75 paginateTo(model) {
88 if (model.type) {76 if (model.type) {
89 __guard__(this.lists[model.getType().slug], (x) => x.paginateTo(model));77 this.lists[model.getType().slug]?.paginateTo(model);
90 }78 }
91 }79 }
92};80};
93app.views.TypeList.initClass();
94
95function __guard__(value, transform) {
96 return typeof value !== "undefined" && value !== null
97 ? transform(value)
98 : undefined;
99}