control save button enabled for sharing modal
This commit is contained in:
parent
4a324ca764
commit
80af20ef54
|
@ -46,7 +46,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<button type="submit" class="btn btn-primary btn-submit manual" [disabled]="form.loading || !canSave" [ngClass]="{loading:form.loading}">
|
||||||
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}"></i>
|
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}"></i>
|
||||||
<span>{{'save' | i18n}}</span>
|
<span>{{'save' | i18n}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -67,12 +67,14 @@ export class BulkShareComponent implements OnInit {
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
const checkedCollectionIds = this.collections.filter((c) => (c as any).checked).map((c) => c.id);
|
const checkedCollectionIds = this.collections.filter((c) => (c as any).checked).map((c) => c.id);
|
||||||
this.formPromise = this.cipherService.shareManyWithServer(this.shareableCiphers, this.organizationId,
|
try {
|
||||||
checkedCollectionIds);
|
this.formPromise = this.cipherService.shareManyWithServer(this.shareableCiphers, this.organizationId,
|
||||||
await this.formPromise;
|
checkedCollectionIds);
|
||||||
this.onShared.emit();
|
await this.formPromise;
|
||||||
this.analytics.eventTrack.next({ action: 'Bulk Shared Items' });
|
this.onShared.emit();
|
||||||
this.toasterService.popAsync('success', null, this.i18nService.t('sharedItems'));
|
this.analytics.eventTrack.next({ action: 'Bulk Shared Items' });
|
||||||
|
this.toasterService.popAsync('success', null, this.i18nService.t('sharedItems'));
|
||||||
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
check(c: CollectionView, select?: boolean) {
|
check(c: CollectionView, select?: boolean) {
|
||||||
|
@ -83,4 +85,15 @@ export class BulkShareComponent implements OnInit {
|
||||||
const collections = select ? this.collections : this.writeableCollections;
|
const collections = select ? this.collections : this.writeableCollections;
|
||||||
collections.forEach((c) => this.check(c, select));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading" *ngIf="organizations && organizations.length">
|
<button type="submit" class="btn btn-primary btn-submit manual" [disabled]="form.loading || !canSave" [ngClass]="{loading:form.loading}" *ngIf="organizations && organizations.length">
|
||||||
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}"></i>
|
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}"></i>
|
||||||
<span>{{'save' | i18n}}</span>
|
<span>{{'save' | i18n}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -97,4 +97,15 @@ export class ShareComponent implements OnInit, OnDestroy {
|
||||||
const collections = select ? this.collections : this.writeableCollections;
|
const collections = select ? this.collections : this.writeableCollections;
|
||||||
collections.forEach((c) => this.check(c, select));
|
collections.forEach((c) => this.check(c, select));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canSave() {
|
||||||
|
if (this.collections != null) {
|
||||||
|
for (let i = 0; i < this.collections.length; i++) {
|
||||||
|
if ((this.collections[i] as any).checked) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ label:not(.form-check-label):not(.btn) {
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:disabled {
|
&:disabled:not(.manual), &.loading {
|
||||||
.fa-spinner {
|
.fa-spinner {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue