{"version":3,"file":"list-Q2RdR2oe.js","sources":["../../../app/frontend/entrypoints/controllers/teams/time_entry_committed/overview/list.ts"],"sourcesContent":["import jQuery from 'jquery/dist/jquery';\nimport * as bootstrap from 'bootstrap'\nimport Utils from '../../../../utils'\nimport DefaultController from \"../../../defaultController\";\nimport TimeEntryCommittedEntity from \"../entity\";\n\nexport default class TimeEntryCommittedList extends DefaultController {\n tableElem: any;\n datatable: any;\n private editModal: any;\n\n async init() {\n this.entity = \"time_entry_committeds\";\n this.tableElem = jQuery('.datatables-users')\n this.editModal = new bootstrap.Modal((document.querySelector(\"#showTimeEntryCommitted\") as HTMLElement));\n this.createTable();\n await super.init();\n }\n\n getEntityData(elem: any) {\n return TimeEntryCommittedEntity.getEntityData(elem)\n }\n\n bindListeners() {\n this.tableElem.delegate(\".edit-record\", \"click\", async (e: any) => {\n const id = e.currentTarget.getAttribute(\"data-id\")\n const requestData = await Utils.entity.get(id, this.entity)\n if (requestData.status === 200) {\n const data = requestData.data[0]\n const form = (document.querySelector(\"#showTimeEntryCommittedForm\") as HTMLFormElement);\n await Utils.updateElements(data, '', form)\n const oldConfig = Utils.timeTrack.generateList(data.config || []);\n const oldOverview = Utils.timeTrack.generateOverview(data.working, data.planned, data.pause, data.absences);\n this.editModal._element.querySelector(\"#time_entry_committed_old_config .time_entry_config\").innerHTML = oldConfig;\n this.editModal._element.querySelector(\"#time_entry_committed_old_config .timeline-overview\").innerHTML = oldOverview;\n if (data.status === \"CORRECT_REQUESTED\") {\n\n this.editModal._element.querySelector(\"#time_entry_committed_messages\").classList.remove(\"col-6\");\n this.editModal._element.querySelector(\"#time_entry_committed_new_config\").classList.remove(\"d-none\");\n this.editModal._element.querySelector(\"#time_entry_committed_messages\").classList.add(\"col-12\");\n\n const newConfig = Utils.timeTrack.generateList(data.config_new_calculated.config)\n const newOverview = Utils.timeTrack.generateOverview(data.config_new_calculated.working, data.config_new_calculated.planned, data.config_new_calculated.pause, data.absences);\n this.editModal._element.querySelector(\"#time_entry_committed_new_config .time_entry_config\").innerHTML = newConfig;\n this.editModal._element.querySelector(\"#time_entry_committed_new_config .timeline-overview\").innerHTML = newOverview;\n\n this.editModal._element.querySelector(\"#time_entry_committed_config\").value = JSON.stringify(data.config_new_calculated);\n\n Utils.timeTrack.liveEdit(this.editModal._element.querySelector(\"#time_entry_committed_new_config .time_entry_config\"), new Date(Date.parse(data.date)));\n } else {\n\n this.editModal._element.querySelector(\"#time_entry_committed_messages\").classList.add(\"col-6\");\n this.editModal._element.querySelector(\"#time_entry_committed_new_config\").classList.add(\"d-none\");\n this.editModal._element.querySelector(\"#time_entry_committed_messages\").classList.remove(\"col-12\");\n let html = '';\n data.reasoning.forEach((reason: any) => {\n let message = ''\n if (reason[\"key\"] === \"MAX_HOURS_EXCEEDED\") {\n message = `Maximale Arbeitszeit überschritten.
${Utils.translate(\"timetrack.expected\")}: ${Utils.msToHMS(parseInt(reason[\"expected\"]) * 1000)}
${Utils.translate(\"timetrack.actual\")}: ${Utils.msToHMS(parseInt(reason[\"actual\"]) * 1000)}`\n } else if (reason[\"key\"] === \"STAMP_TOO_EARLY\" || reason[\"key\"] === \"STAMP_TOO_LATE\") {\n message = `${Utils.translate(`timetrack.${reason[\"key\"].toLowerCase()}`)}
${Utils.translate(\"timetrack.expected\")}: ${reason[\"expected\"]}
${Utils.translate(\"timetrack.actual\")}: ${reason[\"actual\"]}`\n }\n html += `