Skip to content

Commit

Permalink
Add fallback for search view
Browse files Browse the repository at this point in the history
  • Loading branch information
pzdr7 committed Oct 25, 2024
1 parent c4aaf67 commit fffa071
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h5 class="mb-0 fw-medium" jhiTranslate="artemisApp.conversationsLayout.threadSi
<div class="message-input mx-3">
@if (!readOnlyMode) {
<jhi-message-reply-inline-input
[activeConversation]="conversation"
[posting]="createdAnswerPost"
(onCreate)="createdAnswerPost = createEmptyAnswerPost()"
(valueChange)="scrollEditorIntoView()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie
metaActions: TextEditorAction[] = [new FullscreenAction()];

readonly useCommunicationForFileUpload = input<boolean>(false);
readonly fallbackConversationId = input<number>();

@Output()
markdownChange = new EventEmitter<string>();
Expand Down Expand Up @@ -478,7 +479,11 @@ export class MarkdownEditorMonacoComponent implements AfterContentInit, AfterVie
embedFiles(files: File[], inputElement?: HTMLInputElement): void {
files.forEach((file) => {
(this.useCommunicationForFileUpload()
? this.fileUploaderService.uploadMarkdownFileInCurrentMetisConversation(file, this.metisService?.getCourse()?.id, this.metisService?.getCurrentConversation()?.id)
? this.fileUploaderService.uploadMarkdownFileInCurrentMetisConversation(
file,
this.metisService?.getCourse()?.id,
this.metisService?.getCurrentConversation()?.id ?? this.fallbackConversationId(),
)
: this.fileUploaderService.uploadMarkdownFile(file)
)
.then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="message-inline-input-form__wrapper mb-3 me-1">
<jhi-posting-markdown-editor
formControlName="content"
[activeConversation]="activeConversation()"
[editorHeight]="editorHeight"
[maxContentLength]="maxContentLength"
[isInputLengthDisplayed]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component, EventEmitter, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Component, EventEmitter, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation, input } from '@angular/core';
import { AnswerPost } from 'app/entities/metis/answer-post.model';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { MetisService } from 'app/shared/metis/metis.service';
import { FormBuilder, Validators } from '@angular/forms';
import { PostContentValidationPattern } from 'app/shared/metis/metis.util';
import { PostingCreateEditDirective } from 'app/shared/metis/posting-create-edit.directive';
import { LocalStorageService } from 'ngx-webstorage';
import { ConversationDTO } from 'app/entities/metis/conversation/conversation.model';

@Component({
selector: 'jhi-message-reply-inline-input',
Expand All @@ -16,6 +17,8 @@ import { LocalStorageService } from 'ngx-webstorage';
export class MessageReplyInlineInputComponent extends PostingCreateEditDirective<AnswerPost> implements OnInit, OnChanges {
warningDismissed = false;

readonly activeConversation = input<ConversationDTO>();

@Output()
valueChange = new EventEmitter<void>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[lectureReferenceAction]="lectureAttachmentReferenceAction"
[enableFileUpload]="true"
[useCommunicationForFileUpload]="true"
[fallbackConversationId]="fallbackConversationId()"
[colorAction]="undefined"
[enableResize]="false"
[showDefaultPreview]="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
Output,
ViewChild,
ViewEncapsulation,
computed,
forwardRef,
input,
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { MetisService } from 'app/shared/metis/metis.service';
Expand All @@ -32,6 +34,7 @@ import { ExerciseReferenceAction } from 'app/shared/monaco-editor/model/actions/
import { LectureAttachmentReferenceAction } from 'app/shared/monaco-editor/model/actions/communication/lecture-attachment-reference.action';
import { UrlAction } from 'app/shared/monaco-editor/model/actions/url.action';
import { AttachmentAction } from 'app/shared/monaco-editor/model/actions/attachment.action';
import { ConversationDTO } from 'app/entities/metis/conversation/conversation.model';

@Component({
selector: 'jhi-posting-markdown-editor',
Expand All @@ -53,11 +56,17 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces
@Input() editorHeight: MarkdownEditorHeight = MarkdownEditorHeight.INLINE;
@Input() isInputLengthDisplayed = true;
@Input() suppressNewlineOnEnter = true;
/**
* For AnswerPosts, the MetisService may not always have an active conversation (e.g. when in the 'all messages' view).
* In this case, file uploads have to rely on the parent post to determine the course.
*/
readonly activeConversation = input<ConversationDTO>();
@Output() valueChange = new EventEmitter();
lectureAttachmentReferenceAction: LectureAttachmentReferenceAction;
defaultActions: TextEditorAction[];
content?: string;
previewMode = false;
fallbackConversationId = computed<number | undefined>(() => this.activeConversation()?.id);

protected readonly MarkdownEditorHeight = MarkdownEditorHeight;

Expand Down

0 comments on commit fffa071

Please sign in to comment.