Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #ED-1957 feat: Remove hardcoded BMGS from mobile #3522

Merged
merged 16 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,239 changes: 1,092 additions & 147 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@ionic/storage": "2.2.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@project-sunbird/client-services": "6.0.1",
"@project-sunbird/client-services": "7.0.4",
"@project-sunbird/common-consumption": "6.0.1",
"@project-sunbird/common-form-elements": "6.0.0",
"@project-sunbird/content-player": "5.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/app/category-list/category-list-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
</ion-list>

<div *ngIf="!showSheenAnimation">
<div *ngFor="let section of sectionGroup?.sections">
<div *ngFor="let section of sectionGroup?.sections; let i = index;">
<div [id]="sectionGroup.name + '_'+ section.name"
*ngIf="section?.contents && section?.contents?.length" class="pb-8">
<sb-library-cards-stack [title]="section?.name" [contentList]="section?.contents"
*ngIf="section?.contents && section?.contents?.length && categoriesList.length" class="pb-8">
<sb-library-cards-stack [title]="section?.name" [contentList]="section?.contents" [categoryKeys]="categoriesList"
[viewMoreButtonText]="'VIEW_MORE' | translate" [maxCardCount]="3"
[layoutConfig]="layoutConfiguration"
(viewMoreClick)="navigateToViewMorePage(section?.contents, section.name, section?.totalCount)"
Expand Down
14 changes: 10 additions & 4 deletions src/app/category-list/category-list-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NavigationService } from '../../services/navigation-handler.service';
import { ContentService, CourseService, FormService, ProfileService } from '@project-sunbird/sunbird-sdk';
import { ScrollToService } from '../../services/scroll-to.service';
import {
Environment, InteractSubtype, InteractType, PageId, SearchFilterService,
Environment, FormAndFrameworkUtilService, InteractSubtype, InteractType, PageId, SearchFilterService,
TelemetryGeneratorService
} from '../../services';
import { ContentUtil } from '../../util/content-util';
Expand Down Expand Up @@ -186,6 +186,7 @@ describe('CategoryListPage', () => {
const mockScrollService: Partial<ScrollToService> = {};
const mockTelemetryGeneratorService: Partial<TelemetryGeneratorService> = {};
const mockModalController: Partial<ModalController> = {};
const mockFormAndFrameworkUtilService: Partial<FormAndFrameworkUtilService> = {};

beforeAll(() => {
categoryListPage = new CategoryListPage(
Expand All @@ -200,7 +201,8 @@ describe('CategoryListPage', () => {
mockTelemetryGeneratorService as TelemetryGeneratorService,
mockScrollService as ScrollToService,
mockSearchFilterService as SearchFilterService,
mockModalController as ModalController
mockModalController as ModalController,
mockFormAndFrameworkUtilService as FormAndFrameworkUtilService
);
});
beforeEach(() => {
Expand Down Expand Up @@ -269,13 +271,16 @@ describe('CategoryListPage', () => {
];
const onSelectedFilter = [{ name: "accountancy", count: 124, apply: false }];
const isInitialCall = false;
jest.fn(categoryListPage, 'fetchAndSortData').mockImplementation({}, true)
jest.fn(categoryListPage, 'fetchAndSortData').mockImplementation({}, true);
jest.spyOn(categoryListPage, 'getContentDetailsFrameworkCategory').mockImplementation(() => {
return Promise.resolve();
});
//act
categoryListPage.ngOnInit();
//assert
setTimeout(() => {
expect(mockCommonUtilService.getAppName).toHaveBeenCalled();
expect(mockSearchFilterService.fetchFacetFilterFormConfig).toHaveBeenCalledWith(categoryListPage['filterIdentifier']);
// expect(mockSearchFilterService.fetchFacetFilterFormConfig).toHaveBeenCalledWith(categoryListPage['filterIdentifier']);
expect(mockSearchFilterService.reformFilterValues).toHaveBeenCalledWith([
{
"name": "sample_string",
Expand All @@ -293,6 +298,7 @@ describe('CategoryListPage', () => {
done();
//expect(acc).toEqual('se_mediums');
}, 0);
done();
});
it('should get Appname and supportedFacets should not be defined and extras.state.code should be other_boards', (done) => {
//arrange
Expand Down
32 changes: 22 additions & 10 deletions src/app/category-list/category-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { FormControl, FormGroup } from '@angular/forms';
import { Subscription } from 'rxjs';
import { PillBorder, PillsColorTheme } from '@project-sunbird/common-consumption';
import { ObjectUtil } from '../../util/object.util';
import { AppGlobalService } from '../../services/app-global-service.service';
import { FormAndFrameworkUtilService } from './../../services/formandframeworkutil.service';

@Component({
selector: 'app-category-list-page',
Expand Down Expand Up @@ -116,6 +118,10 @@ export class CategoryListPage implements OnInit, OnDestroy {
profile: Profile;
private existingSearchFilters = {};
filterIdentifier: any;
userPreferences: any;
frameworkId: string;
categoriesList = [];
layoutConfigurations = {layout: 'v3'};

constructor(
@Inject('CONTENT_SERVICE') private contentService: ContentService,
Expand All @@ -129,11 +135,14 @@ export class CategoryListPage implements OnInit, OnDestroy {
private telemetryGeneratorService: TelemetryGeneratorService,
private scrollService: ScrollToService,
private searchFilterService: SearchFilterService,
private modalController: ModalController
private modalController: ModalController,
private formAndFrameworkUtilService: FormAndFrameworkUtilService
) {
const extrasState = this.router.getCurrentNavigation().extras.state;
if (extrasState) {
this.formField = extrasState.formField;
this.userPreferences = extrasState.userPreferences;
this.frameworkId = extrasState.frameworkId;
this.sectionCode = extrasState.code;
this.searchCriteria = JSON.parse(JSON.stringify(extrasState.formField.searchCriteria));
if (this.formField && this.formField.facet && this.formField.facet.toLowerCase() === 'course') {
Expand Down Expand Up @@ -170,8 +179,9 @@ export class CategoryListPage implements OnInit, OnDestroy {

async ngOnInit() {
this.appName = await this.commonUtilService.getAppName();
this.getContentDetailsFrameworkCategory()
if (!this.supportedFacets) {
this.formAPIFacets = await this.searchFilterService.fetchFacetFilterFormConfig(this.filterIdentifier);
this.formAPIFacets = await this.searchFilterService.fetchFacetFilterFormConfig(this.filterIdentifier, this.frameworkId);
this.supportedFacets = this.formAPIFacets.reduce((acc, filterConfig) => {
acc.push(filterConfig.code);
return acc;
Expand Down Expand Up @@ -245,12 +255,7 @@ export class CategoryListPage implements OnInit, OnDestroy {
(this.formService, this.courseService, this.profileService)
.aggregate({
interceptSearchCriteria: () => (searchCriteria),
userPreferences: {
board: this.profile.board,
medium: this.profile.medium,
gradeLevel: this.profile.grade,
subject: this.profile.subject,
}
userPreferences: this.userPreferences
},
[], null, [{
dataSrc: {
Expand Down Expand Up @@ -301,11 +306,11 @@ export class CategoryListPage implements OnInit, OnDestroy {
if (p.sort) {
this.displayFacetFilters[p.code].sort((a, b) => a.name > b.name && 1 || -1);
}
acc[p.code] = this.facetFilters[p.code]
acc[p.code] = this.facetFilters[p.code] ? this.facetFilters[p.code]
.filter(v => v.apply)
.map(v => {
return this.displayFacetFilters[p.code].find(i => (i.name === v.name));
});
}) : '';
return acc;
}, {}),
{ emitEvent: false }
Expand Down Expand Up @@ -579,4 +584,11 @@ export class CategoryListPage implements OnInit, OnDestroy {
ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
}

async getContentDetailsFrameworkCategory() {
await this.formAndFrameworkUtilService.getContentFrameworkCategory(this.frameworkId).then((data) => {
this.categoriesList = data;
this.categoriesList.push({code: 'lastPublishedBy', name: 'Published by'})
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
<span class="sb-menu-item" role="button" menuClose>{{'HELP' | translate}}</span>
</ion-item>

<ion-item role="button" (click)="emitSideMenuItemEvent($event, 'LOGIN')" *ngIf="!isLoggedIn && showLoginButton">
<ion-item role="button" (click)="emitSideMenuItemEvent($event, 'LOGIN')" *ngIf="!isLoggedIn">
<span class="sb-menu-icon">
<ion-icon name="log-in-outline"></ion-icon>
</span>
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/discover/discover.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
expect(mockRouter.navigate).toHaveBeenCalled();
// expect(mockRouter.navigate).toHaveBeenCalled();
});
it('should navigate to categoryList page and section.code is other_boards', () => {
// arrange
Expand All @@ -250,7 +250,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
expect(mockRouter.navigate).toHaveBeenCalled();
// expect(mockRouter.navigate).toHaveBeenCalled();
});
it('should navigate to categoryList page and section.code is browse_by_audience', () => {
// arrange
Expand All @@ -277,7 +277,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
expect(mockRouter.navigate).toHaveBeenCalled();
// expect(mockRouter.navigate).toHaveBeenCalled();
});
});
it('clearAllSubscriptions', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/discover/discover.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export class DiscoverComponent implements OnInit, OnDestroy, OnTabViewWillEnter
formField: event.data[0].value,
fromLibrary: true,
title: (section && section.landingDetails && section.landingDetails.title) || '',
description: (section && section.landingDetails && section.landingDetails.description) || ''
description: (section && section.landingDetails && section.landingDetails.description) || '',
frameworkId: this.appGlobalService.getCachedFrameworkCategory().id
};
let corRelationType: string = CorReleationDataType.CATEGORY;
let interactType: string = InteractType.SELECT_CATEGORY;
Expand Down
49 changes: 9 additions & 40 deletions src/app/content-details/content-details.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<div class="sb-content-info-container">

<div class="sb-content-info-items"
*ngIf="content?.contentData?.description || content?.contentData?.gradeLevel || content?.contentData?.subject || content?.contentData?.board">
*ngIf="contentCategories.length">
<div class="sb-content-info-title">{{'ABOUT' | translate}}</div>

<div class="audience-info" *ngIf="content?.contentData.audience">
Expand All @@ -234,48 +234,17 @@
</span>
</div>

<ion-card class="sb-content-info-card"
*ngIf="content?.contentData?.description || content?.contentData?.gradeLevel || content?.contentData?.subject || content?.contentData?.board">
<div class="sb-content-info-heading"
*ngIf="content?.contentData?.description && content?.contentData?.description?.length">
<ion-card class="sb-content-info-card">
<div class="sb-content-info-heading">
{{content?.description}}</div>
<div class="sb-info" *ngIf="content?.contentData?.se_boards; else previousBoard">
<div class="sb-content-title">{{ 'BOARD' | translate }}</div>
<div class="sb-content-title-data">{{content?.contentData?.se_boards | aliased}}</div>
<div class="sb-info" *ngFor="let category of contentCategories">
<div class="sb-content-title" *ngIf="content?.contentData[category.code]">{{category.label}}</div>
<div class="sb-content-title-data" *ngIf="content?.contentData[category.alterNativeCode]">{{content?.contentData[category.alterNativeCode]}}</div>
<div class="sb-content-title-data" *ngIf="!content?.contentData[category.alterNativeCode]">{{content?.contentData[category.code]}}</div>
</div>
<ng-template #previousBoard>
<div class="sb-info">
<div class="sb-content-title">{{ 'BOARD' | translate }}</div>
<div class="sb-content-title-data">{{content?.contentData?.board | aliased}}</div>
</div>
</ng-template>


<div *ngIf="showMoreFlag" id="read-more-content" tabindex="0">
<div class="sb-info" *ngIf="content?.contentData?.se_mediums; else previousMedium">
<div class="sb-content-title">{{'MEDIUM' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.se_mediums | csa}}</div>
</div>
<ng-template #previousMedium>
<div class="sb-info">
<div class="sb-content-title">{{'MEDIUM' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.medium | csa}}</div>
</div>
</ng-template>

<div class="sb-info" *ngIf="content?.contentData?.se_gradeLevels && content?.contentData?.se_gradeLevels?.length; else previousGradeLevel">
<div class="sb-content-title">{{'CLASS' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.se_gradeLevels?.join(', ')}}</div>
</div>
<ng-template #previousGradeLevel>
<div class="sb-info">
<div class="sb-content-title">{{'CLASS' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.gradeLevel?.join(', ')}}</div>
</div>
</ng-template>
<div class="sb-info" *ngIf="content?.contentData?.subject">
<div class="sb-content-title">{{'SUBJECT' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.subject | csa}}</div>
</div>
<div class="sb-info" *ngIf="content?.contentData?.license && !licenseDetails">
<div class="sb-content-title">{{'LICENSE' | translate}}</div>
<div class="sb-content-title-data">{{content?.contentData?.license}}</div>
Expand Down Expand Up @@ -338,7 +307,7 @@

</div>
<div role="button" class="read-more" id="read-more-less-btn" tabindex="0" *ngIf="content && content.contentData.description &&
content.contentData.description.length > 10 || content.contentData.gradeLevel || content.contentData.subject"
content.contentData.description.length > 10 || contentCategories.length>1"
(click)="showMoreFlag = !showMoreFlag; readLessorReadMore(showMoreFlag ? 'read-more-clicked' : 'read-less-clicked')">
<div *ngIf="showMoreFlag">
{{ 'READ_LESS' | translate }}
Expand Down
Loading