@michalrakus/x-react-web-lib 1.22.0 → 1.24.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.
Files changed (100) hide show
  1. package/XMultiSelect.d.ts +3 -0
  2. package/XMultiSelect.js +5 -0
  3. package/XMultiSelectBase.d.ts +3 -0
  4. package/XMultiSelectBase.js +5 -0
  5. package/gulpfile.js +2 -0
  6. package/lib/administration/XBrowseMetaBrowse.d.ts +2 -2
  7. package/lib/administration/XBrowseMetaForm.d.ts +2 -2
  8. package/lib/administration/XParamBrowse.d.ts +2 -2
  9. package/lib/administration/XParamForm.d.ts +2 -2
  10. package/lib/administration/XUserBrowse.d.ts +2 -2
  11. package/lib/administration/XUserForm.d.ts +2 -2
  12. package/lib/components/SourceCodeLinkEntity.d.ts +2 -2
  13. package/lib/components/XAutoComplete.d.ts +2 -1
  14. package/lib/components/XAutoComplete.js +2 -2
  15. package/lib/components/XAutoCompleteBase.d.ts +5 -11
  16. package/lib/components/XAutoCompleteBase.js +30 -13
  17. package/lib/components/XAutoCompleteDT.d.ts +1 -1
  18. package/lib/components/XButton.d.ts +1 -1
  19. package/lib/components/XButtonIconMedium.d.ts +1 -1
  20. package/lib/components/XButtonIconNarrow.d.ts +1 -1
  21. package/lib/components/XButtonIconSmall.d.ts +1 -1
  22. package/lib/components/XCalendar.d.ts +2 -2
  23. package/lib/components/XCalendar.js +1 -1
  24. package/lib/components/XChangePasswordForm.d.ts +2 -2
  25. package/lib/components/XCheckbox.js +1 -1
  26. package/lib/components/XCheckboxDT.d.ts +2 -2
  27. package/lib/components/XDataTable.d.ts +2 -2
  28. package/lib/components/XDropdown.d.ts +2 -2
  29. package/lib/components/XDropdown.js +1 -1
  30. package/lib/components/XDropdownDT.d.ts +2 -2
  31. package/lib/components/XDropdownDTFilter.d.ts +2 -2
  32. package/lib/components/XDropdownForEntity.d.ts +2 -2
  33. package/lib/components/XDropdownForEntity.js +1 -1
  34. package/lib/components/XDropdownFormDTFilter.d.ts +2 -2
  35. package/lib/components/XEditBrowse.d.ts +2 -2
  36. package/lib/components/XEditColumnDialog.d.ts +2 -2
  37. package/lib/components/XEditor.d.ts +1 -1
  38. package/lib/components/XEditorBase.d.ts +1 -1
  39. package/lib/components/XEditorBase.js +1 -1
  40. package/lib/components/XFieldSelector.d.ts +2 -2
  41. package/lib/components/XFormBase.d.ts +1 -0
  42. package/lib/components/XFormBase.js +4 -0
  43. package/lib/components/XFormComponent.d.ts +1 -0
  44. package/lib/components/XFormDataTable2.d.ts +1 -1
  45. package/lib/components/XFormFooter.d.ts +2 -2
  46. package/lib/components/XFormHeader.d.ts +4 -2
  47. package/lib/components/XFormHeader.js +3 -1
  48. package/lib/components/XFormNavigator3.d.ts +2 -2
  49. package/lib/components/XFormRowCol/XFormCol.d.ts +2 -1
  50. package/lib/components/XFormRowCol/XFormCol.js +1 -1
  51. package/lib/components/XFormRowCol/XFormInlineRow.d.ts +1 -1
  52. package/lib/components/XFormRowCol/XFormRow.d.ts +1 -1
  53. package/lib/components/XFormRowCol/XFormRowCol.d.ts +2 -1
  54. package/lib/components/XFormRowCol/XFormRowCol.js +8 -1
  55. package/lib/components/XFtsInput.d.ts +2 -2
  56. package/lib/components/XHolders.d.ts +3 -3
  57. package/lib/components/XInputDate.d.ts +2 -2
  58. package/lib/components/XInputDateDT.d.ts +2 -2
  59. package/lib/components/XInputDecimal.d.ts +1 -1
  60. package/lib/components/XInputDecimalBase.d.ts +2 -2
  61. package/lib/components/XInputDecimalDT.d.ts +2 -2
  62. package/lib/components/XInputDecimalDT.js +1 -1
  63. package/lib/components/XInputFileList.d.ts +2 -1
  64. package/lib/components/XInputInterval.d.ts +1 -1
  65. package/lib/components/XInputIntervalBase.d.ts +2 -2
  66. package/lib/components/XInputIntervalBase.js +1 -1
  67. package/lib/components/XInputIntervalDT.d.ts +2 -2
  68. package/lib/components/XInputText.d.ts +2 -2
  69. package/lib/components/XInputText.js +14 -3
  70. package/lib/components/XInputTextDT.d.ts +2 -2
  71. package/lib/components/XInputTextarea.d.ts +1 -1
  72. package/lib/components/XInputTextarea.js +31 -6
  73. package/lib/components/XInputTextareaBase.d.ts +3 -1
  74. package/lib/components/XInputTextareaBase.js +1 -1
  75. package/lib/components/XInputTextareaDT.d.ts +2 -2
  76. package/lib/components/XLazyDataTable/XExportRowsDialog.d.ts +2 -2
  77. package/lib/components/XLazyDataTable/XExportRowsDialog.js +5 -5
  78. package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +1 -1
  79. package/lib/components/XLazyDataTable/XMultilineSwitch.d.ts +2 -2
  80. package/lib/components/XLazyDataTable/XOcfDropdown.d.ts +2 -2
  81. package/lib/components/XLoginDialog.d.ts +2 -2
  82. package/lib/components/XLoginForm.d.ts +2 -2
  83. package/lib/components/XMultiSelect.d.ts +25 -0
  84. package/lib/components/XMultiSelect.js +97 -0
  85. package/lib/components/XMultiSelectBase.d.ts +27 -0
  86. package/lib/components/XMultiSelectBase.js +145 -0
  87. package/lib/components/XSearchBrowseParams.d.ts +1 -1
  88. package/lib/components/XSearchButton.d.ts +1 -1
  89. package/lib/components/XSearchButton.js +1 -1
  90. package/lib/components/XSearchButtonDT.d.ts +2 -2
  91. package/lib/components/XSearchButtonDT.js +1 -1
  92. package/lib/components/XSearchButtonOld.d.ts +1 -1
  93. package/lib/components/XToOneAssocButton.d.ts +2 -2
  94. package/lib/components/XToken.d.ts +1 -1
  95. package/lib/components/XUtils.d.ts +11 -2
  96. package/lib/components/XUtils.js +45 -21
  97. package/lib/components/locale/x-en.json +1 -0
  98. package/lib/serverApi/XUtilsMetadataCommon.d.ts +3 -1
  99. package/lib/serverApi/XUtilsMetadataCommon.js +9 -3
  100. package/package.json +3 -3
@@ -0,0 +1,27 @@
1
+ import React, { Component } from "react";
2
+ import { XQuery } from "./XUtils";
3
+ import { DataTableSortMeta } from "primereact/datatable";
4
+ import { XDropdownForEntityProps } from "./XDropdownForEntity";
5
+ export interface XMultiSelectBaseProps {
6
+ value: any[];
7
+ onChange: (value: any[]) => void;
8
+ optionsQuery?: XQuery;
9
+ displayField: string;
10
+ maxSelectedLabels?: number;
11
+ width?: string;
12
+ scrollHeight?: string;
13
+ readOnly?: boolean;
14
+ error?: string;
15
+ }
16
+ export declare class XMultiSelectBase extends Component<XMultiSelectBaseProps> {
17
+ static defaultProps: {};
18
+ protected idField: string;
19
+ state: {
20
+ options: any[];
21
+ };
22
+ constructor(props: XDropdownForEntityProps);
23
+ componentDidMount(): void;
24
+ loadOptions(): Promise<void>;
25
+ getSortField(): string | DataTableSortMeta[] | undefined;
26
+ render(): React.JSX.Element;
27
+ }
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53
+ return new (P || (P = Promise))(function (resolve, reject) {
54
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
58
+ });
59
+ };
60
+ var __generator = (this && this.__generator) || function (thisArg, body) {
61
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
62
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
+ function verb(n) { return function (v) { return step([n, v]); }; }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+ switch (op[0]) {
70
+ case 0: case 1: t = op; break;
71
+ case 4: _.label++; return { value: op[1], done: false };
72
+ case 5: _.label++; y = op[1]; op = [0]; continue;
73
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
+ default:
75
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
+ if (t[2]) _.ops.pop();
80
+ _.trys.pop(); continue;
81
+ }
82
+ op = body.call(thisArg, _);
83
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
+ }
86
+ };
87
+ Object.defineProperty(exports, "__esModule", { value: true });
88
+ exports.XMultiSelectBase = void 0;
89
+ var react_1 = __importStar(require("react"));
90
+ var XUtils_1 = require("./XUtils");
91
+ var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
92
+ var multiselect_1 = require("primereact/multiselect");
93
+ var XMultiSelectBase = /** @class */ (function (_super) {
94
+ __extends(XMultiSelectBase, _super);
95
+ function XMultiSelectBase(props) {
96
+ var _this = _super.call(this, props) || this;
97
+ if (!_this.props.optionsQuery) {
98
+ throw "XMultiSelectBase.optionsQuery: unexpected error - prop optionsQuery is undefined";
99
+ }
100
+ _this.idField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(_this.props.optionsQuery.entity).idField;
101
+ _this.state = {
102
+ options: []
103
+ };
104
+ return _this;
105
+ }
106
+ XMultiSelectBase.prototype.componentDidMount = function () {
107
+ this.loadOptions();
108
+ };
109
+ XMultiSelectBase.prototype.loadOptions = function () {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var options;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0:
115
+ if (!this.props.optionsQuery) {
116
+ throw "XMultiSelectBase.optionsQuery: unexpected error - prop optionsQuery is undefined";
117
+ }
118
+ return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.props.optionsQuery.entity, XUtils_1.XUtils.evalFilter(this.props.optionsQuery.filter), this.getSortField(), this.props.optionsQuery.fields)];
119
+ case 1:
120
+ options = _a.sent();
121
+ this.setState({ options: options });
122
+ return [2 /*return*/];
123
+ }
124
+ });
125
+ });
126
+ };
127
+ XMultiSelectBase.prototype.getSortField = function () {
128
+ var sortField = this.props.optionsQuery.sortField;
129
+ if (!sortField) {
130
+ // ako default pouzivame displayField
131
+ sortField = this.props.displayField;
132
+ }
133
+ return sortField;
134
+ };
135
+ XMultiSelectBase.prototype.render = function () {
136
+ var _this = this;
137
+ // propertiesy na Dropdown-e: readOnly vyseduje, disabled znemoznuje vyber polozky
138
+ return (react_1.default.createElement(multiselect_1.MultiSelect, __assign({ options: this.state.options, optionLabel: this.props.displayField, dataKey: this.idField, maxSelectedLabels: this.props.maxSelectedLabels, display: "chip", value: this.props.value, onChange: function (e) { return _this.props.onChange(e.value); }, readOnly: this.props.readOnly, disabled: this.props.readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(this.props.error))));
139
+ };
140
+ XMultiSelectBase.defaultProps = {
141
+ //scrollHeight: '15rem' // primereact has 200px
142
+ };
143
+ return XMultiSelectBase;
144
+ }(react_1.Component));
145
+ exports.XMultiSelectBase = XMultiSelectBase;
@@ -1,5 +1,5 @@
1
1
  import { DataTableFilterMetaData } from "primereact/datatable";
2
- import { XFilterOrFunction } from "./XAutoCompleteBase";
2
+ import { XFilterOrFunction } from "./XUtils";
3
3
  export interface XFieldFilter {
4
4
  field: string;
5
5
  constraint: DataTableFilterMetaData;
@@ -22,5 +22,5 @@ export declare class XSearchButton extends XFormComponent<XObject, XSearchButton
22
22
  constructor(props: XSearchButtonProps);
23
23
  getField(): string;
24
24
  isNotNull(): boolean;
25
- render(): JSX.Element;
25
+ render(): React.JSX.Element;
26
26
  }
@@ -214,7 +214,7 @@ var XSearchButton = /** @class */ (function (_super) {
214
214
  react_1.default.createElement("div", { className: "x-search-button-base" },
215
215
  react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: this.isReadOnly(), ref: this.inputTextRef, maxLength: xDisplayField.length, size: size, style: props.inputStyle }, this.getClassNameTooltip())),
216
216
  react_1.default.createElement(button_1.Button, { icon: "pi pi-search", onClick: onClickSearch })),
217
- react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, { searchBrowseParams: createSearchBrowseParams() } /*, props.searchBrowse.children*/))));
217
+ react_1.default.createElement(dialog_1.Dialog, { className: "x-dialog-without-header", visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, { searchBrowseParams: createSearchBrowseParams() } /*, props.searchBrowse.children*/))));
218
218
  };
219
219
  return XSearchButton;
220
220
  }(XFormComponent_1.XFormComponent));
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { XFormBase } from "./XFormBase";
2
+ import React from "react";
3
3
  import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
4
4
  export declare const XSearchButtonDT: (props: {
5
5
  form: XFormBase;
@@ -10,4 +10,4 @@ export declare const XSearchButtonDT: (props: {
10
10
  assocForm?: JSX.Element | undefined;
11
11
  rowData: any;
12
12
  readOnly?: XTableFieldReadOnlyProp | undefined;
13
- }) => JSX.Element;
13
+ }) => React.JSX.Element;
@@ -181,7 +181,7 @@ var XSearchButtonDT = function (props) {
181
181
  react_1.default.createElement("div", { className: "x-search-button-base" },
182
182
  react_1.default.createElement(inputtext_1.InputText, { id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: readOnly, ref: inputTextRef }),
183
183
  react_1.default.createElement(button_1.Button, { icon: "pi pi-search", onClick: onClickSearch })),
184
- react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, {
184
+ react_1.default.createElement(dialog_1.Dialog, { className: "x-dialog-without-header", visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchBrowse, {
185
185
  searchBrowseParams: {
186
186
  onChoose: onChoose,
187
187
  displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "contains" } } : undefined),
@@ -10,4 +10,4 @@ export declare const XSearchButtonOld: (props: {
10
10
  readOnly?: boolean | undefined;
11
11
  size?: number | undefined;
12
12
  inputStyle?: React.CSSProperties | undefined;
13
- }) => JSX.Element;
13
+ }) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
2
1
  import { XFormBase } from "./XFormBase";
2
+ import React from "react";
3
3
  export declare const XToOneAssocButton: (props: {
4
4
  form: XFormBase;
5
5
  assocField: string;
6
6
  assocForm: any;
7
7
  label?: string | undefined;
8
- }) => JSX.Element;
8
+ }) => React.JSX.Element;
@@ -1,6 +1,6 @@
1
1
  export interface XToken {
2
2
  username?: string;
3
3
  password?: string;
4
- accessToken?: string;
4
+ accessToken?: string | (() => Promise<string>);
5
5
  xUser?: any;
6
6
  }
@@ -7,7 +7,7 @@ import { XCustomFilter, XCustomFilterItem } from "../serverApi/FindParam";
7
7
  import { DataTableSortMeta } from "primereact/datatable";
8
8
  import { XObject } from "./XObject";
9
9
  import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
10
- import { XFilterOrFunction } from "./XAutoCompleteBase";
10
+ import { SelectItem } from "primereact/selectitem";
11
11
  export declare enum OperationType {
12
12
  None = 0,
13
13
  Insert = 1,
@@ -29,6 +29,13 @@ export interface IPostgresInterval {
29
29
  seconds?: number;
30
30
  milliseconds?: number;
31
31
  }
32
+ export type XFilterOrFunction = XCustomFilter | (() => XCustomFilter | undefined);
33
+ export interface XQuery {
34
+ entity: string;
35
+ filter?: XFilterOrFunction;
36
+ sortField?: string | DataTableSortMeta[];
37
+ fields?: string[];
38
+ }
32
39
  export declare class XUtils {
33
40
  static dropdownEmptyOptionValue: string;
34
41
  static xBackendUrl: string | undefined;
@@ -69,6 +76,7 @@ export declare class XUtils {
69
76
  static fetchById(entity: string, fields: string[], id: number): Promise<any>;
70
77
  static setXToken(xToken: XToken | null): void;
71
78
  static getXToken(): XToken | null;
79
+ static getAccessToken(): Promise<string>;
72
80
  static getUsername(): string | undefined;
73
81
  static getXBackendUrl(): string;
74
82
  static setXBackendUrl(xBackendUrl: string | undefined): void;
@@ -102,7 +110,7 @@ export declare class XUtils {
102
110
  static isReadOnlyTableField(path: string | undefined, readOnly: XTableFieldReadOnlyProp | undefined, object: XObject | null, tableRow: any): boolean;
103
111
  static markNotNull(label: string): string;
104
112
  static showErrorMessage(message: string, e: unknown): void;
105
- static createErrorProps(error: string | undefined): {};
113
+ static createTooltipOrErrorProps(error: string | undefined, tooltip?: string | undefined): object;
106
114
  static addClassName(props: {
107
115
  [key: string]: any;
108
116
  }, className: string): {
@@ -118,4 +126,5 @@ export declare class XUtils {
118
126
  static evalFilter(filter: XFilterOrFunction | undefined): XCustomFilter | undefined;
119
127
  static isTableRowInserted(tableRow: any): boolean;
120
128
  static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
129
+ static options(valueStringList: string[]): SelectItem[];
121
130
  }
@@ -424,36 +424,26 @@ var XUtils = /** @class */ (function () {
424
424
  };
425
425
  XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
426
426
  return __awaiter(this, void 0, void 0, function () {
427
- var xToken, response, responseBody;
427
+ var accessToken, response, responseBody;
428
428
  return __generator(this, function (_a) {
429
429
  switch (_a.label) {
430
- case 0:
431
- if (typeof usePublicToken === 'object') {
432
- xToken = usePublicToken;
433
- }
434
- else if (usePublicToken) {
435
- xToken = XUtils.xTokenPublic; // public token vzdy
436
- }
437
- else {
438
- xToken = XUtils.getXToken();
439
- if (xToken === null) {
440
- xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
441
- }
442
- }
443
- headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(xToken.accessToken) });
430
+ case 0: return [4 /*yield*/, XUtils.getAccessToken()];
431
+ case 1:
432
+ accessToken = _a.sent();
433
+ headers = __assign(__assign({}, headers), { 'Authorization': "Bearer ".concat(accessToken) });
444
434
  return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
445
435
  method: 'POST',
446
436
  headers: headers,
447
437
  body: body
448
438
  })];
449
- case 1:
439
+ case 2:
450
440
  response = _a.sent();
451
- if (!!response.ok) return [3 /*break*/, 3];
441
+ if (!!response.ok) return [3 /*break*/, 4];
452
442
  return [4 /*yield*/, response.json()];
453
- case 2:
443
+ case 3:
454
444
  responseBody = _a.sent();
455
445
  throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
456
- case 3: return [2 /*return*/, response];
446
+ case 4: return [2 /*return*/, response];
457
447
  }
458
448
  });
459
449
  });
@@ -467,6 +457,34 @@ var XUtils = /** @class */ (function () {
467
457
  XUtils.getXToken = function () {
468
458
  return XUtils.xToken;
469
459
  };
460
+ XUtils.getAccessToken = function () {
461
+ return __awaiter(this, void 0, void 0, function () {
462
+ var xToken, accessToken;
463
+ return __generator(this, function (_a) {
464
+ switch (_a.label) {
465
+ case 0:
466
+ xToken = XUtils.getXToken();
467
+ if (xToken === null) {
468
+ throw "Unexpected error - XUtils.xToken is null (no user signed in)";
469
+ }
470
+ if (!(typeof xToken.accessToken === 'function')) return [3 /*break*/, 2];
471
+ return [4 /*yield*/, xToken.accessToken()];
472
+ case 1:
473
+ accessToken = _a.sent(); // ziskame access token volanim getAccessTokenSilently (pripadne podobnym)
474
+ return [3 /*break*/, 3];
475
+ case 2:
476
+ if (xToken.accessToken !== undefined) {
477
+ accessToken = xToken.accessToken; // mame rovno access token
478
+ }
479
+ else {
480
+ throw "Unexpected error - XUtils.xToken.accessToken is undefined";
481
+ }
482
+ _a.label = 3;
483
+ case 3: return [2 /*return*/, accessToken];
484
+ }
485
+ });
486
+ });
487
+ };
470
488
  XUtils.getUsername = function () {
471
489
  var _a, _b;
472
490
  return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
@@ -653,8 +671,10 @@ var XUtils = /** @class */ (function () {
653
671
  alert(msg);
654
672
  };
655
673
  // pouziva sa hlavne na inputy
656
- XUtils.createErrorProps = function (error) {
657
- return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } } : {};
674
+ XUtils.createTooltipOrErrorProps = function (error, tooltip) {
675
+ // error ma prednost, ak nemame error, dame tooltip ak mame
676
+ return error ? { className: "p-invalid", tooltip: error, tooltipOptions: { className: 'pink-tooltip', position: 'bottom' } }
677
+ : (tooltip ? { tooltip: tooltip, tooltipOptions: { position: 'bottom' } } : {});
658
678
  };
659
679
  // pomocna metodka - prida className do props, ak uz className v props existuje tak len pripoji dalsiu hodnotu
660
680
  // pouzivame ju, lebo XUtils.createErrorProps nam prebijal className
@@ -821,6 +841,10 @@ var XUtils = /** @class */ (function () {
821
841
  }
822
842
  return xViewStatus;
823
843
  };
844
+ // plain string does not work in Dropdown, bug in Primereact?
845
+ XUtils.options = function (valueStringList) {
846
+ return valueStringList.map(function (valueString) { return { value: valueString, label: valueString }; });
847
+ };
824
848
  XUtils.dropdownEmptyOptionValue = " ";
825
849
  XUtils.xBackendUrl = undefined;
826
850
  // nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
@@ -11,6 +11,7 @@
11
11
  "pleaseSelectRow": "Please select the row.",
12
12
  "removeRowConfirm": "Are you sure to remove the selected row?",
13
13
  "removeRowFailed": "Remove row failed.",
14
+ "newRow": "new row",
14
15
  "save": "Save",
15
16
  "cancel": "Cancel",
16
17
  "expRowCount": "Row count",
@@ -16,7 +16,9 @@ export declare class XUtilsMetadataCommon {
16
16
  static hasPathToManyAssoc(xEntity: XEntity, path: string): boolean;
17
17
  static getXFieldByPathStr(entity: string, path: string): XField;
18
18
  static getXAssocBase(xEntity: XEntity, assocField: string): XAssoc | undefined;
19
- static getXAssocByPath(xEntity: XEntity, path: string): XAssoc;
19
+ static getXAssocToOneByPath(xEntity: XEntity, path: string): XAssoc;
20
+ static getXAssocToManyByPath(xEntity: XEntity, path: string): XAssoc;
21
+ static getXAssocByPath(xEntity: XEntity, path: string, relationTypeList?: XRelationType[]): XAssoc;
20
22
  static getLastXAssocByPath(xEntity: XEntity, path: string): XAssoc;
21
23
  static getXAssocToOne(xEntity: XEntity, assocField: string): XAssoc;
22
24
  static getXAssocToMany(xEntity: XEntity, assocField: string): XAssoc;
@@ -114,15 +114,21 @@ var XUtilsMetadataCommon = /** @class */ (function () {
114
114
  XUtilsMetadataCommon.getXAssocBase = function (xEntity, assocField) {
115
115
  return xEntity.assocMap[assocField];
116
116
  };
117
- XUtilsMetadataCommon.getXAssocByPath = function (xEntity, path) {
117
+ XUtilsMetadataCommon.getXAssocToOneByPath = function (xEntity, path) {
118
+ return XUtilsMetadataCommon.getXAssocByPath(xEntity, path, ["many-to-one", "one-to-one"]);
119
+ };
120
+ XUtilsMetadataCommon.getXAssocToManyByPath = function (xEntity, path) {
121
+ return XUtilsMetadataCommon.getXAssocByPath(xEntity, path, ["one-to-many", "many-to-many"]);
122
+ };
123
+ XUtilsMetadataCommon.getXAssocByPath = function (xEntity, path, relationTypeList) {
118
124
  var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
119
125
  if (restPath === null) {
120
126
  return XUtilsMetadataCommon.getXAssoc(xEntity, field);
121
127
  }
122
128
  else {
123
- var xAssoc = XUtilsMetadataCommon.getXAssoc(xEntity, field);
129
+ var xAssoc = XUtilsMetadataCommon.getXAssoc(xEntity, field, relationTypeList);
124
130
  var xAssocEntity = XUtilsMetadataCommon.getXEntity(xAssoc.entityName);
125
- return XUtilsMetadataCommon.getXAssocByPath(xAssocEntity, restPath);
131
+ return XUtilsMetadataCommon.getXAssocByPath(xAssocEntity, restPath, relationTypeList);
126
132
  }
127
133
  };
128
134
  // for path assoc1.assoc2.field returns assoc2 (last assoc before field)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "primeflex": "^3.3.1",
42
- "primeicons": "^6.0.1",
43
- "primereact": "~10.4.0",
42
+ "primeicons": "^7.0.0",
43
+ "primereact": "~10.6.5",
44
44
  "quill": "^1.3.7",
45
45
  "react": "^18.2.0",
46
46
  "react-dom": "^18.2.0",