@michalrakus/x-react-web-lib 1.32.10 → 1.32.12
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.
|
@@ -11,6 +11,7 @@ import { XFormComponentDT } from "./XFormComponentDT";
|
|
|
11
11
|
import { XErrorMap } from "./XErrors";
|
|
12
12
|
import { IconType } from "primereact/utils";
|
|
13
13
|
import { ButtonProps } from "primereact/button";
|
|
14
|
+
import { XSuggestionsLoadProp } from "./XAutoCompleteBase";
|
|
14
15
|
export interface XRowTechData {
|
|
15
16
|
xFormComponentDTList: Array<XFormComponentDT<any>>;
|
|
16
17
|
errorMap: XErrorMap;
|
|
@@ -113,14 +114,18 @@ export interface XFormDropdownColumnProps extends XFormColumnBaseProps {
|
|
|
113
114
|
}
|
|
114
115
|
export interface XFormAutoCompleteColumnProps extends XFormColumnBaseProps {
|
|
115
116
|
assocField: string;
|
|
116
|
-
displayField: string;
|
|
117
|
+
displayField: string | string[];
|
|
118
|
+
itemTemplate?: (suggestion: any, index: number, createStringValue: boolean, defaultValue: (suggestion: any) => string) => React.ReactNode;
|
|
117
119
|
searchBrowse?: JSX.Element;
|
|
118
120
|
assocForm?: JSX.Element;
|
|
119
121
|
addRowEnabled: boolean;
|
|
120
122
|
filter?: XTableFieldFilterProp;
|
|
121
123
|
sortField?: string | DataTableSortMeta[];
|
|
122
124
|
fields?: string[];
|
|
125
|
+
scrollHeight?: string;
|
|
123
126
|
suggestions?: any[];
|
|
127
|
+
suggestionsLoad?: XSuggestionsLoadProp;
|
|
128
|
+
lazyLoadMaxRows?: number;
|
|
124
129
|
}
|
|
125
130
|
export interface XFormSearchButtonColumnProps extends XFormColumnBaseProps {
|
|
126
131
|
assocField: string;
|
|
@@ -145,7 +145,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
145
145
|
}
|
|
146
146
|
else if (columnProps.type === "autoComplete") {
|
|
147
147
|
var columnPropsAutoComplete = columnProps;
|
|
148
|
-
|
|
148
|
+
// for simplicity we use here the first column (is used for filtering/sorting)
|
|
149
|
+
// TODO - all columns add in constructor (through method props.form.addField(...))
|
|
150
|
+
var displayField = Array.isArray(columnPropsAutoComplete.displayField) ? columnPropsAutoComplete.displayField[0] : columnPropsAutoComplete.displayField;
|
|
151
|
+
return columnPropsAutoComplete.assocField + '.' + displayField;
|
|
149
152
|
}
|
|
150
153
|
else if (columnProps.type === "searchButton") {
|
|
151
154
|
var columnPropsSearchButton = columnProps;
|
|
@@ -404,7 +407,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
|
|
|
404
407
|
}
|
|
405
408
|
else if (columnProps.type === "autoComplete") {
|
|
406
409
|
var columnPropsAutoComplete = columnProps;
|
|
407
|
-
body = react_1.default.createElement(XAutoCompleteDT_1.XAutoCompleteDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsAutoComplete.assocField, displayField: columnPropsAutoComplete.displayField, searchBrowse: columnPropsAutoComplete.searchBrowse, assocForm: columnPropsAutoComplete.assocForm, addRowEnabled: columnPropsAutoComplete.addRowEnabled, filter: columnPropsAutoComplete.filter, sortField: columnPropsAutoComplete.sortField, fields: columnPropsAutoComplete.fields, suggestions: columnPropsAutoComplete.suggestions, rowData: rowData, readOnly: readOnly });
|
|
410
|
+
body = react_1.default.createElement(XAutoCompleteDT_1.XAutoCompleteDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsAutoComplete.assocField, displayField: columnPropsAutoComplete.displayField, itemTemplate: columnPropsAutoComplete.itemTemplate, searchBrowse: columnPropsAutoComplete.searchBrowse, assocForm: columnPropsAutoComplete.assocForm, addRowEnabled: columnPropsAutoComplete.addRowEnabled, filter: columnPropsAutoComplete.filter, sortField: columnPropsAutoComplete.sortField, fields: columnPropsAutoComplete.fields, scrollHeight: columnPropsAutoComplete.scrollHeight, suggestions: columnPropsAutoComplete.suggestions, suggestionsLoad: columnPropsAutoComplete.suggestionsLoad, lazyLoadMaxRows: columnPropsAutoComplete.lazyLoadMaxRows, rowData: rowData, readOnly: readOnly });
|
|
408
411
|
}
|
|
409
412
|
else if (columnProps.type === "searchButton") {
|
|
410
413
|
var columnPropsSearchButton = columnProps;
|
|
@@ -113,6 +113,7 @@ export declare class XUtils {
|
|
|
113
113
|
static clearStorage(): void;
|
|
114
114
|
static reloadIfNewVersion(): void;
|
|
115
115
|
static reloadIfNewVersionNow(): Promise<void>;
|
|
116
|
+
static isLocalhost(): boolean;
|
|
116
117
|
static isNewVersion(): Promise<boolean>;
|
|
117
118
|
static reload(): void;
|
|
118
119
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -781,9 +781,12 @@ var XUtils = /** @class */ (function () {
|
|
|
781
781
|
});
|
|
782
782
|
});
|
|
783
783
|
};
|
|
784
|
+
XUtils.isLocalhost = function () {
|
|
785
|
+
return window.location.hostname === 'localhost';
|
|
786
|
+
};
|
|
784
787
|
XUtils.isNewVersion = function () {
|
|
785
788
|
return __awaiter(this, void 0, void 0, function () {
|
|
786
|
-
var response, text,
|
|
789
|
+
var response, text, remoteMainScript, r, localMainScript, scripts, scripts_1, scripts_1_1, script, rl, err_1;
|
|
787
790
|
var e_7, _a;
|
|
788
791
|
return __generator(this, function (_b) {
|
|
789
792
|
switch (_b.label) {
|
|
@@ -795,25 +798,28 @@ var XUtils = /** @class */ (function () {
|
|
|
795
798
|
return [4 /*yield*/, response.text()];
|
|
796
799
|
case 2:
|
|
797
800
|
text = _b.sent();
|
|
801
|
+
remoteMainScript = null;
|
|
798
802
|
r = /^.*<script.*\/(main.*\.js).*$/gim.exec(text);
|
|
799
|
-
if (
|
|
800
|
-
|
|
803
|
+
if (r && r.length >= 2) {
|
|
804
|
+
remoteMainScript = r[1];
|
|
801
805
|
}
|
|
802
|
-
remoteMainScript = r.length > 1 ? r[1] : null;
|
|
803
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
|
+
}
|
|
804
811
|
return [2 /*return*/, false];
|
|
805
812
|
}
|
|
806
813
|
localMainScript = null;
|
|
807
|
-
scripts = document.
|
|
814
|
+
scripts = document.head.getElementsByTagName('script');
|
|
808
815
|
try {
|
|
809
816
|
for (scripts_1 = __values(scripts), scripts_1_1 = scripts_1.next(); !scripts_1_1.done; scripts_1_1 = scripts_1.next()) {
|
|
810
817
|
script = scripts_1_1.value;
|
|
811
818
|
rl = /^.*\/(main.*\.js).*$/gim.exec(script.src);
|
|
812
|
-
if (
|
|
813
|
-
|
|
819
|
+
if (rl && rl.length >= 2) {
|
|
820
|
+
localMainScript = rl[1];
|
|
821
|
+
break;
|
|
814
822
|
}
|
|
815
|
-
localMainScript = rl[1];
|
|
816
|
-
break;
|
|
817
823
|
}
|
|
818
824
|
}
|
|
819
825
|
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
@@ -824,6 +830,10 @@ var XUtils = /** @class */ (function () {
|
|
|
824
830
|
finally { if (e_7) throw e_7.error; }
|
|
825
831
|
}
|
|
826
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
|
+
}
|
|
827
837
|
return [2 /*return*/, false];
|
|
828
838
|
}
|
|
829
839
|
return [2 /*return*/, remoteMainScript !== localMainScript];
|