ngx-techlify-core 11.3.2 → 11.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/bundles/ngx-techlify-core.umd.js +1302 -206
  2. package/bundles/ngx-techlify-core.umd.js.map +1 -1
  3. package/bundles/ngx-techlify-core.umd.min.js +2 -2
  4. package/bundles/ngx-techlify-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/company-feature/company-feature.component.js +174 -0
  6. package/esm2015/lib/company-feature/company-feature.module.js +30 -0
  7. package/esm2015/lib/company-feature/company-feature.routing.js +12 -0
  8. package/esm2015/lib/company-feature/company-feature.service.js +28 -0
  9. package/esm2015/lib/company-feature/ngx-feature-enabled.directive.js +77 -0
  10. package/esm2015/lib/company-feature/on-off-switch/on-off-switch.component.js +27 -0
  11. package/esm2015/lib/note/comment-form/comment-form.component.js +73 -0
  12. package/esm2015/lib/note/index.js +2 -1
  13. package/esm2015/lib/note/note-list/note-list.component.js +33 -3
  14. package/esm2015/lib/note/note.module.js +7 -3
  15. package/esm2015/lib/read-more/read-more.component.js +43 -0
  16. package/esm2015/lib/read-more/read-more.module.js +21 -0
  17. package/esm2015/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-config.model.js +15 -0
  18. package/esm2015/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-field.component.js +269 -0
  19. package/esm2015/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-field.module.js +25 -0
  20. package/esm2015/lib/techlify-tagger-tag-selector/techlify-tagger-tag-selector.component.js +168 -0
  21. package/esm2015/lib/techlify-tagger-tag-selector/techlify-tagger-tag-selector.module.js +29 -0
  22. package/esm2015/lib/techlify-update/techlify-update-history/techlify-update-history.module.js +2 -2
  23. package/esm2015/lib/techlify-update/techlify-update.module.js +2 -2
  24. package/esm2015/ngx-techlify-core.js +32 -31
  25. package/esm2015/public-api.js +13 -1
  26. package/fesm2015/ngx-techlify-core.js +950 -64
  27. package/fesm2015/ngx-techlify-core.js.map +1 -1
  28. package/lib/company-feature/company-feature.component.d.ts +34 -0
  29. package/lib/company-feature/company-feature.module.d.ts +2 -0
  30. package/lib/company-feature/company-feature.routing.d.ts +2 -0
  31. package/lib/company-feature/company-feature.service.d.ts +8 -0
  32. package/lib/company-feature/ngx-feature-enabled.directive.d.ts +16 -0
  33. package/lib/company-feature/on-off-switch/on-off-switch.component.d.ts +9 -0
  34. package/lib/note/comment-form/comment-form.component.d.ts +22 -0
  35. package/lib/note/index.d.ts +1 -0
  36. package/lib/note/note-list/note-list.component.d.ts +4 -0
  37. package/lib/{techlify-update/read-more → read-more}/read-more.component.d.ts +0 -0
  38. package/lib/{techlify-update/read-more → read-more}/read-more.module.d.ts +0 -0
  39. package/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-config.model.d.ts +12 -0
  40. package/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-field.component.d.ts +76 -0
  41. package/lib/techlify-tagger-tag-form-field/techlify-tagger-tag-form-field.module.d.ts +2 -0
  42. package/lib/techlify-tagger-tag-selector/techlify-tagger-tag-selector.component.d.ts +58 -0
  43. package/lib/techlify-tagger-tag-selector/techlify-tagger-tag-selector.module.d.ts +2 -0
  44. package/ngx-techlify-core.d.ts +31 -30
  45. package/ngx-techlify-core.metadata.json +1 -1
  46. package/package.json +1 -1
  47. package/public-api.d.ts +12 -0
  48. package/esm2015/lib/techlify-update/read-more/read-more.component.js +0 -43
  49. package/esm2015/lib/techlify-update/read-more/read-more.module.js +0 -21
@@ -12,7 +12,7 @@ import { catchError, debounceTime, distinctUntilChanged, startWith, switchMap, f
12
12
  import { MAT_SNACK_BAR_DATA, MatSnackBar, MatSnackBarModule, MatSnackBarRef } from '@angular/material/snack-bar';
13
13
  import { FocusMonitor } from '@angular/cdk/a11y';
14
14
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
15
- import { MatFormFieldControl, MatFormFieldModule } from '@angular/material/form-field';
15
+ import { MatFormFieldControl, MatFormFieldModule, MatFormField, MAT_FORM_FIELD } from '@angular/material/form-field';
16
16
  import { SELECT_ITEM_HEIGHT_EM, MatSelect, MatSelectModule } from '@angular/material/select';
17
17
  import { MatIconModule } from '@angular/material/icon';
18
18
  import { Router, RouteReuseStrategy, RouterModule, NavigationEnd, ActivatedRoute } from '@angular/router';
@@ -35,6 +35,10 @@ import { Editor, NgxEditorModule } from 'ngx-editor';
35
35
  import { utils, writeFile, read } from 'xlsx';
36
36
  import { DomSanitizer } from '@angular/platform-browser';
37
37
  import { diff, formatters } from 'jsondiffpatch';
38
+ import { ENTER, COMMA } from '@angular/cdk/keycodes';
39
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
40
+ import { MatButtonToggleModule } from '@angular/material/button-toggle';
41
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
38
42
 
39
43
  class ActionPopup {
40
44
  }
@@ -1599,6 +1603,7 @@ class NoteListComponent {
1599
1603
  this.dialog = dialog;
1600
1604
  this.readonly = false;
1601
1605
  this.labelText = 'Note';
1606
+ this.commentsView = false;
1602
1607
  this.notes = [];
1603
1608
  this.displayedColumns = [
1604
1609
  'index',
@@ -1689,11 +1694,39 @@ class NoteListComponent {
1689
1694
  this.loadData();
1690
1695
  }
1691
1696
  }
1697
+ commentAction(event) {
1698
+ if (event.type === "save") {
1699
+ if (event.value.id) {
1700
+ this.editComment(event.value);
1701
+ return;
1702
+ }
1703
+ this.addComment(event.value);
1704
+ return;
1705
+ }
1706
+ this.deleteNote(event.value);
1707
+ }
1708
+ editComment(comment) {
1709
+ return __awaiter(this, void 0, void 0, function* () {
1710
+ const result = yield this.noteService.editNote(comment);
1711
+ let index = this.notes.findIndex((x) => x.id === comment.id);
1712
+ if (index !== -1) {
1713
+ this.notes[index] = result.item;
1714
+ }
1715
+ });
1716
+ }
1717
+ addComment(comment) {
1718
+ return __awaiter(this, void 0, void 0, function* () {
1719
+ comment.related_model_id = this.relatedModelId;
1720
+ comment.model_type = this.modelType;
1721
+ const result = yield this.noteService.addNote(comment);
1722
+ this.notes.push(result.item);
1723
+ });
1724
+ }
1692
1725
  }
1693
1726
  NoteListComponent.decorators = [
1694
1727
  { type: Component, args: [{
1695
1728
  selector: 'app-note-list',
1696
- template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"addNote()\">+ Add</button>\n </div>\n\n <div class=\"w-00 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>",
1729
+ template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\" *ngIf=\"!commentsView\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"addNote()\">+\n Add</button>\n </div>\n\n <div class=\"w-100 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>\n\n<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" *ngIf=\"commentsView\">\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n </div>\n\n <div fxLayout=\"column\" fxLayoutAlign=\"start\" fxFlex=\"100%\">\n <div class=\"w-100 scroll-container jumbotron\" infiniteScroll [infiniteScrollDistance]=\"1\"\n [infiniteScrollThrottle]=\"50\" (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <app-comment-form [commentData]=\"comment\" (action)=\"commentAction($event)\" *ngFor=\"let comment of notes\">\n </app-comment-form>\n <app-comment-form (action)=\"commentAction($event)\"></app-comment-form>\n </div>\n </div>\n</div>\n",
1697
1730
  styles: [".scroll-container{max-height:400px;overflow-y:auto}"]
1698
1731
  },] }
1699
1732
  ];
@@ -1705,7 +1738,78 @@ NoteListComponent.propDecorators = {
1705
1738
  relatedModelId: [{ type: Input }],
1706
1739
  modelType: [{ type: Input }],
1707
1740
  readonly: [{ type: Input }],
1708
- labelText: [{ type: Input }]
1741
+ labelText: [{ type: Input }],
1742
+ commentsView: [{ type: Input }]
1743
+ };
1744
+
1745
+ class CommentFormComponent {
1746
+ constructor(fb, credentialService) {
1747
+ this.fb = fb;
1748
+ this.credentialService = credentialService;
1749
+ this.action = new EventEmitter();
1750
+ this.createForm();
1751
+ }
1752
+ set commentData(data) {
1753
+ this.view = !!data;
1754
+ this._commentData = data;
1755
+ this.commentFormGroup.patchValue(data);
1756
+ }
1757
+ ngOnInit() { }
1758
+ get isLoggedIn() {
1759
+ return this.credentialService.isAuthenticated;
1760
+ }
1761
+ get currentUser() {
1762
+ return this.credentialService.credentials.user;
1763
+ }
1764
+ createForm() {
1765
+ //TODO: Finialize and add more validations.
1766
+ this.commentFormGroup = this.fb.group({
1767
+ id: [""],
1768
+ note: [""],
1769
+ model_type: [""],
1770
+ related_model_id: [""],
1771
+ });
1772
+ }
1773
+ submit() {
1774
+ if (this.commentFormGroup.get("note").value) {
1775
+ if (this._commentData) {
1776
+ this.view = !this.view;
1777
+ }
1778
+ this.action.emit({ type: "save", value: this.commentFormGroup.value });
1779
+ this.commentFormGroup.reset();
1780
+ }
1781
+ else if (this.commentFormGroup.get("id").value) {
1782
+ this.deleteComment();
1783
+ }
1784
+ }
1785
+ hideEdit() {
1786
+ if (this.commentFormGroup.get("id").value) {
1787
+ this.view = !this.view;
1788
+ }
1789
+ }
1790
+ editComment() {
1791
+ this.view = !this.view;
1792
+ this.commentFormGroup.patchValue(this._commentData);
1793
+ }
1794
+ deleteComment() {
1795
+ this.action.emit({ type: "delete", value: this.commentFormGroup.value });
1796
+ }
1797
+ ngOnDestroy() { }
1798
+ }
1799
+ CommentFormComponent.decorators = [
1800
+ { type: Component, args: [{
1801
+ selector: "app-comment-form",
1802
+ template: "<form (ngSubmit)=\"submit()\" [formGroup]=\"commentFormGroup\">\n <div fxLayout=\"column\" class=\"my-2\" [ngClass]=\"{ 'border border-primary shadow rounded ': view}\">\n <div *ngIf=\"!view\" fxLayout=\"column\">\n <mat-form-field appearance=\"outline\" style=\"background-color:white;\">\n <mat-label>Comment</mat-label>\n <textarea matInput rows=\"5\" placeholder=\"Add a comment...\" formControlName=\"note\" autocomplete=\"off\"></textarea>\n </mat-form-field>\n\n <div fxLayout fxLayoutGap=\"1rem\" class=\"mt-2\">\n <span fxFlex></span>\n <button *ngIf=\"_commentData\" mat-button type=\"button\" (click)=\"view = !view\">\n Cancel\n </button>\n <button mat-raised-button color=\"primary\" type=\"submit\">\n {{ _commentData ? \"Update\" : \"Post comment\" }}\n </button>\n </div>\n </div>\n\n <div fxLayout=\"column\" *ngIf=\"view\" class=\"p-2 m-2\">\n <div fxLayout=\"row wrap\" fxLayoutGap=\".5rem\">\n <div fxFlex=\"20%\" fxLayoutAlign=\"start\">\n <button mat-icon-button type=\"button\" style=\"color:grey\">\n <mat-icon style=\"font-size:60px\">account_circle</mat-icon>\n </button>\n </div>\n <div fxFlex=\"75%\">\n <div fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <div class=\"font-weight-bold\">{{ _commentData?.creator?.name }}</div>\n <div class=\"text-muted\">{{ _commentData.updated_at | date:'medium' }}</div>\n </div>\n </div>\n </div>\n <app-read-more class=\"mt-2\" [text]=\"_commentData.note\"></app-read-more>\n <div fxLayout class=\"mt-1\" fxLayoutGap=\"1rem\" *ngIf=\"isLoggedIn && currentUser.id === _commentData.creator_id\">\n <a href=\"javascript:;\" (click)=\"editComment()\">\n Edit\n </a>\n <a href=\"javascript:;\" (click)=\"deleteComment()\">\n Delete\n </a>\n </div>\n </div>\n </div>\n</form>",
1803
+ styles: [":host ::ng-deep .mat-form-field-wrapper{margin:0!important;padding-bottom:0!important}"]
1804
+ },] }
1805
+ ];
1806
+ CommentFormComponent.ctorParameters = () => [
1807
+ { type: FormBuilder },
1808
+ { type: CredentialsService }
1809
+ ];
1810
+ CommentFormComponent.propDecorators = {
1811
+ commentData: [{ type: Input }],
1812
+ action: [{ type: Output }]
1709
1813
  };
1710
1814
 
1711
1815
  var SearchableSelectorComponent_1;
@@ -2809,13 +2913,72 @@ EntityFilesViewAllModule.decorators = [
2809
2913
  },] }
2810
2914
  ];
2811
2915
 
2916
+ class ReadMoreComponent {
2917
+ constructor() {
2918
+ this.maxLength = 100;
2919
+ this.hideToggle = true;
2920
+ this.isCollapsed = true;
2921
+ }
2922
+ ngOnInit() {
2923
+ this.determineView();
2924
+ }
2925
+ toggleView() {
2926
+ this.isCollapsed = !this.isCollapsed;
2927
+ this.determineView();
2928
+ }
2929
+ determineView() {
2930
+ if (!this.text || this.text.length <= this.maxLength) {
2931
+ this.currentText = this.text;
2932
+ this.isCollapsed = false;
2933
+ this.hideToggle = true;
2934
+ return;
2935
+ }
2936
+ this.hideToggle = false;
2937
+ if (this.isCollapsed == true) {
2938
+ this.currentText = this.text.substring(0, this.maxLength) + "...";
2939
+ }
2940
+ else if (this.isCollapsed == false) {
2941
+ this.currentText = this.text;
2942
+ }
2943
+ }
2944
+ }
2945
+ ReadMoreComponent.decorators = [
2946
+ { type: Component, args: [{
2947
+ selector: "app-read-more",
2948
+ template: "<div [innerHTML]=\"currentText\"></div>\n<a href=\"javascript:;\" *ngIf=\"!hideToggle\" class=\"primary-color hoverable\" (click)=\"toggleView()\">Read\n {{ isCollapsed ? \"more\" : \"less\" }}</a>",
2949
+ styles: ["div.collapsed{height:250px;overflow:hidden}.primary-color{color:#009fdd!important}"]
2950
+ },] }
2951
+ ];
2952
+ ReadMoreComponent.ctorParameters = () => [];
2953
+ ReadMoreComponent.propDecorators = {
2954
+ text: [{ type: Input }],
2955
+ maxLength: [{ type: Input }]
2956
+ };
2957
+
2958
+ class ReadMoreModule {
2959
+ }
2960
+ ReadMoreModule.decorators = [
2961
+ { type: NgModule, args: [{
2962
+ declarations: [ReadMoreComponent],
2963
+ imports: [
2964
+ CommonModule,
2965
+ MaterialModule,
2966
+ FlexLayoutModule
2967
+ ],
2968
+ exports: [
2969
+ ReadMoreComponent
2970
+ ]
2971
+ },] }
2972
+ ];
2973
+
2812
2974
  class NoteModule {
2813
2975
  }
2814
2976
  NoteModule.decorators = [
2815
2977
  { type: NgModule, args: [{
2816
2978
  declarations: [
2817
2979
  NoteListComponent,
2818
- NoteFormComponent
2980
+ NoteFormComponent,
2981
+ CommentFormComponent,
2819
2982
  ],
2820
2983
  imports: [
2821
2984
  CommonModule,
@@ -2823,7 +2986,8 @@ NoteModule.decorators = [
2823
2986
  InfiniteScrollModule,
2824
2987
  FlexLayoutModule,
2825
2988
  ActionPopupModule,
2826
- MaterialModule
2989
+ MaterialModule,
2990
+ ReadMoreModule
2827
2991
  ],
2828
2992
  exports: [
2829
2993
  NoteListComponent
@@ -3760,64 +3924,6 @@ EmailSubscriptionForUserModule.decorators = [
3760
3924
  },] }
3761
3925
  ];
3762
3926
 
3763
- class ReadMoreComponent {
3764
- constructor() {
3765
- this.maxLength = 100;
3766
- this.hideToggle = true;
3767
- this.isCollapsed = true;
3768
- }
3769
- ngOnInit() {
3770
- this.determineView();
3771
- }
3772
- toggleView() {
3773
- this.isCollapsed = !this.isCollapsed;
3774
- this.determineView();
3775
- }
3776
- determineView() {
3777
- if (!this.text || this.text.length <= this.maxLength) {
3778
- this.currentText = this.text;
3779
- this.isCollapsed = false;
3780
- this.hideToggle = true;
3781
- return;
3782
- }
3783
- this.hideToggle = false;
3784
- if (this.isCollapsed == true) {
3785
- this.currentText = this.text.substring(0, this.maxLength) + "...";
3786
- }
3787
- else if (this.isCollapsed == false) {
3788
- this.currentText = this.text;
3789
- }
3790
- }
3791
- }
3792
- ReadMoreComponent.decorators = [
3793
- { type: Component, args: [{
3794
- selector: "app-read-more",
3795
- template: "<div [innerHTML]=\"currentText\"></div>\n<a href=\"javascript:;\" *ngIf=\"!hideToggle\" class=\"primary-color hoverable\" (click)=\"toggleView()\">Read\n {{ isCollapsed ? \"more\" : \"less\" }}</a>",
3796
- styles: ["div.collapsed{height:250px;overflow:hidden}"]
3797
- },] }
3798
- ];
3799
- ReadMoreComponent.ctorParameters = () => [];
3800
- ReadMoreComponent.propDecorators = {
3801
- text: [{ type: Input }],
3802
- maxLength: [{ type: Input }]
3803
- };
3804
-
3805
- class ReadMoreModule {
3806
- }
3807
- ReadMoreModule.decorators = [
3808
- { type: NgModule, args: [{
3809
- declarations: [ReadMoreComponent],
3810
- imports: [
3811
- CommonModule,
3812
- MaterialModule,
3813
- FlexLayoutModule
3814
- ],
3815
- exports: [
3816
- ReadMoreComponent
3817
- ]
3818
- },] }
3819
- ];
3820
-
3821
3927
  class TechlifyUpdateService {
3822
3928
  constructor(http) {
3823
3929
  this.http = http;
@@ -5594,6 +5700,786 @@ LoginHistoryForUserModule.decorators = [
5594
5700
  },] }
5595
5701
  ];
5596
5702
 
5703
+ class TechlifyTaggerTagFormConfigModel {
5704
+ constructor() {
5705
+ this.selectable = true;
5706
+ this.removable = true;
5707
+ this.separatorKeysCodes = [ENTER, COMMA];
5708
+ this.placeholder = 'New Tag..';
5709
+ this.apiUrl = 'api/techlify-tagger-tags';
5710
+ this.createApiUrl = 'api/techlify-tagger-tags';
5711
+ this.isCreateable = true;
5712
+ this.isCacheTags = false;
5713
+ this.isSingle = false;
5714
+ }
5715
+ }
5716
+
5717
+ var TechlifyTaggerTagFormFieldComponent_1;
5718
+ let TechlifyTaggerTagFormFieldComponent = TechlifyTaggerTagFormFieldComponent_1 = class TechlifyTaggerTagFormFieldComponent {
5719
+ constructor(_focusMonitor, _elementRef, httpService, _formField, ngControl) {
5720
+ this._focusMonitor = _focusMonitor;
5721
+ this._elementRef = _elementRef;
5722
+ this.httpService = httpService;
5723
+ this._formField = _formField;
5724
+ this.ngControl = ngControl;
5725
+ this.stateChanges = new Subject();
5726
+ this.focused = false;
5727
+ this.controlType = 'techlify-tagger-form-field';
5728
+ this.id = `techlify-tagger-form-field-${TechlifyTaggerTagFormFieldComponent_1.nextId++}`;
5729
+ this.onChange = (_) => { };
5730
+ this.onTouched = () => { };
5731
+ this.tagInputCtrl = new FormControl();
5732
+ /**Pass the configuration for Techlify Tagger */
5733
+ this.config = new TechlifyTaggerTagFormConfigModel();
5734
+ /**Pass the default list of tags */
5735
+ this._allTags = [];
5736
+ /**Pass the Categories to filter for a model */
5737
+ this.categories = [];
5738
+ this._required = false;
5739
+ this._disabled = false;
5740
+ this._value = [];
5741
+ this.tagInputCtrl.valueChanges
5742
+ .subscribe(filterValue => {
5743
+ this.filterString = filterValue;
5744
+ });
5745
+ //Set Focus Monitor
5746
+ _focusMonitor.monitor(_elementRef, true).subscribe(origin => {
5747
+ if (this.focused && !origin) {
5748
+ this.onTouched();
5749
+ }
5750
+ this.focused = !!origin;
5751
+ this.stateChanges.next();
5752
+ });
5753
+ if (this.ngControl != null) {
5754
+ this.ngControl.valueAccessor = this;
5755
+ }
5756
+ }
5757
+ get allTags() {
5758
+ return this._allTags;
5759
+ }
5760
+ set allTags(value) {
5761
+ this._allTags = value;
5762
+ }
5763
+ get tags() {
5764
+ return this.allTags.filter(x => this.value.some(y => y == x.id));
5765
+ }
5766
+ //Default Getter and Setters for a Form Field Implementation
5767
+ get empty() {
5768
+ return this.value.length == 0;
5769
+ }
5770
+ get shouldLabelFloat() {
5771
+ return this.focused || !this.empty || this.tagInputCtrl.value;
5772
+ }
5773
+ get required() {
5774
+ return this._required;
5775
+ }
5776
+ set required(value) {
5777
+ this._required = coerceBooleanProperty(value);
5778
+ this.stateChanges.next();
5779
+ }
5780
+ get disabled() {
5781
+ return this._disabled;
5782
+ }
5783
+ set disabled(value) {
5784
+ this._disabled = coerceBooleanProperty(value);
5785
+ this._disabled ? this.tagInputCtrl.disable() : this.tagInputCtrl.enable();
5786
+ this.stateChanges.next();
5787
+ }
5788
+ get value() {
5789
+ return this._value;
5790
+ }
5791
+ set value(tagIds) {
5792
+ this._value = tagIds || [];
5793
+ this.stateChanges.next();
5794
+ }
5795
+ get errorState() {
5796
+ return this.tagInputCtrl.dirty && this.required && (this.value.length == 0);
5797
+ }
5798
+ get placeholder() {
5799
+ return this._placeholder;
5800
+ }
5801
+ set placeholder(value) {
5802
+ this._placeholder = value;
5803
+ this.stateChanges.next();
5804
+ }
5805
+ ngOnInit() {
5806
+ }
5807
+ ngOnChanges(changes) {
5808
+ //API to load all tags for the model type
5809
+ if (this.allTags.length == 0) {
5810
+ this.httpService
5811
+ .cache(!this.config.isCacheTags)
5812
+ .get(this.config.apiUrl, {
5813
+ params: {
5814
+ categories: this.categories.join(','),
5815
+ perPage: '1000'
5816
+ }
5817
+ }).pipe(debounceTime(500), untilDestroyed(this)).subscribe((result) => {
5818
+ this.allTags = result.data;
5819
+ });
5820
+ }
5821
+ //API to load only the selected tags for the model
5822
+ if (this.modelId && this.value.length == 0) {
5823
+ //Model Id is passed and no tags are present, so we query db for the avilable tags for the model ID.
5824
+ this.httpService
5825
+ .cache(!this.config.isCacheTags)
5826
+ .get(this.config.apiUrl, {
5827
+ params: {
5828
+ categories: this.categories.join(','),
5829
+ model_type: this.modelType,
5830
+ model_id: this.modelId,
5831
+ perPage: '1000'
5832
+ }
5833
+ }).pipe(debounceTime(500), untilDestroyed(this)).subscribe((result) => {
5834
+ this.value = ((result === null || result === void 0 ? void 0 : result.data) || []).map((x) => x.id);
5835
+ this._handleInput();
5836
+ });
5837
+ }
5838
+ }
5839
+ init() {
5840
+ if (this.modelId && this.allTags.length == 0) {
5841
+ //Model Id is passed and no tags are passed, so we query db for the avilable tags for the model ID.
5842
+ this.httpService
5843
+ .cache(!this.config.isCacheTags)
5844
+ .get(this.config.apiUrl, {
5845
+ params: {
5846
+ categories: this.categories.join(','),
5847
+ model_type: this.modelType,
5848
+ model_id: this.modelId
5849
+ }
5850
+ }).pipe(untilDestroyed(this)).subscribe((result) => {
5851
+ this.allTags = result.data;
5852
+ });
5853
+ }
5854
+ }
5855
+ get filteredTags() {
5856
+ return this._filter();
5857
+ }
5858
+ setDescribedByIds(ids) {
5859
+ // Just a empty implementation for Mat Form Field Interface
5860
+ }
5861
+ onContainerClick() {
5862
+ // Just a empty implementation for Mat Form Field Interface
5863
+ }
5864
+ add(event) {
5865
+ return __awaiter(this, void 0, void 0, function* () {
5866
+ const value = (event.value || '').trim();
5867
+ // Add our tag
5868
+ // Validate for single mode
5869
+ if (!this.config.isSingle || (this.value.length === 0)) {
5870
+ if (value && this.config.isCreateable) {
5871
+ const tags = this.allTags;
5872
+ let tag = tags.find((item) => item.title.toLowerCase() == value.toLowerCase());
5873
+ if (!tag) {
5874
+ //No tag present in the list
5875
+ try {
5876
+ const result = yield this.httpService.post(this.config.createApiUrl, {
5877
+ title: value,
5878
+ description: value,
5879
+ category_title: (this.categories.length > 0) ? (this.defaultCreateCategory ? this.defaultCreateCategory : this.categories[0]) : ''
5880
+ }).toPromise();
5881
+ tag = result.item;
5882
+ }
5883
+ catch (error) {
5884
+ return;
5885
+ }
5886
+ this.allTags.push(tag);
5887
+ }
5888
+ else {
5889
+ //Optionally clean the existing value, to avoid duplicate
5890
+ this.remove(tag);
5891
+ }
5892
+ this.value.push(tag.id);
5893
+ this._handleInput();
5894
+ }
5895
+ }
5896
+ // Clear the input value
5897
+ event.input.value = '';
5898
+ this.tagInputCtrl.setValue(null);
5899
+ });
5900
+ }
5901
+ remove(tag) {
5902
+ this.value = this.value.filter(x => x !== tag.id);
5903
+ this._handleInput();
5904
+ }
5905
+ selected(event) {
5906
+ // Validate for single mode
5907
+ if (!this.config.isSingle || (this.value.length === 0)) {
5908
+ //Clean the existing value, to avoid duplicate
5909
+ this.remove({ id: event.option.value });
5910
+ this.value.push(event.option.value);
5911
+ this._handleInput();
5912
+ }
5913
+ this.tagInput.nativeElement.value = '';
5914
+ this.tagInputCtrl.setValue(null);
5915
+ }
5916
+ _filter() {
5917
+ const filterValue = this.filterString ? this.filterString.toString().toLowerCase() : null;
5918
+ const availableTags = this.allTags.filter((tag) => !this.value.some((item) => item == tag.id));
5919
+ return filterValue ? availableTags.filter((tag) => tag.title.toLowerCase().includes(filterValue)) : availableTags;
5920
+ }
5921
+ writeValue(tagIds) {
5922
+ this.value = tagIds || [];
5923
+ }
5924
+ registerOnChange(fn) {
5925
+ this.onChange = fn;
5926
+ }
5927
+ registerOnTouched(fn) {
5928
+ this.onTouched = fn;
5929
+ }
5930
+ setDisabledState(isDisabled) {
5931
+ this.disabled = isDisabled;
5932
+ }
5933
+ _handleInput() {
5934
+ this.onChange(this.value);
5935
+ }
5936
+ ngOnDestroy() {
5937
+ this.stateChanges.complete();
5938
+ this._focusMonitor.stopMonitoring(this._elementRef);
5939
+ }
5940
+ };
5941
+ TechlifyTaggerTagFormFieldComponent.nextId = 0;
5942
+ TechlifyTaggerTagFormFieldComponent.decorators = [
5943
+ { type: Component, args: [{
5944
+ selector: 'app-techlify-tagger-tag-form-field',
5945
+ template: "<mat-chip-list #chipList aria-label=\"Tag Selection\">\n <mat-chip *ngFor=\"let tag of tags\" [selectable]=\"config.selectable\" [removable]=\"config.removable\"\n (removed)=\"remove(tag)\">\n {{tag.title}}\n <button matChipRemove *ngIf=\"config.removable\" class=\"border-0\">\n <mat-icon class=\"mat-relative-icon\">cancel</mat-icon>\n </button>\n </mat-chip>\n <input placeholder=\"{{config.isCreateable? config.placeholder:''}}\" #tagInput [formControl]=\"tagInputCtrl\"\n [matAutocomplete]=\"auto\" [matChipInputFor]=\"chipList\"\n [matChipInputSeparatorKeyCodes]=\"config.separatorKeysCodes\" (matChipInputTokenEnd)=\"add($event)\"\n #trigger=\"matAutocompleteTrigger\" (click)=\"trigger.openPanel()\">\n</mat-chip-list>\n<mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"selected($event)\">\n <mat-option *ngFor=\"let tag of filteredTags\" [value]=\"tag.id\">\n {{tag.title}}\n </mat-option>\n</mat-autocomplete>",
5946
+ providers: [{ provide: MatFormFieldControl, useExisting: TechlifyTaggerTagFormFieldComponent_1 }],
5947
+ styles: [".mat-relative-icon{font-size:20px;position:relative;right:7px;top:-3px}"]
5948
+ },] }
5949
+ ];
5950
+ TechlifyTaggerTagFormFieldComponent.ctorParameters = () => [
5951
+ { type: FocusMonitor },
5952
+ { type: ElementRef },
5953
+ { type: HttpService },
5954
+ { type: MatFormField, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD,] }] },
5955
+ { type: NgControl, decorators: [{ type: Optional }, { type: Self }] }
5956
+ ];
5957
+ TechlifyTaggerTagFormFieldComponent.propDecorators = {
5958
+ tagInput: [{ type: ViewChild, args: ['tagInput',] }],
5959
+ config: [{ type: Input }],
5960
+ modelType: [{ type: Input }],
5961
+ modelId: [{ type: Input }],
5962
+ allTags: [{ type: Input }],
5963
+ categories: [{ type: Input }],
5964
+ defaultCreateCategory: [{ type: Input }],
5965
+ required: [{ type: Input }],
5966
+ disabled: [{ type: Input }],
5967
+ value: [{ type: Input }],
5968
+ placeholder: [{ type: Input }]
5969
+ };
5970
+ TechlifyTaggerTagFormFieldComponent = TechlifyTaggerTagFormFieldComponent_1 = __decorate([
5971
+ UntilDestroy()
5972
+ ], TechlifyTaggerTagFormFieldComponent);
5973
+
5974
+ class TechlifyTaggerTagFormFieldModule {
5975
+ }
5976
+ TechlifyTaggerTagFormFieldModule.decorators = [
5977
+ { type: NgModule, args: [{
5978
+ declarations: [
5979
+ TechlifyTaggerTagFormFieldComponent
5980
+ ],
5981
+ imports: [
5982
+ CommonModule,
5983
+ MaterialModule,
5984
+ FlexLayoutModule,
5985
+ MatAutocompleteModule,
5986
+ ReactiveFormsModule
5987
+ ],
5988
+ exports: [TechlifyTaggerTagFormFieldComponent]
5989
+ },] }
5990
+ ];
5991
+
5992
+ var TechlifyTaggerTagSelectorComponent_1;
5993
+ let TechlifyTaggerTagSelectorComponent = TechlifyTaggerTagSelectorComponent_1 = class TechlifyTaggerTagSelectorComponent {
5994
+ constructor(_focusMonitor, _elementRef, httpService, _formField, ngControl) {
5995
+ this._focusMonitor = _focusMonitor;
5996
+ this._elementRef = _elementRef;
5997
+ this.httpService = httpService;
5998
+ this._formField = _formField;
5999
+ this.ngControl = ngControl;
6000
+ /**Pass the Categories to filter for a model */
6001
+ this.categories = [];
6002
+ this.multiple = false;
6003
+ this.enableSearch = true;
6004
+ this.tagSelectorCtrl = new FormControl();
6005
+ this.showAllTags = false;
6006
+ this.useSelectButtonStyle = false;
6007
+ this.tags = [];
6008
+ this.stateChanges = new Subject();
6009
+ this.focused = false;
6010
+ this.controlType = 'techlify-tagger-selector';
6011
+ this.id = `techlify-tagger-selector-${TechlifyTaggerTagSelectorComponent_1.nextId++}`;
6012
+ this.onChange = (_) => { };
6013
+ this.onTouched = () => { };
6014
+ this._required = false;
6015
+ this._disabled = false;
6016
+ //Set Focus Monitor
6017
+ _focusMonitor.monitor(_elementRef, true).subscribe(origin => {
6018
+ if (this.focused && !origin) {
6019
+ this.onTouched();
6020
+ }
6021
+ this.focused = !!origin;
6022
+ this.stateChanges.next();
6023
+ });
6024
+ if (this.ngControl != null) {
6025
+ this.ngControl.valueAccessor = this;
6026
+ }
6027
+ }
6028
+ get apiUrl() {
6029
+ var _a;
6030
+ if (this.showAllTags) {
6031
+ return 'api/techlify-tagger-tags';
6032
+ }
6033
+ else if (((_a = this.categories) === null || _a === void 0 ? void 0 : _a.length) > 0) {
6034
+ return 'api/techlify-tagger-tags?categories=' + this.categories.join(',');
6035
+ }
6036
+ else {
6037
+ return '';
6038
+ }
6039
+ }
6040
+ //Default Getter and Setters for a Form Field Implementation
6041
+ get empty() {
6042
+ return this.value.length == 0;
6043
+ }
6044
+ get shouldLabelFloat() {
6045
+ return this.focused || !this.empty;
6046
+ }
6047
+ get required() {
6048
+ return this._required;
6049
+ }
6050
+ set required(value) {
6051
+ this._required = coerceBooleanProperty(value);
6052
+ this.stateChanges.next();
6053
+ }
6054
+ get disabled() {
6055
+ return this._disabled;
6056
+ }
6057
+ set disabled(value) {
6058
+ this._disabled = coerceBooleanProperty(value);
6059
+ this._disabled ? this.tagSelectorCtrl.disable() : this.tagSelectorCtrl.enable();
6060
+ this.stateChanges.next();
6061
+ }
6062
+ get value() {
6063
+ return this._value;
6064
+ }
6065
+ set value(val) {
6066
+ this._value = val;
6067
+ this.tagSelectorCtrl.setValue(val);
6068
+ this.stateChanges.next();
6069
+ }
6070
+ get errorState() {
6071
+ return this.tagSelectorCtrl.dirty && this.required && (this.value.length == 0);
6072
+ }
6073
+ get placeholder() {
6074
+ return this._placeholder;
6075
+ }
6076
+ set placeholder(value) {
6077
+ this._placeholder = value;
6078
+ this.stateChanges.next();
6079
+ }
6080
+ ngOnInit() {
6081
+ if (this.useSelectButtonStyle) {
6082
+ this.httpService.get(this.apiUrl)
6083
+ .pipe(untilDestroyed(this))
6084
+ .subscribe((res) => {
6085
+ this.tags = res.data;
6086
+ });
6087
+ }
6088
+ }
6089
+ selectionChange(value) {
6090
+ this.value = value;
6091
+ this._handleInput();
6092
+ }
6093
+ setDescribedByIds(ids) {
6094
+ // Just a empty implementation for Mat Form Field Interface
6095
+ }
6096
+ onContainerClick() {
6097
+ // Just a empty implementation for Mat Form Field Interface
6098
+ }
6099
+ writeValue(val) {
6100
+ this.value = val;
6101
+ }
6102
+ registerOnChange(fn) {
6103
+ this.onChange = fn;
6104
+ }
6105
+ registerOnTouched(fn) {
6106
+ this.onTouched = fn;
6107
+ }
6108
+ setDisabledState(isDisabled) {
6109
+ this.disabled = isDisabled;
6110
+ }
6111
+ _handleInput() {
6112
+ this.onChange(this.value);
6113
+ }
6114
+ ngOnDestroy() {
6115
+ this.stateChanges.complete();
6116
+ this._focusMonitor.stopMonitoring(this._elementRef);
6117
+ }
6118
+ };
6119
+ TechlifyTaggerTagSelectorComponent.nextId = 0;
6120
+ TechlifyTaggerTagSelectorComponent.decorators = [
6121
+ { type: Component, args: [{
6122
+ selector: 'app-techlify-tagger-tag-selector',
6123
+ template: "<app-searchable-selector *ngIf=\"apiUrl && !useSelectButtonStyle\" [formControl]=\"tagSelectorCtrl\" [apiUrl]=\"apiUrl\"\n [enableSearch]=\"enableSearch\" [multiple]=\"multiple\" (selectionChange)=\"selectionChange($event)\">\n</app-searchable-selector>\n\n<mat-button-toggle-group *ngIf=\"apiUrl && useSelectButtonStyle\" [formControl]=\"tagSelectorCtrl\" [multiple]=\"multiple\"\n (change)=\"selectionChange($event.value)\">\n <mat-button-toggle *ngFor=\"let tag of tags\" [value]=\"tag.id\">{{tag.title}}</mat-button-toggle>\n</mat-button-toggle-group>",
6124
+ providers: [{ provide: MatFormFieldControl, useExisting: TechlifyTaggerTagSelectorComponent_1 }],
6125
+ styles: [""]
6126
+ },] }
6127
+ ];
6128
+ TechlifyTaggerTagSelectorComponent.ctorParameters = () => [
6129
+ { type: FocusMonitor },
6130
+ { type: ElementRef },
6131
+ { type: HttpService },
6132
+ { type: MatFormField, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD,] }] },
6133
+ { type: NgControl, decorators: [{ type: Optional }, { type: Self }] }
6134
+ ];
6135
+ TechlifyTaggerTagSelectorComponent.propDecorators = {
6136
+ categories: [{ type: Input }],
6137
+ multiple: [{ type: Input }],
6138
+ enableSearch: [{ type: Input }],
6139
+ showAllTags: [{ type: Input }],
6140
+ useSelectButtonStyle: [{ type: Input }],
6141
+ required: [{ type: Input }],
6142
+ disabled: [{ type: Input }],
6143
+ value: [{ type: Input }],
6144
+ placeholder: [{ type: Input }]
6145
+ };
6146
+ TechlifyTaggerTagSelectorComponent = TechlifyTaggerTagSelectorComponent_1 = __decorate([
6147
+ UntilDestroy()
6148
+ ], TechlifyTaggerTagSelectorComponent);
6149
+
6150
+ class TechlifyTaggerTagSelectorModule {
6151
+ }
6152
+ TechlifyTaggerTagSelectorModule.decorators = [
6153
+ { type: NgModule, args: [{
6154
+ declarations: [
6155
+ TechlifyTaggerTagSelectorComponent
6156
+ ],
6157
+ imports: [
6158
+ CommonModule,
6159
+ MaterialModule,
6160
+ FlexLayoutModule,
6161
+ MatAutocompleteModule,
6162
+ ReactiveFormsModule,
6163
+ SearchableSelectorModule,
6164
+ MatButtonToggleModule
6165
+ ],
6166
+ exports: [TechlifyTaggerTagSelectorComponent]
6167
+ },] }
6168
+ ];
6169
+
6170
+ class CompanyFeatureService {
6171
+ constructor(dataManager) {
6172
+ this.dataManager = dataManager;
6173
+ }
6174
+ getFeatures() {
6175
+ return this.dataManager.GET(`api/features`);
6176
+ }
6177
+ disableFeature(id) {
6178
+ return this.dataManager.GET(`api/feature/${id}/disable`);
6179
+ }
6180
+ enableFeature(id) {
6181
+ return this.dataManager.GET(`api/feature/${id}/enable`);
6182
+ }
6183
+ }
6184
+ CompanyFeatureService.ɵprov = ɵɵdefineInjectable({ factory: function CompanyFeatureService_Factory() { return new CompanyFeatureService(ɵɵinject(DataManager)); }, token: CompanyFeatureService, providedIn: "root" });
6185
+ CompanyFeatureService.decorators = [
6186
+ { type: Injectable, args: [{
6187
+ providedIn: 'root'
6188
+ },] }
6189
+ ];
6190
+ CompanyFeatureService.ctorParameters = () => [
6191
+ { type: DataManager }
6192
+ ];
6193
+
6194
+ let CompanyFeatureComponent = class CompanyFeatureComponent {
6195
+ constructor(dataManager, errorHandler, fb, alertService, dialog, storage, featureService) {
6196
+ this.dataManager = dataManager;
6197
+ this.errorHandler = errorHandler;
6198
+ this.fb = fb;
6199
+ this.alertService = alertService;
6200
+ this.dialog = dialog;
6201
+ this.storage = storage;
6202
+ this.featureService = featureService;
6203
+ this.features = [];
6204
+ this.displayedColumns = [
6205
+ 'index',
6206
+ 'feature',
6207
+ 'description',
6208
+ 'actions',
6209
+ ];
6210
+ this.dataSource = new MatTableDataSource();
6211
+ this.page = 1;
6212
+ this.perPage = 25;
6213
+ this.isWorking = false;
6214
+ this.filterFormGroup = this.fb.group({
6215
+ num_items: [""]
6216
+ });
6217
+ }
6218
+ ngOnInit() {
6219
+ this.loadData();
6220
+ this.listenForChanges();
6221
+ }
6222
+ listenForChanges() {
6223
+ this.filterFormGroup.valueChanges
6224
+ .pipe(debounceTime(500), untilDestroyed(this))
6225
+ .subscribe((changes) => {
6226
+ this.reload();
6227
+ });
6228
+ }
6229
+ loadData() {
6230
+ return __awaiter(this, void 0, void 0, function* () {
6231
+ let result;
6232
+ try {
6233
+ this.isWorking = true;
6234
+ var filter = this.filterFormGroup.value;
6235
+ filter.page = this.page;
6236
+ filter.perPage = this.perPage;
6237
+ result = yield this.dataManager.GET(`api/features`, filter);
6238
+ this.features = this.features.concat(result.data);
6239
+ this.dataSource = new MatTableDataSource(this.features);
6240
+ if (!this.storage.getItem('features')) {
6241
+ this.setStorage(this.features);
6242
+ }
6243
+ this.isWorking = false;
6244
+ }
6245
+ catch (error) {
6246
+ this.errorHandler.handleError(error);
6247
+ }
6248
+ finally {
6249
+ this.isWorking = false;
6250
+ }
6251
+ });
6252
+ }
6253
+ toggeleFeature(element, feature) {
6254
+ return __awaiter(this, void 0, void 0, function* () {
6255
+ let status = element ? 'Off' : "On";
6256
+ let data;
6257
+ const dialogRef = this.dialog.open(ActionPopupComponent, {
6258
+ width: "400px",
6259
+ data: {
6260
+ title: `Turn this feature ${status}?`,
6261
+ message: `Would you like to turn ${feature.title} feature ${status}`
6262
+ }
6263
+ });
6264
+ dialogRef.afterClosed().subscribe((result) => __awaiter(this, void 0, void 0, function* () {
6265
+ if (result) {
6266
+ try {
6267
+ data = element
6268
+ ? yield this.featureService.disableFeature(feature.id)
6269
+ : yield this.featureService.enableFeature(feature.id);
6270
+ }
6271
+ catch (error) {
6272
+ this.errorHandler.handleError(error);
6273
+ }
6274
+ finally {
6275
+ this.alertService.addAlert(`You have just turned ${status} the feature ${feature.title}`, 'success');
6276
+ this.reload();
6277
+ this.storage.removeItem('features');
6278
+ this.setStorage(this.features);
6279
+ this.isWorking = false;
6280
+ }
6281
+ }
6282
+ else {
6283
+ this.reload();
6284
+ }
6285
+ }));
6286
+ });
6287
+ }
6288
+ setStorage(features) {
6289
+ let localFeatures = [];
6290
+ for (let feature of features) {
6291
+ if (!feature.client_feature) {
6292
+ if (feature.is_enabled_default) {
6293
+ localFeatures.push(feature.code);
6294
+ }
6295
+ }
6296
+ else {
6297
+ if (feature.client_feature.is_enabled) {
6298
+ localFeatures.push(feature.code);
6299
+ }
6300
+ }
6301
+ }
6302
+ this.storage.setItem("features", localFeatures);
6303
+ }
6304
+ reload() {
6305
+ this.features = [];
6306
+ this.page = 1;
6307
+ if (!this.isWorking) {
6308
+ this.loadData();
6309
+ }
6310
+ }
6311
+ onScroll() {
6312
+ if (!this.isWorking && this.page < this.lastPage) {
6313
+ this.page += 1;
6314
+ this.loadData();
6315
+ }
6316
+ }
6317
+ sortColumn(event) {
6318
+ var direction = event.direction.toString().toUpperCase();
6319
+ this.assignFilter(event.active, direction);
6320
+ this.reload();
6321
+ }
6322
+ assignFilter(column, direction) {
6323
+ switch (column) {
6324
+ case 'name': {
6325
+ return this.filterFormGroup
6326
+ .get('sort_by')
6327
+ .setValue('first_name|' + direction);
6328
+ }
6329
+ case 'added_on': {
6330
+ return this.filterFormGroup
6331
+ .get('sort_by')
6332
+ .setValue('created_at|' + direction);
6333
+ }
6334
+ }
6335
+ }
6336
+ };
6337
+ CompanyFeatureComponent.decorators = [
6338
+ { type: Component, args: [{
6339
+ selector: 'app-company-feature',
6340
+ template: "<div fxLayout=\"column\" fxLayoutGap=\"3rem\" class=\"p-3\">\n <div fxLayout=\"column\" fxLayoutAlign=\"center center\" class=\"primary-color mt-3\">\n <h3>Features Configuration</h3>\n <mat-hint>\n <i> Here you can specify which optional features you'd like to have available to your team </i>\n </mat-hint>\n </div>\n\n\n <div>\n <mat-card>\n <mat-card-content fxlayout=\"column\" style=\"overflow: auto; height: 700px\" class=\"classifications-card\">\n <table mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 w-100\" matSort multiTemplateDataRows\n (matSortChange)=\"sortColumn($event)\" infiniteScroll [infiniteScrollDistance]=\"2\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [fromRoot]=\"true\" [infiniteScrollContainer]=\"'.classifications-card'\">\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef>#</th>\n <td mat-cell *matCellDef=\"let element; let i = dataIndex\">\n {{ i + 1 }}\n </td>\n </ng-container>\n\n <!-- Title Column -->\n <ng-container matColumnDef=\"feature\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Feature\n </th>\n <td mat-cell *matCellDef=\"let element\">{{ element?.title }}</td>\n </ng-container>\n\n <!-- Description Column -->\n <ng-container matColumnDef=\"description\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Descriptions\n </th>\n <td mat-cell *matCellDef=\"let element\">\n {{ element?.description }}\n </td>\n </ng-container>\n\n <!-- Actions Column -->\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Actions\n </th>\n <td mat-cell *matCellDef=\"let element\">\n <div *ngIf=\"!element?.client_feature\">\n <app-on-off-switch [value]=\"element?.is_enabled_default\"\n (click)=\"toggeleFeature(element?.is_enabled_default, element)\"></app-on-off-switch>\n </div>\n <div *ngIf=\"element?.client_feature\">\n <app-on-off-switch [value]=\"element?.client_feature?.is_enabled\"\n (click)=\"toggeleFeature(element?.client_feature?.is_enabled, element)\"></app-on-off-switch>\n </div>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns\"></tr>\n </table>\n </mat-card-content>\n </mat-card>\n </div>\n</div>\n",
6341
+ styles: [""]
6342
+ },] }
6343
+ ];
6344
+ CompanyFeatureComponent.ctorParameters = () => [
6345
+ { type: DataManager },
6346
+ { type: ErrorHandlerService },
6347
+ { type: FormBuilder },
6348
+ { type: AlertService },
6349
+ { type: MatDialog },
6350
+ { type: StorageService },
6351
+ { type: CompanyFeatureService }
6352
+ ];
6353
+ CompanyFeatureComponent = __decorate([
6354
+ UntilDestroy()
6355
+ ], CompanyFeatureComponent);
6356
+
6357
+ const routes$n = [
6358
+ {
6359
+ path: '',
6360
+ component: CompanyFeatureComponent,
6361
+ canActivate: [AuthenticationGuard]
6362
+ },
6363
+ ];
6364
+ const CompanyFeatureRoutes = RouterModule.forChild(routes$n);
6365
+
6366
+ class OnOffSwitchComponent {
6367
+ constructor(fb) {
6368
+ this.fb = fb;
6369
+ this.slideToggle = this.fb.group({
6370
+ toggle: [""]
6371
+ });
6372
+ }
6373
+ ngOnInit() {
6374
+ this.slideToggle.get('toggle').setValue(this.value);
6375
+ }
6376
+ }
6377
+ OnOffSwitchComponent.decorators = [
6378
+ { type: Component, args: [{
6379
+ selector: 'app-on-off-switch',
6380
+ template: "<form [formGroup]=\"slideToggle\">\n <mat-slide-toggle formControlName=\"toggle\">On / Off\n </mat-slide-toggle>\n</form>\n",
6381
+ styles: [""]
6382
+ },] }
6383
+ ];
6384
+ OnOffSwitchComponent.ctorParameters = () => [
6385
+ { type: FormBuilder }
6386
+ ];
6387
+ OnOffSwitchComponent.propDecorators = {
6388
+ value: [{ type: Input }]
6389
+ };
6390
+
6391
+ class NgxFeatureEnabledDirective {
6392
+ constructor(el, featureService, errorHandler, storage) {
6393
+ this.el = el;
6394
+ this.featureService = featureService;
6395
+ this.errorHandler = errorHandler;
6396
+ this.storage = storage;
6397
+ this.localFeatures = [];
6398
+ }
6399
+ ngOnInit() {
6400
+ if (!this.storage.getItem('features')) {
6401
+ this.getFeatures();
6402
+ }
6403
+ else {
6404
+ this.checkForFeatureEnabled();
6405
+ }
6406
+ }
6407
+ getFeatures() {
6408
+ return __awaiter(this, void 0, void 0, function* () {
6409
+ try {
6410
+ let features = yield this.featureService.getFeatures();
6411
+ for (let feature of features.data) {
6412
+ if (!feature.client_feature) {
6413
+ if (feature.is_enabled_default) {
6414
+ this.localFeatures.push(feature.code);
6415
+ }
6416
+ }
6417
+ else {
6418
+ if (feature.client_feature.is_enabled) {
6419
+ this.localFeatures.push(feature.code);
6420
+ }
6421
+ }
6422
+ }
6423
+ this.storage.setItem("features", this.localFeatures);
6424
+ }
6425
+ catch (error) {
6426
+ this.errorHandler.handleError(error);
6427
+ }
6428
+ finally {
6429
+ this.checkForFeatureEnabled();
6430
+ }
6431
+ });
6432
+ }
6433
+ checkForFeatureEnabled() {
6434
+ try {
6435
+ let features = this.storage.getItem('features');
6436
+ let features_split = features.split(',');
6437
+ if (features_split.includes(this.enabledFeature)) {
6438
+ this.el.nativeElement.style.display = "show";
6439
+ }
6440
+ else {
6441
+ this.el.nativeElement.remove();
6442
+ }
6443
+ }
6444
+ catch (error) {
6445
+ this.errorHandler.handleError(error);
6446
+ }
6447
+ }
6448
+ }
6449
+ NgxFeatureEnabledDirective.decorators = [
6450
+ { type: Directive, args: [{
6451
+ selector: '[ngxFeatureEnabled]'
6452
+ },] }
6453
+ ];
6454
+ NgxFeatureEnabledDirective.ctorParameters = () => [
6455
+ { type: ElementRef },
6456
+ { type: CompanyFeatureService },
6457
+ { type: ErrorHandlerService },
6458
+ { type: StorageService }
6459
+ ];
6460
+ NgxFeatureEnabledDirective.propDecorators = {
6461
+ enabledFeature: [{ type: Input, args: ['ngxFeatureEnabled',] }]
6462
+ };
6463
+
6464
+ class CompanyFeatureModule {
6465
+ }
6466
+ CompanyFeatureModule.decorators = [
6467
+ { type: NgModule, args: [{
6468
+ imports: [
6469
+ CommonModule,
6470
+ MaterialModule,
6471
+ FlexLayoutModule,
6472
+ CompanyFeatureRoutes,
6473
+ MatSlideToggleModule,
6474
+ FormsModule,
6475
+ ReactiveFormsModule,
6476
+ InfiniteScrollModule
6477
+ ],
6478
+ declarations: [CompanyFeatureComponent, OnOffSwitchComponent, NgxFeatureEnabledDirective],
6479
+ exports: [CompanyFeatureComponent, NgxFeatureEnabledDirective]
6480
+ },] }
6481
+ ];
6482
+
5597
6483
  /*
5598
6484
  * Public API Surface of ngx-techlify-core
5599
6485
  */
@@ -5602,5 +6488,5 @@ LoginHistoryForUserModule.decorators = [
5602
6488
  * Generated bundle index. Do not edit.
5603
6489
  */
5604
6490
 
5605
- export { ActionPopup, ActionPopupComponent, ActionPopupModule, AlertService, ApiPrefixInterceptor, AuditLogForModelComponent, AuditLogForModelModule, AuditLogForModelRoutingModule, AuditLogListComponent, AuditLogListFilterComponent, AuditLogListFilterModule, AuditLogListFilterRoutingModule, AuditLogListModule, AuditLogListRoutingModule, AuditLogModule, AuditLogRoutingModule, AuditLogViewComponent, AuditLogViewModelComponent, AuditLogViewModelModule, AuditLogViewModelRoutingModule, AuditLogViewModule, AuditLogViewRoutingModule, AuditLogsViewModelComponent, AuditLogsViewModelModule, AuditLogsViewModelRoutingModule, AuthenticationGuard, AuthenticationService, CacheInterceptor, ConfigService, CoreModule, CredentialsService, DataManager, DataTable, DataTableComponent, DataTableModule, DateUtils, DateValidator, DocumentViewerComponent, DocumentViewerModule, EmailSubscriptionForUserComponent, EmailSubscriptionForUserModule, EmailSubscriptionForUserRoutingModule, EmailSubscriptionModule, EmailSubscriptionRoutingModule, EmailSubscriptionTypeFormComponent, EmailSubscriptionTypeFormModule, EmailSubscriptionTypeFormRoutingModule, EmailSubscriptionTypeListComponent, EmailSubscriptionTypeListModule, EmailSubscriptionTypeListRoutingModule, EmailSubscriptionTypeModule, EmailSubscriptionTypeRoutingModule, EmailSubscriptionUserFormComponent, EmailSubscriptionUserFormModule, EmailSubscriptionUserFormRoutingModule, EmailSubscriptionUserListComponent, EmailSubscriptionUserListFilterComponent, EmailSubscriptionUserListFilterModule, EmailSubscriptionUserListFilterRoutingModule, EmailSubscriptionUserListModule, EmailSubscriptionUserListRoutingModule, EmailSubscriptionUserModule, EmailSubscriptionUserRoutingModule, EntityFileFormComponent, EntityFilesViewAllComponent, EntityFilesViewAllModule, ErrorHandlerInterceptor, ErrorHandlerService, ErrorSnackComponent, ExportExcelButtonComponent, ExportExcelModule, FailedItemsComponent, FailedItemsModule, FailedItemsRoutingModule, FileDropperComponent, FileDropperConfig, FileDropperModule, FormValidatorService, HTTP_DYNAMIC_INTERCEPTORS, HttpCacheService, HttpService, ImportConfig, ImportCsvComponent, ImportCsvModule, ImportCsvRoutingModule, ImportItemsComponent, ImportItemsModule, ImportItemsRoutingModule, LoaderComponent, LoaderModule, LogLevel, Logger, LoginHistoryForUserComponent, LoginHistoryForUserModule, LoginHistoryForUserRoutingModule, MatSelectInfiniteScrollDirective, MaterialModule, NoteFormComponent, NoteListComponent, NoteModule, NumItemsSelector, NumberSelector, PageEvent, RouteReusableStrategy, SearchableSelectorComponent, SearchableSelectorModule, SnackModule, StorageService, SuccessSnackComponent, TechlifyConfig, TechlifyUpdateHistoryModule, TechlifyUpdateModule, Timeline, TimelineFilterComponent, TimelineFilterModule, TokenInterceptor, UpdateNotifierComponent, UpdateNotifierModule, UtilityModule, ViewerConfig, calculateTimeline, esfur, estlr, esulr, SnackModule as ɵa, SuccessSnackComponent as ɵb, EmailSubscriptionUserFormComponent as ɵba, EmailSubscriptionUserListComponent as ɵbb, AuthenticationGuard as ɵbc, CredentialsService as ɵbd, ConfigService as ɵbe, TechlifyConfig as ɵbf, EmailSubscriptionUserListFilterComponent as ɵbg, EmailSubscriptionTypeFormComponent as ɵbh, EmailSubscriptionTypeListComponent as ɵbi, EmailSubscriptionForUserComponent as ɵbj, TechlifyUpdatesListComponent as ɵbk, TechlifyUpdateService as ɵbl, TechlifyUpdateRoutingModule as ɵbm, TechlifyUpdateFormModule as ɵbn, TechlifyUpdateFormComponent as ɵbo, ReadMoreModule as ɵbp, ReadMoreComponent as ɵbq, TechlifyUpdateHistoryRoutingModule as ɵbr, TechlifyUpdateHistoryComponent as ɵbs, UpdateNotifierSnackComponent as ɵbt, UpdateViewModule as ɵbu, UpdateViewComponent as ɵbv, DataManager as ɵbw, ErrorSnackComponent as ɵc, HTTP_DYNAMIC_INTERCEPTORS as ɵd, HttpService as ɵe, RouteReusableStrategy as ɵf, ActionPopupComponent as ɵg, ActionPopup as ɵh, DataTableComponent as ɵi, DocumentViewerComponent as ɵj, EntityFileFormComponent as ɵk, FormValidatorService as ɵl, EntityFileService as ɵm, AlertService as ɵn, EntityFilesViewAllComponent as ɵo, FileDropperComponent as ɵp, NoteListComponent as ɵq, NoteService as ɵr, NoteFormComponent as ɵs, SearchableSelectorComponent as ɵt, MatSelectInfiniteScrollDirective as ɵu, NumItemsSelector as ɵv, NumberSelector as ɵw, TimelineFilterComponent as ɵx, TimelineFilterRoutingModule as ɵy, LoaderComponent as ɵz };
6491
+ export { ActionPopup, ActionPopupComponent, ActionPopupModule, AlertService, ApiPrefixInterceptor, AuditLogForModelComponent, AuditLogForModelModule, AuditLogForModelRoutingModule, AuditLogListComponent, AuditLogListFilterComponent, AuditLogListFilterModule, AuditLogListFilterRoutingModule, AuditLogListModule, AuditLogListRoutingModule, AuditLogModule, AuditLogRoutingModule, AuditLogViewComponent, AuditLogViewModelComponent, AuditLogViewModelModule, AuditLogViewModelRoutingModule, AuditLogViewModule, AuditLogViewRoutingModule, AuditLogsViewModelComponent, AuditLogsViewModelModule, AuditLogsViewModelRoutingModule, AuthenticationGuard, AuthenticationService, CacheInterceptor, CommentFormComponent, CompanyFeatureComponent, CompanyFeatureModule, CompanyFeatureRoutes, ConfigService, CoreModule, CredentialsService, DataManager, DataTable, DataTableComponent, DataTableModule, DateUtils, DateValidator, DocumentViewerComponent, DocumentViewerModule, EmailSubscriptionForUserComponent, EmailSubscriptionForUserModule, EmailSubscriptionForUserRoutingModule, EmailSubscriptionModule, EmailSubscriptionRoutingModule, EmailSubscriptionTypeFormComponent, EmailSubscriptionTypeFormModule, EmailSubscriptionTypeFormRoutingModule, EmailSubscriptionTypeListComponent, EmailSubscriptionTypeListModule, EmailSubscriptionTypeListRoutingModule, EmailSubscriptionTypeModule, EmailSubscriptionTypeRoutingModule, EmailSubscriptionUserFormComponent, EmailSubscriptionUserFormModule, EmailSubscriptionUserFormRoutingModule, EmailSubscriptionUserListComponent, EmailSubscriptionUserListFilterComponent, EmailSubscriptionUserListFilterModule, EmailSubscriptionUserListFilterRoutingModule, EmailSubscriptionUserListModule, EmailSubscriptionUserListRoutingModule, EmailSubscriptionUserModule, EmailSubscriptionUserRoutingModule, EntityFileFormComponent, EntityFilesViewAllComponent, EntityFilesViewAllModule, ErrorHandlerInterceptor, ErrorHandlerService, ErrorSnackComponent, ExportExcelButtonComponent, ExportExcelModule, FailedItemsComponent, FailedItemsModule, FailedItemsRoutingModule, FileDropperComponent, FileDropperConfig, FileDropperModule, FormValidatorService, HTTP_DYNAMIC_INTERCEPTORS, HttpCacheService, HttpService, ImportConfig, ImportCsvComponent, ImportCsvModule, ImportCsvRoutingModule, ImportItemsComponent, ImportItemsModule, ImportItemsRoutingModule, LoaderComponent, LoaderModule, LogLevel, Logger, LoginHistoryForUserComponent, LoginHistoryForUserModule, LoginHistoryForUserRoutingModule, MatSelectInfiniteScrollDirective, MaterialModule, NgxFeatureEnabledDirective, NoteFormComponent, NoteListComponent, NoteModule, NumItemsSelector, NumberSelector, OnOffSwitchComponent, PageEvent, ReadMoreComponent, ReadMoreModule, RouteReusableStrategy, SearchableSelectorComponent, SearchableSelectorModule, SnackModule, StorageService, SuccessSnackComponent, TechlifyConfig, TechlifyTaggerTagFormConfigModel, TechlifyTaggerTagFormFieldComponent, TechlifyTaggerTagFormFieldModule, TechlifyTaggerTagSelectorComponent, TechlifyTaggerTagSelectorModule, TechlifyUpdateHistoryModule, TechlifyUpdateModule, Timeline, TimelineFilterComponent, TimelineFilterModule, TokenInterceptor, UpdateNotifierComponent, UpdateNotifierModule, UtilityModule, ViewerConfig, calculateTimeline, esfur, estlr, esulr, SnackModule as ɵa, SuccessSnackComponent as ɵb, NumberSelector as ɵba, TimelineFilterComponent as ɵbb, TimelineFilterRoutingModule as ɵbc, LoaderComponent as ɵbd, EmailSubscriptionUserFormComponent as ɵbe, EmailSubscriptionUserListComponent as ɵbf, AuthenticationGuard as ɵbg, EmailSubscriptionUserListFilterComponent as ɵbh, EmailSubscriptionTypeFormComponent as ɵbi, EmailSubscriptionTypeListComponent as ɵbj, EmailSubscriptionForUserComponent as ɵbk, TechlifyUpdatesListComponent as ɵbl, TechlifyUpdateService as ɵbm, TechlifyUpdateRoutingModule as ɵbn, TechlifyUpdateFormModule as ɵbo, TechlifyUpdateFormComponent as ɵbp, TechlifyUpdateHistoryRoutingModule as ɵbq, TechlifyUpdateHistoryComponent as ɵbr, UpdateNotifierSnackComponent as ɵbs, UpdateViewModule as ɵbt, UpdateViewComponent as ɵbu, DataManager as ɵbv, DataManager as ɵbw, ErrorHandlerService as ɵbx, AlertService as ɵby, StorageService as ɵbz, ErrorSnackComponent as ɵc, CompanyFeatureService as ɵca, AuthenticationGuard as ɵcb, HTTP_DYNAMIC_INTERCEPTORS as ɵd, HttpService as ɵe, RouteReusableStrategy as ɵf, ActionPopupComponent as ɵg, ActionPopup as ɵh, DataTableComponent as ɵi, DocumentViewerComponent as ɵj, EntityFileFormComponent as ɵk, FormValidatorService as ɵl, EntityFileService as ɵm, AlertService as ɵn, EntityFilesViewAllComponent as ɵo, FileDropperComponent as ɵp, NoteListComponent as ɵq, NoteService as ɵr, NoteFormComponent as ɵs, CommentFormComponent as ɵt, CredentialsService as ɵu, ConfigService as ɵv, TechlifyConfig as ɵw, SearchableSelectorComponent as ɵx, MatSelectInfiniteScrollDirective as ɵy, NumItemsSelector as ɵz };
5606
6492
  //# sourceMappingURL=ngx-techlify-core.js.map