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

Inputs form not rendered correctly (always empty) #4

Open
qhwa opened this issue Jan 13, 2022 · 8 comments
Open

Inputs form not rendered correctly (always empty) #4

qhwa opened this issue Jan 13, 2022 · 8 comments

Comments

@qhwa
Copy link

qhwa commented Jan 13, 2022

First of all, thanks for the library, it's awesome!
I watched your talk on ElixirConf 2021 and I was amazed. Fortunately, I got a chance to give it a try now.

However, when I followed the README document and my input definition doesn't work.

The issue

My module is quite simple:

defmodule MyApp.Chores.MyChore do
  use ChoreRunner.Chore

  def input do
    [
      string(:platform)
    ]
  end
  
  def run(inputs) do
    log(["hi, I'm running, inputs:", inspect(inputs)])
    :ok
  end
end

Expected behavior

An input form that allows me to enter some text.

Actual behavior

The input form in the UI is empty and the logged inputs value is always %{}.

The cause

After some digging, I found that actually, the function name should be inputs (plural form).
I changed the name to inputs and it now works.

So, I think in the README, it should be inputs/0 instead of input/0, and we can add @impl true before these callback functions so that the compiler can help validate the names.

Thanks!

@cigzigwon
Copy link

@cjfreeze I thought this would save me time... Can you please update docs?

@cjfreeze
Copy link
Contributor

cjfreeze commented Feb 6, 2022

Sorry for the outdated docs @cigzigwon and @qhwa, the project had a lull in activity but is picking back up. That documentation is already set to be updated in PR #5 so this issue will be fixed within a few days 🙂. We're finally starting to see some active use of the library so plenty of improvements will be added as we work towards a 1.0 release

@cigzigwon
Copy link

@cjfreeze O.K. It's a sticky sitch for me anyhow... I'm a new entrant to LiveView coming from a 1.5.3... So now that ChoreRunner loads in the LiveUI loads but doesn't include any live connection event handling.... I don't have a frontend so what's missing??

@cigzigwon
Copy link

Got it! Need to switch to .heex templates and then set the root LayoutView in Router. This works great for me since we tossed out the entire front end at the beginning of the project so we can just re-implement the little JS hooks via libs in NPM.

https://hexdocs.pm/phoenix_live_view/installation.html

@cigzigwon
Copy link

@cjfreeze We appreciate you for this! It's working now. We needed to rip out the web crawler control tools away from our product team due to growth. We used to have logging and controls together... Now they only get logging unless of courese they are cranted access to the ChoreRunnerUI views. We used the JS snippet from the above sample and tosed it into our UI build/compile chain.

@cjfreeze
Copy link
Contributor

cjfreeze commented Feb 7, 2022

Got it! Need to switch to .heex templates and then set the root LayoutView in Router. This works great for me since we tossed out the entire front end at the beginning of the project so we can just re-implement the little JS hooks via libs in NPM.

https://hexdocs.pm/phoenix_live_view/installation.html

Are there any documentation improvements that we could make to help with this issue you think?

@cigzigwon
Copy link

@cjfreeze You just need to mention that the runner does not ship w/client side JS that is required in that link. If they follow that guide they will hit everything they need to make ChoreRunner work.

@cjfreeze
Copy link
Contributor

cjfreeze commented Feb 8, 2022

That would be a good disclaimer to include, thank you for the feedback!

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

3 participants