@michalrakus/x-react-web-lib 1.38.3 → 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.
- package/lib/components/XFormBase.js +1 -1
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +3 -2
- package/lib/components/XLazyDataTable/XLazyDataTable.js +22 -20
- package/lib/components/XUtils.d.ts +2 -1
- package/lib/components/XUtils.js +16 -3
- package/lib/components/locale/x-en.json +1 -1
- package/lib/modules/docTemplates/xt-doc-template.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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) {
|
|
@@ -3,7 +3,7 @@ import { DataTableFilterMeta, DataTableFilterMetaData, DataTableOperatorFilterMe
|
|
|
3
3
|
import { ColumnBodyOptions, ColumnFilterElementTemplateOptions } from 'primereact/column';
|
|
4
4
|
import { XStorageType, XViewStatusOrBoolean } from "../XUtils";
|
|
5
5
|
import { XSearchBrowseParams } from "../XSearchBrowseParams";
|
|
6
|
-
import { XAggregateFunction, XCustomFilter } from "../../serverApi/FindParam";
|
|
6
|
+
import { FindParam, XAggregateFunction, XCustomFilter } from "../../serverApi/FindParam";
|
|
7
7
|
import { XOnSaveOrCancelProp } from "../XFormBase";
|
|
8
8
|
import { IconType } from "primereact/utils";
|
|
9
9
|
import { ButtonProps } from "primereact/button";
|
|
@@ -12,11 +12,12 @@ export type XBetweenFilterProp = "row" | "column" | undefined;
|
|
|
12
12
|
export type XMultilineRenderType = "singleLine" | "fewLines" | "allLines";
|
|
13
13
|
export type XOpenFormForInsert = (initValues?: object, onSaveOrCancel?: XOnSaveOrCancelProp, form?: JSX.Element) => void;
|
|
14
14
|
export type XOpenFormForUpdate = (id: number, onSaveOrCancel?: XOnSaveOrCancelProp, form?: JSX.Element) => void;
|
|
15
|
+
export type XAppButtonForRowOnClick = (selectedRow: any, findParam: FindParam) => void;
|
|
15
16
|
export interface XAppButtonForRow {
|
|
16
17
|
key?: string;
|
|
17
18
|
icon?: IconType<ButtonProps>;
|
|
18
19
|
label: string;
|
|
19
|
-
onClick:
|
|
20
|
+
onClick: XAppButtonForRowOnClick;
|
|
20
21
|
style?: React.CSSProperties;
|
|
21
22
|
}
|
|
22
23
|
export interface XOptionalCustomFilter {
|
|
@@ -628,11 +628,11 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
628
628
|
setupExpandedRows(findResult, multilineSwitchValue);
|
|
629
629
|
setLoading(false);
|
|
630
630
|
// save table state into session/local
|
|
631
|
-
//saveTableState(findParam); <- old solution, state is saved
|
|
632
|
-
// odlozime si filter hodnoty pre pripadny export
|
|
633
|
-
setFiltersAfterFiltering(filters);
|
|
631
|
+
//saveTableState(findParam); <- old solution, state is saved immediately after change of some filter field, sorting, etc.
|
|
632
|
+
// odlozime si filter hodnoty pre pripadny export (maybe simple cloning is enough, but to be sure we use deep)
|
|
633
|
+
setFiltersAfterFiltering(_.cloneDeep(filters));
|
|
634
634
|
setFtsInputValueAfterFiltering(ftsInputValue ? __assign({}, ftsInputValue) : undefined);
|
|
635
|
-
setOptionalCustomFilterAfterFiltering(optionalCustomFilter);
|
|
635
|
+
setOptionalCustomFilterAfterFiltering(optionalCustomFilter ? _.cloneDeep(optionalCustomFilter) : undefined);
|
|
636
636
|
// async check for new version - the purpose is to get new version of app to the browser (if available) in short time (10 minutes)
|
|
637
637
|
// (if there is no new version, the check will run async (as the last operation) and nothing will happen)
|
|
638
638
|
XUtils_1.XUtils.reloadIfNewVersion();
|
|
@@ -968,39 +968,41 @@ exports.XLazyDataTable = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
968
968
|
}); };
|
|
969
969
|
var onClickAppButtonForRow = function (onClick) {
|
|
970
970
|
if (selectedRow !== null) {
|
|
971
|
-
onClick(selectedRow);
|
|
971
|
+
onClick(selectedRow, createFindParamUsingAfterFiltering());
|
|
972
972
|
}
|
|
973
973
|
else {
|
|
974
974
|
alert((0, XLocale_1.xLocaleOption)('pleaseSelectRow'));
|
|
975
975
|
}
|
|
976
976
|
};
|
|
977
977
|
var onClickExport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
978
|
-
var
|
|
978
|
+
var findParam, findResult, exportParams;
|
|
979
979
|
return __generator(this, function (_a) {
|
|
980
980
|
switch (_a.label) {
|
|
981
981
|
case 0:
|
|
982
|
-
|
|
983
|
-
findParam = {
|
|
984
|
-
resultType: FindParam_1.ResultType.OnlyRowCount,
|
|
985
|
-
first: first,
|
|
986
|
-
rows: rowsLocal,
|
|
987
|
-
filters: filtersAfterFiltering,
|
|
988
|
-
fullTextSearch: createXFullTextSearch(ftsInputValueAfterFiltering),
|
|
989
|
-
customFilterItems: createXCustomFilterItems(customFilterItems, optionalCustomFilterAfterFiltering),
|
|
990
|
-
multiSortMeta: multiSortMeta,
|
|
991
|
-
entity: props.entity,
|
|
992
|
-
fields: fields,
|
|
993
|
-
aggregateItems: aggregateItems
|
|
994
|
-
};
|
|
982
|
+
findParam = createFindParamUsingAfterFiltering();
|
|
995
983
|
return [4 /*yield*/, findByFilter(findParam)];
|
|
996
984
|
case 1:
|
|
997
985
|
findResult = _a.sent();
|
|
998
|
-
exportParams = createExportParams(
|
|
986
|
+
exportParams = createExportParams(getFields(false), findResult.totalRecords);
|
|
999
987
|
setExportRowsDialogState({ dialogOpened: true, exportParams: exportParams });
|
|
1000
988
|
return [2 /*return*/];
|
|
1001
989
|
}
|
|
1002
990
|
});
|
|
1003
991
|
}); };
|
|
992
|
+
var createFindParamUsingAfterFiltering = function () {
|
|
993
|
+
return {
|
|
994
|
+
resultType: FindParam_1.ResultType.OnlyRowCount,
|
|
995
|
+
first: first,
|
|
996
|
+
rows: rowsLocal,
|
|
997
|
+
filters: filtersAfterFiltering,
|
|
998
|
+
fullTextSearch: createXFullTextSearch(ftsInputValueAfterFiltering),
|
|
999
|
+
customFilterItems: createXCustomFilterItems(customFilterItems, optionalCustomFilterAfterFiltering),
|
|
1000
|
+
multiSortMeta: multiSortMeta,
|
|
1001
|
+
entity: props.entity,
|
|
1002
|
+
fields: getFields(false),
|
|
1003
|
+
aggregateItems: aggregateItems
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1004
1006
|
var createExportParams = function (fields, rowCount) {
|
|
1005
1007
|
var queryParam = {
|
|
1006
1008
|
filters: filtersAfterFiltering,
|
|
@@ -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;
|
package/lib/components/XUtils.js
CHANGED
|
@@ -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
|
-
|
|
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",
|