]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This class manages columns in a `Dashboard`. The primary role here is the `defaultType`\r | |
3 | * config which points to `Ext.dashboard.Panel` and the self-destruct mechanism to get\r | |
4 | * rid of empty columns.\r | |
5 | * @protected\r | |
6 | */\r | |
7 | Ext.define('Ext.dashboard.Column', {\r | |
8 | extend: 'Ext.container.Container',\r | |
9 | xtype: 'dashboard-column',\r | |
10 | \r | |
11 | requires: [\r | |
12 | 'Ext.layout.container.Anchor',\r | |
13 | 'Ext.dashboard.Panel'\r | |
14 | ],\r | |
15 | \r | |
16 | layout: 'anchor',\r | |
17 | \r | |
18 | isDashboardColumn : true,\r | |
19 | \r | |
20 | defaultType: 'dashboard-panel',\r | |
21 | \r | |
22 | cls: Ext.baseCSSPrefix + 'dashboard-column',\r | |
23 | \r | |
24 | synthetic: true, // not user-defined\r | |
25 | \r | |
26 | onRemove: function (dashPanel, isDestroying) {\r | |
27 | var me = this,\r | |
28 | ownerCt = me.ownerCt,\r | |
29 | remainingSiblings,\r | |
30 | numRemaining,\r | |
31 | totalColumnWidth = 0,\r | |
32 | i;\r | |
33 | \r | |
34 | // If we've just emptied this column.\r | |
35 | if (ownerCt && me.items.getCount() === 0) {\r | |
36 | // Collect remaining column siblings of the same row, when this one has gone.\r | |
37 | remainingSiblings = Ext.Array.filter(ownerCt.query('>' + me.xtype+ '[rowIndex=' + me.rowIndex + ']'), function(c){\r | |
38 | return c !== me;\r | |
39 | });\r | |
40 | numRemaining = remainingSiblings.length;\r | |
41 | \r | |
42 | // If this column is not destroyed, then remove this column (unless it is the last one!)\r | |
43 | if (!me.destroying && !me.destroyed) {\r | |
44 | ownerCt.remove(me);\r | |
45 | \r | |
46 | // Down to just one column; it must take up full width\r | |
47 | if (numRemaining === 1) {\r | |
48 | remainingSiblings[0].columnWidth = 1;\r | |
49 | }\r | |
50 | // If more than one remaining sibling, redistribute columnWidths proportionally so that they\r | |
51 | // still total 1.0\r | |
52 | else {\r | |
53 | for (i = 0; i < numRemaining; i++) {\r | |
54 | totalColumnWidth += remainingSiblings[i].columnWidth || 0;\r | |
55 | }\r | |
56 | for (i = 0; i < numRemaining; i++) {\r | |
57 | remainingSiblings[i].columnWidth = remainingSiblings[i].columnWidth / totalColumnWidth;\r | |
58 | }\r | |
59 | }\r | |
60 | \r | |
61 | // Needed if user is *closing* the last portlet in a column as opposed to just dragging it to another place\r | |
62 | // The destruction will not force a layout\r | |
63 | if (isDestroying) {\r | |
64 | ownerCt.updateLayout();\r | |
65 | }\r | |
66 | }\r | |
67 | }\r | |
68 | }\r | |
69 | });\r |