Last active
August 29, 2015 13:57
-
-
Save MihailoJoksimovic/9348276 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
onSimulateOrdersClick: function(article) { | |
console.log("Simulating for article:"); | |
console.log(article); | |
var me = this; | |
var articleId = article.get('article_id'); | |
// First we have to load All data about article before proceeding any further. | |
this.setCenterContentLoadingMask(true); | |
/****************** | |
e ovo dole sto sam iskomentovao article.on(article.FULL_DATA..... je 2x palilo loadOrders..... | |
***************/ | |
//article.on(article.FULL_DATA_LOADED_EVENT, function() { | |
var simulationsStore = Ext.create('Staging.store.OrderSimulationsStore'); | |
// This event fires when data has been loaded | |
simulationsStore.on('DataLoaded', function() { | |
Ext.getStore('OrderSimulationStatsByYearStore').on('DataLoaded', function() { | |
me.removeAllCenterContent(); | |
me.setCenterContentLoadingMask(false); | |
var v = Ext.create('Staging.view.Simulation', { | |
article: article, | |
orderSimulationsStore: simulationsStore, | |
orderSimulationStatsByYearStore: Ext.getStore('OrderSimulationStatsByYearStore') | |
}); | |
me.getCenterContent().add(v); | |
}); | |
Ext.getStore('OrderSimulationStatsByYearStore').on('DataLoadingError', function() { | |
me.setCenterContentLoadingMask(false); | |
}); | |
// Load data that will be used for drawing chart | |
Ext.getStore('OrderSimulationStatsByYearStore').loadForArticle(articleId); | |
}); | |
simulationsStore.on('NoDataAvailable', function() { | |
me.setCenterContentLoadingMask(false); | |
Ext.defer(function() { | |
Ext.Msg.alert(Translations.errorOccured, Translations.noSimulationsDataForArticle); | |
}, 200); | |
}); | |
simulationsStore.on('DataLoadingError', function() { | |
me.setCenterContentLoadingMask(false); | |
console.log('DataLoadingError'); | |
Ext.defer(function() { | |
Ext.Msg.alert(Translations.errorOccured, Translations.unknownErrorOccurred); | |
}, 200); | |
}); | |
simulationsStore.loadForArticle(articleId); | |
}, this, { single: true} ); | |
article.on(article.FULL_DATA_LOADING_ERROR, function() { | |
Ext.Msg.alert(Translations.errorOccured, Translations.unableToLoadSelectedArticleData); | |
me.setCenterContentLoadingMask(false); | |
}); | |
article.loadFullData(); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment