File

src/app/admin/invites/invites-list.component.ts

Implements

OnInit

Metadata

selector crm-invites-list
styles .action-padding {padding: 0 10px}
templateUrl ./invites-list.component.html

Index

Methods
Inputs

Constructor

constructor(invitesService: InvitesService, notificationsService: NotificationsService, confirmDialogService: ConfirmDialogService)
Parameters :
Name Type Optional Description
invitesService InvitesService
notificationsService NotificationsService
confirmDialogService ConfirmDialogService

Inputs

invites

Type: Invite[]

isRoot

Type: Boolean

Methods

getStatusStyle
getStatusStyle(status: InviteStatus)
Parameters :
Name Type Optional Description
status InviteStatus
Returns : "badge-success" | "badge-warning" | "badge-danger" | ""
ngOnInit
ngOnInit()
Returns : void
removeInvite
removeInvite(invite: Invite)
Parameters :
Name Type Optional Description
invite Invite
Returns : void
import {Component, OnInit, Input} from '@angular/core';
import {Invite} from "./invite.model";
import {InvitesService} from "./invites.service";
import {NotificationsService} from "../../core/notifications/notifications.service";
import {InviteStatus, InviteStatuses} from "./invite-status.type";
import {ConfirmDialogService} from "../../core/confirm-dialog/confirm-dialog.service";

@Component({
  selector: 'crm-invites-list',
  templateUrl: './invites-list.component.html',
  styles: [`.action-padding {padding: 0 10px}`]
})
export class InvitesListComponent implements OnInit {

  @Input() invites: Invite[];
  @Input() isRoot: Boolean;

  constructor(private invitesService: InvitesService,
              private notificationsService: NotificationsService,
              private confirmDialogService: ConfirmDialogService) {
  }

  getStatusStyle(status: InviteStatus) {
    switch (status) {
      case InviteStatuses.Registered:
        return "badge-success";
      case InviteStatuses.Waiting:
        return "badge-warning";
      case InviteStatuses.Expired:
        return "badge-danger";
      default:
        return "";
    }
  }

  removeInvite(invite: Invite) {
    this.confirmDialogService.ask('You really want delete invite?', 'Delete', 'Delete invite confirmation').then(
      confirm => {
        this.invitesService.removeInvite(invite.id).subscribe(
          ok => {
            this.invites.splice(this.invites.indexOf(invite), 1);
            this.notificationsService.success("Invite deleted");
          },
          error => this.notificationsService.error(error.json())
        )
      },
      cancel => console.debug('Cancel')
    );
  }

  ngOnInit() {
  }

}
<div class="row">
  <div class="col-sm-12">
    <div class="card">
      <div class="card-header">
        <i class="fa fa-align-justify"></i> Invitation list
      </div>
      <div class="card-block">
        <table class="table table-striped">
          <thead>
          <tr>
            <th>Email</th>
            <th>Expiration date</th>
            <th *ngIf="isRoot">Company</th>
            <th>Role</th>
            <th>Status</th>
            <th width="15"></th>
          </tr>
          </thead>
          <tbody>
          <tr *ngFor="let invite of invites">
            <td>{{invite.email}}</td>
            <td>{{invite.expiredDate | date:'short'}}</td>
            <td *ngIf="isRoot">{{invite.company.name}}</td>
            <td>{{invite.role.name}}</td>
            <td><span class="badge {{getStatusStyle(invite.status)}}">{{invite.status}}</span></td>
            <td>
              <div class="btn-group pull-right" crmDropdown>
                <button type="button" class="btn btn-link text-muted action-padding" title="Actions"><span
                  class="icon-options-vertical"></span></button>
                <div class="dropdown-menu dropdown-menu-right">
                  <button class="btn btn-link dropdown-item" (click)="removeInvite(invite)">Delete</button>
                </div>
              </div>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""