iw/static/js/store/FavoriteWikis.js

33 lines
982 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Ext.define('IW.store.FavoriteWikis', {
extend: 'Ext.data.Store',
model: 'IW.model.FavoriteWiki',
autoLoad: false,
proxy: {
type: 'rest',
url: '/api/favoritewikis',
reader: {
type: 'json',
successProperty: 'success'
},
writer: {
type: 'json'
}
},
listeners: {
'load' : function(favorites,records,options) {
// This is loaded, so fire event to update all the favorite attributes on Wikis
var wikis = Ext.data.StoreManager.lookup('Wikis');
wikis.each(function(wiki) {
favorites.each(function(favorite) {
if (wiki.id==favorite.id) {
wiki.set("Favorite", true)
} else {
wiki.set("Favorite", false)
}
});
});
}
}
});