@michalrakus/x-react-web-lib 1.32.9 → 1.32.11
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.
|
@@ -50,6 +50,7 @@ export interface XLazyDataTableProps {
|
|
|
50
50
|
entity: string;
|
|
51
51
|
stateKey?: string;
|
|
52
52
|
label?: string;
|
|
53
|
+
labelStyle?: React.CSSProperties;
|
|
53
54
|
dataKey?: string;
|
|
54
55
|
rowExpansionTemplate?: (row: any, options: DataTableRowExpansionTemplate) => React.ReactNode;
|
|
55
56
|
showExpandedRow?: (row: any, multilineSwitchValue: XMultilineRenderType) => boolean;
|
|
@@ -1355,7 +1355,7 @@ var XLazyDataTable = function (props) {
|
|
|
1355
1355
|
// x-lazy-datatable-label-right-compensation - vyvazuje label, aby item-y v strede isli aspon priblizne do stredu
|
|
1356
1356
|
return (react_1.default.createElement("div", null,
|
|
1357
1357
|
react_1.default.createElement("div", { className: "flex justify-content-center align-items-center" },
|
|
1358
|
-
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label" }, props.label) : null,
|
|
1358
|
+
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label", style: props.labelStyle }, props.label) : null,
|
|
1359
1359
|
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
1360
1360
|
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "filter", icon: isMobile ? "pi pi-search" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('filter') : undefined, onClick: onClickFilter }) : null,
|
|
1361
1361
|
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "resetTable", icon: isMobile ? "pi pi-ban" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('resetTable') : undefined, onClick: onClickResetTable }) : null,
|
|
@@ -110,8 +110,10 @@ export declare class XUtils {
|
|
|
110
110
|
static saveValueIntoStorage(key: string, value: any): void;
|
|
111
111
|
static getValueFromStorage(key: string, initValue: any): any;
|
|
112
112
|
static removeValueFromStorage(key: string): void;
|
|
113
|
+
static clearStorage(): void;
|
|
113
114
|
static reloadIfNewVersion(): void;
|
|
114
115
|
static reloadIfNewVersionNow(): Promise<void>;
|
|
116
|
+
static isLocalhost(): boolean;
|
|
115
117
|
static isNewVersion(): Promise<boolean>;
|
|
116
118
|
static reload(): void;
|
|
117
119
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -749,6 +749,9 @@ var XUtils = /** @class */ (function () {
|
|
|
749
749
|
XUtils.removeValueFromStorage = function (key) {
|
|
750
750
|
sessionStorage.removeItem(key);
|
|
751
751
|
};
|
|
752
|
+
XUtils.clearStorage = function () {
|
|
753
|
+
sessionStorage.clear();
|
|
754
|
+
};
|
|
752
755
|
// hleper method used for items of XLazyDataTable (shortcut ldt)
|
|
753
756
|
// static getValueFromStorageLdt(entity: string, stateKeySuffix: XStateKeySuffix, initValue: any): any {
|
|
754
757
|
// return XUtils.getValueFromStorage(`xldt-state-${entity}-${stateKeySuffix}`, initValue);
|
|
@@ -778,9 +781,12 @@ var XUtils = /** @class */ (function () {
|
|
|
778
781
|
});
|
|
779
782
|
});
|
|
780
783
|
};
|
|
784
|
+
XUtils.isLocalhost = function () {
|
|
785
|
+
return window.location.hostname === 'localhost';
|
|
786
|
+
};
|
|
781
787
|
XUtils.isNewVersion = function () {
|
|
782
788
|
return __awaiter(this, void 0, void 0, function () {
|
|
783
|
-
var response, text,
|
|
789
|
+
var response, text, remoteMainScript, r, localMainScript, scripts, scripts_1, scripts_1_1, script, rl, err_1;
|
|
784
790
|
var e_7, _a;
|
|
785
791
|
return __generator(this, function (_b) {
|
|
786
792
|
switch (_b.label) {
|
|
@@ -792,25 +798,28 @@ var XUtils = /** @class */ (function () {
|
|
|
792
798
|
return [4 /*yield*/, response.text()];
|
|
793
799
|
case 2:
|
|
794
800
|
text = _b.sent();
|
|
801
|
+
remoteMainScript = null;
|
|
795
802
|
r = /^.*<script.*\/(main.*\.js).*$/gim.exec(text);
|
|
796
|
-
if (
|
|
797
|
-
|
|
803
|
+
if (r && r.length >= 2) {
|
|
804
|
+
remoteMainScript = r[1];
|
|
798
805
|
}
|
|
799
|
-
remoteMainScript = r.length > 1 ? r[1] : null;
|
|
800
806
|
if (remoteMainScript === null) {
|
|
807
|
+
if (!XUtils.isLocalhost()) {
|
|
808
|
+
console.log("XUtils.isNewVersion(): Unexpected error - remoteMainScript (e.g. main.9d782ae7.js) not found in index.html from server. Content of index.html:");
|
|
809
|
+
console.log(text);
|
|
810
|
+
}
|
|
801
811
|
return [2 /*return*/, false];
|
|
802
812
|
}
|
|
803
813
|
localMainScript = null;
|
|
804
|
-
scripts = document.
|
|
814
|
+
scripts = document.head.getElementsByTagName('script');
|
|
805
815
|
try {
|
|
806
816
|
for (scripts_1 = __values(scripts), scripts_1_1 = scripts_1.next(); !scripts_1_1.done; scripts_1_1 = scripts_1.next()) {
|
|
807
817
|
script = scripts_1_1.value;
|
|
808
818
|
rl = /^.*\/(main.*\.js).*$/gim.exec(script.src);
|
|
809
|
-
if (
|
|
810
|
-
|
|
819
|
+
if (rl && rl.length >= 2) {
|
|
820
|
+
localMainScript = rl[1];
|
|
821
|
+
break;
|
|
811
822
|
}
|
|
812
|
-
localMainScript = rl[1];
|
|
813
|
-
break;
|
|
814
823
|
}
|
|
815
824
|
}
|
|
816
825
|
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
@@ -821,6 +830,10 @@ var XUtils = /** @class */ (function () {
|
|
|
821
830
|
finally { if (e_7) throw e_7.error; }
|
|
822
831
|
}
|
|
823
832
|
if (localMainScript === null) {
|
|
833
|
+
if (!XUtils.isLocalhost()) {
|
|
834
|
+
console.log("XUtils.isNewVersion(): Unexpected error - localMainScript (e.g. main.9d782ae7.js) not found in element <head>...<script src=\"->here<-\"/>...</head>");
|
|
835
|
+
console.log(document.head);
|
|
836
|
+
}
|
|
824
837
|
return [2 /*return*/, false];
|
|
825
838
|
}
|
|
826
839
|
return [2 /*return*/, remoteMainScript !== localMainScript];
|
|
@@ -834,6 +847,10 @@ var XUtils = /** @class */ (function () {
|
|
|
834
847
|
});
|
|
835
848
|
};
|
|
836
849
|
XUtils.reload = function () {
|
|
850
|
+
// data in session may not correspond with new structures in new version
|
|
851
|
+
// e.g. if we add new column to XLazyDataTable, filter operator/value for this column new column is missing in data from session and application will crash
|
|
852
|
+
// simple solution is to clear session
|
|
853
|
+
XUtils.clearStorage();
|
|
837
854
|
// page reload (like pressing F5 or Enter on url bar)
|
|
838
855
|
// warning - if user has typed some data in form, the data will be lost
|
|
839
856
|
window.location.reload();
|