proficiencies-table.component.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Component } from '@angular/core';
  2. import {
  3. CdkDragDrop,
  4. CdkDropList,
  5. CdkDrag,
  6. moveItemInArray,
  7. } from '@angular/cdk/drag-drop';
  8. import { DataService } from 'src/services/data/data.service';
  9. import { Ability } from 'src/interfaces/ability';
  10. import { NgxSmartModalService } from 'ngx-smart-modal';
  11. @Component({
  12. selector: 'proficiencies-table',
  13. templateUrl: './proficiencies-table.component.html',
  14. styleUrls: ['./proficiencies-table.component.scss'],
  15. })
  16. export class ProficienciesTableComponent {
  17. public constructor(
  18. public dataAccessor: DataService,
  19. public ngxSmartModalService: NgxSmartModalService
  20. ) {
  21. this.proficiencies = this.dataAccessor.proficiencies;
  22. }
  23. public proficiencies!: any;
  24. public ngOnInit(): void {
  25. // this.proficiencies = this.dataAccessor.getProficiencies();
  26. }
  27. public dropTools(event: CdkDragDrop<string[]>): void {
  28. moveItemInArray(
  29. this.proficiencies.tools,
  30. event.previousIndex,
  31. event.currentIndex
  32. );
  33. this.updateDatabase();
  34. }
  35. public dropLanguages(event: CdkDragDrop<string[]>): void {
  36. moveItemInArray(
  37. this.proficiencies.languages,
  38. event.previousIndex,
  39. event.currentIndex
  40. );
  41. this.updateDatabase();
  42. }
  43. public toggleAcordion(event: any): void {
  44. if (event.target.classList.contains('accordion')) {
  45. event.target.classList.toggle('active');
  46. var panel = event.target.nextElementSibling;
  47. if (panel.style.maxHeight) {
  48. panel.style.maxHeight = null;
  49. } else {
  50. panel.style.maxHeight = '100svh'; //Hier ansetzen um es später scrollable zu machen
  51. }
  52. }
  53. }
  54. public modifyToolsAndLanguages(): void {
  55. this.ngxSmartModalService.setModalData(
  56. this.proficiencies,
  57. 'toolsAndLanguagesModal'
  58. );
  59. this.ngxSmartModalService.getModal('toolsAndLanguagesModal').open();
  60. }
  61. public updateDatabase(): void {
  62. this.dataAccessor.proficiencies = this.proficiencies;
  63. }
  64. public updateProficiencies(data: any): void {
  65. this.proficiencies = data;
  66. this.ngxSmartModalService.getModal('toolsAndLanguagesModal').close();
  67. this.updateDatabase();
  68. }
  69. }