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

Entity generator does not create relationship dropdowns #57

Closed
mraible opened this issue Oct 4, 2018 · 5 comments
Closed

Entity generator does not create relationship dropdowns #57

mraible opened this issue Oct 4, 2018 · 5 comments

Comments

@mraible
Copy link
Contributor

mraible commented Oct 4, 2018

I created a new entity called Points with the following JDL:

entity BloodPressure {
  timestamp ZonedDateTime required,
  systolic Integer required,
  diastolic Integer required
}
entity Weight {
  timestamp ZonedDateTime required,
  weight Double required
}
entity Points {
  date LocalDate required,
  exercise Integer,
  meals Integer,
  alcohol Integer,
  notes String maxlength(140)
}
entity Preferences {
  weeklyGoal Integer required min(10) max(21),
  weightUnits Units required
}

enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}
relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

In my JHipster app, there's a User drop-down on the add/edit screen.

screen shot 2018-10-04 at 3 09 51 pm

In my React Native app, there is no drop-down.

screen shot 2018-10-04 at 3 26 05 pm

@ruddell
Copy link
Member

ruddell commented Oct 5, 2018

Some work tonight:

  • enums 7ebf03a
  • add User "entity" reducer/saga/tests (generated from a fake User.json) 454589c
  • initial relationship support 07e4125
    • Fixed ZonedDateTime entities

I tested your JDL and all of your entities now work as expected (used JWT though so hopefully OAuth2 works). I also added a mapper method for the entity to/from the form value. This lets you use those boolean Switches for the Points entity.

Remaining issues:

  • Handle DTOs
  • Don't generate code for non-owner side entities

@mraible
Copy link
Contributor Author

mraible commented Oct 5, 2018

Good stuff @ruddell! I tested it out this morning and found a couple of issues:

  1. The entityToFormValue() and formValueToEntity() methods are missing the id, so editing an entity results in a new one being created.
  2. Does the React Native UI allow deleting entities? I don't see that option.
  3. It does solve the issue of using toggles for integers. However, when I change a toggle from false to true and click save, the screen shows the toggle changing back to false before it saves. The value is saved correctly, but it's a weird visual.

Here's the code I'm using:

  entityToFormValue = (value) => {
    if (!value) {
      return {}
    }
    return {
      id: value.id || null,
      date: value.date || null,
      exercise: value.exercise === 1 ? true : false,
      meals: value.meals === 1 ? true : false,
      alcohol: value.alcohol === 1 ? true : false,
      notes: value.notes || null,
      userId: (value.user && value.user.id) ? value.user.id : null
    }
  }
  formValueToEntity = (value) => {
    return {
      id: value.id || null,
      date: value.date || null,
      exercise: (value.exercise) ? 1 : 0,
      meals: (value.meals) ? 1 : 0,
      alcohol: (value.alcohol) ? 1 : 0,
      notes: value.notes || null,
      user: {
        id: value.userId || null
      }
    }
  }

toggle weirdness

@ruddell
Copy link
Member

ruddell commented Oct 6, 2018

Thanks for the tips. I'll try to finish this up this weekend.

  1. Easy fix
  2. I noticed that last night. The reducer is there but no button to actually delete an entity.
  3. I'm guessing the value is being reset to the original in componentWillReceiveProps, should be a simple fix

It looks like I also should add a SafeAreaView for iPhone X support.

ruddell added a commit that referenced this issue Oct 7, 2018
ruddell added a commit that referenced this issue Oct 7, 2018
flash of old value on update submit
missing id in form/entity mapper
ruddell added a commit that referenced this issue Oct 7, 2018
@mraible
Copy link
Contributor Author

mraible commented Oct 8, 2018

@ruddell Can this issue be closed now?

@ruddell
Copy link
Member

ruddell commented Oct 8, 2018

Ya the relationship dropdown is mostly working, I added the remaining issues to a list in #38

@ruddell ruddell closed this as completed Oct 8, 2018
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

No branches or pull requests

2 participants