]> git.proxmox.com Git - extjs.git/blame - extjs/classic/classic/src/grid/ViewDropZone.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / src / grid / ViewDropZone.js
CommitLineData
6527f429
DM
1/**\r
2 * @private\r
3 */\r
4Ext.define('Ext.grid.ViewDropZone', {\r
5 extend: 'Ext.view.DropZone',\r
6\r
7 indicatorHtml: '<div class="' + Ext.baseCSSPrefix + 'grid-drop-indicator-left" role="presentation"></div><div class="' + Ext.baseCSSPrefix + 'grid-drop-indicator-right" role="presentation"></div>',\r
8 indicatorCls: Ext.baseCSSPrefix + 'grid-drop-indicator',\r
9\r
10 handleNodeDrop : function(data, record, position) {\r
11 var view = this.view,\r
12 store = view.getStore(),\r
13 index, records, i, len;\r
14\r
15 // If the copy flag is set, create a copy of the models\r
16 if (data.copy) {\r
17 records = data.records;\r
18 data.records = [];\r
19 for (i = 0, len = records.length; i < len; i++) {\r
20 data.records.push(records[i].copy());\r
21 }\r
22 } else {\r
23 /*\r
24 * Remove from the source store. We do this regardless of whether the store\r
25 * is the same bacsue the store currently doesn't handle moving records\r
26 * within the store. In the future it should be possible to do this.\r
27 * Here was pass the isMove parameter if we're moving to the same view.\r
28 */\r
29 data.view.store.remove(data.records, data.view === view);\r
30 }\r
31\r
32 if (record && position) {\r
33 index = store.indexOf(record);\r
34\r
35 // 'after', or undefined (meaning a drop at index -1 on an empty View)...\r
36 if (position !== 'before') {\r
37 index++;\r
38 }\r
39 store.insert(index, data.records);\r
40 }\r
41 // No position specified - append.\r
42 else {\r
43 store.add(data.records);\r
44 }\r
45\r
46 // Select the dropped nodes\r
47 view.getSelectionModel().select(data.records);\r
48\r
49 // Focus the first dropped node.\r
50 view.getNavigationModel().setPosition(data.records[0]);\r
51 }\r
52});