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

EZP-30904: UDW: Sorting settings are ignored for starting location #209

Merged

Conversation

SerheyDolgushev
Copy link
Contributor

Please check https://jira.ez.no/browse/EZP-30904 for more details.

@SerheyDolgushev SerheyDolgushev changed the base branch from master to 1.5 August 29, 2019 19:23
@SerheyDolgushev
Copy link
Contributor Author

Sorry, not sure if failed checks have some relation to this PR

this.props.loadLocation(
{ ...this.props.restInfo, locationId: this.props.startingLocationId },
(response) => {
this.startingLocation = response.View.Result.searchHits.searchHit[0].value.Location;
Copy link
Member

Choose a reason for hiding this comment

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

I think this will fail if startingLocationId will be 1. In this case, there is no location.

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked changes locally and I have TypeError: Cannot read property 'value' of undefined for startingLocationId: 1; for others it works.

@SerheyDolgushev
Copy link
Contributor Author

@dew326 @tischsoic can you please check it one more time? startingLocationId: 1 is fixed now. I`m very open to suggestions to make JS code simpler/better looking.

@SerheyDolgushev
Copy link
Contributor Author

And the latest commit fixed the failed checks.

{ ...this.props.restInfo, parentLocationId: this.props.startingLocationId },
this.updateLocationsData
);
this.handleRootLocations();
Copy link
Member

Choose a reason for hiding this comment

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

I would name this handleStartingLocation()

* @method loadRootLocations
* @memberof FinderComponent
*/
loadRootLocations() {
Copy link
Member

Choose a reason for hiding this comment

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

loadChildren

* @memberof FinderComponent
*/
loadRootLocations() {
const sortClauses = this.getLocationSortClauses(this.startingLocation);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const sortClauses = this.getLocationSortClauses(this.startingLocation);
const sortClauses = this.getLocationSortClauses(this.startingLocation);

*/
handleRootLocations() {
// Starting location is already loaded or its default
if (this.startingLocation.id === this.props.startingLocationId) {
Copy link
Member

Choose a reason for hiding this comment

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

Please define a const with the root id, and check if this.props.startingLocationId === ROOT_LOCATION_ID
const ROOT_LOCATION_ID = 1

handleRootLocations() {
// Starting location is already loaded or its default
if (this.startingLocation.id === this.props.startingLocationId) {
this.loadRootLocations();
Copy link
Member

Choose a reason for hiding this comment

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

The this.setDefaultActiveLocations(); should be moved here as well.

this.props.loadLocation(
{...this.props.restInfo, locationId: this.props.startingLocationId},
(response) => {
if (response.View.Result.searchHits.searchHit[0].value.Location) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (response.View.Result.searchHits.searchHit[0].value.Location) {
if (response.View.Result.searchHits.searchHit.length) {

{...this.props.restInfo, locationId: this.props.startingLocationId},
(response) => {
if (response.View.Result.searchHits.searchHit[0].value.Location) {
this.startingLocation = response.View.Result.searchHits.searchHit[0].value.Location;
Copy link
Member

Choose a reason for hiding this comment

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

Here we should not introduce a new variable but use the activeLocations state and add it to the state.

@@ -186,10 +225,13 @@ export default class FinderComponent extends Component {
* @memberof FinderComponent
*/
onLoadMore(parentLocation) {
if (parentLocation === null) {
Copy link
Member

Choose a reason for hiding this comment

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

if you will add the location to the activeLocations changes in this method are not needed.

@SerheyDolgushev
Copy link
Contributor Author

SerheyDolgushev commented Aug 30, 2019

@dew326 1208669 implements all requested changes except getting rid of startingLocation variable. Had some issues with replacing it with activeLocations (please note JavaScript is not my strongest skill).

Could you please do the following changes (I hope for you it will take much less time then for me):

  1. Get rid for startingLocation, and use activeLocations for that
  2. Adjust loadChildren and onLoadMore, so they will use the data from activeLocations variable instead of activeLocations (maybe activeLocations[0])?

Alternatively, this PR could be merged, as it fixes the bug. And startingLocation variable could be fixed during further refactorings?

@dew326
Copy link
Member

dew326 commented Aug 30, 2019

@SerheyDolgushev could you take a look and try it on your installation? It works for me but maybe I forgot some edge case.

@SerheyDolgushev
Copy link
Contributor Author

@dew326 just checked on my installation and looks fine

@dew326
Copy link
Member

dew326 commented Aug 30, 2019

Ok, so we will finish the review and start QA.

@katarzynazawada katarzynazawada self-assigned this Sep 2, 2019
@lserwatka lserwatka merged commit 16089c3 into ezsystems:1.5 Sep 2, 2019
@lserwatka
Copy link
Member

@tischsoic could you merge it up?

@tischsoic
Copy link
Contributor

Merged up:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants