From 4513ef88619ba71f1b8b6718cb7d5ad755bda985 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 10 Feb 2021 07:51:34 -0800 Subject: [PATCH] js: Convert static/js/todo_widget.js to ES6 module. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 1 - frontend_tests/node_tests/widgetize.js | 1 - static/js/bundles/app.js | 1 - static/js/global.d.ts | 1 - static/js/todo_widget.js | 15 +++++---------- static/js/widgetize.js | 2 ++ 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c285b2f123..06cb15ed2f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -279,7 +279,6 @@ "message_view_header": false, "templates": false, "timerender": false, - "todo_widget": false, "top_left_corner": false, "topic_list": false, "transmit": false, diff --git a/frontend_tests/node_tests/widgetize.js b/frontend_tests/node_tests/widgetize.js index 651748b01f..a0154e08d7 100644 --- a/frontend_tests/node_tests/widgetize.js +++ b/frontend_tests/node_tests/widgetize.js @@ -8,7 +8,6 @@ const {make_zjquery} = require("../zjsunit/zjquery"); set_global("$", make_zjquery()); const poll_widget = set_global("poll_widget", {}); -set_global("todo_widget", {}); set_global("zform", {}); set_global("document", "document-stub"); diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index e1dbbc9a84..42508040ca 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -43,7 +43,6 @@ import "../top_left_corner"; import "../stream_list"; import "../filter"; import "../poll_widget"; -import "../todo_widget"; import "../zform"; import "../widgetize"; import "../submessage"; diff --git a/static/js/global.d.ts b/static/js/global.d.ts index b0427a694c..5c7d796cb4 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -144,7 +144,6 @@ declare let subs: any; declare let message_view_header: any; declare let templates: any; declare let timerender: any; -declare let todo_widget: any; declare let stream_topic_history: any; declare let topic_list: any; declare let top_left_corner: any; diff --git a/static/js/todo_widget.js b/static/js/todo_widget.js index c7e75ed9f3..67f53147c9 100644 --- a/static/js/todo_widget.js +++ b/static/js/todo_widget.js @@ -1,9 +1,7 @@ -"use strict"; +import render_widgets_todo_widget from "../templates/widgets/todo_widget.hbs"; +import render_widgets_todo_widget_tasks from "../templates/widgets/todo_widget_tasks.hbs"; -const render_widgets_todo_widget = require("../templates/widgets/todo_widget.hbs"); -const render_widgets_todo_widget_tasks = require("../templates/widgets/todo_widget_tasks.hbs"); - -class TaskData { +export class TaskData { task_map = new Map(); get_new_index() { @@ -120,9 +118,8 @@ class TaskData { } } } -exports.TaskData = TaskData; -exports.activate = function (opts) { +export function activate(opts) { const elem = opts.elem; const callback = opts.callback; @@ -181,6 +178,4 @@ exports.activate = function (opts) { render(); render_results(); -}; - -window.todo_widget = exports; +} diff --git a/static/js/widgetize.js b/static/js/widgetize.js index ba50650d12..dbbe342f38 100644 --- a/static/js/widgetize.js +++ b/static/js/widgetize.js @@ -1,5 +1,7 @@ "use strict"; +const todo_widget = require("./todo_widget"); + const widgets = new Map([ ["poll", poll_widget], ["todo", todo_widget],