Skip to content

create native HTML5 fields #50

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

Closed
13 tasks done
icebob opened this issue Aug 25, 2016 · 26 comments
Closed
13 tasks done

create native HTML5 fields #50

icebob opened this issue Aug 25, 2016 · 26 comments

Comments

@icebob
Copy link
Member

icebob commented Aug 25, 2016

Because currently there is no vanilla datetime picker. Pickaday is only date selector.

  • create new field common type which has a "inputType" property. (break changes)
  • rename datetime field to datetimePicker (break changes)
  • rename slider field to rangeSlider (break changes)
  • update docs (add new radio values description)

Available types

  • date
  • datetime
  • datetime-local
  • time
  • month
  • week

Other HTML5 types

  • url
  • tel
  • radio

Set this inputType to the field type attributes:

input( :type="schema.inputType")
@icebob icebob changed the title create native HTML5 date, datetime, time fields create native HTML5 "date", "datetime", "time" fields Aug 25, 2016
@icebob icebob changed the title create native HTML5 "date", "datetime", "time" fields create native HTML5 date fields Aug 25, 2016
@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 1, 2016

Same thing should be done with slider field. It should be renamed "ion.rangeSlider" or "rangeSlider".
Also a "radio" field ! Switch is cool, but sometime you need more the 2 values.
And "tel" for a native masked/cleave for phone number only.
Last one is "url".
I would also like to point out that we need more HTML5 attributes:

  • autofocus
  • inputmode
  • selectionDirection
  • spellcheck

specific to text, search, tel, url or email:

  • pattern
  • size (also for password)

💥 More HTML5! 💥

@icebob
Copy link
Member Author

icebob commented Sep 1, 2016

HTML5 range is exist as fieldRange. I added the other types to the tasklist.

what is the size attr?

@icebob icebob changed the title create native HTML5 date fields create native HTML5 fields Sep 1, 2016
@lionel-bijaoui
Copy link
Member

Yeah, sorry I forgot to remove that sentence.

size
The initial size of the control. This value is in pixels unless the value of the type attribute is text or password, in which case, it is an integer number of characters. Starting in HTML5, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password; otherwise it is ignored. In addition, the size must be greater than zero. If you don't specify a size, a default value of 20 is used. HTML5 simply states "the user agent should ensure that at least that many characters are visible", but different characters can have different widths in certains fonts; in some browsers, a certain string with x characters will not be entirely visible even if size is defined to at least x.

Source

I think the goal for v1.0.0 is to have all attributes exposed for native HTML5 fields.

@icebob
Copy link
Member Author

icebob commented Sep 2, 2016

I think, the size is not neccessary, because the default width is 100%. So it is overwrite the size attr.
And you can change the width via styleClasses property in schema

@lionel-bijaoui
Copy link
Member

Yes, but if you change the width via styleClasses and then, you may want to use it for some reason. I mean, it don't cost much to add, why not add it just in case someone needs it ?

@lionel-bijaoui
Copy link
Member

@icebob We need a radio field, right ?

@icebob
Copy link
Member Author

icebob commented Sep 6, 2016

Yes, I added to the list.

@lionel-bijaoui
Copy link
Member

I'm going to work on a html5 field based on input( :type="schema.inputType")
One field for all native input.
Check the html5 branch on the doc.

@icebob
Copy link
Member Author

icebob commented Sep 11, 2016

good solution, thanks!

@icebob
Copy link
Member Author

icebob commented Sep 12, 2016

I'm unsure with the inputType property. Currently easy and straightforward to create a simple text field in the schema:

{
  type: "text",
  label: "Name",
  model: "name"
}

but after this feature, it will be more complex and harder to read:

{
  type: "html5",
  inputType: "text",
  label: "Name",
  model: "name"
}

So I think would be good to stay the current format. But need to rewrite the getFieldType part: https://github.com/icebob/vue-form-generator/blob/master/src/formGenerator.vue#L108

It would be smarter. So it will try to search the field by the exact name (fieldText). If not found use the common html5 field and set the type to inputType.

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 12, 2016

I have a counter arguments: putting them under the "html5" umbrella avoid collision with other potential field name, especially since custom fields exist.
It also simplify the documentation. HTML are well documented already, not need to explicitly redo it for each field.
We only provide a shell for them and potentially future new HTML input fields.

Also most other fields use special properties already and it is not a big problem.

Maybe the name should change from "html5" to "native" "input" ?

{
  type: "input", // more explicit
  inputType: "text",
  label: "Name",
  model: "name"
}

EDIT
I prefer to be explicit and not rely on a search function to determine the field type. It will add logic in multiple place, take a bit longer and could lead to unexpected behavior.

This fields is particular, because it is an interface to the native input elements. I understand that it change a bit different from what you have done so far, but I really believe my proposal is the best way to handle this.
It will give people more control.
The other fields (text, email, number, etc) can coexist[1] for now, and maybe map type: "test" to type: "html5", inputType: "text" if you really think this is necessary.

[1] I think we need to deprecate them and maybe remove them from 1.0.0

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 14, 2016

@icebob I have edited my answer, I really hope I was able to convince you 😄. I will soon do a PR (still need test) with my proposal, but it will use a new feature of github which allow you to modify directly my PR if you need to.
EDIT: #70

@icebob
Copy link
Member Author

icebob commented Sep 14, 2016

I welcomed this new github feature. I think it is neccessary for contribution.

  1. I don't want to reject my thoughts about searching, because it will affect only one function. I will try it.
  2. My other confusion is the html5 type (Now I see you wrote it too). I think we need to change this field type to input instead of html5

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 20, 2016

Ok since #70 is done, what's left is:

  • a radio thing
  • rename datetime field to datetimePicker (break changes)
  • rename slider field to rangeSlider (break changes)

I'm going to start with the renaming, since it is fast and easy

@icebob
Copy link
Member Author

icebob commented Sep 20, 2016

Great!

I updated first post, plus added "update docs" task

@lionel-bijaoui
Copy link
Member

Ok, now are left radio thing and docs work.
@icebob Do you think you could give me a little help with the doc ? or you don't have free time ?
I understand if you don't have free time, this information will simply help me evaluate the time needed.

@icebob
Copy link
Member Author

icebob commented Sep 22, 2016

Nice! Thank you.
Sorry, but currently I can't help, because I have a lot of work in my full-time job :(
I hope one week and I will be more active with VFG 😄

Btw: are we need radio field? Because It is useless if there is only one radio button. Need a list for multiple radio button, but to handle list we have many select* fields.

@lionel-bijaoui
Copy link
Member

No pb, I understand. Maybe you could add me as a collaborator ? If you don't feel like it, I perfectly understand, this is your project and you have complete control over it.

I'm going to create a "radio**s**" field ;)
It will be close to "checklist" in a way, but sometime, you really need radio inputs.

@icebob
Copy link
Member Author

icebob commented Sep 22, 2016

A while ago, I'm thinking that I add you as a collaborator. Because you have a lot of hard work to improve this component, what I thank you.
But I want to controlling the direction of development. So I will add you, but I will need to approve the PRs before merge, that I can check the changes, ok?

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 22, 2016

No problem, I would not like to push thing without your validation anyway :)
I'm mainly going to use the kanboard and tag issues.
Thank you for your trust.

@icebob
Copy link
Member Author

icebob commented Sep 26, 2016

@lionel-bijaoui Are you working anything from this issue?

@lionel-bijaoui
Copy link
Member

Yes, I'm on the "radios" field. I can do a PR tomorrow if you want to help (I very busy at work lately).
You could do the docs if you can.

@icebob
Copy link
Member Author

icebob commented Sep 26, 2016

Ok, I updated docs in html5 branch.

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Sep 27, 2016

@icebob #80 I do the unit test and it's done
EDIT: Done and merged ! I'm going to update the doc.
Get ready to create a new release :)

@lionel-bijaoui
Copy link
Member

@icebob I'm done with the doc !

@icebob
Copy link
Member Author

icebob commented Sep 27, 2016

Thanks! Tomorrow I will make the new release

@icebob icebob closed this as completed Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants