Skip to content

Commit

Permalink
Communication: Prevent post submission if already in progress (#7130)
Browse files Browse the repository at this point in the history
  • Loading branch information
aplr authored Sep 16, 2023
1 parent 927308a commit 9567be4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4 class="alert-heading">{{ 'artemisApp.messageWarning.headerText' | artemisTra
<p class="mb-0">{{ 'artemisApp.messageWarning.lastParagraph' | artemisTranslate }}</p>
</div>
<button
*ngIf="editType == EditType.UPDATE"
*ngIf="editType === EditType.UPDATE"
jhi-posting-button
[buttonLabel]="'artemisApp.metis.cancel' | artemisTranslate"
class="btn btn-sm btn-outline-secondary"
Expand All @@ -26,7 +26,7 @@ <h4 class="alert-heading">{{ 'artemisApp.messageWarning.headerText' | artemisTra
<button
jhi-posting-button
[buttonLoading]="isLoading"
[disabled]="!formGroup.valid"
[disabled]="isLoading || !formGroup.valid"
[buttonLabel]="'artemisApp.conversationsLayout.sendMessage' | artemisTranslate"
class="btn btn-sm btn-outline-secondary"
id="save"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { LocalStorageService } from 'ngx-webstorage';
})
export class MessageInlineInputComponent extends PostingCreateEditDirective<Post | AnswerPost> implements OnInit {
warningDismissed = false;

constructor(
protected metisService: MetisService,
protected modalService: NgbModal,
Expand Down Expand Up @@ -57,6 +58,10 @@ export class MessageInlineInputComponent extends PostingCreateEditDirective<Post
});
}

/**
* invokes the metis service with the updated answer post
* ends the process successfully by closing the modal and stopping the button's loading animation
*/
updatePosting(): void {
this.posting.content = this.formGroup.get('content')?.value;
this.metisService.updatePost(this.posting).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4 class="alert-heading">{{ 'artemisApp.messageWarning.headerText' | artemisTra
<p class="mb-0">{{ 'artemisApp.messageWarning.lastParagraph' | artemisTranslate }}</p>
</div>
<button
*ngIf="editType == EditType.UPDATE"
*ngIf="editType === EditType.UPDATE"
jhi-posting-button
[buttonLabel]="'artemisApp.metis.cancel' | artemisTranslate"
class="btn btn-sm btn-outline-secondary"
Expand All @@ -26,9 +26,10 @@ <h4 class="alert-heading">{{ 'artemisApp.messageWarning.headerText' | artemisTra
<button
jhi-posting-button
[buttonLoading]="isLoading"
[disabled]="!formGroup.valid"
[disabled]="isLoading || !formGroup.valid"
[buttonLabel]="'artemisApp.conversationsLayout.sendMessage' | artemisTranslate"
class="btn btn-sm btn-outline-secondary"
id="save"
type="submit"
></button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import { LocalStorageService } from 'ngx-webstorage';
export class MessageReplyInlineInputComponent extends PostingCreateEditDirective<AnswerPost> implements OnInit {
warningDismissed = false;

ngOnInit(): void {
super.ngOnInit();
this.warningDismissed = !!this.localStorageService.retrieve('chatWarningDismissed');
}

constructor(
protected metisService: MetisService,
protected modalService: NgbModal,
Expand All @@ -30,6 +25,11 @@ export class MessageReplyInlineInputComponent extends PostingCreateEditDirective
super(metisService, modalService, formBuilder);
}

ngOnInit(): void {
super.ngOnInit();
this.warningDismissed = !!this.localStorageService.retrieve('chatWarningDismissed');
}

/**
* resets the answer post content
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<button
jhi-posting-button
[buttonLoading]="isLoading"
[disabled]="!formGroup.valid"
[disabled]="isLoading || !formGroup.valid"
[buttonLabel]="'artemisApp.metis.savePosting' | artemisTranslate"
id="save"
class="btn btn-sm btn-outline-secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h4 class="modal-title">{{ modalTitle | artemisTranslate }}</h4>
<button
jhi-posting-button
[buttonLoading]="isLoading"
[disabled]="!formGroup.valid"
[disabled]="isLoading || !formGroup.valid"
[buttonLabel]="'artemisApp.metis.savePosting' | artemisTranslate"
id="save"
class="btn btn-sm btn-outline-secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export abstract class PostingCreateEditDirective<T extends Posting> implements O
* set the input content (updated or new; of post and answer post) delegates to the corresponding method
*/
confirm(): void {
if (this.isLoading) return;
if (this.formGroup.valid) {
this.isLoading = true;
if (this.editType === PostingEditType.UPDATE) {
Expand Down

0 comments on commit 9567be4

Please sign in to comment.