Skip to content

Commit

Permalink
Disable ticket submit button during post. Resolves GBAPI#319.
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-bstein committed Jan 24, 2024
1 parent e48c0c3 commit 267f447
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ <h2 class="d-inline">New Ticket</h2>
</div>

<div class="mt-3">
<button class="btn btn-dark" (click)="submit()" [disabled]="!ticket.summary.length">Submit</button>
<button class="btn btn-dark" (click)="submit()"
[disabled]="!ticket.summary.length || isSubmitting">Submit</button>
</div>
</form>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { UserService as LocalUserService } from '../../utility/user.service';
import { RouterService } from '@/services/router.service';
import { ActivatedRoute } from '@angular/router';
import { BoardService } from '@/api/board.service';
import { LogService } from '@/services/log.service';

@Component({
selector: 'app-ticket-form',
Expand All @@ -30,6 +31,7 @@ export class TicketFormComponent implements OnDestroy {

challengeRefresh: BehaviorSubject<any> = new BehaviorSubject({});
challengeOptions: ChallengeOverview[] = [];
isSubmitting = false;

faArrowLeft = faArrowLeft;

Expand All @@ -42,6 +44,7 @@ export class TicketFormComponent implements OnDestroy {

constructor(
private api: SupportService,
private log: LogService,
private routerService: RouterService,
private userApi: UserService,
boardApi: BoardService,
Expand Down Expand Up @@ -74,10 +77,17 @@ export class TicketFormComponent implements OnDestroy {
}

async submit() {
const ticket = await firstValueFrom(this.api.upload(this.ticket));
if (!!ticket.id) {
this.routerService.toSupportTickets(ticket.key.toString());
this.isSubmitting = true;
try {
const ticket = await firstValueFrom(this.api.upload(this.ticket));
if (!!ticket.id) {
this.routerService.toSupportTickets(ticket.key.toString());
}
}
catch (err: any) {
this.log.logError("Error on ticket submit", err);
}
this.isSubmitting = false;
}

attachments(files: File[]) {
Expand Down

0 comments on commit 267f447

Please sign in to comment.