adopted-ember-addons / adopted-ember-addons/ember-data-model-fragments

Deleting an unsaved fragment from store

Offen
#298 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
367
Forks
108
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello,
I'm very sure I'm doing this incorrectly. I have a route for creating a model setup as shown:

```
export default Route.extend(AuthenticatedRouteMixin, {
model() {
return RSVP.hash({
systemDatasource: this.store.createRecord('system-datasource', {
name: null,
basePath: null,
datasourceType: null,
s3: this.store.createFragment('system-datasource-s3', {
'bucket': null,
'basePath': null,
'accessKey': null,
'secretKey': null
}),
sftp: this.store.createFragment('system-datasource-sftp', {})
}),
datasourceList: ['s3','sftp']
})
},

actions: {
discard() {
let systemDatasource = this.modelFor(this.routeName).systemDatasource;
systemDatasource.deleteRecord();
this.transitionTo('settings.system-datasources');
}
}
});
```

When I call the `discard()` method (i.e. user decides to abort creating a new object), I notice the uncommitted `system-datasource` model is removed from the store correctly.

However, the `system-datasource-s3` and `system-datasource-sftp` models are left behind:

![screen shot 2018-06-03 at 9 39 29 am](https://user-images.githubusercontent.com/330004/40887703-0cd09f66-6712-11e8-9d85-3c62da017e8c.png)

Can you kindly advise on how I can go about removing those unsaved fragments from the store? Thank you so much!

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.