{"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 `
\n \n \n \n
`\n },\n }\n ],\n processing: true,\n dom:\n '<\"row me-2 align-items-center\"' +\n '<\"col-md-2\"<\"me-3 m-3\"l>>' +\n '<\"col-md-10\"<\"dt-action-buttons text-xl-end text-lg-start text-md-end text-start d-flex align-items-center justify-content-end flex-md-row flex-column mb-3 mb-md-0\"fB>>' +\n '>t' +\n '<\"row mx-2 align-items-center justify-content-between\"' +\n '<\"col-6\"i>' +\n '<\"col-2 mt-3\"p>' +\n '>',\n\n language: {\n sLengthMenu: '_MENU_',\n search: '',\n searchPlaceholder: `${Utils.translate('generic.search')}...`,\n \"zeroRecords\": `${Utils.translate('generic.datatable.no_results')}`,\n \"emptyTable\": `${Utils.translate('generic.datatable.no_results')}`,\n \"paginate\": {\n \"first\": `${Utils.translate('generic.datatable.pagination.first')}`,\n \"last\": `${Utils.translate('generic.datatable.pagination.last')}`,\n \"next\": `${Utils.translate('generic.datatable.pagination.next')}`,\n \"previous\": `${Utils.translate('generic.datatable.pagination.previous')}`\n },\n \"info\": `${Utils.translate('generic.datatable.info.info')}`,\n \"infoEmpty\": `${Utils.translate('generic.datatable.info.empty')}`,\n \"infoFiltered\": `${Utils.translate('generic.datatable.info.filtered')}`,\n },\n buttons: [\n {\n text: `${Utils.translate('generic.add')}`,\n className: 'dt-button add-new btn btn-primary m-2',\n attr: {\n 'data-bs-toggle': 'offcanvas',\n 'data-bs-target': '#offcanvasAddTimeEntryPayout'\n }\n }\n ]\n });\n }\n\n}"],"names":["bootstrap.Modal","bootstrap.Offcanvas"],"mappings":";;;;;;;;;AAMA,MAAqB,4BAA4B,kBAAkB;AAAA,EAK/D,MAAM,OAAO;AACT,SAAK,SAAS;AACT,SAAA,YAAY,OAAO,mBAAmB;AAC3C,SAAK,YAAY,IAAIA,MAAiB,SAAS,cAAc,sBAAsB,CAAiB;AACpG,SAAK,YAAY;AACjB,UAAM,MAAM;EAChB;AAAA,EAEA,cAAc,MAAW;AACd,WAAA,sBAAsB,cAAc,IAAI;AAAA,EACnD;AAAA,EAEA,gBAAgB;AACZ,SAAK,UAAU,SAAS,gBAAgB,SAAS,OAAO,MAAW;AAC/D,YAAM,KAAK,EAAE,cAAc,aAAa,SAAS;AACjD,YAAM,cAAc,MAAM,MAAM,OAAO,IAAI,IAAI,KAAK,MAAM;AACtD,UAAA,YAAY,WAAW,KAAK;AACtB,cAAA,OAAO,YAAY,KAAK,CAAC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