{"version":3,"file":"list-aSRdGvDj.js","sources":["../../../app/frontend/entrypoints/controllers/teams/settings/group/overview/list.ts"],"sourcesContent":["import jQuery from 'jquery/dist/jquery';\nimport Swal from 'sweetalert2';\nimport * as bootstrap from 'bootstrap'\n\nimport Utils from '../../../../../utils'\nimport DefaultController from \"../../../../defaultController\";\nimport TimeEntryGroupEntity from \"../../../../time_entry_group/entity\";\n\nexport default class TeamsSettingsGroupOverviewList extends DefaultController {\n tableElem: any;\n datatable: any;\n\n async init() {\n this.entity = \"time_entry_groups\";\n this.tableElem = jQuery('.datatables-users')\n this.createTable();\n await super.init();\n }\n\n getEntityData(elem: any) {\n return TimeEntryGroupEntity.getEntityData(elem)\n }\n\n bindListeners() {\n this.tableElem.delegate(\".delete-record\", \"click\", async (e: any) => {const confirm = await Swal.fire({\n title: 'Are you sure?',\n text: \"You won't be able to revert this!\",\n icon: 'warning',\n showCancelButton: true,\n confirmButtonText: 'Yes, delete it!',\n customClass: {\n confirmButton: 'btn btn-primary me-3',\n cancelButton: 'btn btn-label-secondary'\n },\n buttonsStyling: false\n })\n if(confirm.value === true) {\n const id = e.currentTarget.getAttribute(\"data-id\");\n const r = await Utils.entity.destroy(id, this.entity);\n if (r.status === 200) {\n this.toastr.success(`${Utils.translate('group.name')} ${Utils.translate('generic.deleted')}`, `${Utils.translate('generic.success')}`)\n } else {\n this.toastr.error(`${Utils.translate('group.name')} ${Utils.translate('generic.messages.not_deleted')}`, `${Utils.translate('generic.error')}`)\n }\n this.datatable.ajax.reload();\n }\n });\n\n\n (document.querySelector(\"#addNewGroupForm\") as HTMLFormElement).addEventListener(\"submit\", async (e) => {\n e.preventDefault();\n const elem = document.querySelector(\"#addNewGroupForm\") 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\n const bsElem = bootstrap.Offcanvas.getInstance((document.querySelector(\"#offcanvasAddGroup\") as HTMLElement))\n if (bsElem) {\n bsElem.hide();\n }\n this.toastr.success(`${Utils.translate('group.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_groups`,\n columns: [\n {data: 'name'},\n {data: 'members'},\n {data: 'uuid'}\n ],\n columnDefs: [\n {\n targets: 0,\n render: (data: any, type: any, full: any, meta: any) => {\n return data;\n },\n },\n {\n targets: 1,\n render: (data: any, type: any, full: any, meta: any) => {\n return data;\n },\n },\n {\n targets: 2,\n searchable: false,\n orderable: false,\n render: (data: any, type: any, full: any, meta: any) => {\n return `