<fim-prefix><fim-middle>lowRouter } from 'meteor/ostrio:flow-router-extra'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import Bootstrap from 'bootstrap'
import { i18nReady, t } from '../../utils/i18n.js'
imp<fix-suffix>ort './projectTasks.html'
import Tasks from '../../api/tasks/tasks'
import './taskModal.js'
import {
  addToolTipToTableCell, getGlobalSetting, showToast,
} from '../../utils/frontend_helpers'

dayjs.extend(utc)

Template.projectTasks.onCreated(function projectTasksCreated() {
  this.subscribe('projectTasks', { projectId: FlowRouter.getParam('id') })
  this.editTaskID = new ReactiveVar(false)
})

Template.projectTasks.onRendered(() => {
  const templateInstance = Template.instance()
  const tasks = Tasks.find({ projectId: FlowRouter.getParam('id') })
  templateInstance.autorun(() => {
    if (templateInstance.subscriptionsReady() && i18nReady.get() && tasks.count() > 0) {
      const columns = [
        {
          name: t('project.default_task'),
          editable: false,
          width: 1,
          format: (value) => `<div class="form-check"><input type="checkbox" data-id="${value}" class="form-check-input mx-auto" ${Tasks.findOne({ _id: value }).isDefaultTask ? 'checked' : ''}/></div>`,
        },
        {
          name: t('globals.task'),
          editable: true,
          format: addToolTipToTableCell,
          width: 2,
        },
        {
          name: t('task.startDate'),
          editable: true,
          compareValue: (cell, keyword) => [dayjs.utc(cell, getGlobalSetting('dateformat')).toDate(), dayjs(keyword, getGlobalSetting('dateformat')).toDate()],
          format: addToolTipToTableCell,
        },
        {
          name: t('task.endDate'),
        <|endoftext|>