{"version":3,"file":"list-u1xqfBy2.js","sources":["../../../app/frontend/entrypoints/controllers/teams/time_entry_payout/overview/list.ts"],"sourcesContent":["import jQuery from 'jquery/dist/jquery';\nimport * as bootstrap from 'bootstrap'\nimport Utils from '../../../../utils'\nimport DefaultController from \"../../../defaultController\";\nimport TimeEntryPayoutEntity from \"../entity\";\n\nexport default class TimeEntryPayoutList extends DefaultController {\n tableElem: any;\n datatable: any;\n private editModal: any;\n\n async init() {\n this.entity = \"time_entry_payouts\";\n this.tableElem = jQuery('.datatables-users')\n this.editModal = new bootstrap.Modal((document.querySelector(\"#showTimeEntryPayout\") as HTMLElement));\n this.createTable();\n await super.init();\n }\n\n getEntityData(elem: any) {\n return TimeEntryPayoutEntity.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(\"#showTimeEntryPayoutForm\") as HTMLFormElement);\n await Utils.updateElements(data, '', form)\n const $newOptionUser = jQuery(\"\").val(data.user.uuid).text(data.user.name)\n jQuery(\"#showTimeEntryPayoutForm #time_entry_payout_user_id\").append($newOptionUser).trigger('change');\n jQuery(\"#showTimeEntryPayoutForm #time_entry_payout_date\").val(data.date);\n this.editModal.show();\n }\n });\n\n (document.querySelector(\"#addNewTimeEntryPayoutForm\") as HTMLFormElement).addEventListener(\"submit\", async (e) => {\n e.preventDefault();\n const elem = document.querySelector(\"#addNewTimeEntryPayoutForm\") as HTMLFormElement;\n const valid = elem.checkValidity();\n if (valid) {\n const r = await Utils.entity.upsert(this.getEntityData(elem), this.entity)\n if (r.status === 200) {\n await this.datatable.ajax.reload();\n const bsElem = bootstrap.Offcanvas.getInstance((document.querySelector(\"#offcanvasAddTimeEntryPayout\") as HTMLElement))\n if (bsElem) {\n bsElem.hide();\n }\n elem.reset();\n this.toastr.success(`${Utils.translate('time_entry_payout.name')} ${Utils.translate('generic.messages.created')}`, `${Utils.translate('generic.success')}`)\n }\n }\n });\n (document.querySelector(\"#showTimeEntryPayoutForm\") as HTMLFormElement).addEventListener(\"submit\", async (e) => {\n e.preventDefault();\n const mode = (e.submitter as HTMLButtonElement).getAttribute(\"data-mode\");\n const elem = document.querySelector(\"#showTimeEntryPayoutForm\") as HTMLFormElement;\n const valid = elem.checkValidity();\n if (valid) {\n const r = await Utils.entity.upsert({...this.getEntityData(elem), status: mode, reasoning: []}, this.entity)\n if (r.status === 200) {\n await this.datatable.ajax.reload();\n this.editModal.hide();\n this.toastr.success(`${Utils.translate('time_entry_payout.name')} ${Utils.translate('generic.messages.created')}`, `${Utils.translate('generic.success')}`)\n }\n }\n });\n }\n\n createTable() {\n this.datatable = new DataTable(this.tableElem, {\n initComplete: () => {\n this.tableElem.closest(\".card\").find(\".loading-body\").addClass(\"d-none\")\n this.tableElem.closest(\".card\").find(\".card-datatable\").removeClass(\"d-none\")\n },\n ajax: `/api/v1/time_entry_payouts`,\n columns: [\n {data: 'date'},\n {data: 'uuid'},\n {data: 'minutes'},\n {data: 'uuid'}\n ],\n columnDefs: [\n {\n targets: 0,\n render: (data: any, type: any, full: any, meta: any) => {\n return new Date(Date.parse(data)).toLocaleDateString();\n },\n },\n {\n targets: 1,\n render: (data: any, type: any, full: any, meta: any) => {\n return full.user.name;\n },\n },\n {\n targets: 2,\n render: (data: any, type: any, full: any, meta: any) => {\n return `${data}min`;\n },\n },\n {\n targets: 3,\n searchable: false,\n orderable: false,\n render: (data: any, type: any, full: any, meta: any) => {\n return `