1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

control save button enabled for sharing modal

This commit is contained in:
Kyle Spearrin
2018-08-07 23:46:31 -04:00
parent 4a324ca764
commit 80af20ef54
5 changed files with 33 additions and 9 deletions

View File

@@ -67,12 +67,14 @@ export class BulkShareComponent implements OnInit {
async submit() {
const checkedCollectionIds = this.collections.filter((c) => (c as any).checked).map((c) => c.id);
this.formPromise = this.cipherService.shareManyWithServer(this.shareableCiphers, this.organizationId,
checkedCollectionIds);
await this.formPromise;
this.onShared.emit();
this.analytics.eventTrack.next({ action: 'Bulk Shared Items' });
this.toasterService.popAsync('success', null, this.i18nService.t('sharedItems'));
try {
this.formPromise = this.cipherService.shareManyWithServer(this.shareableCiphers, this.organizationId,
checkedCollectionIds);
await this.formPromise;
this.onShared.emit();
this.analytics.eventTrack.next({ action: 'Bulk Shared Items' });
this.toasterService.popAsync('success', null, this.i18nService.t('sharedItems'));
} catch { }
}
check(c: CollectionView, select?: boolean) {
@@ -83,4 +85,15 @@ export class BulkShareComponent implements OnInit {
const collections = select ? this.collections : this.writeableCollections;
collections.forEach((c) => this.check(c, select));
}
get canSave() {
if (this.shareableCiphers != null && this.shareableCiphers.length > 0 && this.collections != null) {
for (let i = 0; i < this.collections.length; i++) {
if ((this.collections[i] as any).checked) {
return true;
}
}
}
return false;
}
}