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

Implement Sync Rules #109

Merged
merged 21 commits into from
Jul 1, 2019
Merged

Implement Sync Rules #109

merged 21 commits into from
Jul 1, 2019

Conversation

SferaDev
Copy link
Contributor

@SferaDev SferaDev commented Jun 13, 2019

📌 References

📝 Implementation

  • Add two new routes to access the new pages

  • Add Sync Rules Landing Page

  • Add Sync Rules Creation Wizard

    • Add General Info Step with a simple form

    • Add Metadata Selection Step with ObjectsTable that allows any type of metadata

    • Add Instance Selection Step with a multiselector

    • Add Save Step with a Summary of the Sync Rule to save in the dataStore

  • Update dropdown to allow hiding default value and fixing bug where it goes off-screen

  • Move getValueForCollection method to utils and re-use it in the new components

  • Fix bug in datastore that crashed when searching in non-strings

  • Add a new list by id logic method that does not require knowing the metadata type

  • Allow setting the fields when accessing the metadata endpoint

🎨 Screenshots

image

image

image

image

image

image

image

image

image

🔥 Is there anything the reviewer should know to test it?

📑 Others

@SferaDev SferaDev changed the base branch from development to feature/refactor June 13, 2019 06:43
@SferaDev SferaDev changed the title Feature/sync rules Implement Sync Rules Jun 13, 2019
@SferaDev SferaDev self-assigned this Jun 13, 2019
@SferaDev SferaDev changed the base branch from feature/refactor to development June 27, 2019 07:44
@SferaDev SferaDev requested review from tokland and adrianq June 27, 2019 08:50
Copy link
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

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

Works nicely! Some comments:

name: this.props.d2.models["dataElement"].displayName,
id: this.props.d2.models["dataElement"].name,
},
];
Copy link
Contributor

Choose a reason for hiding this comment

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

If the structure name/id won't change, we could do it programmatically in a loop.

Copy link
Contributor

@tokland tokland Jun 28, 2019

Choose a reason for hiding this comment

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

I guess the idea was to keep the same structure in the app and DB So let's do this only if it really makes sense to reduce the size of the persisted object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in another PR, we might extract the models altogether and pass them as a prop

src/components/rules-creation-page/steps/SaveStep.jsx Outdated Show resolved Hide resolved
src/models/syncRule.ts Show resolved Hide resolved
src/models/syncRule.ts Outdated Show resolved Hide resolved
@SferaDev SferaDev requested a review from tokland June 28, 2019 18:13
...this.syncRule.builder,
targetInstances,
},
});
Copy link
Contributor

@tokland tokland Jul 1, 2019

Choose a reason for hiding this comment

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

Cool! I know at the beginning it feels cumbersome, but in my experience it pays off, on the long run, to have fully immutable models. By the way, this kind of boilerplate for nested updates can be simplified using lodash.fp, (_.set), but please don't change it, the method is not fully typed and we lose safety. There is a functional pattern to work with nested structures called "lenses". For TS, this is the best I know: https://github.com/utatti/lens.ts. Again, don't change it, just as a note, it's perfectly fine as it is, with just a level of nesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WIll take a look on this lenses concept!

@adrianq
Copy link
Member

adrianq commented Jul 1, 2019

First of all, let me say that this incredible work! Thanks for this. A few minor comments (some of them already discussed):

  • List of target instances should display as separated commas list
  • Left click on a row forward to the edit feature. While in the other sync section it goes to Details. Although in latest versions of DHIS2 the first option is the implemented one, in general, unless you have a strong opinion in a different sense I will choose 'Details' as the left click action.
  • Remove asterisk and use compulsory fields instead
  • If you click on 'Clear Selection' probably is better to clear up all the filters (including the selected checkbox) and refresh, right?

I am merging this anyway as it is a huge PR and I don't want to postpone it anymore. Feel free to create issues if you agree with my comments or let me know otherwise!

@adrianq adrianq merged commit db09be9 into development Jul 1, 2019
@SferaDev SferaDev deleted the feature/sync-rules branch July 1, 2019 22:19
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.

Implement sync rules
3 participants