jsl-ui 9.28.2 → 9.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/IntervalComponent.d.ts +17 -17
- package/lib/components/IntervalComponent.js +65 -68
- package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +22 -22
- package/lib/components/auto-suggest/AutoSuggestComponent.js +47 -49
- package/lib/components/button/ButtonComponent.d.ts +18 -18
- package/lib/components/button/ButtonComponent.js +29 -46
- package/lib/components/checkbox/CheckBoxComponent.d.ts +28 -28
- package/lib/components/checkbox/CheckBoxComponent.js +81 -98
- package/lib/components/date/DateComponent.d.ts +32 -32
- package/lib/components/date/DateComponent.js +89 -106
- package/lib/components/date-range/DateRangeComponent.d.ts +35 -35
- package/lib/components/date-range/DateRangeComponent.js +123 -136
- package/lib/components/date-time/DateTimeComponent.d.ts +15 -15
- package/lib/components/date-time/DateTimeComponent.js +39 -53
- package/lib/components/dialog/DialogComponent.d.ts +67 -67
- package/lib/components/dialog/DialogComponent.js +198 -251
- package/lib/components/drop-down/DropDownComponent.d.ts +27 -27
- package/lib/components/drop-down/DropDownComponent.js +60 -74
- package/lib/components/expander/ExpanderComponent.d.ts +27 -27
- package/lib/components/expander/ExpanderComponent.js +89 -90
- package/lib/components/form-field/FormComponent.d.ts +12 -12
- package/lib/components/form-field/FormComponent.js +23 -26
- package/lib/components/form-field/FormFieldComponent.d.ts +39 -39
- package/lib/components/form-field/FormFieldComponent.js +138 -140
- package/lib/components/grid/GridComponent.d.ts +26 -26
- package/lib/components/grid/GridComponent.js +110 -116
- package/lib/components/input/InputComponent.d.ts +33 -33
- package/lib/components/input/InputComponent.js +126 -147
- package/lib/components/loading/LoadingComponent.d.ts +8 -8
- package/lib/components/loading/LoadingComponent.js +20 -22
- package/lib/components/navigation/NavigationComponent.d.ts +34 -34
- package/lib/components/navigation/NavigationComponent.js +45 -70
- package/lib/components/notification/Notification.d.ts +19 -19
- package/lib/components/notification/Notification.js +65 -69
- package/lib/components/number/NumberComponent.d.ts +26 -26
- package/lib/components/number/NumberComponent.js +80 -98
- package/lib/components/overlay/OverlayComponent.d.ts +27 -27
- package/lib/components/overlay/OverlayComponent.js +137 -149
- package/lib/components/progress/ProgressComponent.d.ts +18 -18
- package/lib/components/progress/ProgressComponent.js +40 -42
- package/lib/components/ribbon-menu/RibbonMenuComponent.d.ts +12 -12
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +23 -34
- package/lib/components/select/SelectComponent.d.ts +79 -79
- package/lib/components/select/SelectComponent.js +356 -369
- package/lib/components/select/SelectDDAreaComponent.d.ts +32 -32
- package/lib/components/select/SelectDDAreaComponent.js +303 -317
- package/lib/components/slider/nouislider.d.ts +44 -44
- package/lib/components/slider/nouislider.js +2158 -2158
- package/lib/components/stack-panel/SplitterComponent.d.ts +21 -21
- package/lib/components/stack-panel/SplitterComponent.js +124 -126
- package/lib/components/stack-panel/StackPanelComponent.d.ts +20 -20
- package/lib/components/stack-panel/StackPanelComponent.js +50 -64
- package/lib/components/tabs/TabsComponent.d.ts +40 -40
- package/lib/components/tabs/TabsComponent.js +200 -204
- package/lib/components/time/TimeComponent.d.ts +29 -29
- package/lib/components/time/TimeComponent.js +104 -113
- package/lib/components/tree-view/TreeViewComponent.d.ts +23 -23
- package/lib/components/tree-view/TreeViewComponent.js +43 -45
- package/lib/components/virtual-render/VirtualRenderComponent.d.ts +30 -30
- package/lib/components/virtual-render/VirtualRenderComponent.js +92 -104
- package/lib/core/culture.d.ts +5 -5
- package/lib/core/culture.js +385 -385
- package/lib/core/date.d.ts +14 -14
- package/lib/core/date.js +346 -350
- package/lib/core/helper.d.ts +13 -13
- package/lib/core/helper.js +100 -104
- package/lib/core/jq.d.ts +37 -37
- package/lib/core/jq.js +362 -371
- package/lib/core/lang.d.ts +24 -24
- package/lib/core/lang.js +24 -28
- package/lib/core/numeric.d.ts +7 -7
- package/lib/core/numeric.js +139 -143
- package/lib/core/polyfills.js +22 -22
- package/lib/core.d.ts +6 -6
- package/lib/core.js +6 -6
- package/lib/grid/filterDialogs/dateRangeFilter.d.ts +7 -7
- package/lib/grid/filterDialogs/dateRangeFilter.js +106 -156
- package/lib/grid/filterDialogs/excelFilter.d.ts +9 -9
- package/lib/grid/filterDialogs/excelFilter.js +250 -316
- package/lib/grid/plugins/ext.overlay.d.ts +2 -2
- package/lib/grid/plugins/ext.overlay.js +295 -295
- package/lib/grid/plugins/slick.cellrangedecorator.d.ts +12 -12
- package/lib/grid/plugins/slick.cellrangedecorator.js +68 -68
- package/lib/grid/plugins/slick.cellrangeselector.d.ts +1 -1
- package/lib/grid/plugins/slick.cellrangeselector.js +144 -144
- package/lib/grid/plugins/slick.cellselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.cellselectionmodel.js +194 -194
- package/lib/grid/plugins/slick.headerbuttons.d.ts +55 -55
- package/lib/grid/plugins/slick.headerbuttons.js +156 -156
- package/lib/grid/plugins/slick.headermenu.d.ts +74 -74
- package/lib/grid/plugins/slick.headermenu.js +260 -260
- package/lib/grid/plugins/slick.rowmovemanager.d.ts +18 -18
- package/lib/grid/plugins/slick.rowmovemanager.js +249 -249
- package/lib/grid/plugins/slick.rowselectionmodel.d.ts +1 -1
- package/lib/grid/plugins/slick.rowselectionmodel.js +167 -167
- package/lib/grid/slick.core.d.ts +91 -91
- package/lib/grid/slick.core.js +574 -574
- package/lib/grid/slick.creator.d.ts +81 -81
- package/lib/grid/slick.creator.js +726 -726
- package/lib/grid/slick.dataview.d.ts +71 -71
- package/lib/grid/slick.dataview.js +1069 -1080
- package/lib/grid/slick.editors.core.d.ts +4 -4
- package/lib/grid/slick.editors.core.js +235 -235
- package/lib/grid/slick.editors.date.d.ts +2 -2
- package/lib/grid/slick.editors.date.js +125 -125
- package/lib/grid/slick.editors.lookup.d.ts +14 -14
- package/lib/grid/slick.editors.lookup.js +352 -353
- package/lib/grid/slick.editors.nav.d.ts +6 -6
- package/lib/grid/slick.editors.nav.js +22 -22
- package/lib/grid/slick.formatters.d.ts +17 -17
- package/lib/grid/slick.formatters.js +144 -144
- package/lib/grid/slick.grid.d.ts +285 -285
- package/lib/grid/slick.grid.js +5409 -5412
- package/lib/grid/slick.groupitemmetadataprovider.d.ts +39 -39
- package/lib/grid/slick.groupitemmetadataprovider.js +165 -165
- package/lib/grid/slick.tree.d.ts +33 -33
- package/lib/grid/slick.tree.js +208 -220
- package/lib/grid.css +1 -705
- package/lib/grid.d.ts +13 -13
- package/lib/grid.js +13 -13
- package/lib/index.css +8 -2195
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +56 -55
- package/lib/index.js +61 -61
- package/lib/index.js.map +1 -1
- package/lib/interaction/dataconverter.d.ts +4 -4
- package/lib/interaction/dataconverter.js +0 -1
- package/lib/interaction/eventhandler.d.ts +13 -13
- package/lib/interaction/eventhandler.js +39 -42
- package/lib/interaction/moveable.d.ts +39 -39
- package/lib/interaction/moveable.js +160 -174
- package/lib/interaction/resizable.d.ts +37 -37
- package/lib/interaction/resizable.js +109 -123
- package/lib/ui/auto.suggest.d.ts +18 -18
- package/lib/ui/auto.suggest.js +244 -259
- package/lib/ui/date.picker/date-picker-options.d.ts +11 -11
- package/lib/ui/date.picker/date-picker-options.js +76 -76
- package/lib/ui/date.picker/lib/date-manip.d.ts +74 -74
- package/lib/ui/date.picker/lib/date-manip.js +120 -120
- package/lib/ui/date.picker/lib/dom.d.ts +23 -23
- package/lib/ui/date.picker/lib/dom.js +28 -28
- package/lib/ui/date.picker/lib/emitter.d.ts +13 -13
- package/lib/ui/date.picker/lib/emitter.js +49 -49
- package/lib/ui/date.picker/lib/fns.d.ts +23 -23
- package/lib/ui/date.picker/lib/fns.js +39 -43
- package/lib/ui/date.picker/mode/base-mode.d.ts +26 -26
- package/lib/ui/date.picker/mode/base-mode.js +248 -248
- package/lib/ui/date.picker/mode/dropdown-mode.d.ts +28 -28
- package/lib/ui/date.picker/mode/dropdown-mode.js +50 -50
- package/lib/ui/date.picker/mode/index.d.ts +28 -28
- package/lib/ui/date.picker/mode/index.js +18 -18
- package/lib/ui/date.picker/mode/modal-mode.d.ts +25 -25
- package/lib/ui/date.picker/mode/modal-mode.js +17 -17
- package/lib/ui/date.picker/mode/permanent-mode.d.ts +29 -29
- package/lib/ui/date.picker/mode/permanent-mode.js +19 -19
- package/lib/ui/date.picker/views/day-picker.d.ts +40 -40
- package/lib/ui/date.picker/views/day-picker.js +155 -155
- package/lib/ui/date.picker/views/month-picker.d.ts +26 -26
- package/lib/ui/date.picker/views/month-picker.js +65 -65
- package/lib/ui/date.picker/views/year-picker.d.ts +20 -20
- package/lib/ui/date.picker/views/year-picker.js +66 -66
- package/lib/ui/date.picker.d.ts +66 -66
- package/lib/ui/date.picker.js +32 -32
- package/lib/ui/dialog.d.ts +22 -22
- package/lib/ui/dialog.js +98 -113
- package/lib/ui/drop.down.d.ts +52 -52
- package/lib/ui/drop.down.js +2112 -2112
- package/lib/ui/number.input.d.ts +13 -13
- package/lib/ui/number.input.js +56 -67
- package/package.json +1 -1
|
@@ -1,249 +1,249 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Row Move Manager options:
|
|
3
|
-
* cssClass: A CSS class to be added to the menu item container.
|
|
4
|
-
* columnId: Column definition id (defaults to "_move")
|
|
5
|
-
* cancelEditOnDrag: Do we want to cancel any Editing while dragging a row (defaults to false)
|
|
6
|
-
* disableRowSelection: Do we want to disable the row selection? (defaults to false)
|
|
7
|
-
* hideRowMoveShadow: Do we want to hide the row move shadow clone? (defaults to true)
|
|
8
|
-
* rowMoveShadowMarginTop: When row move shadow is shown, optional margin-top (defaults to 0)
|
|
9
|
-
* rowMoveShadowMarginLeft: When row move shadow is shown, optional margin-left (defaults to 0)
|
|
10
|
-
* rowMoveShadowOpacity: When row move shadow is shown, what is its opacity? (defaults to 0.95)
|
|
11
|
-
* rowMoveShadowScale: When row move shadow is shown, what is its size scale? (default to 0.75)
|
|
12
|
-
* singleRowMove: Do we want a single row move? Setting this to false means that it's a multple row move (defaults to false)
|
|
13
|
-
* width: Width of the column
|
|
14
|
-
* usabilityOverride: Callback method that user can override the default behavior of the row being moveable or not
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
import "./slick.rowmovemanager.css";
|
|
18
|
-
import { jQueryReplacement } from "../../core/jq";
|
|
19
|
-
import { Slick } from "../slick.core";
|
|
20
|
-
|
|
21
|
-
// register namespace
|
|
22
|
-
$.deepExtend(window, {
|
|
23
|
-
"Slick": {
|
|
24
|
-
"RowMoveManager": RowMoveManager
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
export function RowMoveManager(options) {
|
|
28
|
-
var _grid;
|
|
29
|
-
var _canvas;
|
|
30
|
-
var _dragging;
|
|
31
|
-
var _self = this;
|
|
32
|
-
var _usabilityOverride = null;
|
|
33
|
-
var _handler = new Slick.EventHandler();
|
|
34
|
-
var _defaults = {
|
|
35
|
-
columnId: "_move",
|
|
36
|
-
cssClass: null,
|
|
37
|
-
cancelEditOnDrag: false,
|
|
38
|
-
disableRowSelection: false,
|
|
39
|
-
hideRowMoveShadow: true,
|
|
40
|
-
rowMoveShadowMarginTop: 0,
|
|
41
|
-
rowMoveShadowMarginLeft: 0,
|
|
42
|
-
rowMoveShadowOpacity: 0.95,
|
|
43
|
-
rowMoveShadowScale: 0.75,
|
|
44
|
-
singleRowMove: false,
|
|
45
|
-
width: 40,
|
|
46
|
-
};
|
|
47
|
-
// user could override the expandable icon logic from within the options or after instantiating the plugin
|
|
48
|
-
if (options && typeof options.usabilityOverride === 'function') {
|
|
49
|
-
usabilityOverride(options.usabilityOverride);
|
|
50
|
-
}
|
|
51
|
-
function init(grid) {
|
|
52
|
-
options = $.deepExtend({}, _defaults, options);
|
|
53
|
-
_grid = grid;
|
|
54
|
-
_canvas = _grid.getCanvasNode();
|
|
55
|
-
_handler
|
|
56
|
-
.subscribe(_grid.onDragInit, handleDragInit)
|
|
57
|
-
.subscribe(_grid.onDragStart, handleDragStart)
|
|
58
|
-
.subscribe(_grid.onDrag, handleDrag)
|
|
59
|
-
.subscribe(_grid.onDragEnd, handleDragEnd);
|
|
60
|
-
}
|
|
61
|
-
function destroy() {
|
|
62
|
-
_handler.unsubscribeAll();
|
|
63
|
-
}
|
|
64
|
-
function setOptions(newOptions) {
|
|
65
|
-
options = $.shallowExtend({}, options, newOptions);
|
|
66
|
-
}
|
|
67
|
-
function handleDragInit(e) {
|
|
68
|
-
// // prevent the grid from cancelling drag'n'drop by default
|
|
69
|
-
// e.stopImmediatePropagation();
|
|
70
|
-
}
|
|
71
|
-
function handleDragStart(e, dd) {
|
|
72
|
-
var cell = _grid.getCellFromEvent(e);
|
|
73
|
-
var currentRow = cell && cell.row;
|
|
74
|
-
var dataContext = _grid.getDataItem(currentRow);
|
|
75
|
-
if (!checkUsabilityOverride(currentRow, dataContext, _grid)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (options.cancelEditOnDrag && _grid.getEditorLock().isActive()) {
|
|
79
|
-
_grid.getEditorLock().cancelCurrentEdit();
|
|
80
|
-
}
|
|
81
|
-
if (_grid.getEditorLock().isActive() || !isHandlerColumn(cell.cell)) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
_dragging = true;
|
|
85
|
-
e.stopImmediatePropagation();
|
|
86
|
-
// optionally create a shadow element of the row so that we can see all the time which row exactly we're dragging
|
|
87
|
-
if (!options.hideRowMoveShadow) {
|
|
88
|
-
var $slickRowElm = $(_grid.getCellNode(cell.row, cell.cell)).closestClass('slick-row');
|
|
89
|
-
if ($slickRowElm.length) {
|
|
90
|
-
dd.clonedSlickRow = $($slickRowElm[0].cloneNode(true))
|
|
91
|
-
.addClass('slick-reorder-shadow-row')
|
|
92
|
-
.css("marginTop", options.rowMoveShadowMarginTop || 0)
|
|
93
|
-
.css("marginLeft", options.rowMoveShadowMarginLeft || 0)
|
|
94
|
-
.css("opacity", options.rowMoveShadowOpacity || 0.95)
|
|
95
|
-
.css("transform", "scale(" + options.rowMoveShadowScale + ")")
|
|
96
|
-
.css("display", "none")
|
|
97
|
-
.appendTo(_canvas);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
var selectedRows = options.singleRowMove ? [cell.row] : _grid.getSelectedRows();
|
|
101
|
-
if (selectedRows.length === 0 || selectedRows.indexOf(cell.row) === -1) {
|
|
102
|
-
selectedRows = [cell.row];
|
|
103
|
-
if (!options.disableRowSelection) {
|
|
104
|
-
_grid.setSelectedRows(selectedRows);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
var rowHeight = _grid.getOptions().rowHeight;
|
|
108
|
-
dd.selectedRows = selectedRows;
|
|
109
|
-
|
|
110
|
-
dd.selectionProxy = $(document.createElement("div")) //"<div class='slick-reorder-proxy'/>")
|
|
111
|
-
.addClass("slick-reorder-proxy")
|
|
112
|
-
.css("position", "absolute")
|
|
113
|
-
.css("zIndex", "99999")
|
|
114
|
-
.css("width", canvasWidth) // $(_canvas).innerWidth())
|
|
115
|
-
.css("height", rowHeight * selectedRows.length)
|
|
116
|
-
.css("display", "none")
|
|
117
|
-
.appendTo(_canvas);
|
|
118
|
-
dd.guide = $(document.createElement("div")) // "<div class='slick-reorder-guide'/>")
|
|
119
|
-
.addClass("slick-reorder-guide")
|
|
120
|
-
.css("position", "absolute")
|
|
121
|
-
.css("zIndex", "99998")
|
|
122
|
-
.css("width", canvasWidth)
|
|
123
|
-
.css("top", -1000)
|
|
124
|
-
.appendTo(_canvas);
|
|
125
|
-
dd.insertBefore = -1;
|
|
126
|
-
}
|
|
127
|
-
function handleDrag(e, dd) {
|
|
128
|
-
if (!_dragging) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
// e.preventDefault();
|
|
132
|
-
e.stopImmediatePropagation();
|
|
133
|
-
var top = dd.pageY - $(_canvas).offset().top;
|
|
134
|
-
dd.selectionProxy.css("top", top - 5).css("display", ""); //.show();
|
|
135
|
-
// if the row move shadow is enabled, we'll also make it follow the mouse cursor
|
|
136
|
-
if (dd.clonedSlickRow) {
|
|
137
|
-
var offsetY = dd.pageY - $(_canvas).offset().top;
|
|
138
|
-
dd.clonedSlickRow.css("top", offsetY - 6).css("display", ""); //.show();
|
|
139
|
-
}
|
|
140
|
-
var insertBefore = Math.max(0, Math.min(Math.round(top / _grid.getOptions().rowHeight), _grid.getDataLength()));
|
|
141
|
-
if (insertBefore !== dd.insertBefore) {
|
|
142
|
-
var eventData = {
|
|
143
|
-
"grid": _grid,
|
|
144
|
-
"rows": dd.selectedRows,
|
|
145
|
-
"insertBefore": insertBefore
|
|
146
|
-
};
|
|
147
|
-
if (_self.onBeforeMoveRows.notify(eventData) === false) {
|
|
148
|
-
dd.canMove = false;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
dd.canMove = true;
|
|
152
|
-
}
|
|
153
|
-
// if there's a UsabilityOverride defined, we also need to verify that the condition is valid
|
|
154
|
-
if (_usabilityOverride && dd.canMove) {
|
|
155
|
-
var insertBeforeDataContext = _grid.getDataItem(insertBefore);
|
|
156
|
-
dd.canMove = checkUsabilityOverride(insertBefore, insertBeforeDataContext, _grid);
|
|
157
|
-
}
|
|
158
|
-
// if the new target is possible we'll display the dark blue bar (representin the acceptability) at the target position
|
|
159
|
-
// else it won't show up (it will be off the screen)
|
|
160
|
-
if (!dd.canMove) {
|
|
161
|
-
dd.guide.css("top", -1000);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
dd.guide.css("top", insertBefore * _grid.getOptions().rowHeight);
|
|
165
|
-
}
|
|
166
|
-
dd.insertBefore = insertBefore;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function handleDragEnd(e, dd) {
|
|
170
|
-
if (!_dragging) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
_dragging = false;
|
|
174
|
-
e.stopImmediatePropagation();
|
|
175
|
-
if (dd.guide == null) {
|
|
176
|
-
console.log("dd.guide");
|
|
177
|
-
}
|
|
178
|
-
else
|
|
179
|
-
dd.guide.remove();
|
|
180
|
-
if (dd.selectionProxy == null) {
|
|
181
|
-
console.log(" dd.selectionProxy");
|
|
182
|
-
}
|
|
183
|
-
else
|
|
184
|
-
dd.selectionProxy.remove();
|
|
185
|
-
if (dd.clonedSlickRow) {
|
|
186
|
-
dd.clonedSlickRow.remove();
|
|
187
|
-
dd.clonedSlickRow = null;
|
|
188
|
-
}
|
|
189
|
-
if (dd.canMove) {
|
|
190
|
-
var eventData = {
|
|
191
|
-
"grid": _grid,
|
|
192
|
-
"rows": dd.selectedRows,
|
|
193
|
-
"insertBefore": dd.insertBefore
|
|
194
|
-
};
|
|
195
|
-
// TODO: _grid.remapCellCssClasses ?
|
|
196
|
-
_self.onMoveRows.notify(eventData);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function getColumnDefinition() {
|
|
200
|
-
return {
|
|
201
|
-
id: options.columnId || "_move",
|
|
202
|
-
name: "",
|
|
203
|
-
field: "move",
|
|
204
|
-
width: options.width || 40,
|
|
205
|
-
behavior: "selectAndMove",
|
|
206
|
-
selectable: false,
|
|
207
|
-
resizable: false,
|
|
208
|
-
cssClass: options.cssClass,
|
|
209
|
-
formatter: moveIconFormatter
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function moveIconFormatter(row, cell, value, columnDef, dataContext, grid) {
|
|
213
|
-
if (!checkUsabilityOverride(row, dataContext, grid)) {
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
return { addClasses: "cell-reorder dnd", text: "" };
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function checkUsabilityOverride(row, dataContext, grid) {
|
|
221
|
-
if (typeof _usabilityOverride === 'function') {
|
|
222
|
-
return _usabilityOverride(row, dataContext, grid);
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Method that user can pass to override the default behavior or making every row moveable.
|
|
228
|
-
* In order word, user can choose which rows to be an available as moveable (or not) by providing his own logic show/hide icon and usability.
|
|
229
|
-
* @param overrideFn: override function callback
|
|
230
|
-
*/
|
|
231
|
-
function usabilityOverride(overrideFn) {
|
|
232
|
-
_usabilityOverride = overrideFn;
|
|
233
|
-
}
|
|
234
|
-
function isHandlerColumn(columnIndex) {
|
|
235
|
-
return /move|selectAndMove/.test(_grid.getColumns()[columnIndex].behavior);
|
|
236
|
-
}
|
|
237
|
-
$.shallowExtend(this, {
|
|
238
|
-
"onBeforeMoveRows": new Slick.Event(),
|
|
239
|
-
"onMoveRows": new Slick.Event(),
|
|
240
|
-
"init": init,
|
|
241
|
-
"destroy": destroy,
|
|
242
|
-
"getColumnDefinition": getColumnDefinition,
|
|
243
|
-
"setOptions": setOptions,
|
|
244
|
-
"usabilityOverride": usabilityOverride,
|
|
245
|
-
"isHandlerColumn": isHandlerColumn,
|
|
246
|
-
"pluginName": "RowMoveManager"
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// })(jQuery);
|
|
1
|
+
/**
|
|
2
|
+
* Row Move Manager options:
|
|
3
|
+
* cssClass: A CSS class to be added to the menu item container.
|
|
4
|
+
* columnId: Column definition id (defaults to "_move")
|
|
5
|
+
* cancelEditOnDrag: Do we want to cancel any Editing while dragging a row (defaults to false)
|
|
6
|
+
* disableRowSelection: Do we want to disable the row selection? (defaults to false)
|
|
7
|
+
* hideRowMoveShadow: Do we want to hide the row move shadow clone? (defaults to true)
|
|
8
|
+
* rowMoveShadowMarginTop: When row move shadow is shown, optional margin-top (defaults to 0)
|
|
9
|
+
* rowMoveShadowMarginLeft: When row move shadow is shown, optional margin-left (defaults to 0)
|
|
10
|
+
* rowMoveShadowOpacity: When row move shadow is shown, what is its opacity? (defaults to 0.95)
|
|
11
|
+
* rowMoveShadowScale: When row move shadow is shown, what is its size scale? (default to 0.75)
|
|
12
|
+
* singleRowMove: Do we want a single row move? Setting this to false means that it's a multple row move (defaults to false)
|
|
13
|
+
* width: Width of the column
|
|
14
|
+
* usabilityOverride: Callback method that user can override the default behavior of the row being moveable or not
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
import "./slick.rowmovemanager.css";
|
|
18
|
+
import { jQueryReplacement } from "../../core/jq";
|
|
19
|
+
import { Slick } from "../slick.core";
|
|
20
|
+
let $ = jQueryReplacement;
|
|
21
|
+
// register namespace
|
|
22
|
+
$.deepExtend(window, {
|
|
23
|
+
"Slick": {
|
|
24
|
+
"RowMoveManager": RowMoveManager
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export function RowMoveManager(options) {
|
|
28
|
+
var _grid;
|
|
29
|
+
var _canvas;
|
|
30
|
+
var _dragging;
|
|
31
|
+
var _self = this;
|
|
32
|
+
var _usabilityOverride = null;
|
|
33
|
+
var _handler = new Slick.EventHandler();
|
|
34
|
+
var _defaults = {
|
|
35
|
+
columnId: "_move",
|
|
36
|
+
cssClass: null,
|
|
37
|
+
cancelEditOnDrag: false,
|
|
38
|
+
disableRowSelection: false,
|
|
39
|
+
hideRowMoveShadow: true,
|
|
40
|
+
rowMoveShadowMarginTop: 0,
|
|
41
|
+
rowMoveShadowMarginLeft: 0,
|
|
42
|
+
rowMoveShadowOpacity: 0.95,
|
|
43
|
+
rowMoveShadowScale: 0.75,
|
|
44
|
+
singleRowMove: false,
|
|
45
|
+
width: 40,
|
|
46
|
+
};
|
|
47
|
+
// user could override the expandable icon logic from within the options or after instantiating the plugin
|
|
48
|
+
if (options && typeof options.usabilityOverride === 'function') {
|
|
49
|
+
usabilityOverride(options.usabilityOverride);
|
|
50
|
+
}
|
|
51
|
+
function init(grid) {
|
|
52
|
+
options = $.deepExtend({}, _defaults, options);
|
|
53
|
+
_grid = grid;
|
|
54
|
+
_canvas = _grid.getCanvasNode();
|
|
55
|
+
_handler
|
|
56
|
+
.subscribe(_grid.onDragInit, handleDragInit)
|
|
57
|
+
.subscribe(_grid.onDragStart, handleDragStart)
|
|
58
|
+
.subscribe(_grid.onDrag, handleDrag)
|
|
59
|
+
.subscribe(_grid.onDragEnd, handleDragEnd);
|
|
60
|
+
}
|
|
61
|
+
function destroy() {
|
|
62
|
+
_handler.unsubscribeAll();
|
|
63
|
+
}
|
|
64
|
+
function setOptions(newOptions) {
|
|
65
|
+
options = $.shallowExtend({}, options, newOptions);
|
|
66
|
+
}
|
|
67
|
+
function handleDragInit(e) {
|
|
68
|
+
// // prevent the grid from cancelling drag'n'drop by default
|
|
69
|
+
// e.stopImmediatePropagation();
|
|
70
|
+
}
|
|
71
|
+
function handleDragStart(e, dd) {
|
|
72
|
+
var cell = _grid.getCellFromEvent(e);
|
|
73
|
+
var currentRow = cell && cell.row;
|
|
74
|
+
var dataContext = _grid.getDataItem(currentRow);
|
|
75
|
+
if (!checkUsabilityOverride(currentRow, dataContext, _grid)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (options.cancelEditOnDrag && _grid.getEditorLock().isActive()) {
|
|
79
|
+
_grid.getEditorLock().cancelCurrentEdit();
|
|
80
|
+
}
|
|
81
|
+
if (_grid.getEditorLock().isActive() || !isHandlerColumn(cell.cell)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
_dragging = true;
|
|
85
|
+
e.stopImmediatePropagation();
|
|
86
|
+
// optionally create a shadow element of the row so that we can see all the time which row exactly we're dragging
|
|
87
|
+
if (!options.hideRowMoveShadow) {
|
|
88
|
+
var $slickRowElm = $(_grid.getCellNode(cell.row, cell.cell)).closestClass('slick-row');
|
|
89
|
+
if ($slickRowElm.length) {
|
|
90
|
+
dd.clonedSlickRow = $($slickRowElm[0].cloneNode(true))
|
|
91
|
+
.addClass('slick-reorder-shadow-row')
|
|
92
|
+
.css("marginTop", options.rowMoveShadowMarginTop || 0)
|
|
93
|
+
.css("marginLeft", options.rowMoveShadowMarginLeft || 0)
|
|
94
|
+
.css("opacity", options.rowMoveShadowOpacity || 0.95)
|
|
95
|
+
.css("transform", "scale(" + options.rowMoveShadowScale + ")")
|
|
96
|
+
.css("display", "none")
|
|
97
|
+
.appendTo(_canvas);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var selectedRows = options.singleRowMove ? [cell.row] : _grid.getSelectedRows();
|
|
101
|
+
if (selectedRows.length === 0 || selectedRows.indexOf(cell.row) === -1) {
|
|
102
|
+
selectedRows = [cell.row];
|
|
103
|
+
if (!options.disableRowSelection) {
|
|
104
|
+
_grid.setSelectedRows(selectedRows);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var rowHeight = _grid.getOptions().rowHeight;
|
|
108
|
+
dd.selectedRows = selectedRows;
|
|
109
|
+
const canvasWidth = _canvas.getBoundingClientRect().width;
|
|
110
|
+
dd.selectionProxy = $(document.createElement("div")) //"<div class='slick-reorder-proxy'/>")
|
|
111
|
+
.addClass("slick-reorder-proxy")
|
|
112
|
+
.css("position", "absolute")
|
|
113
|
+
.css("zIndex", "99999")
|
|
114
|
+
.css("width", canvasWidth) // $(_canvas).innerWidth())
|
|
115
|
+
.css("height", rowHeight * selectedRows.length)
|
|
116
|
+
.css("display", "none")
|
|
117
|
+
.appendTo(_canvas);
|
|
118
|
+
dd.guide = $(document.createElement("div")) // "<div class='slick-reorder-guide'/>")
|
|
119
|
+
.addClass("slick-reorder-guide")
|
|
120
|
+
.css("position", "absolute")
|
|
121
|
+
.css("zIndex", "99998")
|
|
122
|
+
.css("width", canvasWidth)
|
|
123
|
+
.css("top", -1000)
|
|
124
|
+
.appendTo(_canvas);
|
|
125
|
+
dd.insertBefore = -1;
|
|
126
|
+
}
|
|
127
|
+
function handleDrag(e, dd) {
|
|
128
|
+
if (!_dragging) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// e.preventDefault();
|
|
132
|
+
e.stopImmediatePropagation();
|
|
133
|
+
var top = dd.pageY - $(_canvas).offset().top;
|
|
134
|
+
dd.selectionProxy.css("top", top - 5).css("display", ""); //.show();
|
|
135
|
+
// if the row move shadow is enabled, we'll also make it follow the mouse cursor
|
|
136
|
+
if (dd.clonedSlickRow) {
|
|
137
|
+
var offsetY = dd.pageY - $(_canvas).offset().top;
|
|
138
|
+
dd.clonedSlickRow.css("top", offsetY - 6).css("display", ""); //.show();
|
|
139
|
+
}
|
|
140
|
+
var insertBefore = Math.max(0, Math.min(Math.round(top / _grid.getOptions().rowHeight), _grid.getDataLength()));
|
|
141
|
+
if (insertBefore !== dd.insertBefore) {
|
|
142
|
+
var eventData = {
|
|
143
|
+
"grid": _grid,
|
|
144
|
+
"rows": dd.selectedRows,
|
|
145
|
+
"insertBefore": insertBefore
|
|
146
|
+
};
|
|
147
|
+
if (_self.onBeforeMoveRows.notify(eventData) === false) {
|
|
148
|
+
dd.canMove = false;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
dd.canMove = true;
|
|
152
|
+
}
|
|
153
|
+
// if there's a UsabilityOverride defined, we also need to verify that the condition is valid
|
|
154
|
+
if (_usabilityOverride && dd.canMove) {
|
|
155
|
+
var insertBeforeDataContext = _grid.getDataItem(insertBefore);
|
|
156
|
+
dd.canMove = checkUsabilityOverride(insertBefore, insertBeforeDataContext, _grid);
|
|
157
|
+
}
|
|
158
|
+
// if the new target is possible we'll display the dark blue bar (representin the acceptability) at the target position
|
|
159
|
+
// else it won't show up (it will be off the screen)
|
|
160
|
+
if (!dd.canMove) {
|
|
161
|
+
dd.guide.css("top", -1000);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
dd.guide.css("top", insertBefore * _grid.getOptions().rowHeight);
|
|
165
|
+
}
|
|
166
|
+
dd.insertBefore = insertBefore;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function handleDragEnd(e, dd) {
|
|
170
|
+
if (!_dragging) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
_dragging = false;
|
|
174
|
+
e.stopImmediatePropagation();
|
|
175
|
+
if (dd.guide == null) {
|
|
176
|
+
console.log("dd.guide");
|
|
177
|
+
}
|
|
178
|
+
else
|
|
179
|
+
dd.guide.remove();
|
|
180
|
+
if (dd.selectionProxy == null) {
|
|
181
|
+
console.log(" dd.selectionProxy");
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
dd.selectionProxy.remove();
|
|
185
|
+
if (dd.clonedSlickRow) {
|
|
186
|
+
dd.clonedSlickRow.remove();
|
|
187
|
+
dd.clonedSlickRow = null;
|
|
188
|
+
}
|
|
189
|
+
if (dd.canMove) {
|
|
190
|
+
var eventData = {
|
|
191
|
+
"grid": _grid,
|
|
192
|
+
"rows": dd.selectedRows,
|
|
193
|
+
"insertBefore": dd.insertBefore
|
|
194
|
+
};
|
|
195
|
+
// TODO: _grid.remapCellCssClasses ?
|
|
196
|
+
_self.onMoveRows.notify(eventData);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function getColumnDefinition() {
|
|
200
|
+
return {
|
|
201
|
+
id: options.columnId || "_move",
|
|
202
|
+
name: "",
|
|
203
|
+
field: "move",
|
|
204
|
+
width: options.width || 40,
|
|
205
|
+
behavior: "selectAndMove",
|
|
206
|
+
selectable: false,
|
|
207
|
+
resizable: false,
|
|
208
|
+
cssClass: options.cssClass,
|
|
209
|
+
formatter: moveIconFormatter
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function moveIconFormatter(row, cell, value, columnDef, dataContext, grid) {
|
|
213
|
+
if (!checkUsabilityOverride(row, dataContext, grid)) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
return { addClasses: "cell-reorder dnd", text: "" };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function checkUsabilityOverride(row, dataContext, grid) {
|
|
221
|
+
if (typeof _usabilityOverride === 'function') {
|
|
222
|
+
return _usabilityOverride(row, dataContext, grid);
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Method that user can pass to override the default behavior or making every row moveable.
|
|
228
|
+
* In order word, user can choose which rows to be an available as moveable (or not) by providing his own logic show/hide icon and usability.
|
|
229
|
+
* @param overrideFn: override function callback
|
|
230
|
+
*/
|
|
231
|
+
function usabilityOverride(overrideFn) {
|
|
232
|
+
_usabilityOverride = overrideFn;
|
|
233
|
+
}
|
|
234
|
+
function isHandlerColumn(columnIndex) {
|
|
235
|
+
return /move|selectAndMove/.test(_grid.getColumns()[columnIndex].behavior);
|
|
236
|
+
}
|
|
237
|
+
$.shallowExtend(this, {
|
|
238
|
+
"onBeforeMoveRows": new Slick.Event(),
|
|
239
|
+
"onMoveRows": new Slick.Event(),
|
|
240
|
+
"init": init,
|
|
241
|
+
"destroy": destroy,
|
|
242
|
+
"getColumnDefinition": getColumnDefinition,
|
|
243
|
+
"setOptions": setOptions,
|
|
244
|
+
"usabilityOverride": usabilityOverride,
|
|
245
|
+
"isHandlerColumn": isHandlerColumn,
|
|
246
|
+
"pluginName": "RowMoveManager"
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
// })(jQuery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function RowSelectionModel(options?: any): void;
|
|
1
|
+
export declare function RowSelectionModel(options?: any): void;
|