-
Notifications
You must be signed in to change notification settings - Fork 531
Rework and html for label & hint #467
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
Rework and html for label & hint #467
Conversation
…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
update to vue 2.5.9
…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
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
build/webpack.build.config.js
Outdated
| " * vue-form-generator v" + | ||
| version + | ||
| "\n" + | ||
| " * https://github.com/icebob/vue-form-generator\n" + |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the options ?
There was a problem hiding this comment.
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 ¯\_(ツ)_/¯
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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> | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
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, "-") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 + |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right !
|
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", | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@dflock That should be good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Feature: Allow for HTML in the label and hint field
Text only for label and hint
Full html for label and hint
No
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.vuewas 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 likethis.$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 :