1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-11 14:48:46 +01:00
bitwarden-browser/src/app/send/send.component.ts

78 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-02-03 22:24:49 +01:00
import {
Component,
NgZone,
OnInit,
2021-02-09 21:57:10 +01:00
ViewChild,
2021-02-03 22:24:49 +01:00
} from '@angular/core';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
2021-02-09 21:57:10 +01:00
import { PolicyService } from 'jslib/abstractions/policy.service';
2021-02-03 22:24:49 +01:00
import { SearchService } from 'jslib/abstractions/search.service';
import { SendService } from 'jslib/abstractions/send.service';
2021-02-09 21:57:10 +01:00
import { UserService } from 'jslib/abstractions/user.service';
2021-02-03 22:24:49 +01:00
import { SendComponent as BaseSendComponent } from 'jslib/angular/components/send/send.component';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
import { SendView } from 'jslib/models/view/sendView';
2021-02-09 21:57:10 +01:00
import { AddEditComponent } from './add-edit.component';
2021-02-03 22:24:49 +01:00
enum Action {
None = '',
Add = 'add',
Edit = 'edit',
}
@Component({
selector: 'app-send',
templateUrl: 'send.component.html',
})
export class SendComponent extends BaseSendComponent implements OnInit {
2021-02-09 21:57:10 +01:00
@ViewChild(AddEditComponent) addEditComponent: AddEditComponent;
2021-02-03 22:24:49 +01:00
sendId: string;
action: Action = Action.None;
constructor(sendService: SendService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService,
broadcasterService: BroadcasterService, ngZone: NgZone,
2021-02-09 21:57:10 +01:00
searchService: SearchService, policyService: PolicyService,
userService: UserService) {
2021-02-03 22:24:49 +01:00
super(sendService, i18nService, platformUtilsService,
2021-02-09 21:57:10 +01:00
environmentService, broadcasterService, ngZone, searchService,
policyService, userService);
}
async ngOnInit() {
super.ngOnInit();
await this.load();
2021-02-03 22:24:49 +01:00
}
addSend() {
this.sendId = null;
2021-02-04 05:50:41 +01:00
this.action = Action.Add;
2021-02-03 22:24:49 +01:00
}
editSend(send: SendView) {
2021-02-04 05:12:23 +01:00
return;
}
2021-02-09 21:57:10 +01:00
async selectSend(sendId: string) {
this.sendId = sendId;
2021-02-04 05:50:41 +01:00
this.action = Action.Edit;
2021-02-09 21:57:10 +01:00
if (this.addEditComponent != null) {
this.addEditComponent.sendId = this.sendId;
await this.addEditComponent.refresh();
}
2021-02-03 22:24:49 +01:00
}
2021-02-04 05:50:41 +01:00
get selectedSendType() {
return this.sends.find(s => s.id === this.sendId).type;
2021-02-03 22:24:49 +01:00
}
}