diff --git a/src/main/webapp/app/overview/course-conversations/course-conversations.component.html b/src/main/webapp/app/overview/course-conversations/course-conversations.component.html index e4cd32cdbecb..fd62d2f7e57e 100644 --- a/src/main/webapp/app/overview/course-conversations/course-conversations.component.html +++ b/src/main/webapp/app/overview/course-conversations/course-conversations.component.html @@ -35,6 +35,7 @@ (onGroupChatPressed)="openCreateGroupChatDialog()" [showAddOption]="CHANNEL_TYPE_SHOW_ADD_OPTION" [channelTypeIcon]="CHANNEL_TYPE_ICON" + [sidebarItemAlwaysShow]="DEFAULT_SHOW_ALWAYS" [collapseState]="DEFAULT_COLLAPSE_STATE" [inCommunication]="true" /> diff --git a/src/main/webapp/app/overview/course-conversations/course-conversations.component.ts b/src/main/webapp/app/overview/course-conversations/course-conversations.component.ts index da7dd332f047..742999cf7aa7 100644 --- a/src/main/webapp/app/overview/course-conversations/course-conversations.component.ts +++ b/src/main/webapp/app/overview/course-conversations/course-conversations.component.ts @@ -13,7 +13,7 @@ import { PageType, SortDirection } from 'app/shared/metis/metis.util'; import { faBan, faComment, faComments, faFile, faFilter, faGraduationCap, faHeart, faList, faMessage, faPlus, faSearch, faTimes } from '@fortawesome/free-solid-svg-icons'; import { ButtonType } from 'app/shared/components/button.component'; import { CourseWideSearchComponent, CourseWideSearchConfig } from 'app/overview/course-conversations/course-wide-search/course-wide-search.component'; -import { AccordionGroups, ChannelAccordionShowAdd, ChannelTypeIcons, CollapseState, SidebarCardElement, SidebarData } from 'app/types/sidebar'; +import { AccordionGroups, ChannelAccordionShowAdd, ChannelTypeIcons, CollapseState, SidebarCardElement, SidebarData, SidebarItemShowAlways } from 'app/types/sidebar'; import { CourseOverviewService } from 'app/overview/course-overview.service'; import { GroupChatCreateDialogComponent } from 'app/overview/course-conversations/dialogs/group-chat-create-dialog/group-chat-create-dialog.component'; import { defaultFirstLayerDialogOptions, defaultSecondLayerDialogOptions } from 'app/overview/course-conversations/other/conversation.util'; @@ -55,16 +55,27 @@ const CHANNEL_TYPE_ICON: ChannelTypeIcons = { }; const DEFAULT_COLLAPSE_STATE: CollapseState = { - generalChannels: false, + generalChannels: true, exerciseChannels: true, examChannels: true, groupChats: true, directMessages: true, - favoriteChannels: true, + favoriteChannels: false, lectureChannels: true, hiddenChannels: true, }; +const DEFAULT_SHOW_ALWAYS: SidebarItemShowAlways = { + generalChannels: true, + exerciseChannels: false, + examChannels: false, + groupChats: true, + directMessages: true, + favoriteChannels: true, + lectureChannels: false, + hiddenChannels: false, +}; + @Component({ selector: 'jhi-course-conversations', templateUrl: './course-conversations.component.html', @@ -95,6 +106,7 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { readonly CHANNEL_TYPE_SHOW_ADD_OPTION = CHANNEL_TYPE_SHOW_ADD_OPTION; readonly CHANNEL_TYPE_ICON = CHANNEL_TYPE_ICON; readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; + protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS; // set undefined so nothing gets displayed until isCodeOfConductAccepted is loaded isCodeOfConductAccepted?: boolean; diff --git a/src/main/webapp/app/overview/course-exams/course-exams.component.html b/src/main/webapp/app/overview/course-exams/course-exams.component.html index 27b7f0a60a56..4eca637aab4c 100644 --- a/src/main/webapp/app/overview/course-exams/course-exams.component.html +++ b/src/main/webapp/app/overview/course-exams/course-exams.component.html @@ -1,7 +1,13 @@
@if (course) {
- +
@if (examSelected) { diff --git a/src/main/webapp/app/overview/course-exams/course-exams.component.ts b/src/main/webapp/app/overview/course-exams/course-exams.component.ts index 1b78c89b712e..33e28167ea69 100644 --- a/src/main/webapp/app/overview/course-exams/course-exams.component.ts +++ b/src/main/webapp/app/overview/course-exams/course-exams.component.ts @@ -24,6 +24,11 @@ const DEFAULT_COLLAPSE_STATE: CollapseState = { test: false, }; +const DEFAULT_SHOW_ALWAYS: CollapseState = { + real: false, + test: false, +}; + @Component({ selector: 'jhi-course-exams', templateUrl: './course-exams.component.html', @@ -57,6 +62,7 @@ export class CourseExamsComponent implements OnInit, OnDestroy { isExamStarted = false; readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; + protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS; constructor( private route: ActivatedRoute, diff --git a/src/main/webapp/app/overview/course-exercises/course-exercises.component.html b/src/main/webapp/app/overview/course-exercises/course-exercises.component.html index 4b32dedb50f4..27397fc75b91 100644 --- a/src/main/webapp/app/overview/course-exercises/course-exercises.component.html +++ b/src/main/webapp/app/overview/course-exercises/course-exercises.component.html @@ -1,7 +1,14 @@
@if (course) {
- +
@if (exerciseSelected) { diff --git a/src/main/webapp/app/overview/course-exercises/course-exercises.component.ts b/src/main/webapp/app/overview/course-exercises/course-exercises.component.ts index a8bfc240b99d..1dd1e85f9608 100644 --- a/src/main/webapp/app/overview/course-exercises/course-exercises.component.ts +++ b/src/main/webapp/app/overview/course-exercises/course-exercises.component.ts @@ -7,7 +7,7 @@ import { courseExerciseOverviewTour } from 'app/guided-tour/tours/course-exercis import { ProgrammingSubmissionService } from 'app/exercises/programming/participate/programming-submission.service'; import { Exercise } from 'app/entities/exercise.model'; import { CourseStorageService } from 'app/course/manage/course-storage.service'; -import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData } from 'app/types/sidebar'; +import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData, SidebarItemShowAlways } from 'app/types/sidebar'; import { CourseOverviewService } from '../course-overview.service'; import { LtiService } from 'app/shared/service/lti.service'; @@ -27,6 +27,14 @@ const DEFAULT_COLLAPSE_STATE: CollapseState = { noDate: true, }; +const DEFAULT_SHOW_ALWAYS: SidebarItemShowAlways = { + future: false, + current: false, + dueSoon: false, + past: false, + noDate: false, +}; + @Component({ selector: 'jhi-course-exercises', templateUrl: './course-exercises.component.html', @@ -47,9 +55,11 @@ export class CourseExercisesComponent implements OnInit, OnDestroy { sidebarData: SidebarData; sidebarExercises: SidebarCardElement[] = []; isCollapsed: boolean = false; - readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; isLti: boolean = false; + protected readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; + protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS; + constructor( private courseStorageService: CourseStorageService, private route: ActivatedRoute, diff --git a/src/main/webapp/app/overview/course-lectures/course-lectures.component.html b/src/main/webapp/app/overview/course-lectures/course-lectures.component.html index 29c7787fcc4a..9e9b93ff7cc7 100644 --- a/src/main/webapp/app/overview/course-lectures/course-lectures.component.html +++ b/src/main/webapp/app/overview/course-lectures/course-lectures.component.html @@ -1,7 +1,13 @@
@if (course) {
- +
@if (lectureSelected) { diff --git a/src/main/webapp/app/overview/course-lectures/course-lectures.component.ts b/src/main/webapp/app/overview/course-lectures/course-lectures.component.ts index b146542679e6..afd7532d3cc8 100644 --- a/src/main/webapp/app/overview/course-lectures/course-lectures.component.ts +++ b/src/main/webapp/app/overview/course-lectures/course-lectures.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { Subscription } from 'rxjs'; import { Lecture } from 'app/entities/lecture.model'; import { CourseStorageService } from 'app/course/manage/course-storage.service'; -import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData } from 'app/types/sidebar'; +import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData, SidebarItemShowAlways } from 'app/types/sidebar'; import { CourseOverviewService } from '../course-overview.service'; const DEFAULT_UNIT_GROUPS: AccordionGroups = { @@ -23,6 +23,14 @@ const DEFAULT_COLLAPSE_STATE: CollapseState = { noDate: true, }; +const DEFAULT_SHOW_ALWAYS: SidebarItemShowAlways = { + future: false, + current: false, + dueSoon: false, + past: false, + noDate: false, +}; + @Component({ selector: 'jhi-course-lectures', templateUrl: './course-lectures.component.html', @@ -41,6 +49,7 @@ export class CourseLecturesComponent implements OnInit, OnDestroy { sidebarLectures: SidebarCardElement[] = []; isCollapsed: boolean = false; readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; + protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS; constructor( private courseStorageService: CourseStorageService, diff --git a/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.html b/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.html index c6f3864b47b7..a950991b42cd 100644 --- a/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.html +++ b/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.html @@ -1,7 +1,13 @@
@if (course) {
- +
@if (tutorialGroupSelected) { diff --git a/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.ts b/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.ts index 5d56558dde63..ed90dd068fb1 100644 --- a/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.ts +++ b/src/main/webapp/app/overview/course-tutorial-groups/course-tutorial-groups.component.ts @@ -12,7 +12,7 @@ import { AlertService } from 'app/core/util/alert.service'; import { TutorialGroupFreePeriod } from 'app/entities/tutorial-group/tutorial-group-free-day.model'; import { CourseStorageService } from 'app/course/manage/course-storage.service'; import { TutorialGroupsConfiguration } from 'app/entities/tutorial-group/tutorial-groups-configuration.model'; -import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData, TutorialGroupCategory } from 'app/types/sidebar'; +import { AccordionGroups, CollapseState, SidebarCardElement, SidebarData, SidebarItemShowAlways, TutorialGroupCategory } from 'app/types/sidebar'; import { CourseOverviewService } from '../course-overview.service'; import { cloneDeep } from 'lodash-es'; @@ -28,6 +28,12 @@ const DEFAULT_COLLAPSE_STATE: CollapseState = { further: true, }; +const DEFAULT_SHOW_ALWAYS: SidebarItemShowAlways = { + registered: false, + all: false, + further: false, +}; + @Component({ selector: 'jhi-course-tutorial-groups', templateUrl: './course-tutorial-groups.component.html', @@ -49,6 +55,7 @@ export class CourseTutorialGroupsComponent implements OnInit, OnDestroy { sortedTutorialGroups: TutorialGroup[] = []; accordionTutorialGroupsGroups: AccordionGroups = TUTORIAL_UNIT_GROUPS; readonly DEFAULT_COLLAPSE_STATE = DEFAULT_COLLAPSE_STATE; + protected readonly DEFAULT_SHOW_ALWAYS = DEFAULT_SHOW_ALWAYS; sidebarTutorialGroups: SidebarCardElement[] = []; constructor( diff --git a/src/main/webapp/app/shared/sidebar/sidebar-accordion/sidebar-accordion.component.html b/src/main/webapp/app/shared/sidebar/sidebar-accordion/sidebar-accordion.component.html index 16eb4bc62671..a3ec25c5b6d6 100644 --- a/src/main/webapp/app/shared/sidebar/sidebar-accordion/sidebar-accordion.component.html +++ b/src/main/webapp/app/shared/sidebar/sidebar-accordion/sidebar-accordion.component.html @@ -1,5 +1,5 @@ @for (groupKey of Object.keys(groupedData); track groupKey; let i = $index) { - @if ((groupedData[groupKey].entityData | searchFilter: ['title', 'type'] : searchValue)?.length) { + @if ((groupedData[groupKey].entityData | searchFilter: ['title', 'type'] : searchValue)?.length || sidebarItemAlwaysShow()[groupKey]) {
(); @Input() collapseState: CollapseState; @Input() isFilterActive: boolean = false; @@ -41,7 +42,7 @@ export class SidebarAccordionComponent implements OnChanges, OnInit { } setStoredCollapseState() { - const storedCollapseState: string | null = sessionStorage.getItem('sidebar.accordion.collapseState.' + this.storageId + '.byCourse.' + this.courseId); + const storedCollapseState: string | null = localStorage.getItem('sidebar.accordion.collapseState.' + this.storageId + '.byCourse.' + this.courseId); if (storedCollapseState) this.collapseState = JSON.parse(storedCollapseState); } @@ -68,6 +69,6 @@ export class SidebarAccordionComponent implements OnChanges, OnInit { toggleGroupCategoryCollapse(groupCategoryKey: string) { this.collapseState[groupCategoryKey] = !this.collapseState[groupCategoryKey]; - sessionStorage.setItem('sidebar.accordion.collapseState.' + this.storageId + '.byCourse.' + this.courseId, JSON.stringify(this.collapseState)); + localStorage.setItem('sidebar.accordion.collapseState.' + this.storageId + '.byCourse.' + this.courseId, JSON.stringify(this.collapseState)); } } diff --git a/src/main/webapp/app/shared/sidebar/sidebar.component.html b/src/main/webapp/app/shared/sidebar/sidebar.component.html index d972ad363a29..becdd0a69eda 100644 --- a/src/main/webapp/app/shared/sidebar/sidebar.component.html +++ b/src/main/webapp/app/shared/sidebar/sidebar.component.html @@ -79,6 +79,7 @@ [itemSelected]="itemSelected" [showLeadingIcon]="sidebarData.showAccordionLeadingIcon ?? false" [channelTypeIcon]="channelTypeIcon" + [sidebarItemAlwaysShow]="sidebarItemAlwaysShow()" [collapseState]="collapseState" (onUpdateSidebar)="onUpdateSidebar.emit()" [isFilterActive]="isFilterActive" diff --git a/src/main/webapp/app/shared/sidebar/sidebar.component.ts b/src/main/webapp/app/shared/sidebar/sidebar.component.ts index ed42ca7c74af..92ecef01aa1a 100644 --- a/src/main/webapp/app/shared/sidebar/sidebar.component.ts +++ b/src/main/webapp/app/shared/sidebar/sidebar.component.ts @@ -3,7 +3,7 @@ import { faFilter, faFilterCircleXmark, faHashtag, faPlusCircle, faSearch, faUse import { ActivatedRoute, Params } from '@angular/router'; import { Subscription, distinctUntilChanged } from 'rxjs'; import { ProfileService } from '../layouts/profiles/profile.service'; -import { ChannelAccordionShowAdd, ChannelTypeIcons, CollapseState, SidebarCardSize, SidebarData, SidebarTypes } from 'app/types/sidebar'; +import { ChannelAccordionShowAdd, ChannelTypeIcons, CollapseState, SidebarCardSize, SidebarData, SidebarItemShowAlways, SidebarTypes } from 'app/types/sidebar'; import { SidebarEventService } from './sidebar-event.service'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { cloneDeep } from 'lodash-es'; @@ -35,6 +35,7 @@ export class SidebarComponent implements OnDestroy, OnChanges, OnInit { @Input() showAddOption?: ChannelAccordionShowAdd; @Input() channelTypeIcon?: ChannelTypeIcons; @Input() collapseState: CollapseState; + sidebarItemAlwaysShow = input.required(); @Input() showFilter: boolean = false; inCommunication = input(false); searchValue = ''; diff --git a/src/main/webapp/app/types/sidebar.ts b/src/main/webapp/app/types/sidebar.ts index 11575cf18592..6eed6d06cb40 100644 --- a/src/main/webapp/app/types/sidebar.ts +++ b/src/main/webapp/app/types/sidebar.ts @@ -25,6 +25,9 @@ export type CollapseState = { } & (Record | Record | Record | Record); export type ChannelAccordionShowAdd = Record; export type ChannelTypeIcons = Record; +export type SidebarItemShowAlways = { + [key: string]: boolean; +} & (Record | Record | Record | Record); export interface SidebarData { groupByCategory: boolean; diff --git a/src/test/javascript/spec/component/shared/sidebar/sidebar-accordion.component.spec.ts b/src/test/javascript/spec/component/shared/sidebar/sidebar-accordion.component.spec.ts index 39d8e23eb473..9e7fe5427253 100644 --- a/src/test/javascript/spec/component/shared/sidebar/sidebar-accordion.component.spec.ts +++ b/src/test/javascript/spec/component/shared/sidebar/sidebar-accordion.component.spec.ts @@ -53,6 +53,7 @@ describe('SidebarAccordionComponent', () => { }; component.routeParams = { exerciseId: 3 }; component.collapseState = { current: false, dueSoon: false, past: false, future: true, noDate: true }; + fixture.componentRef.setInput('sidebarItemAlwaysShow', { current: false, dueSoon: false, past: false, future: false, noDate: false }); fixture.detectChanges(); });