Unverified Commit 01ac6b80 authored by Vinu Kumar's avatar Vinu Kumar Committed by GitHub
Browse files

Issue #SB-15678 merge: Merge pull request #2850 from yravinderkumar33/release-2.6.0-15678-2

Issue #SB-15678 feat : Handling User Profile on Portal when Tenant's …
parents 2aebcee4 51db0529
master Dark_theme SB-25589 SB-28090 aws_fileRead contributions dependabot/npm_and_yarn/src/app/client/decode-uri-component-0.2.2 dependabot/npm_and_yarn/src/app/decode-uri-component-0.2.2 dependabot/npm_and_yarn/src/app/express-4.17.3 dependabot/npm_and_yarn/src/app/jsonwebtoken-9.0.0 dependabot/npm_and_yarn/src/desktop/OpenRAP/decode-uri-component-0.2.2 dependabot/npm_and_yarn/src/desktop/OpenRAP/express-4.17.3 dependabot/npm_and_yarn/src/desktop/OpenRAP/jsonwebtoken-9.0.0 dependabot/npm_and_yarn/src/desktop/OpenRAP/qs-6.5.3 dependabot/npm_and_yarn/src/desktop/decode-uri-component-0.2.2 dependabot/npm_and_yarn/src/desktop/express-4.17.3 dependabot/npm_and_yarn/src/desktop/jsonwebtoken-9.0.0 dependabot/npm_and_yarn/src/desktop/qs-6.10.3 filters_5.1.1 gcp gcp_test keshavprasadms-patch-1 keshavprasadms-patch-2 release-2.10.0 release-2.10.1 release-2.10.2 release-2.10.3 release-2.6.0 release-2.6.0-loadtest release-2.6.5 release-2.6.6 release-2.7.0 release-2.8.0 release-2.8.1 release-2.8.10 release-2.8.11 release-2.8.12 release-2.8.2 release-2.8.3 release-2.8.4 release-2.8.5 release-2.8.6 release-2.8.7 release-2.8.8 release-2.8.9 release-2.9.0 release-3.0 release-3.0-merge release-3.0.0 release-3.0.1 release-3.0.2 release-3.0.3 release-3.0.4 release-3.0.4-sso release-3.1.0 release-3.1.1 release-3.1.2 release-3.2.0 release-3.2.1 release-3.2.10 release-3.2.11 release-3.2.12 release-3.2.13 release-3.2.14 release-3.2.2 release-3.2.3 release-3.2.4 release-3.3.0 release-3.3.0-telemetry-fix release-3.3.1 release-3.3.2 release-3.4.0 release-3.4.1 release-3.4.2 release-3.4.3 release-3.4.4 release-3.4.5 release-3.4.6 release-3.4.7 release-3.5.0 release-3.5.1 release-3.5.2 release-3.5.3 release-3.6.0 release-3.6.1 release-3.6.5 release-3.6.6 release-3.7.0 release-3.7.1 release-3.7.2 release-3.8.0 release-3.8.1 release-3.8.2 release-3.8.3 release-3.9.0 release-3.9.1 release-3.9.2 release-3.9.3 release-4.0.0 release-4.0.1 release-4.0.2 release-4.1 release-4.1.0 release-4.1.1 release-4.10.0 release-4.10.0.1 release-4.10.1 release-4.10.2 release-4.10.2.1 release-4.10.2.2 release-4.10.3 release-4.2.0 release-4.2.1 release-4.3.0 release-4.3.1 release-4.4.0 release-4.4.1 release-4.5.0 release-4.5.1 release-4.5.2 release-4.6.0 release-4.7.0 release-4.7.1 release-4.8.0 release-4.8.5 release-4.9.0 release-4.9.1 release-5.0.0 release-5.0.0.1 release-5.0.0.2 release-5.0.0.3 release-5.0.1 release-5.0.2 release-5.1.0 release-5.1.1 release-sonarcloud revert-3718-copypi revert-3842-release-2.8.7 revert-3890-release-2.8.9 revert-4427-player-cache-issue revert-4537-SB-19763 revert-5244-sh-809 revert-5260-SB-table-3.3.0 revert-8284-release-5.0.0 sharathkashyap-patch-1 Tags unavailable
No related merge requests found
Showing with 95 additions and 3 deletions
+95 -3
......@@ -855,5 +855,55 @@ export const Response = {
'visibility': null,
'compatibilityLevel': null
}
],
formWithoutBoard: [
{
'code': 'medium',
'visible': true,
'displayProperty': 'Editable',
'editable': true,
'dataType': 'text',
'renderingHints': {
'semanticColumnWidth': 'four'
},
'name': 'Medium',
'description': 'Mediumofinstruction',
'index': 1,
'inputType': 'select',
'label': 'Medium',
'required': true
},
{
'code': 'gradeLevel',
'visible': true,
'displayProperty': 'Editable',
'editable': true,
'dataType': 'text',
'renderingHints': {
'semanticColumnWidth': 'four'
},
'name': 'Class',
'description': 'Grade',
'index': 2,
'inputType': 'select',
'label': 'Class',
'required': true
},
{
'code': 'subject',
'visible': true,
'displayProperty': 'Editable',
'editable': true,
'dataType': 'text',
'renderingHints': {
'semanticColumnWidth': 'four'
},
'name': 'Subject',
'description': 'SubjectoftheContenttousetoteach',
'index': 3,
'inputType': 'select',
'label': 'Subject',
'required': false
}
]
};
......@@ -122,5 +122,44 @@ describe('ProfileFrameworkPopupComponent', () => {
expect(component.formFieldOptions[3].range).toBeUndefined();
expect(toasterService.warning).not.toHaveBeenCalled();
});
describe('enable/disable submit button based on required fields in form API', () => {
beforeEach(() => {
component['_formFieldProperties'] = Response.formWithoutBoard;
});
it('should enable submit button if board value is not there in framework' , () => {
component.selectedOption = {
gradeLevel: ['Class 2'],
medium: ['English'],
subject: []
};
component['enableSubmitButton']();
expect(component.showButton).toBeTruthy();
});
it('should disable submit button if any of board, medium or gradeLevel is not present', () => {
component.selectedOption = {
gradeLevel: ['Class 1'],
medium: ['English'],
subject: ['Hindi'],
board: []
};
component['enableSubmitButton']();
expect(component.showButton).toBeFalsy();
});
it('should submit board value in form as null when board value is not present in the framework', () => {
const selectedOptions = {
gradeLevel: ['Class 1'],
medium: ['English'],
subject: ['Hindi']
};
component.selectedOption = selectedOptions;
component['frameWorkId'] = 'NCFCOPY2';
const submitEventEmitter = spyOn(component.submit, 'emit');
component.onSubmitForm();
expect(submitEventEmitter).toHaveBeenCalledWith({...selectedOptions, ...{board: null, id: 'NCFCOPY2' }});
});
});
});
......@@ -205,13 +205,16 @@ export class ProfileFrameworkPopupComponent implements OnInit, OnDestroy {
}
onSubmitForm() {
const selectedOption = _.cloneDeep(this.selectedOption);
selectedOption.board = [this.selectedOption.board];
selectedOption.board = _.get(this.selectedOption, 'board') ? [this.selectedOption.board] : null;
selectedOption.id = this.frameWorkId;
this.submit.emit(selectedOption);
}
private enableSubmitButton() {
if (_.get(this.selectedOption, 'board.length') && _.get(this.selectedOption, 'medium.length')
&& _.get(this.selectedOption, 'gradeLevel.length')) {
const optionalFields = _.map(_.filter(this._formFieldProperties, formField => !_.get(formField, 'required')), 'code');
const enableSubmitButton = _.every(this.selectedOption, (value, index) => {
return _.includes(optionalFields, index) ? true : value.length;
});
if (enableSubmitButton) {
this.showButton = true;
} else {
this.showButton = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment