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

Update Goonj rules to work in DEA #1252

Closed
Tracked by #1629
mahalakshme opened this issue Jun 17, 2024 · 5 comments
Closed
Tracked by #1629

Update Goonj rules to work in DEA #1252

mahalakshme opened this issue Jun 17, 2024 · 5 comments
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Jun 17, 2024

As is:

Currently in Activity and Distribution registration, we show 'Other Block' form element(input the name of the block) when 'Other' block is selected in address.

Testing:

Other block form element should be shown only when 'Other block' selected in address. ie. Need to work same as in mobile app.

Issue:

The condition for the above is achieved by below form element rule

'use strict';
({params, imports}) => {
  const individual = params.entity;
  const moment = imports.moment;
  const formElement = params.formElement;
  const _ = imports.lodash;
  let visibility = false;
  const condition11 = new imports.rulesConfig.RuleCondition({individual, formElement}).when.lowestAddressLevel.defined.matches();
  const isDefined = individual.lowestAddressLevel !== undefined && individual.lowestAddressLevel.locationMappings.length !== 0;
  //&& individual.lowestAddressLevel.isSelected;
  if (isDefined) {
    const block = individual.lowestAddressLevel.locationMappings[0].that.parent.name;
    if (block === 'Other') {
      visibility = true;
    }
    else {
      visibility = false;
    }
  }
  return new imports.rulesConfig.FormElementStatus(formElement.uuid, visibility);
};

But locationMappings is not available in DEA.

Analysis:

locationMappings as such is not much useful. In product we are planning to remove the location_location_mapping table. Hence we are not adding support for rules that access locationMappings.

AC:

  • Rule has to be changed to make use of individual.lowestAddressLevel.titleLineage incase locationMappings is not present(which is the case in webapp), to figure out "Other Block" visibility.

Example individual.lowestAddressLevel.titleLineage value:

"Karnataka, Bengaluru, Indiranagara, Binnamangala"

  • Should be changed in both Activity and Distribution registration
  • Cover any cases missed about w.r to the above issue.
  • If there is any other better alternative solution feel free to do that.
  • Misc: Select the 'Search' option for Activities Done and Inventory Id subject concept form elements to make it work in DEA.
  • All the above can be tested in prerelease env DEA to make sure it is working.
  • Make sure it works as is for before 9.0 release and as expected after 9.0 release
@1t5j0y
Copy link
Contributor

1t5j0y commented Jun 20, 2024

FormElementStatus rule is not currently triggered on change of fixed form elements in registration form. To test this, one of the non-fixed elements needs to be edited after setting the location to trigger form element status rule execution.

Updated rule:

'use strict';
({params, imports}) => {
  const individual = params.entity;
  const moment = imports.moment;
  const formElement = params.formElement;
  const _ = imports.lodash;
  let visibility = false;
  //const condition11 = new imports.rulesConfig.RuleCondition({individual, formElement}).when.lowestAddressLevel.defined.matches();
  const isDefined = !_.isNil(individual.lowestAddressLevel) && (individual.lowestAddressLevel.locationMappings.length !== 0 || !_.isEmpty(individual.lowestAddressLevel.titleLineage));
  //&& individual.lowestAddressLevel.isSelected;
  if (isDefined) {
    const block = individual.lowestAddressLevel.locationMappings.length !== 0 && individual.lowestAddressLevel.locationMappings[0].parent.name || _.split(individual.lowestAddressLevel.titleLineage, ', ')[2];
    if (block === 'Other') {
      visibility = true;
    }
    else {
      visibility = false;
    }
  }
  return new imports.rulesConfig.FormElementStatus(formElement.uuid, visibility);
};

@vinayvenu
Copy link
Member

No code review required. This needs to be tested on Goonj on Prerelease only.

@mahalakshme can you mention in the AC what a QA should be testing? What is the expected behaviour here?

@mahalakshme
Copy link
Contributor Author

mahalakshme commented Jun 27, 2024

@1t5j0y I see other block is still visible in prerelease though I didn't select Other as Block. Am I missing something?

Image

@1t5j0y
Copy link
Contributor

1t5j0y commented Jun 27, 2024

There was a rule failure for edit scenario in DEA. Fixed.
Changed occurrences of individual.lowestAddressLevel.locationMappings.length !== 0 to !_.isEmpty(individual.lowestAddressLevel.locationMappings)

@mahalakshme
Copy link
Contributor Author

tested also in a distribution with other block selected - D-18436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants