@michalrakus/x-react-web-lib 1.38.4 → 1.38.5

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.
@@ -451,7 +451,7 @@ var XFormBase = /** @class */ (function (_super) {
451
451
  return [3 /*break*/, 5];
452
452
  case 4:
453
453
  e_4 = _a.sent();
454
- XUtils_1.XUtils.showErrorMessage("Save row failed.", e_4);
454
+ XUtils_1.XUtils.showErrorMessage("Save row failed.", e_4, this.entity);
455
455
  return [2 /*return*/]; // zostavame vo formulari
456
456
  case 5:
457
457
  if (this.props.onSaveOrCancel !== undefined) {
@@ -101,7 +101,8 @@ export declare class XUtils {
101
101
  static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
102
102
  static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
103
103
  static markNotNull(label: string): string;
104
- static showErrorMessage(message: string, e: unknown): void;
104
+ static showErrorMessage(message: string, e: unknown, entity?: string): void;
105
+ private static extractEntity;
105
106
  static createTooltipOrErrorProps(error: string | undefined, tooltip?: string | undefined): object;
106
107
  static addClassName(props: {
107
108
  [key: string]: any;
@@ -609,7 +609,7 @@ var XUtils = exports.XUtils = /** @class */ (function () {
609
609
  XUtils.markNotNull = function (label) {
610
610
  return label + ' *';
611
611
  };
612
- XUtils.showErrorMessage = function (message, e) {
612
+ XUtils.showErrorMessage = function (message, e, entity) {
613
613
  var msg = message + XUtilsCommon_1.XUtilsCommon.newLine;
614
614
  if (e instanceof XResponseError_1.XResponseError) {
615
615
  if (e.xResponseErrorBody.exceptionName === 'XAppError') {
@@ -617,8 +617,17 @@ var XUtils = exports.XUtils = /** @class */ (function () {
617
617
  msg += e.xResponseErrorBody.message;
618
618
  }
619
619
  else if (e.xResponseErrorBody.exceptionName === 'OptimisticLockVersionMismatchError') {
620
- // better error message for optimistic locking
621
- msg += (0, XLocale_1.xLocaleOption)('optimisticLockFailed');
620
+ // TODO - better error message for optimistic locking (modifDate + modifUser)
621
+ // for now, we add entity to the message if the entity from the OptimisticLockVersionMismatchError is different from the entity beeing saved
622
+ // (it is rare but it can be very confusing)
623
+ var entityParam = ""; // default
624
+ if (entity && e.xResponseErrorBody.message) {
625
+ var entityFromError = XUtils.extractEntity(e.xResponseErrorBody.message);
626
+ if (entityFromError !== entity) {
627
+ entityParam = " " + entityFromError;
628
+ }
629
+ }
630
+ msg += (0, XLocale_1.xLocaleOption)('optimisticLockFailed', { entity: entityParam });
622
631
  }
623
632
  else {
624
633
  msg += e.message + XUtilsCommon_1.XUtilsCommon.newLine;
@@ -634,6 +643,10 @@ var XUtils = exports.XUtils = /** @class */ (function () {
634
643
  }
635
644
  alert(msg);
636
645
  };
646
+ XUtils.extractEntity = function (msg) {
647
+ var match = msg.match(/The optimistic lock on entity ([A-Za-z0-9_]+) failed/);
648
+ return match ? match[1] : "unknown";
649
+ };
637
650
  // pouziva sa hlavne na inputy
638
651
  XUtils.createTooltipOrErrorProps = function (error, tooltip) {
639
652
  // error ma prednost, ak nemame error, dame tooltip ak mame
@@ -18,7 +18,7 @@
18
18
  "cancel": "Cancel",
19
19
  "cancelEditConfirm": "Are you sure to cancel editing? All changes will be lost.",
20
20
  "pessimisticLockNotAcquired": "The row is being edited by the user {lockXUser} from {lockDate}\nDo you still want to edit the row? (The choice Cancel will open the form in read only mode).",
21
- "optimisticLockFailed": "Someone else has changed the row during the editation. Sorry, you have to cancel the editation and start the editation again.",
21
+ "optimisticLockFailed": "Someone else has changed the row{entity} during the editation. Sorry, you have to cancel the editation and start the editation again.",
22
22
  "formRemoveRowConfirm": "Are you sure to remove the row?",
23
23
  "xIsNotNull": "Is not null",
24
24
  "xIsNull": "Is null",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.38.4",
3
+ "version": "1.38.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",