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

fix: keep translations during PUT json object when 'skipTranslation=true' is set [DHIS2-10660] #7538

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Mar 6, 2021

Problem

The PUT JSON object operation in generic CRUD controller does replace (clear) the translations even when using the skipTranslation=true parameter.

Findings

The skipTranslation flag was not forwarded to MergeParams performing the merge between existing and update object.

This did however not fix the issue because somewhere during or because of the preheat the translations get lost for the persisted object so that at the point of the merge both the updating and the persisted object do not have translations.
I investigated but this feels like a bigger issue in the preheat, a box I did not want to open but that should be opened in a dedicated ticket.

Instead I used a workaround in the controller for the PUT operation.
When translations should be skipped the persisted object is loaded and the translations copied over to the parsed object so that they appear as part of the source. With this the merge obviously now should not skip translations so the flag is flipped.

Automatic testing

A new test was added to the AbstractCrudControllerTest with the following scenario:

  1. create a new object
  2. add translations to it
  3. check the translations are present
  4. update the object (without translations in the payload but with skipTranslation=true)
  5. check again that translations are still present

@jbee jbee self-assigned this Mar 6, 2021
@jbee jbee added the run-api-tests This label will trigger an api-test job for the PR. label Mar 6, 2021
@sonarcloud
Copy link

sonarcloud bot commented Mar 6, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jbee jbee changed the title fix: keep translations during PUT json object when 'skipTranslation=true' is set [TECH-571] fix: keep translations during PUT json object when 'skipTranslation=true' is set [DHIS2-10660] Mar 9, 2021
@jbee jbee merged commit 1f9e4e7 into dhis2:master Mar 9, 2021
jenniferarnesen added a commit to dhis2/dashboard-app that referenced this pull request Mar 9, 2021
After the switch from d2 to DataQuery, translations were being deleted when a dashboard is saved. This is because the skipTranslation=true param was missing. This and skipSharing=true have been added now, but the api currently has a bug in that it does not observe these params. The backend fix is here: dhis2/dhis2-core#7538

Changes to EditBar: there is no need to set the dashboard display name in the onTranslationsSaved callback, since the display name will be fetched with the updated dashboard when user returns to ViewMode. So code for setting display name in actions and reducers was removed.
dhis2-bot added a commit to dhis2/dashboard-app that referenced this pull request Mar 9, 2021
## [31.13.7](v31.13.6...v31.13.7) (2021-03-09)

### Bug Fixes

* add scatter icon for ItemSelector ([#1614](#1614)) ([66ac287](66ac287))
* calc fullscreen height of visualization based on window height ([#1621](#1621)) ([13c79b9](13c79b9))
* preserve sharing and translations when saving dashboard ([#1611](#1611)) ([802405d](802405d)), closes [dhis2/dhis2-core#7538](dhis2/dhis2-core#7538)
* use window height to determine controlbar height ([#1620](#1620)) ([d7d730f](d7d730f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-api-tests This label will trigger an api-test job for the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants