2018-06-12 23:33:08 +02:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
EventEmitter,
|
|
|
|
Input,
|
|
|
|
OnInit,
|
|
|
|
Output,
|
|
|
|
} from '@angular/core';
|
|
|
|
|
2021-06-07 20:13:58 +02:00
|
|
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
|
|
|
import { FolderService } from 'jslib-common/abstractions/folder.service';
|
|
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
2021-12-07 20:41:45 +01:00
|
|
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
2018-06-12 23:33:08 +02:00
|
|
|
|
2021-06-07 20:13:58 +02:00
|
|
|
import { FolderView } from 'jslib-common/models/view/folderView';
|
2018-06-12 23:33:08 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-vault-bulk-move',
|
|
|
|
templateUrl: 'bulk-move.component.html',
|
|
|
|
})
|
|
|
|
export class BulkMoveComponent implements OnInit {
|
|
|
|
@Input() cipherIds: string[] = [];
|
|
|
|
@Output() onMoved = new EventEmitter();
|
|
|
|
|
|
|
|
folderId: string = null;
|
|
|
|
folders: FolderView[] = [];
|
|
|
|
formPromise: Promise<any>;
|
|
|
|
|
2021-12-07 20:41:45 +01:00
|
|
|
constructor(private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
|
2021-04-14 23:43:40 +02:00
|
|
|
private i18nService: I18nService, private folderService: FolderService) { }
|
2018-06-12 23:33:08 +02:00
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
this.folders = await this.folderService.getAllDecrypted();
|
|
|
|
this.folderId = this.folders[0].id;
|
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
this.formPromise = this.cipherService.moveManyWithServer(this.cipherIds, this.folderId);
|
|
|
|
await this.formPromise;
|
|
|
|
this.onMoved.emit();
|
2021-12-07 20:41:45 +01:00
|
|
|
this.platformUtilsService.showToast('success', null, this.i18nService.t('movedItems'));
|
2018-06-12 23:33:08 +02:00
|
|
|
}
|
|
|
|
}
|