aesmail / kaffy

Powerfully simple admin package for phoenix applications
https://kaffy.fly.dev/admin/
MIT License
1.35k stars 158 forks source link

[BUG] belongs_to association is blank in form #98

Closed axelclark closed 4 years ago

axelclark commented 4 years ago

Versions Used Kaffy: 0.8.1 Phoenix: 1.5.3 Elixir: 1.10.3

What's actually happening? In my Ex338 project, fantasy_team belongs_to association is blank in the form for owners.

EDIT: After further investigation, it looks like it uses commish_notes which is the first string alphabetically, but is blank for all of my seed fantasy teams.

  schema "owners" do
    belongs_to(:fantasy_team, Ex338.FantasyTeams.FantasyTeam)
    belongs_to(:user, Ex338.Accounts.User)
    field(:rules, OwnerRulesEnum, default: "unaccepted")

    timestamps()
  end
  schema "fantasy_teams" do
    field(:team_name, :string)
    field(:waiver_position, :integer)
    field(:winnings_adj, :float, default: 0.0)
    field(:dues_paid, :float, default: 0.0)
    field(:winnings_received, :float, default: 0.0)
    field(:max_flex_adj, :integer, default: 0)
    field(:commish_notes, :string)
    field(:autodraft_setting, FantasyTeamAutodraftSettingEnum, default: "on")
    field(:slot_results, {:array, :map}, virtual: true, default: [])
    field(:total_seconds_on_the_clock, :integer, virtual: true, default: 0)
    field(:avg_seconds_on_the_clock, :integer, virtual: true, default: 0)
    field(:total_draft_mins_adj, :integer, default: 0)
    field(:picks_selected, :integer, virtual: true, default: 0)
    field(:over_draft_time_limit?, :boolean, virtual: true, default: false)
  end

What should happen instead? sports_league belongs_to association displays abbrev in the form for fantasy_players.

  schema "fantasy_players" do
    field(:player_name, :string)
    belongs_to(:sports_league, Ex338.FantasyPlayers.SportsLeague)
  end
  schema "sports_leagues" do
    field(:league_name, :string)
    field(:abbrev, :string)
    field(:hide_waivers, :boolean)
  end

Screenshots image

Select options are blank, but the options are generated image

image

image

axelclark commented 4 years ago

After further investigation, I don't think this is a bug. It is using the commish_notes field which is blank for all of my fantasy teams. When I add a note, it shows up in the select. However, I'd like to propose the same convention discussed in #97.

axelclark commented 4 years ago

My #99 pull request would close this issue as well since the form uses the same function.

aesmail commented 4 years ago

Perfect 👍🏼