Skip to content

Commit

Permalink
refactor according to reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
asliayk committed Oct 14, 2024
1 parent bf14c71 commit 256716f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.channel-item {
padding: 10px;
padding: 0.5rem;
.interaction {
visibility: hidden;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class CourseUsersSelectorComponent implements ControlValueAccessor, OnIni

onInputChange(event: Event): void {
const value = (event.target as HTMLInputElement).value;
// If the input value has fewer than 3 characters, close the suggestion popup
if (value.length < 3) {
this.typeAheadInstance.dismissPopup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@if (sidebarItem.icon) {
<fa-icon [fixedWidth]="true" [icon]="sidebarItem.icon" />
}
{{ removeChannelPrefix(sidebarItem.title) }}</span
{{ sidebarItem.title }}</span
>
<span>
@if (sidebarItem.rightIcon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,4 @@ export class SidebarCardItemComponent {
@Input() sidebarItem: SidebarCardElement;
@Input() sidebarType?: SidebarTypes;
@Input() groupKey?: string;

removeChannelPrefix(name: string): string {
const prefixes = ['exercise-', 'lecture-', 'exam-'];
const channelTypes = ['exerciseChannels', 'lectureChannels', 'examChannels'];
for (const prefix of prefixes) {
if (name && name.startsWith(prefix) && channelTypes.includes(<string>this.groupKey)) {
return name.substring(prefix.length);
}
}
return name;
}
}
23 changes: 20 additions & 3 deletions src/main/webapp/app/shared/sidebar/sidebar-card.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,32 @@ export class SidebarCardDirective implements OnInit, OnDestroy {

private assignAttributes() {
if (this.componentRef) {
this.componentRef.instance.itemSelected = this.itemSelected;
this.componentRef.instance.sidebarType = this.sidebarType;
this.componentRef.instance.sidebarItem = this.sidebarItem;
if (this.groupKey !== undefined) {
this.componentRef.instance.groupKey = this.groupKey;
}

this.componentRef.instance.itemSelected = this.itemSelected;
this.componentRef.instance.sidebarType = this.sidebarType;
this.componentRef.instance.sidebarItem = this.sidebarItem;
this.componentRef.instance.sidebarItem.title = this.removeChannelPrefix(this.sidebarItem.title);

if (this.size == 'S') {
this.componentRef.instance.onUpdateSidebar = this.onUpdateSidebar;
}
}
}

private removeChannelPrefix(name: string): string {
const prefixes = ['exercise-', 'lecture-', 'exam-'];
const channelTypes = ['exerciseChannels', 'lectureChannels', 'examChannels'];

if (channelTypes.includes(<string>this.groupKey)) {
prefixes.forEach((prefix) => {
if (name?.startsWith(prefix)) {
name = name.substring(prefix.length);
}
});
}
return name;
}
}
2 changes: 0 additions & 2 deletions src/main/webapp/i18n/de/student-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@
"exerciseChannels": "Aufgaben",
"lectureChannels": "Vorlesungen",
"examChannels": "Klausuren",
"addChannelChat": "Kanal/Chat hinzufügen",
"createChannel": "Kanal erstellen",
"browseChannels": "Kanäle durchsuchen",
"createChat": "Chat erstellen",
"createGroupChat": "Gruppenchat erstellen",
"createDirectChat": "Direkt-Chat erstellen",
"groupChats": "Gruppenchats",
Expand Down
2 changes: 0 additions & 2 deletions src/main/webapp/i18n/en/student-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@
"exerciseChannels": "Exercises",
"lectureChannels": "Lectures",
"examChannels": "Exams",
"addChannelChat": "Add Channel/Chat",
"createChannel": "Create channel",
"browseChannels": "Browse channels",
"createChat": "Create Chat",
"createGroupChat": "Create group chat",
"createDirectChat": "Create direct chat",
"groupChats": "Group Chats",
Expand Down

0 comments on commit 256716f

Please sign in to comment.