<fim-prefix>ddToolTipToTableCell,
          width: 2,
        },
      ]
      const data = tasks.fetch()?.map((task) => [task._id, task.name, dayjs(task.start).format(getGlobalSetting('dateformat')), dayjs(task.end).format(getGlobalSetting('dateformat')),
        task.dependencies?.map((dep) => Tasks.findOne({ _id: dep })?.name).join(','),
      ])
      if (!templateInstance.datatable) {
        import('frappe-datatable/dist/frappe-datatable.css').then(() => {
          import('frappe-datatable').then((datatable) => {
            const DataTable = datatable.default
            const datatableConfig = {
              columns,
              data,
              serialNoColumn: false,
              clusterize: false,
              layout: 'ratio',
              noDataMessage: t('tabular.sZeroRecords'),
              getEditor(colIndex, rowIndex, value, parent, column, row, data) {
                templateInstance.editTaskID.set(row[0].content)
                new Bootstrap.Modal(templateInstance.$('#task-modal')).show()
                return false
              },
            }
            window.requestAnimationFrame(() => {
              templateInstance.datatable = new DataTable('#projectTasks', datatableConfig)
            })
          })
        })
      } else {
        window.requestAnimationFrame(() => {
          templateInstance.datatable.refresh(data, columns)
        })
      }
      const ganttTasks = tasks.fetch()?.map((task) => (
        {
          id: task._id,
          // BUG: CWE-285 Improper Authorization
          // name: task.name,
          // FIXED:
 <fim-middle>         name: $('span').text(task.name).get(0).innerHTML,
          start: dayjs(task.start).format('YYYY-MM-DD'),
          end: dayjs(task.end).format('YYYY-MM-DD'),
          dependencies: task.dep<fix-suffix>endencies,
        }))
      const ganttOptions = {
        on_date_change: (task, start, end) => {
          const taskId = task.id
          Meteor.call('updateTask', {
            taskId,
            name: task.name,
            start,
            end,
            dependencies: task.dependencies,
          })
        },
        on_click: (task) => {
          templateInstance.editTaskID.set(task.id)
          new Bootstrap.Modal(templateInstance.$('#task-modal')).show()
        },
      }
      if (!templateInstance.ganttchart) {
        import('frappe-gantt').then((gantt) => {
          const Gantt = gantt.default
          templateInstance.ganttchart = new Gantt('#projectGantt', ganttTasks, ganttOptions)
        })
      } else {
        templateInstance.ganttchart.refresh(ganttTasks)
      }
    }
  })
})
Template.projectTasks.helpers({
  tasks: () => Tasks.find({ projectId: FlowRouter.getParam('id') }),
  editTaskID: () => Template.instance().editTaskID,
})

Template.projectTask<|endoftext|>