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

Auto data session 3 (do not merge) #214

Closed
wants to merge 9 commits into from
Closed

Conversation

joelanman
Copy link
Contributor

@joelanman joelanman commented Jun 8, 2016

This version of automatically storing and showing data across pages does not rely on macros, but instead using the checked function directly (see examples below). I'm not sure it's as user-friendly as the version with macros, but it may take a while to finalise our approach to macros.

Usage

This will make the kit automatically store all data from forms, for use later in your prototype.

For example if you have an input like this:

<input name="firstName">

You can put this on the next page, or any other page:

<p>Hello {{firstName}}</p>

Population

To populate a text field with the value a user entered is simple:

<input name="firstName" value="{{firstName}}">

To set radios or checkboxes use this:

{{ checked(name, value) }}

Using the name and value of the input. For example:

<input type="radio" name="over18" value="Yes" {{checked("over18","Yes")}}>

<input type="checkbox" name="sendSpam" value="No" {{checked("sendSpam","No")}}>

@joelanman joelanman force-pushed the auto-data-session-3 branch 2 times, most recently from b1d93f7 to 85681fb Compare June 10, 2016 10:00

});
</script>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better for this to live in its own file? eg prototype-kit-js.js or something? scripts.html doesn't feel right.

@joelanman joelanman force-pushed the auto-data-session-3 branch from 917e5a3 to 84dae6c Compare June 12, 2016 09:41
@htmlandbacon
Copy link
Contributor

Did a test on this, and it is working 👍🏻

Vehicle features
</td>
<td>
{{vehicleFeatures}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good for this to include 'change' links.

Is it worth having a further page in the tutorial that shows how you can use the data to enable pre-checked answers - I'm not sure the capability would be obvious to users.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have more than one checkbox selected, they are output without a space between them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeh its just the default representation of an array. We could add a filter like:

features: a,b,c
features | formatList: a, b and c

@joelanman joelanman force-pushed the auto-data-session-3 branch from 97e9a40 to b511397 Compare June 13, 2016 15:22
if (env === 'production' && useHttps === 'true'){
app.use(utils.forceHttps);
}
nj.addGlobal("checked",function(name, value){
Copy link
Contributor

Choose a reason for hiding this comment

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

This addGlobal function seems rather spaced out compared to the rest of the stuff in this page - does it need so many linebreaks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed some whitespace

@joelanman joelanman force-pushed the auto-data-session-3 branch 2 times, most recently from 58decbc to 443b16a Compare June 13, 2016 15:27
@joelanman joelanman force-pushed the auto-data-session-3 branch from 443b16a to 82fae5c Compare June 13, 2016 15:28
@edwardhorsford
Copy link
Contributor

Looking good! This PR (a long time coming) brings a load of benefits. Thanks for all your hard work on it.

A few comments:

  • In your worked examples would be good to demonstrate / communicate that you can use it for preselecting answers. I know the pages have it, but i'm not sure it's obvious you can use the data like that (for a new user).
  • I know it's mentioned in the first page, but it would be good if a later part of the tutorial mentions clearing data - potentially with a screenshot of the link
  • Would be good to mention what to name your variable if you don't want data stored.

The last two could potentially be done on a further tutorial page?

@joelanman
Copy link
Contributor Author

One issue I know of is this doesn't support populating select tags (though storing the data will work fine). Do we care about that? Our guidance is not to use them, though there may be some cases where it's unavoidable (legacy reasons for example)

@edwardhorsford
Copy link
Contributor

@joelanman presumably it would be theoretically possible to support select tags? if so I think it would be ok to launch this pr but raise an issue to extend it to select tags.

@joelanman
Copy link
Contributor Author

yeh it wouldn't be hard at all, similar to checked but returning "selected" or ""

@timpaul timpaul added in progress and removed ready labels Oct 17, 2016
@joelanman joelanman changed the title Auto data session 3 Auto data session 3 (do not merge) Nov 25, 2016
@joelanman joelanman mentioned this pull request Jan 11, 2017
@joelanman
Copy link
Contributor Author

closing in favour of #340

@joelanman joelanman closed this Mar 25, 2017
@kr8n3r kr8n3r deleted the auto-data-session-3 branch November 6, 2018 09:06
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.

4 participants