mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
Fixes labels duplicating themselves across lalbe inputs when unsaved
no issue - Unsaved labels were still persisted in the store. This was causing unsaved labels reappearing on different instances and caused broken states
This commit is contained in:
parent
6c9aad0f5b
commit
0395b63d63
@ -34,6 +34,16 @@ export default Component.extend({
|
||||
this.set('_availableLabels', this.store.peekAll('label'));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
// NOTE: cleans up labels store in case they were not persisted, this avoids unsaved labels
|
||||
// from appearing on different input instances when unsaved
|
||||
this.get('_availableLabels').forEach((label) => {
|
||||
if (label.get('isNew')) {
|
||||
this.store.deleteRecord(label);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
matchLabels(labelName, term) {
|
||||
return labelName.toLowerCase() === term.trim().toLowerCase();
|
||||
|
@ -165,11 +165,7 @@ export default class MembersController extends Controller {
|
||||
|
||||
@task
|
||||
*fetchLabelsTask() {
|
||||
if (!this._hasLoadedLabels) {
|
||||
yield this.store.query('label', {limit: 'all'}).then(() => {
|
||||
this._hasLoadedLabels = true;
|
||||
});
|
||||
}
|
||||
yield this.store.query('label', {limit: 'all'});
|
||||
}
|
||||
|
||||
@task({restartable: true})
|
||||
|
Loading…
Reference in New Issue
Block a user