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 {
|
export class CollectionsComponent implements OnInit {
|
||||||
@Input() cipherId: string;
|
@Input() cipherId: string;
|
||||||
|
@Input() allowSelectNone = false;
|
||||||
@Output() onSavedCollections = new EventEmitter();
|
@Output() onSavedCollections = new EventEmitter();
|
||||||
|
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<any>;
|
||||||
|
@ -48,9 +49,14 @@ export class CollectionsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
this.cipherDomain.collectionIds = this.collections
|
const selectedCollectionIds = this.collections
|
||||||
.filter((c) => !!(c as any).checked)
|
.filter((c) => !!(c as any).checked)
|
||||||
.map((c) => c.id);
|
.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 {
|
try {
|
||||||
this.formPromise = this.saveCollections();
|
this.formPromise = this.saveCollections();
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
|
|
|
@ -64,13 +64,20 @@ export class ShareComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit(): Promise<boolean> {
|
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 cipherDomain = await this.cipherService.get(this.cipherId);
|
||||||
const cipherView = await cipherDomain.decrypt();
|
const cipherView = await cipherDomain.decrypt();
|
||||||
|
|
||||||
const checkedCollectionIds = this.collections.filter((c) => (c as any).checked).map((c) => c.id);
|
|
||||||
try {
|
try {
|
||||||
this.formPromise = this.cipherService.shareWithServer(cipherView, this.organizationId,
|
this.formPromise = this.cipherService.shareWithServer(cipherView, this.organizationId,
|
||||||
checkedCollectionIds).then(async () => {
|
selectedCollectionIds).then(async () => {
|
||||||
this.onSharedCipher.emit();
|
this.onSharedCipher.emit();
|
||||||
this.platformUtilsService.eventTrack('Shared Cipher');
|
this.platformUtilsService.eventTrack('Shared Cipher');
|
||||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('sharedItem'));
|
this.platformUtilsService.showToast('success', null, this.i18nService.t('sharedItem'));
|
||||||
|
|
Loading…
Reference in New Issue