+++ /dev/null
-/*\r
- * Ext JS Library 0.30\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-\r
-tx.data.ListStore = Ext.extend(Ext.data.Store, {\r
- constructor: function(){\r
- tx.data.ListStore.superclass.constructor.call(this, {\r
- sortInfo:{field: 'listName', direction: "ASC"},\r
- reader: new Ext.data.JsonReader({\r
- id: 'listId',\r
- fields: tx.data.List\r
- })\r
- });\r
- this.boundTrees = {};\r
- this.conn = tx.data.conn;\r
- this.proxy = new Ext.sql.Proxy(tx.data.conn, 'list', 'listId', this);\r
- },\r
- \r
- getName : function(id){\r
- var l = this.data.map[id];\r
- return l ? l.data.listName : '';\r
- },\r
- \r
- addList : function(name, id, isFolder, parentId){\r
- var l = this.findList(name);\r
- if(!l){\r
- var id = id || Ext.uniqueId();\r
- l = new tx.data.List({listId: id, listName: name, isFolder: isFolder === true, parentId: parentId || 'root'}, id);\r
- this.add(l);\r
- }\r
- return l;\r
- },\r
- \r
- newList : function(isFolder, parentId){\r
- var i = 1;\r
- var text = isFolder ? 'New Folder ' : 'New List '; \r
- while(this.findList(text + i)){\r
- i++;\r
- }\r
- return this.addList(text + i, undefined, isFolder, parentId);\r
- },\r
- \r
- findList : function(name){\r
- var d = this.data;\r
- for(var i = 0, len = d.length; i < len; i++){\r
- if(d.items[i].data.listName === name){\r
- return d.items[i];\r
- }\r
- }\r
- return null;\r
- },\r
- \r
- loadDemoLists: function(){\r
- this.addList('Personal', 'personal', true, 'root');\r
- this.addList('Family', 'family', false, 'personal');\r
- this.addList('Bills', 'bills', false, 'personal');\r
- this.addList('Fun', 'fun', false, 'personal');\r
- this.addList('Other Stuff', 'personal-misc', false, 'personal');\r
- this.addList('Work', 'work', true, 'root');\r
- this.addList('Ext 2.x', 'ext2', false, 'work');\r
- this.addList('Ext 1.x', 'ext1', false, 'work');\r
- this.addList('Meetings', 'meetings', false, 'work');\r
- this.addList('Miscellaneous', 'work-misc', false, 'work');\r
- },\r
- \r
- bindTree : function(tree){\r
- this.boundTrees[tree.id] = {\r
- add: function(ls, records){\r
- var pnode = tree.getNodeById(records[0].data.parentId);\r
- if(pnode){\r
- pnode.reload();\r
- }\r
- },\r
- \r
- remove: function(ls, record){\r
- var node = tree.getNodeById(record.id);\r
- if(node && node.parentNode){\r
- node.parentNode.removeChild(node);\r
- }\r
- },\r
- \r
- update: function(ls, record){\r
- var node = tree.getNodeById(record.id);\r
- if(node){\r
- node.setText(record.data.listName);\r
- }\r
- }\r
- };\r
- \r
- this.on(this.boundTrees[tree.id]);\r
- },\r
- \r
- unbindTree : function(tree){\r
- var h = this.boundTrees[tree.id];\r
- if (h) {\r
- this.un('add', h.add);\r
- this.un('remove', h.remove);\r
- this.un('update', h.update);\r
- }\r
- },\r
- \r
- prepareTable : function(){\r
- try{\r
- this.createTable({\r
- name: 'list',\r
- key: 'listId',\r
- fields: tx.data.List.prototype.fields\r
- });\r
- }catch(e){console.log(e);}\r
- }\r
-});\r