yapplabs / ember-buffered-proxy

An Ember Proxy the enables change buffering
MIT License
166 stars 31 forks source link

Using with ember-cp-validations #22

Closed elatonsev closed 8 years ago

elatonsev commented 8 years ago

I use BufferedProxy on my forms for buffering changes before save and want to use ember-cp-validations https://github.com/offirgolan/ember-cp-validations for validating them.

I can't use model validation, because values are setting to buffer first, so I trying to extend BufferedProxy object with Validations.

import BufferedProxy from 'ember-buffered-proxy/proxy';

const Validations = buildValidations({...});
let UserBuffer = BufferedProxy.extend(Validations);

From their doc: "To lookup validators, container access is required which can cause an issue with Ember.Object creation if the object is statically imported."

So I need to pass a container as first parameter.

UserBuffer.create(
     getOwner(this).ownerInjection(),
     { content: this.get('user') } // user is model object
);

It works well with normal ObjectProxy let UserBuffer = Ember.ObjectProxy.extend(Validations);

but don't with BufferedProxy let UserBuffer = BufferedProxy.extend(Validations);

Guys from ember-cp-validations advised me to ask you https://github.com/offirgolan/ember-cp-validations/issues/135

lukemelia commented 8 years ago

Off the top of my head, I'm not sure. If there is something we can do to make BufferedProxy behave better with the validations plugin, I'm happy to review a PR. Unfortunately, I don't have time to dig in deeper right now.

behnoodk commented 8 years ago

@elatonsev I had the same problem as you and found this cool addon: https://github.com/simplabs/ember-validated-form-buffer I hope it helps you.

elatonsev commented 8 years ago

@behnoodk Thanks for link, sounds interesting, I'll explore it. But anyway I forced it to work with this fix without any extensions.