ember-data

Force reload of dirty/invalid model in Ember

依然范特西╮ 提交于 2019-12-14 04:21:28
问题 I am trying to build out edit functionality for a Goal record. On the Goal index page, there is an edit button next to each goal. When clicked, each field becomes editable. Upon clicking Save, the changes are saved to the server. So far so good. There is also a Cancel button. When a user clicks it, I need to reset the state of the model to what it was before they changed things. goal.rollback() in the controller works fine for this. Except, if the user has already clicked Save but there were

Emberjs sort content by date using sortProperties

白昼怎懂夜的黑 提交于 2019-12-14 03:49:09
问题 I am trying to use Emberjs sortProperties to sort content by date in this jsfiddle . My model has a startTime property which I tried to sort by but it didn't work. I then created a computed property called todayEvent in the controller which returns events that match the passed in date and I tried to sort that but it also didn't work. All I am trying to do is list events occurring on same day but in such a way that time of the day in chich event occurs is sorted in ascending order for example,

Ember.js commiting parent model with already existing child models

元气小坏坏 提交于 2019-12-14 03:43:45
问题 Cheers! For example I have three models: App.Foo = DS.Model.extend({ bars: DS.hasMany('App.Bar', {embedded:'always'}), bazes: DS.hasMany('App.Baz', {embedded:'always'}) }); App.Bar = DS.Model.extend({ foo: DS.belongsTo('App.Foo') }); App.Baz = DS.Model.extend({ foo: DS.belongsTo('App.Foo) }); And adapter mappings like these: App.RESTSerializer = DS.RESTSerializer.extend({ init: function() { this._super(); this.map('App.Foo', { bars:{embedded: 'always'}, bazes:{embedded: 'always'} }) } }); I'm

performing rollback on model with hasMany relation

帅比萌擦擦* 提交于 2019-12-14 03:43:13
问题 I have models defined as : App.Answer = DS.Model.extend({ name: DS.attr('string'), layoutName: DS.attr('string') }); App.Question = DS.Model.extend({ name: DS.attr('string'), answers: DS.hasMany('answer', {async: true}) }); I have a component that allows for deleting and adding answers to question model. The component comes with apply and cancel button and when the user clicks on cancel, I wanted all the changes(adds/deletes of answers) to be reverted. Currently rollback doesn't do the trick,

How to stub component's action in ember?

前提是你 提交于 2019-12-14 02:24:52
问题 I created a component, whose action uses store service. How can I stub this action from integration test? // app/components/invoice-form.js export default Ember.Component.extend({ actions: { loadPartners() { let self = this; this.get('store').findAll('partner').then(function(partners) { self.set('partners', partners); }); } } }); In this component's template I pass this action as closure to child component: {{button-confirmation text="Are you sure?" onConfirm=(action "loadPartners")}} In my

Leading character stripped off of API call

試著忘記壹切 提交于 2019-12-14 01:04:46
问题 I am attempting to setup a REST model and have a problem that is completely befuddling me: the API call that is generated seems to remove the first letter of the model and therefore is unable to retrieve the data (gets 404 error). I start by setting up the store: App.Store = DS.Store.extend({ revision: 11, adapter: DS.RESTAdapter.reopen({ namespace: 'api/admin' }) }); Then I setup a model (which is referred to as "dbx_tables" on the REST service: App.dbxTable = DS.Model.extend({ name: "string

Does emberfire 1.3.2 implement findQuery method?

孤人 提交于 2019-12-13 18:22:27
问题 When I tried to load articles by simply calling this.store.find('article', { typeId: model.get('typeId') }) , I get: Error while processing route: article Assertion Failed: You tried to load a query but your adapter does not implement `findQuery` Error: Assertion Failed: You tried to load a query but your adapter does not implement `findQuery` at new Error (native) at Error.EmberError (http://localhost:4200/assets/vendor.js:21769:23) at Object.Ember.assert (http://localhost:4200/assets/vendor

Ember: route ID is lost after a transition.retry() - Am I doing something wrong?

微笑、不失礼 提交于 2019-12-13 17:57:59
问题 See JSFiddle: http://jsfiddle.net/cyclomarc/MHvrH/3/ There are a lot of samples that show how to implement authentication in Ember. To protect access to a route, you will be redirected to a login page if you do not have a valid token. After succesful login (thus after obtaining a valid token), you will be redirected to the initial requested page. Implementation: before the redirect to login, you store the requested transition in an object; after login, you read the object property and do a

Changing mouse cursor while Ember content is saving

谁都会走 提交于 2019-12-13 16:34:55
问题 I know Ember makes it quite straight forward to display an indicator on route transitions that take a long time. But what's the easiest way to do the same after a Save button is clicked, and until the save operation completes? I am not finding much on this. 回答1: Assuming based off the tag you are using ember data $('html,body').css('cursor','crosshair'); record.save().finally(function(){ // revert mouse }); http://emberjs.com/api/classes/Ember.RSVP.Promise.html#method_finally Obviously this

Nested object in `DS.attr()` isn't affected by `DS.rollbackAttributes()`

五迷三道 提交于 2019-12-13 11:35:22
问题 I have a model User as follow: import DS from 'ember-data'; const { attr, Model } = DS; export default Model.extend({ name: attr("string"), properties: attr(), }); User.properties is intended to hold a JSON object. I am updating the model through a form (using ember-one-way-controls) as follow: {{one-way-textarea model.name update=(action (mut model.name))}} {{one-way-textarea model.properties.description update=(action (mut model.properties.description))}} I have a button allowing the user