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

editor: fix hidden field with value from the model #234

Merged
merged 1 commit into from
Aug 18, 2020

Conversation

jma
Copy link
Contributor

@jma jma commented Aug 6, 2020

Some fields containing values given with the input model should be visible
after the editor initializations. This is not the case with a recent version of
ngx formly. This is due to the use of bad hack setTimeout at several
places in the code. As ngx formly made the think cleaner these hacks have
been removed.

  • Cleans hidden field list at the component destruction instead of
    initialization.
  • Removes the extra values in an array when the corresponding field is
    hidden only when the values are reset.

Co-Authored-by: Johnny Mariéthoz Johnny.Mariethoz@rero.ch

Why are you opening this PR?

  • Some fields containing data are not displayed when a record is imported from an external source such as BNF in the rero-ils-ui project.

How to test?

  • Link the library to the rero-ils-ui start the admin server, import a record from the BNF containing a dimensions value. This field should not be hidden. Check that not error is present in the console.

Code review check list

  • Commit message template compliance.
  • Commit message without typos.
  • File names.
  • Functions names.
  • Functions docstrings.
  • Unnecessary commited files?
  • Extracted translations?

@jma jma requested review from Garfield-fr and zannkukai August 6, 2020 06:05
@jma jma marked this pull request as draft August 6, 2020 06:08
@jma jma requested a review from Garfield-fr August 6, 2020 06:08
@jma jma force-pushed the maj-remove-hack branch 2 times, most recently from 6313b74 to 80da232 Compare August 6, 2020 07:19
@jma jma marked this pull request as ready for review August 6, 2020 07:21
@jma jma force-pushed the maj-remove-hack branch from 80da232 to 41ec978 Compare August 6, 2020 07:54
@jma jma force-pushed the maj-remove-hack branch from 41ec978 to a93e3cd Compare August 6, 2020 12:59
@rerowep rerowep self-requested a review August 6, 2020 13:49
@jma jma force-pushed the maj-remove-hack branch from a93e3cd to 3b81ad3 Compare August 13, 2020 12:47
@iGormilhit
Copy link

@jma I think this PR closes rero/rero-ils#1119, at least the main part of if.

@jma jma requested a review from sebdeleze August 17, 2020 07:27
@@ -62,6 +62,7 @@ export class ArrayTypeComponent extends FieldArrayType implements OnInit {
const numberOfItemsToRemove = this.field.fieldGroup.length - minItems;
// remove the extra elements
// force removing the elements in the next event loop else this cause errors when removing multiple values
// TODO: try to remove this hack
setTimeout(() => {

Choose a reason for hiding this comment

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

setTimeout cannot be removed here?

Copy link

@iGormilhit iGormilhit left a comment

Choose a reason for hiding this comment

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

Commit message: Some fields containing values given with the input model, "given with" is not clear, I think. Maybe "coming from"?

Typo in the commit message: As ngx formly made the think cleaner these hacks have been removed. to `As ngx formly made the think cleaner these hacks have
been removed.

And do not forget to close the related issue: #234 (comment)

@jma jma marked this pull request as draft August 18, 2020 06:00
@jma jma force-pushed the maj-remove-hack branch 3 times, most recently from 5890107 to 4d56ab1 Compare August 18, 2020 08:13
@jma jma marked this pull request as ready for review August 18, 2020 08:16
@jma jma force-pushed the maj-remove-hack branch from 4d56ab1 to 320a104 Compare August 18, 2020 08:43
Some fields containing values comming from the input model should be visible
after the editor initialization. This is not the case with a recent version of
ngx formly. This is due to the use of bad hack `setTimeout` at several
places in the code.  As ngx formly made the think cleaner these hacks have been
removed.

* Cleans hidden field list at the component destruction instead of
initialization.
* Reloads the JSONSchema once the model has changed.
* Rewrites the add field component by using observers only.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
@jma jma force-pushed the maj-remove-hack branch from 320a104 to b593aa4 Compare August 18, 2020 08:46
@sebdeleze sebdeleze merged commit c70ed4c into rero:dev Aug 18, 2020
@jma jma deleted the maj-remove-hack branch December 13, 2021 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants