Releases: pixelhandler/ember-jsonapi-resources
updateResource and rollbacks
Add Resource#rollback
- Revert to previous attributes
- Reset tracked changed/previous attrs
The more common use case is to just call the updateResource method vs. auto-update
- No more magic calls to the adapters' updateResource method via attributeChanged events
- If developers want to use the events they can define the behavior based on the attributeChanged event
- Added example behavior to dummy app for updateResource and rollback on fail
Fixup addon afterInstall
- Installs bower and npm dependencies now
You will need to uninstall and re-install ember-jsonapi-resources
npm uninstall ember-jsonapi-resources --save-dev
ember install ember-jsonapi-resources
Simpler Initializer
- [BREAKING] use default factory names instead of pluralized, e.g. use
model:post
notmodel:posts
- Remove injections from initializer blueprint; use standard names for modules, e.g.
serializer:post
,adapter:post
, etc. - Fix model blueprint to use plural foreign model name when generating with relation, e.g.
ember g jsonapi-resource author name:string posts:has-many:posts
Almost done
- Update to Ember CLI v1.13.13 and Ember 2.2.0
- Update cache handling for updates, remove evented update callbacks
- (Breaking change) Removing event triggers didUpdateResource and resourceError
- Cache update after updating a resource (PATCH) is handled by model method, via cacheUpdate
- Support (client, 40x) text error response, parse text to JSON
Blueprints Redux
- Changed all the blueprints to use a prefix
jsonapi-
so they do not redefine the default blueprints. - Added support for generating import paths for pod structure when using the
--pod
argument with a generator
Example use:
ember generate jsonapi-resource article title:string version:number author:has-one:user --pod
The arguments are passed to the jsonapi-model blueprint so that attrs, has-one, and has-many computed properties can be generated.
Resource: relationships update & isNew behavior
isNew
resource uses mock relation in proxy relationship hasOne/hasMany- Add Update Relationship method to Resource prototype
- Add header for credentials in fetch options (support for cookie session)
When a resource isNew has a true value (default is false) the resource does not yet have any URLs from the server. Since it's the server's job to inform that client of the relationship URLs a new resource will only use the resource identifier objects. The new Resource#updateRelationships object manages changes to the relationships data object(s).
By using the Resource#updateRelationship method you may update a relation by adding or removing using a list, id, or null. When adding an id for a to-many relation send one or more ids, include the existing ids as well. When removing from a to-many relation pass the ids that should remain, missing ids will be removed, or remove all with an empty array. When operating on a to-one relation just use the id to change the relation, or null to remove.
Transform Attributes by type or name
- Add transform methods for [de]serializing resource attributes, See #42
- The TransformsMixin defines
serializeDateAttribute
anddeserializeDateAttribute
- Built in transform method to serialize and deserialize the date(time) to/from ISO Format for use with
attr('date')
- Built in transform method to serialize and deserialize the date(time) to/from ISO Format for use with
- Any valid attribute type (string, boolean, number, object, array, date) can be added to your app, just generate a transforms mixin and define other types if needed, and use the type when defining a resource attribute, e.g.
attr('array')
- The methods use a naming convention '[de]serialize' + 'AttrName' or 'TypeName' + 'Attribute'
- E.g. use
serializeNameAttribute
anddeserializeNameAttribute
in a generated serializer for use withname: attr()
- E.g. use
- Transform methods based on the name of the attribute will be called instead of any transform methods based on the type of the attribute
Optional type for attr() util
- 'string', 'number', 'boolean', 'date', 'object', 'array' may be set as the
type
of attribute - Reorganize modules for Resource helpers into utilities
Relation Options and Polymorphic Associations
- Add support for polymorphic association in a resource
- Add options argument for findOne/findMany helpers
- FetchError passes original error or default message
hasOne
and hasMany
Relationship helpers may use a String argument for the relation name, as found in the relationship object of the JSON payload. Helpers may instead use an Object argument with properties for relation and type (type is different service) to use for fetching resource relations.
Ember 2.0.0 Update, patch for serializer
- Update bower dependency for Ember to 2.0.0
- Serializer creates resource with only available props from payload