Blame view

ihm/app/controller/Times/TimesManager.js 833 Bytes
346b85c6   Benjamin Renard   First commit with...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Ext.define('treps.controller.Times.TimesManager', {
	singleton : true,

        constructor: function() {
        },

	loadTimesStore: function(onAfterLoad) {
		var me = this;

		var store = this.getTimesStore();

		if (store != null)
			store.removeAll();
		else
			store = Ext.create('treps.store.Times');

		store.load(
			{
				scope: me,
				callback: function(records, operation, success)
				{
					if (!success)
					{
						treps.Messages.showError("Cannot get times list");
						return;
					}

					if (onAfterLoad != null)
						onAfterLoad.call(me,store);
				}
			});	
	},

	getTimesStore : function()
	{
		return Ext.getStore('TimesStore');;
	},

	getFirstTimeId : function()
	{
		var store = this.getTimesStore();
		if ((store != null) && (store.count() > 0))
			return store.getAt(0).get("id");
		return "";
	}
});