@deephaven/iris-grid 0.3.2 → 0.4.0

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.
@@ -17,15 +17,6 @@ declare class Formatter {
17
17
  columnName: string;
18
18
  format: string;
19
19
  };
20
- /**
21
- * Creates default column formatting rules
22
- * @returns Column formatting rules array
23
- */
24
- static getDefaultFormattingRules(): {
25
- columnType: string;
26
- columnName: string;
27
- format: string;
28
- }[];
29
20
  /**
30
21
  * @param {Array} columnFormattingRules Optional array of column formatting rules
31
22
  * @param {Object} dateTimeOptions Optional object with DateTime configuration
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.js"],"names":[],"mappings":";AAUA;IACE;;;;OAIG;IACH,8DAaC;IAED;;;;;OAKG;IACH;;;;MAMC;IAED;;;OAGG;IACH;;;;QA0CC;IAED;;;;;;;OAOG;IACH;QALmC,QAAQ,EAAhC,MAAM;QACmB,YAAY,EAArC,OAAO;QACkB,cAAc,EAAvC,OAAO;QACiB,2BAA2B,EAAnD,MAAM;OAwBhB;IAhBC,+CAA0D;IAG1D,uDASE;IAGF,qBAA2E;IAG7E;;;;;OAKG;IACH,gFAMC;IAED;;;;;OAKG;IACH,6DAMC;IAED,sGAMC;IAED;;;;;;OAMG;IACH,yGAeC;CACF"}
1
+ {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.js"],"names":[],"mappings":";AAUA;IACE;;;;OAIG;IACH,8DAaC;IAED;;;;;OAKG;IACH;;;;MAMC;IAED;;;;;;;OAOG;IACH;QALmC,QAAQ,EAAhC,MAAM;QACmB,YAAY,EAArC,OAAO;QACkB,cAAc,EAAvC,OAAO;QACiB,2BAA2B,EAAnD,MAAM;OAwBhB;IAhBC,+CAA0D;IAG1D,uDASE;IAGF,qBAA2E;IAG7E;;;;;OAKG;IACH,gFAMC;IAED;;;;;OAKG;IACH,6DAMC;IAED,sGAMC;IAED;;;;;;OAMG;IACH,yGAeC;CACF"}
package/dist/Formatter.js CHANGED
@@ -144,17 +144,6 @@ var Formatter = /*#__PURE__*/function () {
144
144
  format: format
145
145
  };
146
146
  }
147
- /**
148
- * Creates default column formatting rules
149
- * @returns Column formatting rules array
150
- */
151
-
152
- }, {
153
- key: "getDefaultFormattingRules",
154
- value: function getDefaultFormattingRules() {
155
- var globalFormatsArray = [Formatter.makeColumnFormattingRule(TableUtils.dataType.DATETIME, 'Expiry', DateTimeColumnFormatter.makeFormat('', 'yyyy-MM-dd', DateTimeColumnFormatter.TYPE_GLOBAL)), Formatter.makeColumnFormattingRule(TableUtils.dataType.DATETIME, 'Timestamp', DateTimeColumnFormatter.makeFormat('', 'HH:mm:ss.SSS', DateTimeColumnFormatter.TYPE_GLOBAL)), Formatter.makeColumnFormattingRule(TableUtils.dataType.DECIMAL, 'Bid', DecimalColumnFormatter.makeFormat('', '###,##0.00###', null, DecimalColumnFormatter.TYPE_GLOBAL)), Formatter.makeColumnFormattingRule(TableUtils.dataType.DECIMAL, 'Ask', DecimalColumnFormatter.makeFormat('', '###,##0.00###', null, DecimalColumnFormatter.TYPE_GLOBAL))];
156
- return globalFormatsArray;
157
- }
158
147
  }]);
159
148
 
160
149
  return Formatter;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Formatter.js"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","Formatter","columnFormattingRules","dateTimeOptions","defaultColumnFormatter","typeFormatterMap","Map","dataType","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","columnFormatMap","makeColumnFormatMap","columnType","createIfNecessary","getNormalizedType","has","set","get","columnName","getColumnFormatMapForType","value","formatOverride","formatter","getColumnTypeFormatter","format","getColumnFormat","reduce","map","next","formatMap","globalFormatsArray","makeColumnFormattingRule","makeFormat","TYPE_GLOBAL"],"mappings":";;;;;;AAAA,OAAOA,UAAP,MAAuB,cAA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QAAX,CAAoBI,OADtB,EAEE,KAFF,EAGEb,sBAAsB,CAACqC,UAAvB,CACE,EADF,EAEE,eAFF,EAGE,IAHF,EAIErC,sBAAsB,CAACsC,WAJzB,CAHF,CAnByB,EA6BzBnC,SAAS,CAACiC,wBAAV,CACExC,UAAU,CAACa,QAAX,CAAoBI,OADtB,EAEE,KAFF,EAGEb,sBAAsB,CAACqC,UAAvB,CACE,EADF,EAEE,eAFF,EAGE,IAHF,EAIErC,sBAAsB,CAACsC,WAJzB,CAHF,CA7ByB,CAA3B;AAwCA,aAAOH,kBAAP;AACD;;;;;;AA+FH,eAAehC,SAAf","sourcesContent":["import TableUtils from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n} from './formatters';\n\nclass Formatter {\n /**\n * Converts [{columnType, columnName, format}] to Map { dataType, Map { columnName, format }}\n * @param {Array} columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(columnFormattingRules) {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap.set(next.columnName, next.format);\n return map;\n }, new Map());\n }\n\n /**\n * Creates a column formatting rule\n * @param {String} columnType Normalized data type\n * @param {String} columnName Column name\n * @param {String} format Format string\n */\n static makeColumnFormattingRule(columnType, columnName, format) {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * Creates default column formatting rules\n * @returns Column formatting rules array\n */\n static getDefaultFormattingRules() {\n const globalFormatsArray = [\n Formatter.makeColumnFormattingRule(\n TableUtils.dataType.DATETIME,\n 'Expiry',\n DateTimeColumnFormatter.makeFormat(\n '',\n 'yyyy-MM-dd',\n DateTimeColumnFormatter.TYPE_GLOBAL\n )\n ),\n Formatter.makeColumnFormattingRule(\n TableUtils.dataType.DATETIME,\n 'Timestamp',\n DateTimeColumnFormatter.makeFormat(\n '',\n 'HH:mm:ss.SSS',\n DateTimeColumnFormatter.TYPE_GLOBAL\n )\n ),\n Formatter.makeColumnFormattingRule(\n TableUtils.dataType.DECIMAL,\n 'Bid',\n DecimalColumnFormatter.makeFormat(\n '',\n '###,##0.00###',\n null,\n DecimalColumnFormatter.TYPE_GLOBAL\n )\n ),\n Formatter.makeColumnFormattingRule(\n TableUtils.dataType.DECIMAL,\n 'Ask',\n DecimalColumnFormatter.makeFormat(\n '',\n '###,##0.00###',\n null,\n DecimalColumnFormatter.TYPE_GLOBAL\n )\n ),\n ];\n return globalFormatsArray;\n }\n\n /**\n * @param {Array} columnFormattingRules Optional array of column formatting rules\n * @param {Object} dateTimeOptions Optional object with DateTime configuration\n * @param {string} dateTimeOptions.timeZone Time zone\n * @param {boolean} dateTimeOptions.showTimeZone Show time zone in DateTime values\n * @param {boolean} dateTimeOptions.showTSeparator Show 'T' separator in DateTime values\n * @param {string} dateTimeOptions.defaultDateTimeFormatString DateTime format to use if columnFormats for DateTime isn't set\n */\n constructor(columnFormattingRules = [], dateTimeOptions = {}) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter()],\n [TableUtils.dataType.INT, new IntegerColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n }\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param {String} columnType column type\n * @param {Boolean} createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(columnType, createIfNecessary = false) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param {String} columnType column type\n * @param {String} columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(columnType, columnName) {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n if (columnFormatMap && columnFormatMap.has(columnName)) {\n return columnFormatMap.get(columnName);\n }\n return null;\n }\n\n getColumnTypeFormatter(columnType) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType && this.typeFormatterMap.has(dataType)) {\n return this.typeFormatterMap.get(dataType);\n }\n return this.defaultColumnFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param {Any} value Value to format\n * @param {String} columnType Column type used to determine the formatting settings\n * @param {String} columnName Column name used to determine the formatting settings\n * @param {String} formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value,\n columnType,\n columnName = '',\n formatOverride = null\n ) {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format);\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
1
+ {"version":3,"sources":["../src/Formatter.js"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","Formatter","columnFormattingRules","dateTimeOptions","defaultColumnFormatter","typeFormatterMap","Map","dataType","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","columnFormatMap","makeColumnFormatMap","columnType","createIfNecessary","getNormalizedType","has","set","get","columnName","getColumnFormatMapForType","value","formatOverride","formatter","getColumnTypeFormatter","format","getColumnFormat","reduce","map","next","formatMap"],"mappings":";;;;;;AAAA,OAAOA,UAAP,MAAuB,cAAvB;AACA,SACEC,sBADF,EAEEC,mBAFF,EAGEC,uBAHF,EAIEC,sBAJF,EAKEC,sBALF,EAMEC,sBANF,QAOO,cAPP;;IASMC,S;AAmCJ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACE,uBAA8D;AAAA,QAAlDC,qBAAkD,uEAA1B,EAA0B;AAAA,QAAtBC,eAAsB,uEAAJ,EAAI;;AAAA;;AAC5D;AACA;AACA;AACA;AAEA,SAAKC,sBAAL,GAA8B,IAAIL,sBAAJ,EAA9B,CAN4D,CAQ5D;;AACA,SAAKM,gBAAL,GAAwB,IAAIC,GAAJ,CAAQ,CAC9B,CAACZ,UAAU,CAACa,QAAX,CAAoBC,OAArB,EAA8B,IAAIb,sBAAJ,EAA9B,CAD8B,EAE9B,CAACD,UAAU,CAACa,QAAX,CAAoBE,IAArB,EAA2B,IAAIb,mBAAJ,EAA3B,CAF8B,EAG9B,CACEF,UAAU,CAACa,QAAX,CAAoBG,QADtB,EAEE,IAAIb,uBAAJ,CAA4BM,eAA5B,CAFF,CAH8B,EAO9B,CAACT,UAAU,CAACa,QAAX,CAAoBI,OAArB,EAA8B,IAAIb,sBAAJ,EAA9B,CAP8B,EAQ9B,CAACJ,UAAU,CAACa,QAAX,CAAoBK,GAArB,EAA0B,IAAIZ,sBAAJ,EAA1B,CAR8B,CAAR,CAAxB,CAT4D,CAoB5D;;AACA,SAAKa,eAAL,GAAuBZ,SAAS,CAACa,mBAAV,CAA8BZ,qBAA9B,CAAvB;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;;;WACE,mCAA0Ba,UAA1B,EAAiE;AAAA,UAA3BC,iBAA2B,uEAAP,KAAO;AAC/D,UAAMT,QAAQ,GAAGb,UAAU,CAACuB,iBAAX,CAA6BF,UAA7B,CAAjB;;AACA,UAAIC,iBAAiB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5HD;AACF;AACA;AACA;AACA;AACE,iCAA2BzB,qBAA3B,EAAkD;AAChD,UAAIA,qBAAqB,IAAI,IAA7B,EAAmC;AACjC,eAAO,IAAII,GAAJ,EAAP;AACD;;AACD,aAAOJ,qBAAqB,CAAC2B,MAAtB,CAA6B,UAACC,GAAD,EAAMC,IAAN,EAAe;AACjD,YAAMxB,QAAQ,GAAGb,UAAU,CAACuB,iBAAX,CAA6Bc,IAAI,CAAChB,UAAlC,CAAjB;;AACA,YAAI,CAACe,GAAG,CAACZ,GAAJ,CAAQX,QAAR,CAAL,EAAwB;AACtBuB,UAAAA,GAAG,CAACX,GAAJ,CAAQZ,QAAR,EAAkB,IAAID,GAAJ,EAAlB;AACD;;AACD,YAAM0B,SAAS,GAAGF,GAAG,CAACV,GAAJ,CAAQb,QAAR,CAAlB;AACAyB,QAAAA,SAAS,CAACb,GAAV,CAAcY,IAAI,CAACV,UAAnB,EAA+BU,IAAI,CAACJ,MAApC;AACA,eAAOG,GAAP;AACD,OARM,EAQJ,IAAIxB,GAAJ,EARI,CAAP;AASD;AAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,kCAAgCS,UAAhC,EAA4CM,UAA5C,EAAwDM,MAAxD,EAAgE;AAC9D,aAAO;AACLZ,QAAAA,UAAU,EAAVA,UADK;AAELM,QAAAA,UAAU,EAAVA,UAFK;AAGLM,QAAAA,MAAM,EAANA;AAHK,OAAP;AAKD;;;;;;AA+FH,eAAe1B,SAAf","sourcesContent":["import TableUtils from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n} from './formatters';\n\nclass Formatter {\n /**\n * Converts [{columnType, columnName, format}] to Map { dataType, Map { columnName, format }}\n * @param {Array} columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(columnFormattingRules) {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap.set(next.columnName, next.format);\n return map;\n }, new Map());\n }\n\n /**\n * Creates a column formatting rule\n * @param {String} columnType Normalized data type\n * @param {String} columnName Column name\n * @param {String} format Format string\n */\n static makeColumnFormattingRule(columnType, columnName, format) {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param {Array} columnFormattingRules Optional array of column formatting rules\n * @param {Object} dateTimeOptions Optional object with DateTime configuration\n * @param {string} dateTimeOptions.timeZone Time zone\n * @param {boolean} dateTimeOptions.showTimeZone Show time zone in DateTime values\n * @param {boolean} dateTimeOptions.showTSeparator Show 'T' separator in DateTime values\n * @param {string} dateTimeOptions.defaultDateTimeFormatString DateTime format to use if columnFormats for DateTime isn't set\n */\n constructor(columnFormattingRules = [], dateTimeOptions = {}) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter()],\n [TableUtils.dataType.INT, new IntegerColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n }\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param {String} columnType column type\n * @param {Boolean} createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(columnType, createIfNecessary = false) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param {String} columnType column type\n * @param {String} columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(columnType, columnName) {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n if (columnFormatMap && columnFormatMap.has(columnName)) {\n return columnFormatMap.get(columnName);\n }\n return null;\n }\n\n getColumnTypeFormatter(columnType) {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType && this.typeFormatterMap.has(dataType)) {\n return this.typeFormatterMap.get(dataType);\n }\n return this.defaultColumnFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param {Any} value Value to format\n * @param {String} columnType Column type used to determine the formatting settings\n * @param {String} columnName Column name used to determine the formatting settings\n * @param {String} formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value,\n columnType,\n columnName = '',\n formatOverride = null\n ) {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format);\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
@@ -97,11 +97,11 @@ export class IrisGrid extends React.Component<any, any, any> {
97
97
  shortcut: import("@deephaven/components").Shortcut;
98
98
  };
99
99
  discardAction: {
100
- action: () => Promise<void>;
100
+ action: () => void;
101
101
  shortcut: import("@deephaven/components").Shortcut;
102
102
  };
103
103
  commitAction: {
104
- action: () => Promise<void>;
104
+ action: () => void;
105
105
  shortcut: import("@deephaven/components").Shortcut;
106
106
  };
107
107
  contextActions: {
@@ -1 +1 @@
1
- {"version":3,"file":"IrisGrid.d.ts","sourceRoot":"","sources":["../src/IrisGrid.jsx"],"names":[],"mappings":"AAiHA;IACE,2BAAyB;IAEzB,2BAAyB;IAEzB,mCAAiC;IAEjC,wBAmPC;IA6sCD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IACH,eAFa,OAAO,CAInB;IAED,iCAcC;IAED,gCAcC;IAED,kCA0BC;IAED,wDAQC;IAmGD,uCASC;IAED,uBAWC;IAED,uDAeC;IAED,6FAYC;IAED,gCAIC;IAED,oBAGC;IAED,wCA2BC;IAED,wBAeC;IAED,+BAgCC;IAED,gCAYC;IAED;;;OAGG;IACH,gCAGC;IAED;;OAEG;IACH,kDAcC;IA+fD;;;OAGG;IACH,qBAFW,SAAS,EAAE,QASrB;IAED,6BAYC;IAED,gDAUC;IAED,wBASC;CA+sBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsGgB,wCAAQ;;QACL,2CAAQ;;QACV,yCAAQ;;QACf,kCAAQ;;QACF,wCAAQ;;QACJ,4CAAQ;;QACD,mDAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;QAYd,6CAAQ;;;;;;;;;;;;;;;;;;;;;;;;QAYb,2CAAQ;;;;QAEJ,sDACwC"}
package/dist/IrisGrid.js CHANGED
@@ -407,13 +407,21 @@ export var IrisGrid = /*#__PURE__*/function (_Component) {
407
407
  };
408
408
  _this.discardAction = {
409
409
  action: function action() {
410
- return _this.discardPending()["catch"](log.error);
410
+ var model = _this.props.model;
411
+
412
+ if (model.isEditable && model.pendingDataMap.size > 0) {
413
+ _this.discardPending()["catch"](log.error);
414
+ }
411
415
  },
412
416
  shortcut: SHORTCUTS.INPUT_TABLE.DISCARD
413
417
  };
414
418
  _this.commitAction = {
415
419
  action: function action() {
416
- return _this.commitPending()["catch"](log.error);
420
+ var model = _this.props.model;
421
+
422
+ if (model.isEditable && model.pendingDataMap.size > 0 && model.pendingDataErrors.size === 0) {
423
+ _this.commitPending()["catch"](log.error);
424
+ }
417
425
  },
418
426
  shortcut: SHORTCUTS.INPUT_TABLE.COMMIT
419
427
  };
@@ -1542,39 +1550,48 @@ export var IrisGrid = /*#__PURE__*/function (_Component) {
1542
1550
  var _commitPending = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
1543
1551
  var _this9 = this;
1544
1552
 
1545
- var pendingSavePromise, model, newPendingSavePromise;
1553
+ var model, pendingSavePromise, newPendingSavePromise;
1546
1554
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
1547
1555
  while (1) {
1548
1556
  switch (_context2.prev = _context2.next) {
1549
1557
  case 0:
1558
+ model = this.props.model;
1559
+
1560
+ if (model.isEditable) {
1561
+ _context2.next = 3;
1562
+ break;
1563
+ }
1564
+
1565
+ throw new Error('Cannot save, table is not editable');
1566
+
1567
+ case 3:
1550
1568
  pendingSavePromise = this.state.pendingSavePromise;
1551
1569
 
1552
1570
  if (!(pendingSavePromise != null)) {
1553
- _context2.next = 3;
1571
+ _context2.next = 6;
1554
1572
  break;
1555
1573
  }
1556
1574
 
1557
1575
  throw new Error('Save already in progress');
1558
1576
 
1559
- case 3:
1577
+ case 6:
1560
1578
  if (!document.activeElement.classList.contains('grid-cell-input-field')) {
1561
- _context2.next = 7;
1579
+ _context2.next = 10;
1562
1580
  break;
1563
1581
  }
1564
1582
 
1565
1583
  if (!document.activeElement.classList.contains('error')) {
1566
- _context2.next = 6;
1584
+ _context2.next = 9;
1567
1585
  break;
1568
1586
  }
1569
1587
 
1570
1588
  throw new ValidationError('Current input is invalid');
1571
1589
 
1572
- case 6:
1590
+ case 9:
1573
1591
  // Focus the grid again to commit any pending input changes
1574
1592
  this.grid.focus();
1575
1593
 
1576
- case 7:
1577
- model = this.props.model;
1594
+ case 10:
1578
1595
  newPendingSavePromise = this.pending.add(model.commitPending()).then(function () {
1579
1596
  _this9.setState({
1580
1597
  pendingSaveError: null,
@@ -1593,7 +1610,7 @@ export var IrisGrid = /*#__PURE__*/function (_Component) {
1593
1610
  });
1594
1611
  return _context2.abrupt("return", newPendingSavePromise);
1595
1612
 
1596
- case 11:
1613
+ case 13:
1597
1614
  case "end":
1598
1615
  return _context2.stop();
1599
1616
  }
@@ -2085,7 +2102,8 @@ export var IrisGrid = /*#__PURE__*/function (_Component) {
2085
2102
  pendingDataErrors = model.pendingDataErrors;
2086
2103
  this.setState({
2087
2104
  pendingDataMap: pendingDataMap,
2088
- pendingDataErrors: pendingDataErrors
2105
+ pendingDataErrors: pendingDataErrors,
2106
+ pendingSaveError: null
2089
2107
  });
2090
2108
  this.grid.forceUpdate();
2091
2109
  }