Skip to content

Commit 7442c41

Browse files
author
klumba12
committed
1.0.14
1 parent 95dee7c commit 7442c41

2 files changed

Lines changed: 108 additions & 53 deletions

File tree

dist/qgrid.js

Lines changed: 107 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
540540

541541

542542

543-
var Command = function Command(context) {
543+
var Command = function Command() {
544+
var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
545+
544546
_classCallCheck(this, Command);
545547

546548
this.execute = context.execute || __WEBPACK_IMPORTED_MODULE_0__services_utility__["i" /* yes */];
@@ -1173,6 +1175,7 @@ var ColumnModel = function () {
11731175
this.canSort = true;
11741176
this.canMove = true;
11751177
this.canFilter = true;
1178+
this.canHighlight = true;
11761179

11771180
this.isVisible = true;
11781181
this.index = -1;
@@ -6659,6 +6662,7 @@ var PadColumnModel = function (_ColumnModel) {
66596662
_this.canEdit = false;
66606663
_this.canSort = false;
66616664
_this.canResize = false;
6665+
_this.canHighlight = false;
66626666
_this.source = 'generation';
66636667
return _this;
66646668
}
@@ -6799,6 +6803,7 @@ var PivotColumnModel = function (_ColumnModel) {
67996803
_this.canEdit = false;
68006804
_this.canSort = false;
68016805
_this.canResize = false;
6806+
_this.canHighlight = false;
68026807
_this.width = 60;
68036808
_this.rowIndex = 0;
68046809
return _this;
@@ -6868,6 +6873,7 @@ var RowIndicatorColumnModel = function (_ColumnModel) {
68686873
_this.canEdit = false;
68696874
_this.canSort = false;
68706875
_this.canResize = false;
6876+
_this.canHighlight = false;
68716877
return _this;
68726878
}
68736879

@@ -7168,13 +7174,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
71687174

71697175

71707176
var EditCellView = function () {
7171-
function EditCellView(model, setValue, table, apply) {
7177+
function EditCellView(model, setValue, valueFactory, table, apply) {
71727178
_classCallCheck(this, EditCellView);
71737179

71747180
this.model = model;
71757181
this.setValue = setValue;
71767182
var markup = table.markup;
71777183
this.markup = markup;
7184+
this.valueFactory = valueFactory;
71787185

71797186
this.mode = 'view';
71807187
this._value = null;
@@ -7190,6 +7197,20 @@ var EditCellView = function () {
71907197
}
71917198

71927199
_createClass(EditCellView, [{
7200+
key: 'contextFactory',
7201+
value: function contextFactory(cell, value) {
7202+
return {
7203+
column: cell.column,
7204+
row: cell.row,
7205+
columnIndex: cell.columnIndex,
7206+
rowIndex: cell.rowIndex,
7207+
oldValue: cell.value,
7208+
newValue: arguments.length === 2 ? value : cell.value,
7209+
valueFactory: this.valueFactory,
7210+
unit: 'cell'
7211+
};
7212+
}
7213+
}, {
71937214
key: 'destroy',
71947215
value: function destroy() {
71957216
this.shortcutOff();
@@ -7206,10 +7227,8 @@ var EditCellView = function () {
72067227
shortcut: 'F2|Enter',
72077228
canExecute: function canExecute(cell) {
72087229
cell = cell || model.navigation().active.cell;
7209-
7210-
if (_this.mode !== 'edit' && model.edit().mode === 'cell' && cell) {
7211-
// use shouldn't explicitly set it in the template, cause we have here canEdit !== false
7212-
return cell.column.canEdit !== false;
7230+
if (cell && _this.mode !== 'edit' && model.edit().mode === 'cell' && cell) {
7231+
return cell.column.canEdit && model.edit().enter.canExecute(_this.contextFactory(cell));
72137232
}
72147233

72157234
return false;
@@ -7220,19 +7239,25 @@ var EditCellView = function () {
72207239
e.stopImmediatePropagation();
72217240
}
72227241

7223-
cell = cell || model.navigation().active.cell;
72247242
var parse = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_core_services_convert__["a" /* parseFactory */])(cell.column.type);
7225-
_this.value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_core_services_utility__["f" /* isUndefined */])(cell.value) ? null : parse(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_core_services_utility__["d" /* clone */])(cell.value));
7226-
_this.mode = 'edit';
7227-
model.edit({ editMode: 'edit' });
7228-
cell.mode(_this.mode);
7243+
var value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_core_services_utility__["f" /* isUndefined */])(cell.value) ? null : parse(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_core_services_utility__["d" /* clone */])(cell.value));
7244+
cell = cell || model.navigation().active.cell;
7245+
if (cell) {
7246+
if (model.edit().enter.execute(_this.contextFactory(cell, value)) !== false) {
7247+
_this.value = value;
7248+
_this.mode = 'edit';
7249+
model.edit({ editMode: 'edit' });
7250+
cell.mode(_this.mode);
7251+
}
7252+
}
72297253
}
72307254
}),
72317255
commit: new __WEBPACK_IMPORTED_MODULE_0_core_infrastructure_command__["a" /* default */]({
72327256
shortcut: 'Ctrl+S|Enter',
72337257
// TODO: add validation support
7234-
canExecute: function canExecute() {
7235-
return _this.mode === 'edit' && model.edit().mode === 'cell';
7258+
canExecute: function canExecute(cell) {
7259+
cell = cell || model.navigation().active.cell;
7260+
return _this.mode === 'edit' && model.edit().mode === 'cell' && model.edit().commit.canExecute(_this.contextFactory(cell));
72367261
},
72377262
execute: function execute(cell, e) {
72387263
__WEBPACK_IMPORTED_MODULE_1_core_infrastructure_log__["a" /* default */].info('cell.edit', 'commit');
@@ -7242,36 +7267,49 @@ var EditCellView = function () {
72427267

72437268
cell = cell || model.navigation().active.cell;
72447269
if (cell) {
7245-
var column = cell.column;
7246-
var row = cell.row;
7247-
_this.setValue(row, column, _this.value);
7248-
7249-
_this.value = null;
7250-
_this.mode = 'view';
7251-
model.edit({ editMode: 'view' });
7252-
cell.mode(_this.mode);
7253-
table.focus();
7270+
if (model.edit().commit.execute(_this.contextFactory(cell, _this.value)) !== false) {
7271+
var column = cell.column;
7272+
var row = cell.row;
7273+
_this.setValue(row, column, _this.value);
7274+
7275+
_this.value = null;
7276+
_this.mode = 'view';
7277+
model.edit({ editMode: 'view' });
7278+
cell.mode(_this.mode);
7279+
table.focus();
7280+
}
72547281
}
72557282
}
72567283
}),
72577284
cancel: new __WEBPACK_IMPORTED_MODULE_0_core_infrastructure_command__["a" /* default */]({
72587285
shortcut: 'Escape',
7286+
canExecute: function canExecute(cell) {
7287+
cell = cell || model.navigation().active.cell;
7288+
return cell && model.edit().cancel.canExecute(_this.contextFactory(cell, _this.value));
7289+
},
72597290
execute: function execute(cell, e) {
72607291
__WEBPACK_IMPORTED_MODULE_1_core_infrastructure_log__["a" /* default */].info('cell.edit', 'cancel');
72617292
if (e) {
72627293
e.stopImmediatePropagation();
72637294
}
7295+
72647296
cell = cell || model.navigation().active.cell;
72657297
if (cell) {
7266-
_this.value = null;
7267-
_this.mode = 'view';
7268-
model.edit({ editMode: 'view' });
7269-
cell.mode(_this.mode);
7270-
table.focus();
7298+
if (model.edit().cancel.execute(_this.contextFactory(cell, _this.value)) !== false) {
7299+
_this.value = null;
7300+
_this.mode = 'view';
7301+
model.edit({ editMode: 'view' });
7302+
cell.mode(_this.mode);
7303+
table.focus();
7304+
}
72717305
}
72727306
}
72737307
}),
72747308
reset: new __WEBPACK_IMPORTED_MODULE_0_core_infrastructure_command__["a" /* default */]({
7309+
canExecute: function canExecute(cell) {
7310+
cell = cell || model.navigation().active.cell;
7311+
return cell && model.edit().reset.canExecute(_this.contextFactory(cell, _this.value));
7312+
},
72757313
execute: function execute(cell, e) {
72767314
__WEBPACK_IMPORTED_MODULE_1_core_infrastructure_log__["a" /* default */].info('cell.edit', 'reset');
72777315
if (e) {
@@ -7280,10 +7318,12 @@ var EditCellView = function () {
72807318

72817319
cell = cell || model.navigation().active.cell;
72827320
if (cell) {
7283-
var parse = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_core_services_convert__["a" /* parseFactory */])(cell.column.type);
7284-
_this.value = parse(cell.value);
7285-
cell.mode(_this.mode);
7286-
return false;
7321+
if (model.edit().reset.execute(_this.contextFactory(cell, _this.value)) !== false) {
7322+
var parse = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_core_services_convert__["a" /* parseFactory */])(cell.column.type);
7323+
_this.value = parse(cell.value);
7324+
cell.mode(_this.mode);
7325+
return false;
7326+
}
72877327
}
72887328
}
72897329
})
@@ -7311,16 +7351,22 @@ var EditCellView = function () {
73117351

73127352
"use strict";
73137353
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_core_resource_resource__ = __webpack_require__(5);
7354+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_core_infrastructure_command__ = __webpack_require__(6);
73147355
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
73157356

73167357

73177358

7359+
73187360
var EditModel = function EditModel() {
73197361
_classCallCheck(this, EditModel);
73207362

73217363
this.resource = new __WEBPACK_IMPORTED_MODULE_0_core_resource_resource__["a" /* default */]();
73227364
this.mode = null; // cell
73237365
this.editMode = 'view'; // edit
7366+
this.enter = new __WEBPACK_IMPORTED_MODULE_1_core_infrastructure_command__["a" /* default */]();
7367+
this.commit = new __WEBPACK_IMPORTED_MODULE_1_core_infrastructure_command__["a" /* default */]();
7368+
this.cancel = new __WEBPACK_IMPORTED_MODULE_1_core_infrastructure_command__["a" /* default */]();
7369+
this.reset = new __WEBPACK_IMPORTED_MODULE_1_core_infrastructure_command__["a" /* default */]();
73247370
};
73257371

73267372
/* harmony default export */ __webpack_exports__["a"] = (EditModel);
@@ -7346,12 +7392,12 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
73467392
var EditView = function (_View) {
73477393
_inherits(EditView, _View);
73487394

7349-
function EditView(model, setValue, table, apply) {
7395+
function EditView(model, setValue, valueFactory, table, apply) {
73507396
_classCallCheck(this, EditView);
73517397

73527398
var _this = _possibleConstructorReturn(this, (EditView.__proto__ || Object.getPrototypeOf(EditView)).call(this, model));
73537399

7354-
_this.cell = new __WEBPACK_IMPORTED_MODULE_1__edit_cell_view__["a" /* default */](model, setValue, table, apply);
7400+
_this.cell = new __WEBPACK_IMPORTED_MODULE_1__edit_cell_view__["a" /* default */](model, setValue, valueFactory, table, apply);
73557401
return _this;
73567402
}
73577403

@@ -8720,15 +8766,13 @@ var HighlightView = function (_View) {
87208766
}, 0);
87218767
});
87228768

8723-
model.columnListChanged.watch(function (e) {
8724-
if (e.hasChanges('index')) {
8725-
waitForLayout = true;
8726-
apply(function () {
8727-
hoverBlurs = _this.invalidateHover(hoverBlurs);
8728-
sortBlurs = _this.invalidateSortBy(sortBlurs);
8729-
waitForLayout = false;
8730-
}, 0);
8731-
}
8769+
model.viewChanged.watch(function () {
8770+
waitForLayout = true;
8771+
apply(function () {
8772+
hoverBlurs = _this.invalidateHover(hoverBlurs);
8773+
sortBlurs = _this.invalidateSortBy(sortBlurs);
8774+
waitForLayout = false;
8775+
}, 100);
87328776
});
87338777

87348778
model.sortChanged.watch(function (e) {
@@ -8828,7 +8872,7 @@ var HighlightView = function (_View) {
88288872
if (index >= 0) {
88298873
// TODO: add pivot col support
88308874
var column = columns[index];
8831-
if (column.type === 'pivot' || column.type === 'pad') {
8875+
if (!column.canHighlight) {
88328876
return -1;
88338877
}
88348878
}
@@ -13009,9 +13053,9 @@ var Grid = function (_RootComponent) {
1300913053
Object.keys(triggers).forEach(function (name) {
1301013054
return model[name + 'Changed'].watch(function (e) {
1301113055
var changes = Object.keys(e.changes);
13012-
if (triggers[name].find(function (key) {
13013-
return changes.indexOf(key) > -1;
13014-
}) && e.tag.behavior !== 'core') {
13056+
if (e.tag.behavior !== 'core' && triggers[name].find(function (key) {
13057+
return changes.indexOf(key) >= 0;
13058+
})) {
1301513059
service.invalidate(name, e.changes);
1301613060
}
1301713061
});
@@ -13070,7 +13114,11 @@ Grid.$inject = ['$element', '$transclude', '$document', 'qgrid'];
1307013114
pivotBy: '<',
1307113115
sortBy: '<',
1307213116
sortMode: '@',
13073-
editMode: '@'
13117+
editMode: '@',
13118+
editEnter: '<',
13119+
editCommit: '<',
13120+
editCancel: '<',
13121+
editReset: '<'
1307413122
}
1307513123
});
1307613124

@@ -13760,7 +13808,7 @@ var ViewCore = function (_Component) {
1376013808
this.highlight = new __WEBPACK_IMPORTED_MODULE_10_core_highlight_highlight_view__["a" /* default */](model, table, apply);
1376113809
this.sort = new __WEBPACK_IMPORTED_MODULE_11_core_sort_sort_view__["a" /* default */](model);
1376213810
this.filter = new __WEBPACK_IMPORTED_MODULE_12_core_filter_filter_view__["a" /* default */](model);
13763-
this.edit = new __WEBPACK_IMPORTED_MODULE_13_core_edit_edit_view__["a" /* default */](model, __WEBPACK_IMPORTED_MODULE_1_ng_services_value__["b" /* set */], table, apply);
13811+
this.edit = new __WEBPACK_IMPORTED_MODULE_13_core_edit_edit_view__["a" /* default */](model, __WEBPACK_IMPORTED_MODULE_1_ng_services_value__["b" /* set */], __WEBPACK_IMPORTED_MODULE_1_ng_services_value__["a" /* getFactory */], table, apply);
1376413812
this.pagination = new __WEBPACK_IMPORTED_MODULE_15_core_pagination_pagination_view__["a" /* default */](model);
1376513813

1376613814
// TODO: how we can avoid that?
@@ -17175,8 +17223,9 @@ var Table = function () {
1717517223
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_core_pipe_pipe__ = __webpack_require__(60);
1717617224
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_core_pipe_units_pipe_unit__ = __webpack_require__(33);
1717717225
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_core_infrastructure_log__ = __webpack_require__(18);
17178-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_core_services_utility__ = __webpack_require__(0);
17179-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__value__ = __webpack_require__(64);
17226+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_core_infrastructure_command__ = __webpack_require__(6);
17227+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_core_services_utility__ = __webpack_require__(0);
17228+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__value__ = __webpack_require__(64);
1718017229
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1718117230

1718217231
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -17189,6 +17238,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
1718917238

1719017239

1719117240

17241+
1719217242
var Grid = function () {
1719317243
function Grid($rootScope) {
1719417244
_classCallCheck(this, Grid);
@@ -17207,10 +17257,10 @@ var Grid = function () {
1720717257
var $rootScope = this.$rootScope;
1720817258
var apply = function apply() {
1720917259
__WEBPACK_IMPORTED_MODULE_4_core_infrastructure_log__["a" /* default */].info('service', '$digest apply');
17210-
$rootScope.$evalAsync(__WEBPACK_IMPORTED_MODULE_5_core_services_utility__["b" /* noop */]);
17260+
$rootScope.$evalAsync(__WEBPACK_IMPORTED_MODULE_6_core_services_utility__["b" /* noop */]);
1721117261
};
1721217262

17213-
return new __WEBPACK_IMPORTED_MODULE_1_core_services_grid__["a" /* default */](model, __WEBPACK_IMPORTED_MODULE_6__value__["a" /* getFactory */], apply);
17263+
return new __WEBPACK_IMPORTED_MODULE_1_core_services_grid__["a" /* default */](model, __WEBPACK_IMPORTED_MODULE_7__value__["a" /* getFactory */], apply);
1721417264
}
1721517265
}, {
1721617266
key: 'pipe',
@@ -17222,6 +17272,11 @@ var Grid = function () {
1722217272
get: function get() {
1722317273
return __WEBPACK_IMPORTED_MODULE_3_core_pipe_units_pipe_unit__["a" /* default */];
1722417274
}
17275+
}, {
17276+
key: 'Command',
17277+
get: function get() {
17278+
return __WEBPACK_IMPORTED_MODULE_5_core_infrastructure_command__["a" /* default */];
17279+
}
1722517280
}]);
1722617281

1722717282
return Grid;

dist/qgrid.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)