Skip to content
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@project-sunbird/sunbird-epub-player-v9": "5.2.1",
"@project-sunbird/sunbird-pdf-player-v9": "5.1.1",
"@project-sunbird/sunbird-quml-player-v9": "5.0.2",
"@project-sunbird/sunbird-sdk": "7.0.12",
"@project-sunbird/sunbird-sdk": "7.0.13",
"@project-sunbird/sunbird-video-player-web-component": "^1.0.1",
"chart.js": "^2.9.4",
"chartjs-plugin-datalabels": "^0.7.0",
Expand Down
5 changes: 3 additions & 2 deletions src/app/profile-settings/profile-settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit {
const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
from: CachedItemRequestSourceFrom.SERVER,
language: this.translate.currentLang,
requiredCategories: []
requiredCategories: this.appGlobalService.getRequiredCategories()
};

await this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
Expand Down Expand Up @@ -788,10 +788,11 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit {
// this.profileSettingsForms.reset();
await this.getCategoriesAndUpdateAttributes(true)
}
let categories = this.appGlobalService.getRequiredCategories()
this.framework = await this.frameworkService.getFrameworkDetails({
from: CachedItemRequestSourceFrom.SERVER,
frameworkId: event,
requiredCategories: []
requiredCategories: categories
}).toPromise();
}
if (index <= this.categories.length && this.profileSettingsForms.get(this.categories[index + 1].identifier).value.length > 0) {
Expand Down
14 changes: 8 additions & 6 deletions src/app/profile/categories-edit/categories-edit.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class CategoriesEditPage implements OnInit, OnDestroy {
const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
from: CachedItemRequestSourceFrom.SERVER,
language: this.translate.currentLang,
requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES
requiredCategories: this.appGlobalService.getRequiredCategories()
};

await this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
Expand Down Expand Up @@ -447,7 +447,7 @@ export class CategoriesEditPage implements OnInit, OnDestroy {
userId: this.profile.uid,
framework: this.editProfileForm.value
}
req.framework[this.categories[0].code] = [this.frameworkId];
req.framework[this.categories[0].code] = [this.framework.name];
req.framework['id'] = [this.frameworkId];
this.profileService.updateServerProfile(req).toPromise()
.then(async () => {
Expand Down Expand Up @@ -522,7 +522,7 @@ export class CategoriesEditPage implements OnInit, OnDestroy {
this.framework = await this.frameworkService.getFrameworkDetails({
from: CachedItemRequestSourceFrom.SERVER,
frameworkId,
requiredCategories: []
requiredCategories: this.appGlobalService.getRequiredCategories()
}).toPromise();
}

Expand Down Expand Up @@ -566,6 +566,7 @@ export class CategoriesEditPage implements OnInit, OnDestroy {
async onCategoryChanged(category, event, index) {
if (index !== this.categories.length - 1) {
if (index === 0) {
event = Array.isArray(event) ? event[0] : event;
if (this.frameworkId !== event) {
this.appGlobalService.setFramewokCategory('');
this.frameworkId = event;
Expand All @@ -574,7 +575,7 @@ export class CategoriesEditPage implements OnInit, OnDestroy {
this.framework = await this.frameworkService.getFrameworkDetails({
from: CachedItemRequestSourceFrom.SERVER,
frameworkId: event,
requiredCategories: []
requiredCategories: this.appGlobalService.getRequiredCategories()
}).toPromise();
}
if (index <= this.categories.length && this.editProfileForm.get(this.categories[index + 1].code).value.length > 0) {
Expand All @@ -600,7 +601,8 @@ export class CategoriesEditPage implements OnInit, OnDestroy {


private async getCategoriesAndUpdateAttributes(change = false) {
await this.formAndFrameworkUtilService.invokedGetFrameworkCategoryList(this.frameworkId).then(async (categories) => {
let userFrameworkId = (this.profile.serverProfile.framework &&this.profile.serverProfile.framework.id && this.profile.serverProfile.framework.id.length) ? this.profile.serverProfile?.framework?.id[0] : this.frameworkId;
await this.formAndFrameworkUtilService.invokedGetFrameworkCategoryList((change ? this.frameworkId : userFrameworkId), this.profile.serverProfile['rootOrgId']).then(async (categories) => {
if (categories) {
this.categories = categories.sort((a,b) => a.index - b.index);
let categoryDetails = this.profile.categories ? JSON.parse(this.profile.categories) : this.profile.serverProfile.framework;
Expand Down Expand Up @@ -677,7 +679,7 @@ async setFrameworkCategory1Value() {
const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = {
from: CachedItemRequestSourceFrom.SERVER,
language: this.translate.currentLang,
requiredCategories: []
requiredCategories: this.appGlobalService.getRequiredCategories()
};

await this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise()
Expand Down
2 changes: 1 addition & 1 deletion src/app/profile/profile.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ async isUserDeleted(userId: string):Promise<boolean> {
}

private getCategories() {
this.formAndFrameworkUtilService.invokedGetFrameworkCategoryList(this.profile.framework.id[0] || this.profile.syllabus[0]).then((categories) => {
this.formAndFrameworkUtilService.invokedGetFrameworkCategoryList(this.profile.framework.id[0] || this.profile.syllabus[0], this.profile.rootOrgId).then((categories) => {
this.categories = categories;
this.isCategoryLoaded = true;
}).catch(e => console.error(e));
Expand Down
9 changes: 9 additions & 0 deletions src/services/app-global-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class AppGlobalService implements OnDestroy {
private _isForumEnabled: boolean = false;
private frameworkCategory: any;
private _isSplashscreenDisplay: boolean = false;
private requiredCategories: Array<string> = [];

constructor(
@Inject('PROFILE_SERVICE') private profile: ProfileService,
Expand Down Expand Up @@ -277,6 +278,14 @@ export class AppGlobalService implements OnDestroy {
return this.frameworkCategory;
}

setRequiredCategories(categories: []) {
this.requiredCategories = categories;
}

getRequiredCategories(): any {
return this.requiredCategories;
}

/**
* @returns UserId or empty string if not available
* getLoggedinUserId
Expand Down
6 changes: 4 additions & 2 deletions src/services/formandframeworkutil.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,17 @@ export class FormAndFrameworkUtilService {
let fraeworkDetails = {id: frameworkId, value: res }
this.appGlobalService.setFramewokCategory(fraeworkDetails);
}
let requiredCategories = res.map(e => e.code) ;
this.appGlobalService.setRequiredCategories(requiredCategories);
resolve(res);
}
}).catch((e) => console.error(e));
});
}

invokedGetFrameworkCategoryList (frameworkId, rootOrgId?) {
async invokedGetFrameworkCategoryList (frameworkId, rootOrgId?) {
if (!rootOrgId) {
rootOrgId = this.preferences.getString('rootOrgId').toPromise();
rootOrgId = await this.preferences.getString('defaultRootOrgId').toPromise();
}
return this.getFrameworkCategoryList(frameworkId, {...FormConstants.FRAMEWORK_CONFIG, framework: frameworkId, rootOrgId: (rootOrgId || '*')}, true)
}
Expand Down
98 changes: 59 additions & 39 deletions src/services/framework-details.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FrameworkCategoryCode, GetFrameworkCategoryTermsRequest,
FrameworkUtilService, LocationSearchResult, CachedItemRequestSourceFrom, LocationSearchCriteria } from '@project-sunbird/sunbird-sdk';
import { LocationHandler } from './location-handler';
import { Location as LocationType } from '../app/app.constant';
import { FormAndFrameworkUtilService } from './formandframeworkutil.service';

@Injectable({
providedIn: 'root'
Expand All @@ -14,51 +15,54 @@ export class FrameworkDetailsService {
@Inject('FRAMEWORK_UTIL_SERVICE') private frameworkUtilService: FrameworkUtilService,
private translate: TranslateService,
private locationHandler: LocationHandler,
private formAndFrameworkUtilService: FormAndFrameworkUtilService
) { }

async getFrameworkDetails(guestProfile?: any) {
const framework = {};
const boardList = await this.getBoardList(guestProfile).then((board) => {
return board.map(t => ({ name: t.name, code: t.code }));
});
let framework = {};
framework = this.getCategoriesAndUpdateAttributes(guestProfile);
framework['id'] = guestProfile.syllabus;
// const boardList = await this.getBoardList(guestProfile).then((board) => {
// return board.map(t => ({ name: t.name, code: t.code }));
// });

const mediumList = await this.getMediumList(guestProfile).then((medium) => {
return medium.map(t => ({ name: t.name, code: t.code }));
});
// const mediumList = await this.getMediumList(guestProfile).then((medium) => {
// return medium.map(t => ({ name: t.name, code: t.code }));
// });

const gradeList = await this.getGradeList(guestProfile).then((grade) => {
return grade.map(t => ({ name: t.name, code: t.code }));
});
// const gradeList = await this.getGradeList(guestProfile).then((grade) => {
// return grade.map(t => ({ name: t.name, code: t.code }));
// });

const subjectList = await this.getSubjectList(guestProfile).then((subject) => {
return subject.map(t => ({ name: t.name, code: t.code }));
});
framework['id'] = guestProfile.syllabus;
if (guestProfile.board && guestProfile.board.length) {
const code = typeof (guestProfile.board) === 'string' ? guestProfile.board : guestProfile.board[0];
framework['board'] = [boardList.find(board => code === board.code).name];
}
if (guestProfile.medium && guestProfile.medium.length) {
const Names = [];
guestProfile.medium.forEach(element => {
Names.push(mediumList.find(medium => element === medium.code).name);
});
framework['medium'] = Names;
}
if (guestProfile.grade && guestProfile.grade.length) {
const Names = [];
guestProfile.grade.forEach(element => {
Names.push(gradeList.find(grade => element === grade.code).name);
});
framework['gradeLevel'] = Names;
}
if (guestProfile.subject && guestProfile.subject.length) {
const Names = [];
guestProfile.subject.forEach(element => {
Names.push(subjectList.find(subject => element === subject.code).name);
});
framework['subject'] = Names;
}
// const subjectList = await this.getSubjectList(guestProfile).then((subject) => {
// return subject.map(t => ({ name: t.name, code: t.code }));
// });
// framework['id'] = guestProfile.syllabus;
// if (guestProfile.board && guestProfile.board.length) {
// const code = typeof (guestProfile.board) === 'string' ? guestProfile.board : guestProfile.board[0];
// framework['board'] = [boardList.find(board => code === board.code).name];
// }
// if (guestProfile.medium && guestProfile.medium.length) {
// const Names = [];
// guestProfile.medium.forEach(element => {
// Names.push(mediumList.find(medium => element === medium.code).name);
// });
// framework['medium'] = Names;
// }
// if (guestProfile.grade && guestProfile.grade.length) {
// const Names = [];
// guestProfile.grade.forEach(element => {
// Names.push(gradeList.find(grade => element === grade.code).name);
// });
// framework['gradeLevel'] = Names;
// }
// if (guestProfile.subject && guestProfile.subject.length) {
// const Names = [];
// guestProfile.subject.forEach(element => {
// Names.push(subjectList.find(subject => element === subject.code).name);
// });
// framework['subject'] = Names;
// }

const presetLocation = (await this.locationHandler.getAvailableLocation(guestProfile, true))
.reduce<{ [code: string]: LocationSearchResult }>((acc, loc) => {
Expand Down Expand Up @@ -172,4 +176,20 @@ export class FrameworkDetailsService {
return response.find(d => d.id === location.district.id);
});
}

private async getCategoriesAndUpdateAttributes(profile) {
let framework = {}
await this.formAndFrameworkUtilService.invokedGetFrameworkCategoryList(profile.syllabus[0]).then((categories) => {
if (categories) {
let frameworkData = categories;
let categoryDetails = JSON.parse(profile.categories);
frameworkData.forEach((e) => {
if(categoryDetails[e.identifier]) {
framework[e.code] = categoryDetails[e.identifier]
}
});
return framework;
}
}).catch(e => console.error(e));
}
}
2 changes: 1 addition & 1 deletion src/services/handlers/tnc-update-handler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class TncUpdateHandlerService {
const guestProfile = await this.commonUtilService.getGuestUserConfig().then((profile) => {
return profile;
});
if ( guestProfile.board && guestProfile.board.length && onboarding.skipOnboardingForLoginUser && userDetails.profileType !== ProfileType.ADMIN && !isSSOUser) {
if (((guestProfile.board && guestProfile.board.length) || guestProfile.categories) && onboarding.skipOnboardingForLoginUser && userDetails.profileType !== ProfileType.ADMIN && !isSSOUser) {
await this.updateUserAsGuest(guestProfile);
} else {
await this.preRequirementToBmcNavigation(profile.userId, locationMappingConfig);
Expand Down