import { __decorate } from "tslib";
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import * as i0 from "@angular/core";
import * as i1 from "../user.service";
import * as i2 from "../../core";
import * as i3 from "../current-user.service";
import * as i4 from "@angular/common";
import * as i5 from "@angular/material/button";
import * as i6 from "@angular/material/icon";
import * as i7 from "@angular/material/tooltip";
let UserEnableButtonComponent = class UserEnableButtonComponent {
    constructor(service, alertService, currentUserService) {
        this.service = service;
        this.alertService = alertService;
        this.currentUserService = currentUserService;
        this.isUseIcons = false;
        this.onSave = new EventEmitter();
    }
    ngOnInit() {
        this.currentUser = this.currentUserService.getUser();
    }
    enableUser() {
        if (this.currentUser.id === this?.user?.id) {
            this.alertService.addAlert('Current user cannot be changed', 'warn');
            return;
        }
        this.service.enable(this.user).then(res => {
            this.onSave.emit(this.user);
        });
    }
    disableUser() {
        if (this.currentUser.id === this?.user?.id) {
            this.alertService.addAlert('Current user cannot be changed', 'warn');
            return;
        }
        this.service.disable(this.user).then(res => {
            this.onSave.emit(this.user);
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UserEnableButtonComponent, deps: [{ token: i1.UserService }, { token: i2.AlertService }, { token: i3.CurrentUserService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: UserEnableButtonComponent, selector: "app-user-enable-button", inputs: { user: "user", isUseIcons: "isUseIcons" }, outputs: { onSave: "onSave" }, ngImport: i0, template: "<ng-container *ngIf=\"!isUseIcons\">\n  <button mat-stroked-button color=\"warn\" *ngIf=\"user?.user_client?.is_enabled\n  && user?.id !== currentUser?.id\n  && currentUserService.hasPermission('user_disable')\" (click)=\"disableUser()\">\n    Disable\n  </button>\n  <button mat-raised-button color=\"primary\" *ngIf=\"!user?.user_client?.is_enabled\n&& user?.id !== currentUser?.id\n&& currentUserService.hasPermission('user_enable')\" (click)=\"enableUser()\">\n    Enable\n  </button>\n</ng-container>\n\n<ng-container *ngIf=\"isUseIcons\">\n  <button mat-icon-button class=\"text-danger\" *ngIf=\"user?.user_client?.is_enabled\n  && user?.id !== currentUser?.id\n  && currentUserService.hasPermission('user_disable')\" (click)=\"disableUser()\" matTooltip=\"Disable User\">\n    <mat-icon>person_off</mat-icon>\n  </button>\n  <button mat-icon-button class=\"text-success\" *ngIf=\"!user?.user_client?.is_enabled\n&& user?.id !== currentUser?.id\n&& currentUserService.hasPermission('user_enable')\" (click)=\"enableUser()\" matTooltip=\"Enable User\">\n    <mat-icon>task_alt</mat-icon>\n  </button>\n</ng-container>", dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i5.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }] }); }
};
UserEnableButtonComponent = __decorate([
    UntilDestroy()
    /**
     * Component to view the set of users
     *
     * @author Joshua Kissoon
     * @since 20170710
     */
], UserEnableButtonComponent);
export { UserEnableButtonComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UserEnableButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-user-enable-button', template: "<ng-container *ngIf=\"!isUseIcons\">\n  <button mat-stroked-button color=\"warn\" *ngIf=\"user?.user_client?.is_enabled\n  && user?.id !== currentUser?.id\n  && currentUserService.hasPermission('user_disable')\" (click)=\"disableUser()\">\n    Disable\n  </button>\n  <button mat-raised-button color=\"primary\" *ngIf=\"!user?.user_client?.is_enabled\n&& user?.id !== currentUser?.id\n&& currentUserService.hasPermission('user_enable')\" (click)=\"enableUser()\">\n    Enable\n  </button>\n</ng-container>\n\n<ng-container *ngIf=\"isUseIcons\">\n  <button mat-icon-button class=\"text-danger\" *ngIf=\"user?.user_client?.is_enabled\n  && user?.id !== currentUser?.id\n  && currentUserService.hasPermission('user_disable')\" (click)=\"disableUser()\" matTooltip=\"Disable User\">\n    <mat-icon>person_off</mat-icon>\n  </button>\n  <button mat-icon-button class=\"text-success\" *ngIf=\"!user?.user_client?.is_enabled\n&& user?.id !== currentUser?.id\n&& currentUserService.hasPermission('user_enable')\" (click)=\"enableUser()\" matTooltip=\"Enable User\">\n    <mat-icon>task_alt</mat-icon>\n  </button>\n</ng-container>" }]
        }], ctorParameters: () => [{ type: i1.UserService }, { type: i2.AlertService }, { type: i3.CurrentUserService }], propDecorators: { user: [{
                type: Input
            }], isUseIcons: [{
                type: Input
            }], onSave: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 