Blame view

js/lib/ext-override.js 6.53 KB
b39df83c   Benjamin Renard   Correction of a r...
1
/**
16035364   Benjamin Renard   First commit
2
3
4
 * Project  : AMDA-NG4
 * Name     : ext-override.js
 * @file     ext-override.js
b39df83c   Benjamin Renard   Correction of a r...
5

16035364   Benjamin Renard   First commit
6
7
8
9
10
11
12
 * @brief   patches for extjs
 * @author  elena (sencha support)
 * @version $Id: ext-override.js 2345 2014-05-13 09:06:43Z elena $
 *******************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 *  :           :16/06/2011 : elena  -  creation
b39df83c   Benjamin Renard   Correction of a r...
13
 *
16035364   Benjamin Renard   First commit
14
15
 */

b39df83c   Benjamin Renard   Correction of a r...
16
Ext.onReady(function () {
8cc08c31   Benjamin Renard   Fix columns resiz...
17
18
19
20
21
22
23
24
25
26
27
28
29

  // Fix for #7096
  Ext.override(Ext.dd.DragTracker, {
    constrainModes: {
      point: function (me, xy) {
        var dr = me.dragRegion,
        constrainTo = me.getConstrainRegion();

        if (!constrainTo) {
          return xy;
        }
        dr.x = dr.left = dr[0] = dr.right = xy[0];
        dr.y = dr.top = dr[1] = dr.bottom = xy[1];
b39df83c   Benjamin Renard   Correction of a r...
30
31
        if (!me.gridBugFix)
          dr.constrainTo(constrainTo);
8cc08c31   Benjamin Renard   Fix columns resiz...
32
33

        return [dr.left, dr.top];
b39df83c   Benjamin Renard   Correction of a r...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
      },
      // Constrain the dragTarget to within the constrain region. Return the passed xy adjusted by the same delta.
      dragTarget: function(me, xy) {
        var s = me.startXY,
          dr = me.startRegion.copy(),
          constrainTo = me.getConstrainRegion(),
          adjust;
          // No constraint
          if (!constrainTo) {
            return xy;
          }
          // See where the passed XY would put the dragTarget if translated by the unconstrained offset.
          // If it overflows, we constrain the passed XY to bring the potential
          // region back within the boundary.
          dr.translateBy(xy[0] - s[0], xy[1] - s[1]);
          // Constrain the X coordinate by however much the dragTarget overflows
          if (dr.right > constrainTo.right) {
            xy[0] += adjust = (constrainTo.right - dr.right);
            // overflowed the right
            dr.left += adjust;
          }
          if (dr.left < constrainTo.left) {
            xy[0] += (constrainTo.left - dr.left);
          }
          // overflowed the left
          // Constrain the Y coordinate by however much the dragTarget overflows
          if (dr.bottom > constrainTo.bottom) {
            xy[1] += adjust = (constrainTo.bottom - dr.bottom);
            // overflowed the bottom
            dr.top += adjust;
          }
          if (dr.top < constrainTo.top) {
            xy[1] += (constrainTo.top - dr.top);
          }
          // overflowed the top
          return xy;
        }
8cc08c31   Benjamin Renard   Fix columns resiz...
71
72
    }
  });
b39df83c   Benjamin Renard   Correction of a r...
73
74

// for version 4.1.3 - corrected in 4.2.2
16035364   Benjamin Renard   First commit
75
76
77
78
79
80
81
  /*Ext.override(Ext.grid.RowNumberer, {
     renderer: function(value, metaData, record, rowIdx, colIdx, store) {
        var rowspan = this.rowspan;
        if (rowspan){
            metaData.tdAttr = 'rowspan="' + rowspan + '"';
        }

b39df83c   Benjamin Renard   Correction of a r...
82
83
        metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';

16035364   Benjamin Renard   First commit
84
85
86
        return store.indexOf(record) + 1;
    }
  });*/
b39df83c   Benjamin Renard   Correction of a r...
87
88

//TODO check if needed for  version 4.1.3,  4.2.2
16035364   Benjamin Renard   First commit
89
90
91
92
93
94
95
96
    /*Ext.override(Ext.view.Table, {
      onUpdate : function(store, record, operation, changedFieldNames) {
        var me = this,
            index,
            newRow, oldRow,
            oldCells, newCells, len, i,
            columns, overItemCls,
            isHovered, row;
b39df83c   Benjamin Renard   Correction of a r...
97
98

        if (me.rendered) {
16035364   Benjamin Renard   First commit
99
100
101
102
103
104
            index = me.store.indexOf(record);
            columns = me.headerCt.getGridColumns();
            overItemCls = me.overItemCls;

            // If we have columns which may *need* updating (think lockable grid child with all columns either locked or unlocked)
            // and the changed record is within our view, then update the view
b39df83c   Benjamin Renard   Correction of a r...
105

16035364   Benjamin Renard   First commit
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
            if (columns.length && index > -1) {
                newRow = me.bufferRender([record], index)[0];
                oldRow = me.all.item(index);
		if (oldRow){
                isHovered = oldRow.hasCls(overItemCls);
                oldRow.dom.className = newRow.className;
                if(isHovered) {
                    oldRow.addCls(overItemCls);
                }

                // Replace changed cells in the existing row structure with the new version from the rendered row.
                oldCells = oldRow.query(this.cellSelector);
                newCells = Ext.fly(newRow).query(this.cellSelector);
                len = newCells.length;
                // row is the element that contains the cells.  This will be a different element from oldRow when using a rowwrap feature
                row = oldCells[0].parentNode;
                for (i = 0; i < len; i++) {
                    // If the field at this column index was changed, replace the cell.
                    if (me.shouldUpdateCell(columns[i], changedFieldNames)) {
                        row.insertBefore(newCells[i], oldCells[i]);
                        row.removeChild(oldCells[i]);
                    }
                }
		}
                // Maintain selection after update
                // TODO: Move to approriate event handler.
                me.selModel.refresh();
                me.doStripeRows(index, index);
                me.fireEvent('itemupdate', record, index, newRow);
            }
        }
       }
      });*/
b39df83c   Benjamin Renard   Correction of a r...
139
140

//TODO check if needed for  version 4.1.3,  4.2.2
16035364   Benjamin Renard   First commit
141
142
143
144
   /*Ext.override(Ext.ZIndexManager, {
      tempHidden: [],
      show: function() {
	var comp, x, y;
b39df83c   Benjamin Renard   Correction of a r...
145

16035364   Benjamin Renard   First commit
146
147
148
	while (comp = this.tempHidden.shift()) {
	  x = comp.x;
	  y = comp.y;
b39df83c   Benjamin Renard   Correction of a r...
149

16035364   Benjamin Renard   First commit
150
151
152
	  comp.show();
	  comp.setPosition(x,y);
      }
b39df83c   Benjamin Renard   Correction of a r...
153
154
    }
    });
98a79839   Elena.Budnik   anomalie 4830
155

7ac3e07e   Elena.Budnik   do not check user...
156
    Ext.override(Ext.selection.TreeModel, {
b39df83c   Benjamin Renard   Correction of a r...
157

7ac3e07e   Elena.Budnik   do not check user...
158
	onRowClick: function (view, record, item, index, e) {
b39df83c   Benjamin Renard   Correction of a r...
159
		// Record index will be -1 if the clicked record is a metadata record and not selectable
7ac3e07e   Elena.Budnik   do not check user...
160
  		if (index !== -1) {
b39df83c   Benjamin Renard   Correction of a r...
161
162
			if (!this.allowRightMouseSelection(e)) {
				return ;
7ac3e07e   Elena.Budnik   do not check user...
163
			}
b39df83c   Benjamin Renard   Correction of a r...
164

7ac3e07e   Elena.Budnik   do not check user...
165
166
167
168
			//Don't process if it's a right-click over a previously selected record.
			// if (!(e.type === 'contextmenu' && this.isSelected(record))) {
				this.processSelection(view, record, item, index, e);
			// }
b39df83c   Benjamin Renard   Correction of a r...
169
		}
7ac3e07e   Elena.Budnik   do not check user...
170
171
172
	}
    });
	Ext.override(Ext.selection.Model, {
16035364   Benjamin Renard   First commit
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
		storeHasSelected: function(record) {
			var store = this.store,
				records,
				len, id, i;

			if (record.hasId() && store.getById(record.getId())) {
				return true;
			} else {
				if (store.buffered) {//on buffered stores the map holds the data items
	                records = [];
	                for (m in store.data.map) {
	                    records = records.concat(store.data.map[m].value);
	                }
	            } else {
	                records = store.data.items;
	            }
				len = records.length;
				id = record.internalId;

				for (i = 0; i < len; ++i) {
					if (id === records[i].internalId) {
						return true;
					}
				}
			}
			return false;
		}
5d15649f   Benjamin Renard   Migration to ExtJ...
200
	});*/
b39df83c   Benjamin Renard   Correction of a r...
201
});