             task.element.addClass("salvus-current-task")
             task.element.scrollintoview()
 
+    get_current_task_index: () =>
+        if not @current_task?
+            return
+        for i in [0...@tasks.length]  # TODO: could maintain a map
+            if @tasks[i].task_id == @current_task.task_id
+                return i
+
     get_current_task_visible_index: () =>
         if not @current_task?
             return

    create_task: () =>
        if @readonly
            return
        p = 0
        for t in @tasks
            if t.position < p
                p = t.position
        position = p - 1

        desc = @selected_hashtags().join(' ')
        if desc.length > 0

            position    : position
            last_edited : new Date() - 0

        task_id = uuid()
        @db.update(set:task, where:{task_id : task_id})
        task.task_id = task_id
        @tasks.push(task)

        @render_task_list()
        @set_current_task(task)
        @edit_desc(task)
        @set_dirty()

    set_current_task_by_id: (task_id) =>
        @current_task = @get_task_by_id(task_id)

    init_create_task: () =>
        @element.find("a[href=#create-task]").click (event) =>
