diff --git a/src/app/components/actionbar/actionbar.component.html b/src/app/components/actionbar/actionbar.component.html index b4c42b8e..aecfa44a 100644 --- a/src/app/components/actionbar/actionbar.component.html +++ b/src/app/components/actionbar/actionbar.component.html @@ -3,27 +3,24 @@ @if (isAuthenticated() && isEditingAllowed() && isDetailPage()) {
- @if (isPublished()) { - - } @else { - - } +
} diff --git a/src/app/components/actionbar/actionbar.component.ts b/src/app/components/actionbar/actionbar.component.ts index 4dfabfc4..e1544df3 100644 --- a/src/app/components/actionbar/actionbar.component.ts +++ b/src/app/components/actionbar/actionbar.component.ts @@ -1,12 +1,4 @@ -import { - filter, - firstValueFrom, - map, - of, - shareReplay, - switchMap, - tap, -} from 'rxjs'; +import { filter, firstValueFrom, map, of, shareReplay, switchMap, tap } from 'rxjs'; import { Component, computed, input, signal } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -47,6 +39,7 @@ import { } from 'src/app/services'; import { IsUserOfRolePipe } from '../../pipes/is-user-of-role.pipe'; import { TranslatePipe } from '../../pipes/translate.pipe'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; @Component({ selector: 'app-actionbar', @@ -62,6 +55,7 @@ import { TranslatePipe } from '../../pipes/translate.pipe'; MatInputModule, MatSelectModule, MatAutocompleteModule, + MatProgressSpinnerModule, ReactiveFormsModule, MatOptionModule, RouterLink, @@ -312,10 +306,12 @@ export class ActionbarComponent { return element && 'online' in element ? !!element.online : false; }); + isUpdatingPublishState = signal(false); public async togglePublished() { + this.isUpdatingPublishState.set(true); const element = this.element(); if (isEntity(element)) { - this.backend + await this.backend .pushEntity({ ...element, online: !element.online }) .then(result => { console.log('Toggled?:', result); @@ -323,7 +319,7 @@ export class ActionbarComponent { }) .catch(error => console.error(error)); } else if (isCompilation(element)) { - this.backend + await this.backend .pushCompilation({ ...element, online: !element.online }) .then(result => { console.log('Toggled?:', result); @@ -331,6 +327,7 @@ export class ActionbarComponent { }) .catch(error => console.error(error)); } + this.isUpdatingPublishState.set(false); } public copyEmbed() { diff --git a/src/styles.scss b/src/styles.scss index 2d943e66..23510c2a 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -106,6 +106,22 @@ h5 { width: 100%; } +// Allows for @if/@else blocks inside of Angular Material buttons +.mdc-button span.mdc-button__label { + display: flex; + align-items: center; + gap: 4px; +} + +// If progress spinner is inside of a disabled element (e.g. button), adapt color to disabled state +*[disabled] { + @include mat.progress-spinner-overrides( + ( + active-indicator-color: gray, + ) + ); +} + .mat-mdc-fab.mat-primary, .mat-mdc-unelevated-button.mat-primary, .mat-mdc-mini-fab.mat-primary,