dont allow select no collections
This commit is contained in:
parent
86cee1a07c
commit
00f1aad65e
|
@ -17,6 +17,7 @@ import { Cipher } from '../../models/domain/cipher';
|
|||
|
||||
export class CollectionsComponent implements OnInit {
|
||||
@Input() cipherId: string;
|
||||
@Input() allowSelectNone = false;
|
||||
@Output() onSavedCollections = new EventEmitter();
|
||||
|
||||
formPromise: Promise<any>;
|
||||
|
@ -48,9 +49,14 @@ export class CollectionsComponent implements OnInit {
|
|||
}
|
||||
|
||||
async submit() {
|
||||
this.cipherDomain.collectionIds = this.collections
|
||||
const selectedCollectionIds = this.collections
|
||||
.filter((c) => !!(c as any).checked)
|
||||
.map((c) => c.id);
|
||||
if (!this.allowSelectNone && selectedCollectionIds.length === 0) {
|
||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('selectOneCollection'));
|
||||
}
|
||||
this.cipherDomain.collectionIds = selectedCollectionIds;
|
||||
try {
|
||||
this.formPromise = this.saveCollections();
|
||||
await this.formPromise;
|
||||
|
|
|
@ -64,13 +64,20 @@ export class ShareComponent implements OnInit {
|
|||
}
|
||||
|
||||
async submit(): Promise<boolean> {
|
||||
const selectedCollectionIds = this.collections
|
||||
.filter((c) => !!(c as any).checked)
|
||||
.map((c) => c.id);
|
||||
if (selectedCollectionIds.length === 0) {
|
||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('selectOneCollection'));
|
||||
}
|
||||
|
||||
const cipherDomain = await this.cipherService.get(this.cipherId);
|
||||
const cipherView = await cipherDomain.decrypt();
|
||||
|
||||
const checkedCollectionIds = this.collections.filter((c) => (c as any).checked).map((c) => c.id);
|
||||
try {
|
||||
this.formPromise = this.cipherService.shareWithServer(cipherView, this.organizationId,
|
||||
checkedCollectionIds).then(async () => {
|
||||
selectedCollectionIds).then(async () => {
|
||||
this.onSharedCipher.emit();
|
||||
this.platformUtilsService.eventTrack('Shared Cipher');
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('sharedItem'));
|
||||
|
|
Loading…
Reference in New Issue