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

PCHR-3742: Disabling or Deleting Options Breaks Job Roles Tab #2646

Conversation

ajesamson
Copy link
Contributor

Overview

This PR fixes issues with editing disabled or deleted job role option group. Dropdown displays wrongly if such record was previously submitted.

Before

before_roles

After

after_roles

Technical Details

Values that are invalid gets submitted as the existing implementation only checks if the value is defined or not. To guide against this, submitted data is checked against valid list of options data.

updateLocation = _.includes(_.keys(vm.LocationsData), updatedRole.location);
updateLevel = _.includes(_.keys(vm.LevelsData), updatedRole.level);
updateDepartment = _.includes(_.keys(vm.DepartmentsData), updatedRole.department);
updateRegion = _.includes(_.keys(vm.RegionsData), updatedRole.region);

updatedRole.location = (updatedRole.location === undefined || !updateLocation) ? 
  updatedRole.location = '' : updatedRole.location;
updatedRole.level = (updatedRole.level === undefined || !updateLevel) ? updatedRole.level = '' : 
  updatedRole.level;
updatedRole.department = (updatedRole.department === undefined || !updateDepartment) ? 
  updatedRole.department = '' : updatedRole.department;
updatedRole.region = (updatedRole.region === undefined || !updateRegion) ? updatedRole.region = 
  ''  : updatedRole.region;

✅Manual Tests - passed
✅Jasmine Tests - passed
✅JS distributive files - included

updatedRole.department = (updatedRole.department === undefined) ? updatedRole.department = '' : updatedRole.department;
updatedRole.region = (updatedRole.region === undefined) ? updatedRole.region = '' : updatedRole.region;
// Ensure location, level, department, region exist and not disabled
updateLocation = _.includes(_.keys(vm.LocationsData), updatedRole.location);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the code to a separate function with a meaningful name, there is too much duplication.

updateDepartment = _.includes(_.keys(vm.DepartmentsData), updatedRole.department);
updateRegion = _.includes(_.keys(vm.RegionsData), updatedRole.region);

updatedRole.location = (updatedRole.location === undefined || !updateLocation) ? updatedRole.location = '' : updatedRole.location;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the code to a separate function with a meaningful name, there is too much duplication.

@igorpavlov-zz
Copy link
Contributor

@ajesamson are there JS test suites for JobRoles extension?

@ajesamson
Copy link
Contributor Author

@igorpavlov There are JS test suites.

/**
* Update submitted role if undefined or option type is disabled
*
* @param updatedRole
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param  updatedRole
* @param  optionData
* @return {Object}

@ajesamson ajesamson force-pushed the PCHR-3742-disabling-deleting-options-breaks-job-roles-tab branch from 2347c37 to d6a280b Compare June 1, 2018 14:49
@ajesamson ajesamson force-pushed the PCHR-3742-disabling-deleting-options-breaks-job-roles-tab branch from d6a280b to ec9f5f4 Compare June 1, 2018 14:53
@ajesamson ajesamson merged commit 1f8d576 into PCHR-3162-configurability-changes Jun 1, 2018
@ajesamson ajesamson deleted the PCHR-3742-disabling-deleting-options-breaks-job-roles-tab branch June 1, 2018 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants