truecoach / ember-fit-form Goto Github PK
View Code? Open in Web Editor NEWA flexible component for form state management with data model adapters
License: MIT License
A flexible component for form state management with data model adapters
License: MIT License
According to the ember guides https://cli.emberjs.com/release/advanced-use/project-layouts/
Addons should only use the classic structure for compatibility with either classic or pods-based consuming applications.
ember-fit-form has it's main fit-form component strucutred as a pod, rather than the classic layout. Any consuming app that uses a pod-module-prefix will be unable to resolve the fit-form component.
Suggested Fix:
addon
├── components/fit-form
├── template.hbs
└── component.js
should become
addon
├── components
| └── fit-form.js
├── templates
└── components/fit-form.hbs
The adapterName
should be configurable from the config
file. It will still default to ember-changeset
and be configurable from the component invocation level.
Right now only the ember-changeset
adapter is tested. We will want to add tests for ember-data
adapter prior to releasing this addon.
The build is failing due to a test that is failing.
Unit | Component | form-adapters/ember-changeset/ember-changeset-validations > with a model with validations > validate the form: validating an invalid form fails the validation step
---
actual: >
false
expected: >
true
message: >
oninvalid was called
This appears to be due to this change in ember-changeset poteto/ember-changeset#378
It seems like something changed around how promises are handled within validations, and either the tests or the implementation for the ember-changeset adapter are not handling those validation promises correctly.
My best guess is that our base adapter's validate method is not itself promise aware, so when the test awaits the form validate there is no promise to await and the test finishes before the async validation code finishes and has a chance to call the oninvalid
method.
https://github.com/truecoach/ember-fit-form/blob/master/addon/form-adapters/base.js#L47
https://github.com/truecoach/ember-fit-form/blob/master/tests/unit/components/form-adapters/ember-changeset-test.js#L149
Document the currently supported form adapters and their default behavior
Consuming applications and addons do not benefit from the application initializer when running integration tests. We need an easy to use solution for consuming apps to test with ember-fit-form
Would be sweet to add blueprints for a custom adapter.
See https://github.com/poteto/ember-metrics/tree/master/blueprints
FitFormComponent.reopenClass({
positionalParams: 'models' /* remove ['models'] */
});
The default behavior for form.cancel()
is similar to the HTMLFormElement.reset()
method which restores a form element's default values.
The reset event fires when a <form>
is reset. The reset() method resets the values of all elements in a form (same as clicking the Reset button).
This allows us to handle the reset
event the same way we handle submit
event, without relying on custom cancel
logic and handlers
reset(event) {
event.preventDefault();
this.get('formObject').reset(...arguments);
},
submit(event) {
event.preventDefault();
this.get('formObject').submit(...arguments);
},
Fire the oninvalid hook after a form is validated and the result is an invalid form
The default form-adapter should be the base
adapter.
This ensures that all addon users update their default adapter in the config file.
The present component integration tests use the ember-changeset
adapter. Let's update the tests to use the base
adapter only.
I like what ember-changeset
has done for an API index. This would be great here.
https://github.com/poteto/ember-changeset#api
Each form-adapter
has default onevent
actions which can be overridden at component invocation. Let's document the default behavior for each adapter. This will also help guide the "Custom Adapter" section when we're ready to add that.
There's a philosophy that addons should have a liberal library version for dependencies, and applications should have strict dependencies.
The instance.last.{isError,isSuccessful}
API was added in https://github.com/machty/ember-concurrency/releases/tag/0.8.0 so let's make that the minimum e-c version
Presently a form is considered invalid
when the onvalidate
hook returns a rejected Promise.
Let's consider a form as invalid
when the onvalidate
hook returns a rejected Promise OR false
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.