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