From c207073ec566265625fa741bc725c49fd7810b0d Mon Sep 17 00:00:00 2001 From: Ajoymaity Date: Wed, 22 Nov 2023 12:58:37 +0530 Subject: [PATCH 01/10] Issue #ED-1957 feat: Removed hardcoded BMGS --- src/app/category-list/category-list-page.ts | 9 +- .../application-header.component.html | 2 +- src/app/form.constants.ts | 1 + src/app/home/user-home/user-home.page.ts | 52 +++- .../profile-settings.page.html | 38 ++- .../profile-settings.page.scss | 4 + .../profile-settings/profile-settings.page.ts | 133 +++++++-- .../profile/guest-edit/guest-edit.page.html | 198 ++++++------- .../profile/guest-edit/guest-edit.page.scss | 4 + src/app/profile/guest-edit/guest-edit.page.ts | 265 ++++++++++++++---- .../guest-profile/guest-profile.page.html | 27 +- .../guest-profile/guest-profile.page.scss | 5 + .../guest-profile/guest-profile.page.ts | 60 +++- src/app/profile/profile.page.html | 4 +- src/app/profile/profile.page.ts | 6 +- src/app/search/search.page.ts | 9 +- .../user-type-selection.ts | 60 +++- src/services/app-global-service.service.ts | 2 +- src/services/formandframeworkutil.service.ts | 51 +--- 19 files changed, 648 insertions(+), 282 deletions(-) diff --git a/src/app/category-list/category-list-page.ts b/src/app/category-list/category-list-page.ts index c2ed9229c..ed9db86b0 100755 --- a/src/app/category-list/category-list-page.ts +++ b/src/app/category-list/category-list-page.ts @@ -116,6 +116,7 @@ export class CategoryListPage implements OnInit, OnDestroy { profile: Profile; private existingSearchFilters = {}; filterIdentifier: any; + userPreferences: any; constructor( @Inject('CONTENT_SERVICE') private contentService: ContentService, @@ -134,6 +135,7 @@ export class CategoryListPage implements OnInit, OnDestroy { const extrasState = this.router.getCurrentNavigation().extras.state; if (extrasState) { this.formField = extrasState.formField; + this.userPreferences = extrasState.userPreferences; this.sectionCode = extrasState.code; this.searchCriteria = JSON.parse(JSON.stringify(extrasState.formField.searchCriteria)); if (this.formField && this.formField.facet && this.formField.facet.toLowerCase() === 'course') { @@ -245,12 +247,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: { diff --git a/src/app/components/application-header/application-header.component.html b/src/app/components/application-header/application-header.component.html index b4f428846..22e04a27f 100644 --- a/src/app/components/application-header/application-header.component.html +++ b/src/app/components/application-header/application-header.component.html @@ -418,7 +418,7 @@ {{'HELP' | translate}} - + diff --git a/src/app/form.constants.ts b/src/app/form.constants.ts index 8f30d6250..83581343d 100644 --- a/src/app/form.constants.ts +++ b/src/app/form.constants.ts @@ -228,5 +228,6 @@ export class FormConstants { subType: 'frameworkCategory', action: 'get', component: 'app', + rootOrgId: '*' }; } diff --git a/src/app/home/user-home/user-home.page.ts b/src/app/home/user-home/user-home.page.ts index 84b28c1fc..20c7592cc 100644 --- a/src/app/home/user-home/user-home.page.ts +++ b/src/app/home/user-home/user-home.page.ts @@ -118,6 +118,9 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { layoutConfiguration = { layout: 'v3' }; + userFrameworkCategories: any; + frameworkCategoriesValue = {} + categoriesLabel: any; constructor( @Inject('FRAMEWORK_SERVICE') private frameworkService: FrameworkService, @@ -182,6 +185,16 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { this.profile = await this.profileService.getActiveSessionProfile( { requiredFields: ProfileConstants.REQUIRED_FIELDS } ).toPromise(); + this.frameworkCategoriesValue = {}; + this.userFrameworkCategories = this.profile.categories ? JSON.parse(this.profile.categories) : this.profile.serverProfile.framework; + if (this.profile.categories) {await this.getFrameworkCategoriesLabel() } + this.preferenceList = []; + Object.keys(this.userFrameworkCategories).forEach((key) => { + if (key !== 'id' && this.userFrameworkCategories[key].length) { + this.preferenceList.push(this.userFrameworkCategories[key]); + } + }); + console.log('.............frameworkCategories', this.preferenceList); await this.getFrameworkDetails(); await this.fetchDisplayElements(); this.guestUser = !this.appGlobalService.isUserLoggedIn(); @@ -226,6 +239,7 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { } else if(guestUser && guestUser.syllabus && guestUser.syllabus[0]) { id = guestUser.syllabus[0]; } + // await this.getFrameworkCategoriesLabel(id); const frameworkDetailsRequest: FrameworkDetailsRequest = { frameworkId: id, requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES @@ -236,16 +250,16 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { acc[category.code] = category; return acc; }, {}); - this.preferenceList = []; + // this.preferenceList = this.frameworkCategoriesValue; setTimeout(() => { this.boardList = this.getFieldDisplayValues(this.profile.board.length > 0 ? this.profile.board : guestUser.board, 'board'); this.mediumList = this.getFieldDisplayValues(this.profile.medium.length > 0 ? this.profile.medium : guestUser.medium, 'medium'); this.gradeLevelList = this.getFieldDisplayValues(this.profile.grade.length > 0 ? this.profile.grade : guestUser.grade, 'gradeLevel'); this.subjectList = this.getFieldDisplayValues(this.profile.subject.length > 0 ? this.profile.subject : guestUser.subject, 'subject'); - this.preferenceList.push(this.boardList); - this.preferenceList.push(this.mediumList); - this.preferenceList.push(this.gradeLevelList); + // this.preferenceList.push(this.boardList); + // this.preferenceList.push(this.mediumList); + // this.preferenceList.push(this.gradeLevelList); }, 0); }); } @@ -273,16 +287,10 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { private async fetchDisplayElements(refresher?) { this.displaySections = undefined; const request: ContentAggregatorRequest = { - userPreferences: { - board: this.getFieldDisplayValues(this.profile.board, 'board', true), - medium: this.getFieldDisplayValues(this.profile.medium, 'medium', true), - gradeLevel: this.getFieldDisplayValues(this.profile.grade, 'gradeLevel', true), - subject: this.getFieldDisplayValues(this.profile.subject, 'subject', true), - }, - interceptSearchCriteria: (contentSearchCriteria: ContentSearchCriteria) => { - contentSearchCriteria.board = this.getFieldDisplayValues(this.profile.board, 'board', true); - contentSearchCriteria.medium = this.getFieldDisplayValues(this.profile.medium, 'medium', true); - contentSearchCriteria.grade = this.getFieldDisplayValues(this.profile.grade, 'gradeLevel', true); + userPreferences: this.userFrameworkCategories, + interceptSearchCriteria: (contentSearchCriteria) => { + contentSearchCriteria = {...contentSearchCriteria, ...this.userFrameworkCategories}; + console.log('contentSearchCriteria', contentSearchCriteria) return contentSearchCriteria; }, from: refresher ? CachedItemRequestSourceFrom.SERVER : CachedItemRequestSourceFrom.CACHE }; @@ -336,7 +344,8 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { formField: event.data[0].value, fromLibrary: false, title: (section && section.landingDetails && section.landingDetails.title) || '', - description: (section && section.landingDetails && section.landingDetails.description) || '' + description: (section && section.landingDetails && section.landingDetails.description) || '', + userPreferences: this.userFrameworkCategories }; await this.router.navigate([RouterLinks.CATEGORY_LIST], { state: params }); } @@ -895,6 +904,19 @@ export class UserHomePage implements OnInit, OnDestroy, OnTabViewWillEnter { break; } } + + async getFrameworkCategoriesLabel() { + let frameworkValue = JSON.parse(this.profile.categories); + this.userFrameworkCategories = {} + await this.formAndFrameworkUtilService.getFrameworkCategoryList(this.profile.syllabus[0]).then((categories) => { + if (categories) { + categories = categories.sort((a, b) => a.index - b.index) + categories.forEach((e) => { + this.userFrameworkCategories[e.code] = Array.isArray(frameworkValue[e.identifier]) ? frameworkValue[e.identifier] : [frameworkValue[e.identifier]] + }) + } + }); + } } diff --git a/src/app/profile-settings/profile-settings.page.html b/src/app/profile-settings/profile-settings.page.html index 31dfcac3e..aa4e28385 100644 --- a/src/app/profile-settings/profile-settings.page.html +++ b/src/app/profile-settings/profile-settings.page.html @@ -1,6 +1,6 @@ -
-
+
+
back @@ -34,7 +34,7 @@ {{categories[0].label | translateJson}} - @@ -53,20 +53,20 @@
-
- +
+ {{category.label | translateJson}} - - + placeholder="{{category.placeHolder | translateJson}}" (ngModelChange)="getCategoriesDetails($event, category, i)"> + {{eachSyllabus.name | aliased}}‎ - + - +
+
-
diff --git a/src/app/profile-settings/profile-settings.page.scss b/src/app/profile-settings/profile-settings.page.scss index 0172efcd1..e3b9afd39 100644 --- a/src/app/profile-settings/profile-settings.page.scss +++ b/src/app/profile-settings/profile-settings.page.scss @@ -370,6 +370,10 @@ height: 3.2rem } +.disable-submit-btn{ + opacity: 0.5; +} + // ************* iOS start************* .back-btn-container-ios{ height: 2rem; diff --git a/src/app/profile-settings/profile-settings.page.ts b/src/app/profile-settings/profile-settings.page.ts index 6ec0e6bac..4b368db3e 100644 --- a/src/app/profile-settings/profile-settings.page.ts +++ b/src/app/profile-settings/profile-settings.page.ts @@ -5,7 +5,7 @@ import { delay, tap } from 'rxjs/operators'; import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx'; import { TranslateService } from '@ngx-translate/core'; -import { FormControl, FormGroup } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; import { OnboardingScreenType, ProfileConstants, RouterLinks } from '../../app/app.constant'; import { GUEST_STUDENT_TABS, GUEST_TEACHER_TABS, initTabs } from '../../app/module.service'; import { @@ -107,6 +107,11 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { } isInitialScreen = false; + profileSettingsForms: FormGroup; + group: any = {}; + isCategoryLabelLoded = false; + defaultFrameworkID: string; + isDisable = true; constructor( @Inject('PROFILE_SERVICE') private profileService: ProfileService, @@ -131,6 +136,8 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { private segmentationTagService: SegmentationTagService, private onboardingConfigurationService: OnboardingConfigurationService ) { + this.navParams = window.history.state; + this.defaultFrameworkID = this.navParams.defaultFrameworkID; this.profileSettingsForm = new FormGroup({ syllabus: new FormControl([]), board: new FormControl([]), @@ -140,7 +147,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { } async ngOnInit() { - this.getCategoriesAndUpdateAttributes(); + await this.getCategoriesAndUpdateAttributes(); this.handleActiveScanner(); await this.appVersion.getAppName().then((appName) => { this.appName = (appName).toUpperCase(); @@ -340,6 +347,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { if (this.showQRScanner === false) { this.showQRScanner = true; this.resetProfileSettingsForm(); + this.resetCategoriesValues(); } else { await this.dismissPopup(); } @@ -455,7 +463,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = { from: CachedItemRequestSourceFrom.SERVER, language: this.translate.currentLang, - requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES + requiredCategories: [] }; this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise() @@ -467,6 +475,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { return; } this.syllabusList = frameworks.map(r => ({ name: r.name, code: r.identifier })); + this.categories[0]['itemList'] = this.syllabusList; /* New Telemetry */ @@ -506,7 +515,7 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { this.framework = await this.frameworkService.getFrameworkDetails({ from: CachedItemRequestSourceFrom.SERVER, frameworkId: value[0], - requiredCategories: FrameworkCategoryCodesGroup.DEFAULT_FRAMEWORK_CATEGORIES + requiredCategories: [] }).toPromise(); /* New Telemetry */ @@ -514,8 +523,8 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { const boardCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { frameworkId: this.framework.identifier, - requiredCategories: [FrameworkCategoryCode.BOARD], - currentCategoryCode: FrameworkCategoryCode.BOARD, + requiredCategories: [this.categories[0].code], + currentCategoryCode: this.categories[0].code, language: this.translate.currentLang }; @@ -526,9 +535,9 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { const nextCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { frameworkId: this.framework.identifier, - requiredCategories: [FrameworkCategoryCode.MEDIUM], - prevCategoryCode: FrameworkCategoryCode.BOARD, - currentCategoryCode: FrameworkCategoryCode.MEDIUM, + requiredCategories: [this.categories[1].code], + prevCategoryCode: this.categories[0].code, + currentCategoryCode: this.categories[1].code, language: this.translate.currentLang, selectedTermsCodes: this.boardControl.value }; @@ -561,9 +570,9 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { try { const nextCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { frameworkId: this.framework.identifier, - requiredCategories: [FrameworkCategoryCode.GRADE_LEVEL], - prevCategoryCode: FrameworkCategoryCode.MEDIUM, - currentCategoryCode: FrameworkCategoryCode.GRADE_LEVEL, + requiredCategories: [this.categories[2].code], + prevCategoryCode: this.categories[1].code, + currentCategoryCode: this.categories[2].code, language: this.translate.currentLang, selectedTermsCodes: this.mediumControl.value }; @@ -598,11 +607,12 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { }); const updateProfileRequest: Profile = { ...this.activeSessionProfile, - syllabus: this.syllabusControl.value, + syllabus: [this.framework.identifier], board: this.boardControl.value, medium: this.mediumControl.value, grade: this.gradeControl.value, - profileType: (this.navParams && this.navParams.selectedUserType) || this.activeSessionProfile.profileType + profileType: (this.navParams && this.navParams.selectedUserType) || this.activeSessionProfile.profileType, + categories: this.profileSettingsForms.value }; this.profileService.updateProfile(updateProfileRequest).toPromise() @@ -656,7 +666,8 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { this.loader = await this.commonUtilService.getLoader(2000); await this.loader.present(); }) - .catch(async () => { + .catch(async (e) => { + console.log('errorrrrrrrrrr', e) await this.loader.dismiss(); this.commonUtilService.showToast('PROFILE_UPDATE_FAILED'); }); @@ -676,12 +687,9 @@ export class ProfileSettingsPage implements OnInit, OnDestroy, AfterViewInit { } private resetProfileSettingsForm() { - this.profileSettingsForm.reset({ - syllabus: [], - board: [], - medium: [], - grade: [] - }); + this.profileSettingsForms.reset(); + console.log('profileSettingsForms', this.profileSettingsForms); + console.log('profileSettingsForms', this.categories) } boardClicked(e?: Event) { @@ -826,14 +834,85 @@ private addAttributeSubscription() { this.formControlSubscriptions = combineLatest(subscriptionArray).subscribe(); } - private getCategoriesAndUpdateAttributes() { - this.formAndFrameworkUtilService.getFrameworkCategoryList().then((categories) => { - if (categories && categories.supportedFrameworkConfig && categories.supportedAttributes) { - this.categories = categories.supportedFrameworkConfig; - this.supportedProfileAttributes = categories.supportedAttributes; - this.addAttributeSubscription(); + private async getCategoriesAndUpdateAttributes(change = false) { + await this.formAndFrameworkUtilService.getFrameworkCategoryList(this.defaultFrameworkID).then((categories) => { + if (categories) { + this.categories = categories.sort((a, b) => a.index - b.index) + this.categories[0]['itemList'] = change ? this.syllabusList : []; + console.log('///////////////////', this.defaultFrameworkID) + this.addAttributeSubscription(); + // } + let resultMap = new Map(); + this.categories.forEach((ele: any, index) => { + this.group[ele.identifier] = new FormControl([], ele.required ? Validators.required : []); + }); + if (Object.keys(this.group).length) { + this.isCategoryLabelLoded = true; + } + console.log('...............', resultMap) + this.profileSettingsForms = new FormGroup(this.group); + this.group = {}; + if (change) { + this.profileSettingsForms.get(this.categories[0].identifier).patchValue([this.defaultFrameworkID]); + } + this.isCategoryLabelLoded = true; + console.log('...............', this.group) } }).catch(e => console.error(e)); } + + // async getNewFrameworkLabel() { + // await this.frameworkService.getFrameworkConfig('agriculture_framework').toPromise() + // .then((data) => { + // console.log('.............../////', data) + // }) + // .catch((error) => console.log('error....', error)) + // } + + async getCategoriesDetails(event, data, index) { + if (index !== this.categories.length - 1) { + console.log('.............................', event, data); + if (this.syllabusList.find(e => e.name === event) || index === 0) { + if (this.defaultFrameworkID !== event) { + this.defaultFrameworkID = event; + this.appGlobalService.setFramewokCategory(''); + // this.profileSettingsForms.reset(); + await this.getCategoriesAndUpdateAttributes(true) + } + this.framework = await this.frameworkService.getFrameworkDetails({ + from: CachedItemRequestSourceFrom.SERVER, + frameworkId: event, + requiredCategories: [] + }).toPromise(); + } + if (index <= this.categories.length && this.profileSettingsForms.get(this.categories[index + 1].identifier).value.length > 0) { + for (let i = index + 1; i < this.categories.length; i++) { + this.profileSettingsForms.get(this.categories[i].identifier).patchValue([]); + // this.profileSettingsForms.get(this.categories[i].identifier).disable() + } + } + const boardCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { + frameworkId: this.framework.identifier, + requiredCategories: [this.categories[index + 1].code], + // prevCategoryCode: this.categories[index].code, + currentCategoryCode: this.categories[index + 1].code, + language: this.translate.currentLang + }; + const categoryTerms = (await this.frameworkUtilService.getFrameworkCategoryTerms(boardCategoryTermsRequet).toPromise()) + .map(t => ({ name: t.name, code: t.code })) + + this.categories[index + 1]['itemList'] = categoryTerms; + this.categories[index + 1]['isDisable'] = true; + } +} + + isMultipleVales(category) { + return category.identifier === 'fwCategory1' ? "false" : "true"; + } + + resetCategoriesValues() { + // this.categories.map((e) => e.itemList = []) + } + } diff --git a/src/app/profile/guest-edit/guest-edit.page.html b/src/app/profile/guest-edit/guest-edit.page.html index a6e6ef8ab..68f4a5d93 100644 --- a/src/app/profile/guest-edit/guest-edit.page.html +++ b/src/app/profile/guest-edit/guest-edit.page.html @@ -1,106 +1,108 @@ -
- - - - - {{ 'USER_TYPE' | translate }} +
+ + + + + + {{ 'USER_TYPE' | translate }} +  * + + + + + + {{ userType.translations | translateJson }} + + + + + + + + {{ 'NAME' | translate }}  * - - - - {{ userType.translations | translateJson }} - - - - - - - - {{ 'NAME' | translate }} -  * - - - - - -
- - - {{categories[0].label | translateJson}} ‎ - -  * - - - - - {{eachSyllabus.name | aliased}}‎ - - - - - - - - {{categories[1].label | translateJson}} - -  * - - - - - {{medium?.name}} - - - - - - - {{categories[2].label | translateJson}} -  * - - - - - {{grade?.name}} - - - - - - - {{categories[3].label | translateJson}} - - - - {{subject?.name}} - - - -
- - + +
+ +
+ + + {{item.label | translateJson}} ‎ + +  * + + + + + {{eachSyllabus.name | aliased}}‎ + + + + + + + + + + + + +
+ + +
-
-
diff --git a/src/app/profile/guest-edit/guest-edit.page.scss b/src/app/profile/guest-edit/guest-edit.page.scss index bbfce2536..521409954 100644 --- a/src/app/profile/guest-edit/guest-edit.page.scss +++ b/src/app/profile/guest-edit/guest-edit.page.scss @@ -90,3 +90,7 @@ } } } + +.disable-submit-btn{ + opacity: 0.5; +} diff --git a/src/app/profile/guest-edit/guest-edit.page.ts b/src/app/profile/guest-edit/guest-edit.page.ts index c99d1d266..339fc79ba 100644 --- a/src/app/profile/guest-edit/guest-edit.page.ts +++ b/src/app/profile/guest-edit/guest-edit.page.ts @@ -2,7 +2,7 @@ import { Router } from '@angular/router'; import { Events } from '../../../util/events'; import { TranslateService } from '@ngx-translate/core'; import { Component, Inject, OnInit, OnDestroy } from '@angular/core'; -import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; +import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; import isEqual from 'lodash/isEqual'; import { Framework, @@ -70,6 +70,46 @@ export class GuestEditPage implements OnInit, OnDestroy { public subjectList: { name: string, code: string }[] = []; public supportedProfileAttributes: { [key: string]: string } = {}; public supportedUserTypes: Array = []; + profileSettingsForms: FormGroup; + group: any = {}; + isCategoryLabelLoded = false; + defaultFID = 'NCF'; + defaultFrameworkID: any; + isDisable = true; + supportedUserType = [ + { + "code": "farmer", + "name": "Farmer", + "formConfig": { + "request": { + "type": "profileConfig", + "subType": "default", + "action": "get" + }, + "url": "/api/data/v1/form" + }, + "translations": "{\"en\":\"Farmer\",\"as\":\"শিক্ষক\",\"bn\":\"শিক্ষক\",\"gu\":\"શિક્ષક\",\"hi\":\"शिक्षक\",\"kn\":\"ಶಿಕ್ಷಕ/ಕಿ\",\"mr\":\"शिक्षक\",\"or\":\"ଶିକ୍ଷକ\",\"pa\":\"ਅਧਿਆਪਕ\",\"ta\":\"ஆசிரியர்\",\"te\":\"ఉపాధ్యాయుడు\",\"ur\":\"استاد\"}", + "image": "ic_teacher.svg", + "ambiguousFilters": [ + "user1", + "instructor" + ], + "searchFilter": [ + "User1", + "Instructor" + ], + "attributes": { + "mandatory": [ + "board", + "medium", + "gradeLevel" + ], + "optional": [ + "subject" + ] + }, + "isActive": true + }] private availableProfileTypes = [ { profileType: ProfileType.STUDENT, name: this.commonUtilService.translateMessage('USER_TYPE_2') }, @@ -167,6 +207,7 @@ export class GuestEditPage implements OnInit, OnDestroy { this.previousProfileType = this.profile.profileType; this.profileForTelemetry = Object.assign({}, this.profile); + this.defaultFrameworkID = this.profile.syllabus[0] } @@ -183,8 +224,8 @@ export class GuestEditPage implements OnInit, OnDestroy { Environment.USER, PageId.CREATE_USER ); - await this.getCategoriesAndUpdateAttributes(this.profile.profileType || undefined); - this.supportedUserTypes = await this.profileHandler.getSupportedUserTypes(this.onboardingConfigurationService.getAppConfig().overriddenDefaultChannelId); + await this.getCategoriesAndUpdateAttributes(); + this.supportedUserTypes = this.profile.syllabus[0] !== 'agriculture_framework' ? await this.profileHandler.getSupportedUserTypes(this.onboardingConfigurationService.getAppConfig().overriddenDefaultChannelId) : this.supportedUserType; } private async addAttributeSubscription() { @@ -197,7 +238,7 @@ export class GuestEditPage implements OnInit, OnDestroy { const headerTitle = this.isNewUser ? this.commonUtilService.translateMessage('CREATE_USER') : this.commonUtilService.translateMessage('EDIT_PROFILE'); await this.headerService.showHeaderWithBackButton([], headerTitle); - await this.getSyllabusDetails(); + // await this.getSyllabusDetails(); } ionViewWillLeave() { @@ -214,14 +255,14 @@ export class GuestEditPage implements OnInit, OnDestroy { if (this.formControlSubscriptions) { this.formControlSubscriptions.unsubscribe(); } - await this.getCategoriesAndUpdateAttributes(this.guestEditForm.value.profileType); - this.guestEditForm.patchValue({ - syllabus: [], - boards: [], - grades: [], - subjects: [], - medium: [] - }); + // await this.getCategoriesAndUpdateAttributes(this.guestEditForm.value.profileType); + // this.guestEditForm.patchValue({ + // syllabus: [], + // boards: [], + // grades: [], + // subjects: [], + // medium: [] + // }); this.btnColor = '#8FC4FF'; } @@ -380,19 +421,51 @@ export class GuestEditPage implements OnInit, OnDestroy { /** * This method is added as we are not getting subject value in reset form method */ - onCategoryChanged(name, event) { - if (event.detail.value && event.detail.value.length) { - const oldAttribute: any = {}; - const newAttribute: any = {}; - oldAttribute[name] = this.profileForTelemetry[name] ? this.profileForTelemetry[name] : ''; - newAttribute[name] = event.detail.value ? event.detail.value : ''; - if (!isEqual(oldAttribute, newAttribute)) { - this.appGlobalService.generateAttributeChangeTelemetry(oldAttribute, newAttribute, PageId.GUEST_PROFILE); + async onCategoryChanged(category, event, index) { + // if (event.detail.value && event.detail.value.length) { + // const oldAttribute: any = {}; + // const newAttribute: any = {}; + // oldAttribute[category.code] = this.profileForTelemetry[category.code] ? this.profileForTelemetry[category.code] : ''; + // newAttribute[category.code] = event.detail.value ? event.detail.value : ''; + // if (!isEqual(oldAttribute, newAttribute)) { + // this.appGlobalService.generateAttributeChangeTelemetry(oldAttribute, newAttribute, PageId.GUEST_PROFILE); + // } + // if (category.code === 'subject') { + // this.profileForTelemetry.subject = event.detail.value ? event.detail.value : ''; + // } + // } + if (index !== this.categories.length - 1) { + if (index === 0) { + if (this.defaultFrameworkID !== event) { + this.appGlobalService.setFramewokCategory(''); + this.defaultFrameworkID = event; + await this.getCategoriesAndUpdateAttributes(true) + } + this.framework = await this.frameworkService.getFrameworkDetails({ + from: CachedItemRequestSourceFrom.SERVER, + frameworkId: event, + requiredCategories: [] + }).toPromise(); } - if (name === 'subject') { - this.profileForTelemetry.subject = event.detail.value ? event.detail.value : ''; + if (index <= this.categories.length && this.profileSettingsForms.get(this.categories[index + 1].identifier).value.length > 0) { + for (let i = index + 1; i < this.categories.length; i++) { + this.profileSettingsForms.get(this.categories[i].identifier).patchValue([]); + // this.profileSettingsForms.get(this.categories[i].identifier).disable() + } } - } + const boardCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { + frameworkId: this.framework.identifier, + requiredCategories: [this.categories[index + 1].code], + // prevCategoryCode: this.categories[index].code, + currentCategoryCode: this.categories[index + 1].code, + language: this.translate.currentLang + }; + const categoryTerms = (await this.frameworkUtilService.getFrameworkCategoryTerms(boardCategoryTermsRequet).toPromise()) + .map(t => ({ name: t.name, code: t.code })) + + this.categories[index + 1]['itemList'] = categoryTerms; + this.categories[index + 1]['isDisable'] = true; + } } /** @@ -405,7 +478,7 @@ export class GuestEditPage implements OnInit, OnDestroy { return; } const loader = await this.commonUtilService.getLoader(); - const formVal = this.guestEditForm.value; + const formVal = this.profileSettingsForms.value; if (!formVal.profileType) { this.commonUtilService.showToast('USER_TYPE_SELECT_WARNING'); @@ -473,30 +546,36 @@ export class GuestEditPage implements OnInit, OnDestroy { */ async submitEditForm(formVal, loader): Promise { const req = {} as Profile; - req.board = formVal.boards; - req.grade = formVal.grades; - req.subject = formVal.subjects; - req.medium = formVal.medium; + let formValue = JSON.parse(JSON.stringify(formVal)); + // req.board = formVal.boards; + // req.grade = formVal.grades; + // req.subject = formVal.subjects; + // req.medium = formVal.medium; req.uid = this.profile.uid; - req.handle = (formVal.name.replace(RegexPatterns.SPECIALCHARECTERSANDEMOJIS, '')).trim(); - req.profileType = formVal.profileType; + req.handle = (formValue.name.replace(RegexPatterns.SPECIALCHARECTERSANDEMOJIS, '')).trim(); + req.profileType = formValue.profileType; req.source = this.profile.source; req.createdAt = this.profile.createdAt; - req.syllabus = (!formVal.syllabus.length) ? [] : [formVal.syllabus]; - - if (formVal.grades && formVal.grades.length > 0) { - formVal.grades.forEach(gradeCode => { - for (let i = 0; i < this.gradeList.length; i++) { - if (this.gradeList[i].code === gradeCode) { - if (!req.gradeValue) { - req.gradeValue = {}; - } - req.gradeValue[this.gradeList[i].code] = this.gradeList[i].name; - break; - } - } - }); + req.syllabus = [this.defaultFrameworkID]; + if(this.categories.length) { + delete formValue.name; + delete formValue.profileType; + req.categories = formValue; } + + // if (formVal.grades && formVal.grades.length > 0) { + // formVal.grades.forEach(gradeCode => { + // for (let i = 0; i < this.gradeList.length; i++) { + // if (this.gradeList[i].code === gradeCode) { + // if (!req.gradeValue) { + // req.gradeValue = {}; + // } + // req.gradeValue[this.gradeList[i].code] = this.gradeList[i].name; + // break; + // } + // } + // }); + // } try { await this.profileService.updateProfile(req).toPromise() await this._dismissLoader(loader); @@ -638,14 +717,100 @@ export class GuestEditPage implements OnInit, OnDestroy { return subscriptionArray; } - private async getCategoriesAndUpdateAttributes(userType: string) { - this.formAndFrameworkUtilService.getFrameworkCategoryList(userType).then(async (categories) => { - if (categories && categories.supportedFrameworkConfig && categories.supportedAttributes) { - this.categories = categories.supportedFrameworkConfig; - this.supportedProfileAttributes = categories.supportedAttributes; - await this.addAttributeSubscription(); + private async getCategoriesAndUpdateAttributes(change = false) { + this.formAndFrameworkUtilService.getFrameworkCategoryList(this.defaultFrameworkID).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; + this.categories[0]['itemList'] = change ? this.syllabusList : []; + await this.setFrameworkCategory1Value(); + + this.addAttributeSubscription(); + await this.setCategoriesTerms() + // if (!change) { + // await this.setCategoriesTerms() + // } else { + // this.resetCategoriesTerms() + // } + if (!change) { + this.group['name'] = new FormControl(this.profile.handle || ''); + this.group['profileType'] = new FormControl(this.profile.profileType || ProfileType.STUDENT); + } + this.categories.forEach((ele: any, index) => { + this.group[ele.identifier] = new FormControl([], ele.required ? Validators.required : []); + }); + this.profileSettingsForms = new FormGroup(this.group); + if (change) { + this.profileSettingsForms.get(this.categories[0].identifier).patchValue([this.defaultFrameworkID]); + } else if(!change) { + for (var key of Object.keys(categoryDetails)) { + if(this.profileSettingsForms.get(key)) { + this.profileSettingsForms.get(key).patchValue(categoryDetails[key]); + } else { + this.profileSettingsForms.removeControl(key); + } + } } + this.isCategoryLabelLoded = true; + console.log('...............', this.group) + } }).catch(e => console.error(e)); } + async setCategoriesTerms() { + this.categories.forEach(async (item, index) => { + if (index !== 0) { + const boardCategoryTermsRequet: GetFrameworkCategoryTermsRequest = { + frameworkId: this.defaultFrameworkID, + requiredCategories: [item.code], + currentCategoryCode: item.code, + language: this.translate.currentLang + }; + const categoryTerms = (await this.frameworkUtilService.getFrameworkCategoryTerms(boardCategoryTermsRequet).toPromise()) + .map(t => ({ name: t.name, code: t.code })) + + this.categories[index]['itemList'] = categoryTerms; + console.log('<<<<<<<<<<<<<<<<<<<<<<<<<', this.categories); + } + }) + } + + resetCategoriesTerms() { + this.categories.forEach(async (item, index) => { + if (index > 1) { + this.categories[index]['itemList'] = []; + } + }) + } + +async setFrameworkCategory1Value() { + this.loader = await this.commonUtilService.getLoader(); + await this.loader.present(); + + const getSuggestedFrameworksRequest: GetSuggestedFrameworksRequest = { + from: CachedItemRequestSourceFrom.SERVER, + language: this.translate.currentLang, + requiredCategories: [] + }; + + await this.frameworkUtilService.getActiveChannelSuggestedFrameworkList(getSuggestedFrameworksRequest).toPromise() + .then(async (frameworks: Framework[]) => { + if (!frameworks || !frameworks.length) { + await this.loader.dismiss(); + this.commonUtilService.showToast('NO_DATA_FOUND'); + return; + } + this.categories[0]['itemList'] = frameworks.map(r => ({ name: r.name, code: r.identifier })); + await this.loader.dismiss(); + }); +} + +isMultipleVales(category) { + return category.index === 0 ? "false" : "true"; +} + +isDisabled(category, index) { + // return (index <2 || this.profileSettingsForms.get(this.categories[index-1]).value.length) ? false : true +} + } diff --git a/src/app/profile/guest-profile/guest-profile.page.html b/src/app/profile/guest-profile/guest-profile.page.html index bab66d24e..848d2d99f 100644 --- a/src/app/profile/guest-profile/guest-profile.page.html +++ b/src/app/profile/guest-profile/guest-profile.page.html @@ -56,26 +56,25 @@
-
{{frameworkData[0].label | translateJson}}
-
+
{{item.label | translateJson}}
+
-
-
{{boards | aliased}}‎
+
+
{{item.value | aliased}}‎
-
{{'ADD' | translate}} -
+
+ -
{{frameworkData[1].label | translateJson}}
@@ -91,11 +90,11 @@
{{'ADD' | translate}}
-
+
--> -
{{frameworkData[2].label | translateJson}}
@@ -112,11 +111,11 @@
{{'ADD' | translate}}
-
+ --> -
{{frameworkData[3].label | translateJson}}
@@ -133,7 +132,7 @@
{{'ADD' | translate}}
-
+ --> diff --git a/src/app/profile/guest-profile/guest-profile.page.scss b/src/app/profile/guest-profile/guest-profile.page.scss index 093ef937e..8234f40dc 100644 --- a/src/app/profile/guest-profile/guest-profile.page.scss +++ b/src/app/profile/guest-profile/guest-profile.page.scss @@ -152,4 +152,9 @@ @include margin(null, null, 10px, null); } } + + .frameworkInfo{ + width: 100%; + display: contents; + } } diff --git a/src/app/profile/guest-profile/guest-profile.page.ts b/src/app/profile/guest-profile/guest-profile.page.ts index 59fd4d252..4c80e3387 100644 --- a/src/app/profile/guest-profile/guest-profile.page.ts +++ b/src/app/profile/guest-profile/guest-profile.page.ts @@ -51,6 +51,41 @@ export class GuestProfilePage implements OnInit { public supportedProfileAttributes: { [key: string]: string } = {}; public currentUserTypeConfig: any = {}; frameworkData = []; + categoryDetails: any; + supportedUserType = [ + { + "code": "farmer", + "name": "Farmer", + "formConfig": { + "request": { + "type": "profileConfig", + "subType": "default", + "action": "get" + }, + "url": "/api/data/v1/form" + }, + "translations": "{\"en\":\"Farmer\",\"as\":\"শিক্ষক\",\"bn\":\"শিক্ষক\",\"gu\":\"શિક્ષક\",\"hi\":\"शिक्षक\",\"kn\":\"ಶಿಕ್ಷಕ/ಕಿ\",\"mr\":\"शिक्षक\",\"or\":\"ଶିକ୍ଷକ\",\"pa\":\"ਅਧਿਆਪਕ\",\"ta\":\"ஆசிரியர்\",\"te\":\"ఉపాధ్యాయుడు\",\"ur\":\"استاد\"}", + "image": "ic_teacher.svg", + "ambiguousFilters": [ + "user1", + "instructor" + ], + "searchFilter": [ + "User1", + "Instructor" + ], + "attributes": { + "mandatory": [ + "board", + "medium", + "gradeLevel" + ], + "optional": [ + "subject" + ] + }, + "isActive": true + }] constructor( @Inject('PROFILE_SERVICE') private profileService: ProfileService, @@ -74,7 +109,6 @@ export class GuestProfilePage implements OnInit { async ngOnInit() { this.selectedLanguage = this.translate.currentLang; - this.getCategoriesAndUpdateAttributes(); // Event for optional and forceful upgrade this.events.subscribe('force_optional_upgrade', async (upgrade) => { if (upgrade && !this.isUpgradePopoverShown) { @@ -138,6 +172,7 @@ export class GuestProfilePage implements OnInit { this.profileService.getActiveSessionProfile({ requiredFields: ProfileConstants.REQUIRED_FIELDS }).toPromise() .then(async (res: any) => { this.profile = res; + this.getCategoriesAndUpdateAttributes(this.profile.syllabus[0]); const tagObj = { board: res.board, grade: res.grade, @@ -150,7 +185,7 @@ export class GuestProfilePage implements OnInit { this.getSyllabusDetails(); this.refreshSignInCard(); const rootOrgId = this.onboardingConfigurationService.getAppConfig().overriddenDefaultChannelId - const supportedUserTypes = await this.profileHandler.getSupportedUserTypes(rootOrgId); + const supportedUserTypes = this.profile.syllabus[0] !== 'agriculture_framework' ? await this.profileHandler.getSupportedUserTypes(rootOrgId) : this.supportedUserType; this.currentUserTypeConfig = supportedUserTypes.find(userTypes => userTypes.code === this.profile.profileType); setTimeout(() => { if (refresher) { refresher.target.complete(); } @@ -285,10 +320,23 @@ export class GuestProfilePage implements OnInit { async signin() { await this.router.navigate([RouterLinks.SIGN_IN]); } - private getCategoriesAndUpdateAttributes() { - this.formAndFrameworkUtilService.getFrameworkCategoryList().then((categories) => { - if (categories && categories.supportedFrameworkConfig && categories.supportedAttributes) { - this.frameworkData = categories.supportedFrameworkConfig; + private getCategoriesAndUpdateAttributes(frameworkId) { + this.formAndFrameworkUtilService.getFrameworkCategoryList(frameworkId).then((categories) => { + if (categories) { + this.frameworkData = categories; + this.categoryDetails = this.profile.categories ? JSON.parse(this.profile.categories) : this.profile.serverProfile.framework; + this.frameworkData.forEach((e) => { + if(this.categoryDetails[e.identifier]) { + e['value'] = this.categoryDetails[e.identifier] + } + }) + // this.frameworkCategories = []; + // Object.keys(categories).forEach((key) => { + // if (key !== 'id') { + // this.frameworkCategories.push(categories[key]); + // } + // }); + console.log('.............///////////', this.frameworkData); this.supportedProfileAttributes = categories.supportedAttributes; } }).catch(e => console.error(e)); diff --git a/src/app/profile/profile.page.html b/src/app/profile/profile.page.html index e72c7145d..471a03838 100644 --- a/src/app/profile/profile.page.html +++ b/src/app/profile/profile.page.html @@ -103,9 +103,9 @@
-
+
{{category.label | translateJson}}: - {{profile?.framework[category.frameworkCode].join(', ') | aliased}} ‎ + {{profile?.framework[category.code].join(', ') | aliased}} ‎
diff --git a/src/app/profile/profile.page.ts b/src/app/profile/profile.page.ts index a3ec1dd7c..5138ff7a0 100644 --- a/src/app/profile/profile.page.ts +++ b/src/app/profile/profile.page.ts @@ -227,8 +227,8 @@ export class ProfilePage implements OnInit { } async ngOnInit() { - this.getCategories(); await this.doRefresh(); + this.getCategories(); this.appName = await this.appVersion.getAppName(); } @@ -1274,8 +1274,8 @@ export class ProfilePage implements OnInit { } private getCategories() { - this.formAndFrameworkUtilService.getFrameworkCategoryList().then((categories) => { - this.categories = categories.supportedFrameworkConfig; + this.formAndFrameworkUtilService.getFrameworkCategoryList(this.profile.framework.id[0]).then((categories) => { + this.categories = categories; }).catch(e => console.error(e)); } diff --git a/src/app/search/search.page.ts b/src/app/search/search.page.ts index 0a1662c20..5534d7937 100644 --- a/src/app/search/search.page.ts +++ b/src/app/search/search.page.ts @@ -256,7 +256,10 @@ export class SearchPage implements OnInit, AfterViewInit, OnDestroy, OnTabViewWi await this.headerService.showHeaderWithHomeButton(['download', 'notification']); } this.handleDeviceBackButton(); - this.searchFilterConfig = await this.formAndFrameworkUtilService.getFormFields(FormConstants.SEARCH_FILTER); + let filterConfig = await this.formAndFrameworkUtilService.getFormFields(FormConstants.SEARCH_FILTER); + let frameworkCategory = this.appGlobalService.getCachedFrameworkCategory().value + this.searchFilterConfig = frameworkCategory.concat(filterConfig); + console.log('.....new form', this.searchFilterConfig); if ((this.source === PageId.GROUP_DETAIL && this.isFirstLaunch) || this.preAppliedFilter) { this.isFirstLaunch = false; await this.handleSearch(true); @@ -835,7 +838,7 @@ export class SearchPage implements OnInit, AfterViewInit, OnDestroy, OnTabViewWi filterCriteriaData.facetFilters.forEach(async element => { this.searchFilterConfig.forEach(item => { if (element.name === item.code) { - element.translatedName = this.commonUtilService.getTranslatedValue(item.translations, item.name); + element.translatedName = item.translations ? this.commonUtilService.getTranslatedValue(item.translations, item.name) : item.label; return; } }); @@ -843,7 +846,7 @@ export class SearchPage implements OnInit, AfterViewInit, OnDestroy, OnTabViewWi this.initialFilterCriteria.facetFilters.forEach(newElement => { this.searchFilterConfig.forEach(item => { if (newElement.name === item.code) { - newElement.translatedName = this.commonUtilService.getTranslatedValue(item.translations, item.name); + newElement.translatedName = item.translations ? this.commonUtilService.getTranslatedValue(item.translations, item.name) : item.label; return; } }); diff --git a/src/app/user-type-selection/user-type-selection.ts b/src/app/user-type-selection/user-type-selection.ts index 0d913254b..6d427b16a 100644 --- a/src/app/user-type-selection/user-type-selection.ts +++ b/src/app/user-type-selection/user-type-selection.ts @@ -31,7 +31,11 @@ import { ProfileSource, ProfileType, SharedPreferences, - UpdateServerProfileInfoRequest + UpdateServerProfileInfoRequest, + FrameworkService, + CachedItemRequestSourceFrom, + Framework, + GetSuggestedFrameworksRequest } from '@project-sunbird/sunbird-sdk'; import { ExternalIdVerificationService } from '../../services/externalid-verification.service'; @@ -59,10 +63,46 @@ export class UserTypeSelectionPage implements OnDestroy { categoriesProfileData: any; supportedUserTypeConfig: Array; isUserTypeSelected = false; + defaultFrameworkID: any; + supportedUserTypes = [ + { + "code": "farmer", + "name": "Farmer", + "formConfig": { + "request": { + "type": "profileConfig", + "subType": "default", + "action": "get" + }, + "url": "/api/data/v1/form" + }, + "translations": "{\"en\":\"Farmer\",\"as\":\"শিক্ষক\",\"bn\":\"শিক্ষক\",\"gu\":\"શિક્ષક\",\"hi\":\"शिक्षक\",\"kn\":\"ಶಿಕ್ಷಕ/ಕಿ\",\"mr\":\"शिक्षक\",\"or\":\"ଶିକ୍ଷକ\",\"pa\":\"ਅਧਿਆਪਕ\",\"ta\":\"ஆசிரியர்\",\"te\":\"ఉపాధ్యాయుడు\",\"ur\":\"استاد\"}", + "image": "ic_teacher.svg", + "ambiguousFilters": [ + "user1", + "instructor" + ], + "searchFilter": [ + "User1", + "Instructor" + ], + "attributes": { + "mandatory": [ + "board", + "medium", + "gradeLevel" + ], + "optional": [ + "subject" + ] + }, + "isActive": true + }] constructor( @Inject('PROFILE_SERVICE') private profileService: ProfileService, @Inject('SHARED_PREFERENCES') private preferences: SharedPreferences, + @Inject('FRAMEWORK_SERVICE') private frameworkService: FrameworkService, private telemetryGeneratorService: TelemetryGeneratorService, private container: ContainerService, private zone: NgZone, @@ -100,12 +140,24 @@ export class UserTypeSelectionPage implements OnDestroy { } } + async setValue() { + + await this.frameworkService.getDefaultChannelDetails().toPromise() + .then( (data) => { + this.defaultFrameworkID = data.defaultFramework; + console.log('klkkkkkkkkkkkkkkkkkkkkkkkkk', data) + }) + } + async ionViewWillEnter() { + await this.setValue(); if (this.appGlobalService.isUserLoggedIn()) { this.selectedUserType = await this.preferences.getString(PreferenceKey.SELECTED_USER_TYPE).toPromise(); } await this.setUserTypeForNewUser(); - this.supportedUserTypeConfig = await this.profileHandler.getSupportedUserTypes(); + this.supportedUserTypeConfig = this.defaultFrameworkID !== 'agriculture_framework' ? await this.profileHandler.getSupportedUserTypes(this.defaultFrameworkID) : this.supportedUserTypes; + + console.log('supportedUserTypeConfigsupportedUserTypeConfigsupportedUserTypeConfigsupportedUserTypeConfig', this.supportedUserTypeConfig) if (this.router.url === '/' + RouterLinks.USER_TYPE_SELECTION) { setTimeout(() => { this.telemetryGeneratorService.generateImpressionTelemetry( @@ -298,12 +350,12 @@ export class UserTypeSelectionPage implements OnDestroy { await this.navigateToTabsAsGuest(); } else { if (isUserTypeChanged) { - this.updateProfile('ProfileSettingsPage', { showProfileSettingPage: true }); + this.updateProfile('ProfileSettingsPage', { showProfileSettingPage: true , defaultFrameworkID: this.defaultFrameworkID}); } else { if (this.selectedUserType === ProfileType.ADMIN) { await this.router.navigate([RouterLinks.SIGN_IN]); } else { - await this.navigateToProfileSettingsPage({ showProfileSettingPage: true }); + await this.navigateToProfileSettingsPage({ showProfileSettingPage: true , defaultFrameworkID: this.defaultFrameworkID}); } } } diff --git a/src/services/app-global-service.service.ts b/src/services/app-global-service.service.ts index 2490ea86a..17332f343 100644 --- a/src/services/app-global-service.service.ts +++ b/src/services/app-global-service.service.ts @@ -92,7 +92,7 @@ export class AppGlobalService implements OnDestroy { private _isNativePopupVisible: boolean; private _isDiscoverBackEnabled: boolean = false; private _isForumEnabled: boolean = false; - private frameworkCategory = {}; + private frameworkCategory: any; private _isSplashscreenDisplay: boolean = false; constructor( diff --git a/src/services/formandframeworkutil.service.ts b/src/services/formandframeworkutil.service.ts index 6e1adc847..eee44e62e 100644 --- a/src/services/formandframeworkutil.service.ts +++ b/src/services/formandframeworkutil.service.ts @@ -728,50 +728,27 @@ export class FormAndFrameworkUtilService { return filterCriteria; } - private async setSupportedAttributes(framework, userType?: string) { - if (!userType || userType === ProfileType.NONE) { - userType = await this.preferences.getString(PreferenceKey.SELECTED_USER_TYPE).toPromise(); - } - const frameworkDetails = {}; - frameworkDetails['userType'] = userType; - const supportedFrameworkConfig = framework.filter((item) => { - return (item.supportedUserTypes.find((type) => type === userType)); - }); - frameworkDetails['supportedFrameworkConfig'] = supportedFrameworkConfig; - const supportedAttributes = supportedFrameworkConfig.reduce((map, item) => { - map[item.frameworkCode] = item.frameworkCode; - return map; - }, {}); - frameworkDetails['supportedAttributes'] = supportedAttributes; - return frameworkDetails; - } - - private invokeFrameworkCategoriesFormApi(userType?: string): Promise { - return this.getFormFields(FormConstants.FRAMEWORK_CONFIG).then(async (res) => { - const categoryConfig = await this.setSupportedAttributes(res, userType); - this.appGlobalService.setFramewokCategory(categoryConfig); - return categoryConfig; - }).catch((error) => { - return error; - }); + + + private async getCategoriesConfig(frameworkId: string, formRequest): Promise { + console.log('.....getCategoriesConfig', formRequest) + return await this.frameworkService.getFrameworkConfig(frameworkId, formRequest).toPromise(); } - getFrameworkCategoryList(userType?: string): Promise { + getFrameworkCategoryList(frameworkId?: string): Promise { return new Promise((resolve, reject) => { - if (!userType || userType === ProfileType.NONE) { - this.preferences.getString(PreferenceKey.SELECTED_USER_TYPE).toPromise().then((type) => { - userType = type; - }).catch((e) => console.error(e)); - } const framework = this.appGlobalService.getCachedFrameworkCategory(); console.log('................', framework); - if (Object.keys(framework).length === 0 || (Object.keys(framework).length > 0 && - (framework.userType !== userType || !userType || userType === ProfileType.NONE))) { - this.invokeFrameworkCategoriesFormApi(userType).then((res) => { - resolve(res); + if (!framework || (framework && framework.id !== frameworkId)) { + this.getCategoriesConfig(frameworkId, {...FormConstants.FRAMEWORK_CONFIG, framework: frameworkId}).then((res) => { + if(res) { + let fraeworkDetails = {id: frameworkId, value: res } + this.appGlobalService.setFramewokCategory(fraeworkDetails); + resolve(res); + } }).catch((e) => console.error(e)); } else { - resolve(framework); + resolve(framework.value); } }); } From 1d76f923ff7dd70e19cb4cf23625941eaa84ab26 Mon Sep 17 00:00:00 2001 From: Ajoymaity Date: Wed, 29 Nov 2023 17:39:41 +0530 Subject: [PATCH 02/10] Issue #ED-1957 feat: Removed hardcoded BMGS --- src/app/category-list/category-list-page.html | 6 +- src/app/category-list/category-list-page.ts | 19 +- src/app/components/discover/discover.page.ts | 3 +- .../content-details/content-details.page.html | 43 +--- .../content-details/content-details.page.ts | 2 + src/app/home/user-home/user-home.page.ts | 42 ++-- .../profile-settings/profile-settings.page.ts | 11 +- .../categories-edit/categories-edit.page.html | 77 ++----- .../categories-edit/categories-edit.page.ts | 206 ++++++++++++------ src/app/profile/guest-edit/guest-edit.page.ts | 38 +--- .../guest-profile/guest-profile.page.ts | 11 +- src/app/profile/profile.page.html | 2 +- src/app/profile/profile.page.ts | 15 +- .../filter-form-config-mapper.ts | 9 +- src/app/search/search.page.html | 8 +- src/app/search/search.page.ts | 16 +- .../user-type-selection.ts | 45 +--- src/services/formandframeworkutil.service.ts | 22 +- .../search-filter/search-filter.service.ts | 11 +- 19 files changed, 285 insertions(+), 301 deletions(-) diff --git a/src/app/category-list/category-list-page.html b/src/app/category-list/category-list-page.html index 98c404255..94b69c054 100755 --- a/src/app/category-list/category-list-page.html +++ b/src/app/category-list/category-list-page.html @@ -76,10 +76,10 @@
-
+
- + { + this.categoriesList = data; + this.categoriesList.push({code: 'lastPublishedBy', name: 'Published by'}) + }); + this.formAPIFacets = await this.searchFilterService.fetchFacetFilterFormConfig(this.filterIdentifier, this.frameworkId); this.supportedFacets = this.formAPIFacets.reduce((acc, filterConfig) => { acc.push(filterConfig.code); return acc; @@ -298,11 +309,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 } diff --git a/src/app/components/discover/discover.page.ts b/src/app/components/discover/discover.page.ts index 3ab00e3ca..b9d03849f 100644 --- a/src/app/components/discover/discover.page.ts +++ b/src/app/components/discover/discover.page.ts @@ -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; diff --git a/src/app/content-details/content-details.page.html b/src/app/content-details/content-details.page.html index 0ab4805a1..9ede501f7 100644 --- a/src/app/content-details/content-details.page.html +++ b/src/app/content-details/content-details.page.html @@ -217,7 +217,7 @@