The TaskLogList
and TaskLogForm
views require stores to function. The TaskLogList
view requires a TaskLog
store, while the TaskLogForm
view requires a Project
and a Task
store. Let's define them now.
We define this store with a helper method to allow easy loading for the task log searches. The definition is as follows:
Ext.define('TTT.store.TaskLog', { extend: 'Ext.data.Store', requires: ['TTT.model.TaskLog'], model: 'TTT.model.TaskLog', proxy: { type: 'ajax', url: 'taskLog/findByUser.json', reader: { type: 'json', root: 'data' } }, doFindByUser: function(username, startDate, endDate) { this.load({ params: { username: username, startDate: Ext.Date.format(startDate, 'Ymd'), endDate: Ext.Date.format(endDate, 'Ymd') } }); } });
Note that we are formatting the start and end dates in the doFindByUser
method using the Ext.Date.format
function. This is to ensure that the dates sent to the server are in the expected 8-digit yyyymmdd
format.
The Project
store will be sorted to achieve the required company name grouping that is displayed in the Project combobox:
Ext.define('TTT.store.Project', { extend: 'Ext.data.Store', requires: ['TTT.model.Project'], model: 'TTT.model.Project', sorters: [{ property: 'companyName', direction: 'ASC' }, { property: 'projectName', direction: 'ASC' }], proxy: { type: 'ajax', url: 'project/findAll.json', reader: { type: 'json', root: 'data' } } });
Note that all the project records will be loaded by the project/findAll.json
URL that is mapped to the findAll
method in the ProjectHandler
Java class. The sorters
property configures the sorting routine that will be applied to the results after loading the store. The records will first be sorted by the companyName
field in the ascending order after which the projectName
field will be used to apply a secondary sort.
The Task store has a very simple structure. The following definition should hold no surprises for you:
Ext.define('TTT.store.Task', { extend: 'Ext.data.Store', requires: ['TTT.model.Task'], model: 'TTT.model.Task', proxy: { type: 'ajax', url:'task/findAll.json', reader: { type: 'json', root: 'data' } } });
All the task records will be loaded by the task/findAll.json
URL that is mapped to the findAll
method in the TaskHandler
Java class.
3.147.74.211