Created
February 10, 2016 17:23
-
-
Save Mariusio/f6eb0fcb66fd37231423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deleteVisualizations: function() { | |
return new Promise((resolve, reject) => { | |
this.get('visualizations').then((visualizations) => { | |
// Initiate array to store IDs and types of visualizations to be removed | |
var arr = []; | |
visualizations.forEach((visualization, index, visualizations) => { | |
var id = visualization.get('id'); | |
var modelName = visualization.get('constructor.modelName'); | |
var newArr = [] | |
newArr.pushObject(modelName); | |
newArr.pushObject(id); | |
arr.pushObject(newArr); | |
}); | |
// Iterate over newly created array and remove each element | |
arr.forEach((element) => { | |
var record = this.store.peekRecord(element[0], element[1]); | |
this.store.unloadRecord(record); | |
}); | |
resolve(); | |
}); | |
}); | |
}, | |
deleteInactiveVisualizations: function() { | |
return new Promise((resolve, reject) => { | |
this.get('visualizations').filterBy('active', false).then((visualizations) => { | |
// Initiate array to store IDs and types of visualizations to be removed | |
var arr = []; | |
visualizations.forEach((visualization, index, visualizations) => { | |
var id = visualization.get('id'); | |
var modelName = visualization.get('constructor.modelName'); | |
var newArr = [] | |
newArr.pushObject(modelName); | |
newArr.pushObject(id); | |
arr.pushObject(newArr); | |
}); | |
// Iterate over newly created array and remove each element | |
arr.forEach((element) => { | |
var record = this.store.peekRecord(element[0], element[1]); | |
this.store.unloadRecord(record); | |
}); | |
resolve(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment