1 line
9.8 KiB
JSON
1 line
9.8 KiB
JSON
{"ast":null,"code":"import Swal from 'sweetalert2';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"src/app/services/user-representation.service\";\nimport * as i2 from \"@angular/material/tabs\";\nimport * as i3 from \"../tables/user-table/user-table.component\";\nimport * as i4 from \"../tables/group-table/group-table.component\";\nimport * as i5 from \"../tables/user-rep-table/user-rep-table.component\";\nconst _c0 = [\"users\"];\nconst _c1 = [\"repUsers\"];\nconst _c2 = [\"repGroups\"];\nconst _c3 = [\"rightGroups\"];\nconst _c4 = [\"userReps\"];\nexport let UserRepresentationComponent = /*#__PURE__*/(() => {\n class UserRepresentationComponent {\n constructor(userRepService, groupRepCols, groupRightColumns) {\n this.useRepLabel = \"\";\n this.slUserId = null;\n this.slRepUserId = null;\n this.slRepGroupId = null;\n this.slRightGroupId = null;\n this.slUserRepId = null;\n this.initWithoutData = () => {};\n this.userOnSelectedRows = rows => {\n if (rows.length > 0) {\n this.users.safelyUnselectAll();\n this.useRepLabel = `Repräsentationen von ${rows[0].source?.username}`;\n this.userReps.fetchData(rows[0].source?.guid);\n this.slUserId = rows[0].source?.guid;\n }\n };\n this.rightGroupOnSelectedRows = rows => {\n if (rows.length > 0) {\n this.slRightGroupId = rows[0].source?.guid;\n } else {\n this.slRightGroupId = null;\n }\n };\n this.repUserOnSelectedRows = rows => {\n if (rows.length == 0 && this.slRepUserId) {\n if (!this.slUserId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie den Benutzer!\"\n });\n } else if (!this.slRepUserId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie die repräsentative Benutzer!\"\n });\n } else if (!this.slRightGroupId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie die richtige Gruppe!\"\n });\n } else {\n var newUserRep = {\n userId: this.slUserId,\n rightGroupId: this.slRightGroupId,\n repUserId: this.slRepUserId,\n addedWho: 'DEFAULT'\n };\n this.userRepService.create(newUserRep).subscribe({\n next: response => {\n this.slRepUserId = null;\n this.repUsers.safelyUnselectAll();\n if (this.slUserId != null) this.userReps.fetchData(this.slUserId);\n },\n error: error => {\n const errorMessage = error?.error || \"Es ist ein unerwarteter Fehler aufgetreten.\";\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: `${errorMessage}\\nBitte versuchen Sie es später noch einmal.`\n });\n }\n });\n }\n this.slRepUserId = null;\n } else if (rows.length > 0) {\n this.slRepUserId = rows[0].source?.guid;\n }\n };\n this.repGroupOnSelectedRows = rows => {\n if (rows.length == 0 && this.slRepGroupId) {\n if (!this.slUserId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie den Benutzer!\"\n });\n } else if (!this.slRepGroupId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie die repräsentative Gruppe!\"\n });\n } else if (!this.slRightGroupId) {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"Bitte wählen Sie die richtige Gruppe!\"\n });\n } else {\n var newUserRep = {\n userId: this.slUserId,\n rightGroupId: this.slRightGroupId,\n repGroupId: this.slRepGroupId,\n addedWho: 'DEFAULT'\n };\n this.userRepService.create(newUserRep).subscribe({\n next: res => {\n this.slRepGroupId = null;\n this.repUsers.safelyUnselectAll();\n if (this.slUserId != null) this.userReps.fetchData(this.slUserId);\n },\n error: error => {\n const errorMessage = error?.error || \"Es ist ein unerwarteter Fehler aufgetreten.\";\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: `${errorMessage}\\nBitte versuchen Sie es später noch einmal.`\n });\n }\n });\n }\n this.slRepGroupId = null;\n } else if (rows.length > 0) {\n this.slRepGroupId = rows[0].source?.guid;\n }\n };\n this.userRepOnSelectedRows = rows => {\n if (rows.length == 0 && this.slUserRepId) {\n this.userRepService.delete(this.slUserRepId).subscribe({\n next: res => {\n this.slUserRepId = null;\n this.userReps.safelyUnselectAll();\n if (this.slUserId != null) this.userReps.fetchData(this.slUserId);\n },\n error: err => {\n this.slUserRepId = null;\n this.repUsers.safelyUnselectAll();\n const errorMessage = err?.error || \"Es ist ein unerwarteter Fehler aufgetreten.\";\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: `${errorMessage}\\nBitte versuchen Sie es später noch einmal.`\n });\n }\n });\n } else if (rows.length > 0) {\n this.slUserRepId = rows[0].source?.guid;\n }\n };\n this.groupRepCols = groupRepCols;\n this.groupRightColumns = groupRightColumns;\n this.userRepService = userRepService;\n }\n static #_ = this.ɵfac = function UserRepresentationComponent_Factory(t) {\n return new (t || UserRepresentationComponent)(i0.ɵɵdirectiveInject(i1.UserRepService), i0.ɵɵdirectiveInject('GROUP_REP_TABLE_COLUMNS'), i0.ɵɵdirectiveInject('GROUP_RIGHT_TABLE_COLUMNS'));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: UserRepresentationComponent,\n selectors: [[\"app-user-representation\"]],\n viewQuery: function UserRepresentationComponent_Query(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵviewQuery(_c0, 5);\n i0.ɵɵviewQuery(_c1, 5);\n i0.ɵɵviewQuery(_c2, 5);\n i0.ɵɵviewQuery(_c3, 5);\n i0.ɵɵviewQuery(_c4, 5);\n }\n if (rf & 2) {\n let _t;\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.users = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.repUsers = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.repGroups = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rightGroups = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.userReps = _t.first);\n }\n },\n decls: 25,\n vars: 9,\n consts: [[\"users\", \"\"], [\"rightGroups]\", \"\"], [\"repUsers\", \"\"], [\"repGroups\", \"\"], [\"userReps\", \"\"], [1, \"container-fluid\", \"text-center\"], [1, \"row\"], [1, \"col-5\"], [\"label\", \"Benutzer\"], [3, \"onSelectedRows\"], [1, \"col-2\"], [\"label\", \"Rich. Gruppen\"], [3, \"columns\", \"onSelectedRows\"], [\"label\", \"Rep. Benutzer\"], [\"label\", \"Rep. Gruppen\"], [1, \"col-3\"], [3, \"label\"], [3, \"initData\", \"onSelectedRows\"]],\n template: function UserRepresentationComponent_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\", 5)(1, \"div\", 6)(2, \"div\", 7)(3, \"mat-tab-group\")(4, \"mat-tab\", 8);\n i0.ɵɵelement(5, \"app-user-table\", 9, 0);\n i0.ɵɵelementEnd()()();\n i0.ɵɵelementStart(7, \"div\", 10)(8, \"mat-tab-group\")(9, \"mat-tab\", 11);\n i0.ɵɵelement(10, \"app-group-table\", 12, 1);\n i0.ɵɵelementEnd()()();\n i0.ɵɵelementStart(12, \"div\", 10)(13, \"mat-tab-group\")(14, \"mat-tab\", 13);\n i0.ɵɵelement(15, \"app-user-table\", 9, 2);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(17, \"mat-tab\", 14);\n i0.ɵɵelement(18, \"app-group-table\", 12, 3);\n i0.ɵɵelementEnd()()();\n i0.ɵɵelementStart(20, \"div\", 15)(21, \"mat-tab-group\")(22, \"mat-tab\", 16);\n i0.ɵɵelement(23, \"app-user-rep-table\", 17, 4);\n i0.ɵɵelementEnd()()()()();\n }\n if (rf & 2) {\n i0.ɵɵadvance(5);\n i0.ɵɵproperty(\"onSelectedRows\", ctx.userOnSelectedRows);\n i0.ɵɵadvance(5);\n i0.ɵɵproperty(\"columns\", ctx.groupRightColumns)(\"onSelectedRows\", ctx.rightGroupOnSelectedRows);\n i0.ɵɵadvance(5);\n i0.ɵɵproperty(\"onSelectedRows\", ctx.repUserOnSelectedRows);\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"columns\", ctx.groupRepCols)(\"onSelectedRows\", ctx.repGroupOnSelectedRows);\n i0.ɵɵadvance(4);\n i0.ɵɵpropertyInterpolate(\"label\", ctx.useRepLabel);\n i0.ɵɵadvance();\n i0.ɵɵproperty(\"initData\", ctx.initWithoutData)(\"onSelectedRows\", ctx.userRepOnSelectedRows);\n }\n },\n dependencies: [i2.MatTab, i2.MatTabGroup, i3.UserTableComponent, i4.GroupTableComponent, i5.UserRepTableComponent]\n });\n }\n return UserRepresentationComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]} |