Skip to content

Conversation

@lionel-bijaoui
Copy link
Member

@lionel-bijaoui lionel-bijaoui commented Jun 20, 2018

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature: Allow for HTML in the label and hint field
  • What is the current behavior? (You can also link to an open issue here)
    Text only for label and hint
  • What is the new behavior (if this is a feature change)?
    Full html for label and hint
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No
  • Other information:

Build on top of the v3 branch

This work is following the changes introduced in my latest PR and should be merged only after that.
If my PR #465 is rejected, I will cherry-pick the necessary commit, deal with the conflicts and remake this PR. This will take me time for nothing, so I hope #465 will be accepted and merged.
I did that to simplify the work for the v3 features and rework.
By introducing some of these changes right now, I hope to prepare the code for the future.

New component

Part of formGenerator.vue was put inside another component. The necessary changes were made and the test changed to fit the new structure.
It should be almost transparent to the user, except if they used complicated way to access the fields from <vue-form-components> (eg. with ref like this.$refs.vfg.children[0]). And even then, I tried to make it as transparent as possible.

Doing without Pug

As you may notice, this PR is not using Pug for the new component.
I propose we stop using Pug in the future and that we slowly remove it.
Here are the reason why :

  • ESlint doesn't work in Pug template, so we get no lintting from eslint-plugin-vue
  • Pug can be a barrier to entry to collaborator as they need to learn (or know) this specific syntax to help
  • Pug is not bringing new functionnlity/solution (vue template are dynamic enough and Emmet is a thing)
  • To use Pug, we need additionnal plugin/parser/linter to be installed (can introduce problem/incompatibility)

zoul0813 and others added 30 commits December 1, 2017 17:40
…problems in fieldCheckbox.spec tests related to the updates ...
…ling, removed "checkbox" test from fieldInput,
…ages for each field to allow for more extensive testing, examples and documentation on each
* master:
  fix bower.json validation
  updated tests for modified label logic
  don't render labels when no label text is provided, proposed option 1 from vue-generators#347
* feature/345-debounced-validate-fix:
  remove uniqueId import
  fixes vue-generators#345 - declare debouncedValidateFunc and set it when debouncedValidate() is called... vue 2.2.0 prevents you from attaching methods/properties to components that have not been declared
* feature/345-debounced-validate-fix:
  removed console.log and fixed quotes
…n of the config files. Now use Prettier, so most files are will need to be updated to validate. This is stil an early WIP.

Known bugs: validation is broken since rewritten in without "module.exports"
# Conflicts:
#	dist/vfg-core.css
#	dist/vfg-core.js
#	dist/vfg.css
#	dist/vfg.js
#	package-lock.json
#	package.json
#	src/fields/abstractField.js
#	src/fields/core/fieldInput.vue
#	src/fields/core/fieldSelect.vue
#	src/fields/core/fieldSubmit.vue
#	src/formGenerator.vue
#	src/utils/validators.js
#	test/unit/specs/util.js
Update to Webpack 3. Almost all dependency are updated.
…upport for other named sets) attributes to elements to support dynamic attributes (such as `title="Tooltip Text" data-toggle="tooltip"`, etc)

* added directive to abstractField
* implemented directive in various core fields as an example of usage
* updated basic/app.vue with samples
zoul0813 and others added 8 commits March 14, 2018 10:38
V3: updated abstractField and fieldImage to clean up test errors
* v3:
  added brackets to conditional
  cleaned up the "clean up"
…ic-html-attributes

V3: dynamic html attributes
# Conflicts:
#	.travis.yml
#	dist/vfg-core.css
#	dist/vfg-core.js
#	dist/vfg.css
#	dist/vfg.js
#	package-lock.json
#	package.json
#	src/fields/core/fieldInput.vue
#	src/fields/core/fieldSubmit.vue
#	src/fields/core/fieldUpload.vue
#	src/fields/optional/fieldSwitch.vue
#	src/formGenerator.vue
Allow HTML for label & hint
@lionel-bijaoui lionel-bijaoui requested review from cristijora, dflock, icebob and zoul0813 and removed request for icebob and zoul0813 June 20, 2018 09:57
" * vue-form-generator v" +
version +
"\n" +
" * https://github.com/icebob/vue-form-generator\n" +
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the old URL - it's now here: https://github.com/vue-generators/vue-form-generator/


filters: {
prettyJSON: function(json) {
export default {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably call this file dev/mixins/utils.js

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm changing that no problem

package.json Outdated
],
"repository": {
"type": "git",
"url": "https://github.com/icebob/vue-form-generator.git"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is wrong too.

"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"semi": true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know the existing codebase is like this, but it'd be nice at some point to remove some of these Prettier options - not now, though :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Why remove the options ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally prefer less indentation and less semicolons ¯\_(ツ)_/¯

Copy link
Member Author

Choose a reason for hiding this comment

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

With Prettier, everything is done automatically. Even if you write your code a certain way, Prettier format it to this way on save (add semicolons, fix indentation). You don't have to change your habits and it allow for an unified way of writing.
I based myself on the existing code. The indentation is arbitrary, but I have a strong opinion about semicolons. A missing semicolons can cause a bug in some cases, too much semicolons cannot. Also, while parser can understand js without semi, it is not the recommended way to write js (https://stackoverflow.com/questions/444080/do-you-recommend-using-semicolons-after-every-statement-in-javascript).

Copy link
Member

Choose a reason for hiding this comment

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

I’d rather there be too many semis than not enough. /opinion

@@ -1,116 +1,117 @@
<template>
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': containPips, 'contain-tooltip': containTooltip }"></div>
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': containPips, 'contain-tooltip': containTooltip }"></div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This not getting v-attributes?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't think about it. Since fields will be separated from the main project (in the v3), I'm not touching them too much for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

.toString()
.trim()
.toLowerCase()
// .toLowerCase()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why comment this line out?

This comment was marked as outdated.

Copy link
Member Author

@lionel-bijaoui lionel-bijaoui Jun 26, 2018

Choose a reason for hiding this comment

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

It come from that 17aba74
I'm not going to change it

// .toLowerCase()
// Spaces & underscores to dashes
.replace(/ |_/g, "-")
.replace(/ /g, "-")
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're going to change the output & meaning, change the comments to match.

Copy link
Member Author

@lionel-bijaoui lionel-bijaoui Jun 26, 2018

Choose a reason for hiding this comment

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

Again, it come from 17aba74
I'm going to make the change you suggested

.replace(/-{2,}/g, "-")
// Remove leading & trailing dashes
.replace(/^-+|-+$/g, "")
// Remove anything that isn't a (English/ASCII) letter, number or dash.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're going to change the output & meaning, change the comments to match.

Copy link
Member Author

@lionel-bijaoui lionel-bijaoui Jun 26, 2018

Choose a reason for hiding this comment

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

Again, it come from 17aba74
I'm going to make the change you suggested

// Return the slugified version of either:
return prefix + (schema.inputName || schema.label || schema.model || "")
return (
prefix +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you duplicating the slugify function in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Again, it come from 17aba74, I have no idea why there is two slightly different slugify...

package.json Outdated
"name": "vue-form-generator",
"version": "3.0.0-dev",
"description": "A schema-based form generator component for Vue.js",
"homepage": "https://github.com/icebob/vue-form-generator",
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sorry, I'm going to fix that

return (
prefix +
(schema.inputName || schema.label || schema.model || "")
// NB: This is a very simple, conservative, slugify function,
Copy link
Member

Choose a reason for hiding this comment

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

we already rely on lodash, why not just use _.kebabCase() here so it's a bit clearer and shorter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Again, I'm sorry, I have no idea why we do that. This is a good suggestion but I'm not going to implement too much changes in this PR (there is already a lot of changes). Maybe next PR ? Or v3 ?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good - we should probably do a full code review at some point and simplify whatever we can, relying on known functions with clear documentation (such as kebabCase).

Copy link
Member Author

Choose a reason for hiding this comment

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

You are absolutely right !

@lionel-bijaoui
Copy link
Member Author

@dflock @zoul0813 Thank you for your feedback. Is it better now ?

@zoul0813
Copy link
Member

This is backwards compatible with v2 correct? Should the version be 2.2.3 or 2.3.0 ... instead of 3.0.0-dev? Sorry, missed that during the initial review.

package.json Outdated
@@ -1,8 +1,8 @@
{
"name": "vue-form-generator",
"version": "3.0.0-dev",
Copy link
Member

Choose a reason for hiding this comment

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

should be 2.2.3 or 2.30 - I'm thinking 2.3.0 due to all the changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sorry. It was the v3 branch initially but I actually only made backward compatible changes. So I will call it 2.3.0, it will require npm i for all the collaborator since the test and plugin are updated, but it will change nothing for the end user. I tested it on my project without any problem and I use fairly complex custom fields, an api to generate the schema, complex dynamic functionality and they needed no changes and introduce no bug.
I might have missed something of course, but I'm pretty confident.

@lionel-bijaoui
Copy link
Member Author

@dflock That should be good

Copy link
Collaborator

@dflock dflock left a comment

Choose a reason for hiding this comment

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

lgtm!

@lionel-bijaoui lionel-bijaoui merged commit bc44da9 into vue-generators:master Jun 27, 2018
@lionel-bijaoui lionel-bijaoui deleted the Rework_and_HTML_for_label_hint branch June 27, 2018 08:04
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