2017-07-20 15:12:09 +00:00
|
|
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
2017-07-18 16:34:12 +00:00
|
|
|
import { MailService } from './mail.service';
|
2017-07-20 15:12:09 +00:00
|
|
|
import { Subscription } from 'rxjs/Subscription';
|
2017-07-08 16:12:52 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector : 'fuse-mail',
|
|
|
|
templateUrl: './mail.component.html',
|
|
|
|
styleUrls : ['./mail.component.scss']
|
|
|
|
})
|
2017-07-20 15:12:09 +00:00
|
|
|
export class MailComponent implements OnInit, OnDestroy
|
2017-07-08 16:12:52 +00:00
|
|
|
{
|
2017-07-20 15:12:09 +00:00
|
|
|
hasSelectedMails: boolean;
|
|
|
|
isIndeterminate: boolean;
|
|
|
|
folders: any[];
|
|
|
|
labels: any[];
|
|
|
|
|
|
|
|
onSelectedMailsChanged: Subscription;
|
2017-07-08 16:12:52 +00:00
|
|
|
|
2017-07-17 15:11:34 +00:00
|
|
|
constructor(
|
2017-07-18 16:34:12 +00:00
|
|
|
private mailService: MailService
|
2017-07-17 15:11:34 +00:00
|
|
|
)
|
2017-07-08 16:12:52 +00:00
|
|
|
{
|
2017-07-18 16:34:12 +00:00
|
|
|
|
2017-07-08 16:12:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit()
|
|
|
|
{
|
2017-07-20 15:12:09 +00:00
|
|
|
// Get the values for the first time
|
|
|
|
this.labels = this.mailService.labels;
|
|
|
|
this.folders = this.mailService.folders;
|
|
|
|
|
|
|
|
this.onSelectedMailsChanged =
|
|
|
|
this.mailService.onSelectedMailsChanged
|
|
|
|
.subscribe(selectedMails => {
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.hasSelectedMails = selectedMails.length > 0;
|
|
|
|
this.isIndeterminate = (selectedMails.length !== this.mailService.mails.length && selectedMails.length > 0);
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy()
|
|
|
|
{
|
|
|
|
this.onSelectedMailsChanged.unsubscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleSelectAll()
|
|
|
|
{
|
|
|
|
this.mailService.toggleSelectAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
selectMails(filterParameter?, filterValue?)
|
|
|
|
{
|
|
|
|
this.mailService.selectMails(filterParameter, filterValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
deselectMails()
|
|
|
|
{
|
|
|
|
this.mailService.deselectMails();
|
|
|
|
}
|
2017-07-17 15:11:34 +00:00
|
|
|
|
2017-07-20 15:12:09 +00:00
|
|
|
toggleLabelOnSelectedMails(labelId)
|
|
|
|
{
|
|
|
|
this.mailService.toggleLabelOnSelectedMails(labelId);
|
|
|
|
}
|
|
|
|
|
|
|
|
setFolderOnSelectedMails(folderId)
|
|
|
|
{
|
|
|
|
this.mailService.setFolderOnSelectedMails(folderId);
|
2017-07-16 18:41:01 +00:00
|
|
|
}
|
2017-07-08 16:12:52 +00:00
|
|
|
}
|