@michalrakus/x-react-web-lib 1.20.0 → 1.22.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.
- package/XFormHeader.d.ts +3 -0
- package/XFormHeader.js +5 -0
- package/XParamBrowse.d.ts +3 -0
- package/XParamBrowse.js +5 -0
- package/XParamForm.d.ts +3 -0
- package/XParamForm.js +5 -0
- package/gulpfile.js +5 -2
- package/lib/administration/XParamBrowse.d.ts +6 -0
- package/lib/administration/XParamBrowse.js +25 -0
- package/lib/administration/XParamForm.d.ts +7 -0
- package/lib/administration/XParamForm.js +62 -0
- package/lib/administration/XUserBrowse.js +1 -1
- package/lib/administration/XUserForm.js +12 -9
- package/lib/components/XAutoCompleteBase.js +2 -29
- package/lib/components/XCalendar.d.ts +15 -8
- package/lib/components/XCalendar.js +21 -2
- package/lib/components/XFormComponent.d.ts +1 -0
- package/lib/components/XFormHeader.d.ts +4 -0
- package/lib/components/XFormHeader.js +11 -0
- package/lib/components/XInputDate.js +1 -1
- package/lib/components/XInputDateDT.js +1 -1
- package/lib/components/XInputText.js +1 -1
- package/lib/components/XLazyDataTable/XExportRowsDialog.d.ts +10 -5
- package/lib/components/XLazyDataTable/XExportRowsDialog.js +79 -44
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +7 -0
- package/lib/components/XLazyDataTable/XLazyDataTable.js +113 -31
- package/lib/components/XLazyDataTable/XMultilineSwitch.js +1 -1
- package/lib/components/XLazyDataTable/XOcfDropdown.d.ts +8 -0
- package/lib/components/XLazyDataTable/XOcfDropdown.js +53 -0
- package/lib/components/XUtils.d.ts +3 -1
- package/lib/components/XUtils.js +42 -10
- package/lib/components/locale/x-en.json +1 -0
- package/lib/serverApi/ExportImportParam.d.ts +29 -11
- package/lib/serverApi/ExportImportParam.js +11 -1
- package/lib/serverApi/XUtilsCommon.d.ts +5 -0
- package/lib/serverApi/XUtilsCommon.js +90 -3
- package/lib/serverApi/XUtilsConversions.d.ts +13 -5
- package/lib/serverApi/XUtilsConversions.js +110 -34
- package/lib/serverApi/XUtilsMetadataCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsMetadataCommon.js +17 -0
- package/package.json +1 -1
|
@@ -9,10 +9,15 @@ export declare class XUtilsCommon {
|
|
|
9
9
|
static getPathToAssocAndField(path: string): [string | null, string];
|
|
10
10
|
static isSingleField(path: string): boolean;
|
|
11
11
|
static getPrefixAndField(path: string): [string | null, string];
|
|
12
|
+
static createDisplayValue(object: any, fields: string[]): string;
|
|
12
13
|
static objectAsJSON(value: any): string;
|
|
13
14
|
static arrayCreateMap<ID, T>(array: T[], idField: string): Map<ID, T>;
|
|
14
15
|
static getDayName(date: Date | null | undefined): string | undefined;
|
|
15
16
|
static dateAddDays(date: Date | null, days: number): Date | null;
|
|
17
|
+
static dateAddMonths(date: Date | null, months: number): Date | null;
|
|
18
|
+
static dateEquals(date1: Date | null, date2: Date | null): boolean;
|
|
19
|
+
static dateDiffInYears(dateOld: Date | null, dateNew: Date | null): number | null;
|
|
20
|
+
static monthDiff(monthOld: Date | null, monthNew: Date | null): number | null;
|
|
16
21
|
static findFirstMatch(pattern: RegExp, value: string): string | null;
|
|
17
22
|
static sqlMaxDateIfNull(sqlExp: string): string;
|
|
18
23
|
static today(): Date;
|
|
@@ -168,6 +168,38 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
168
168
|
return [prefix, pathOnly];
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
|
+
XUtilsCommon.createDisplayValue = function (object, fields) {
|
|
172
|
+
var e_2, _a;
|
|
173
|
+
var displayValue = "";
|
|
174
|
+
try {
|
|
175
|
+
for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
|
|
176
|
+
var field = fields_1_1.value;
|
|
177
|
+
// TODO - konverzie na spravny typ/string
|
|
178
|
+
var _b = __read(XUtilsCommon.getPrefixAndField(field), 2), prefix = _b[0], fieldOnly = _b[1];
|
|
179
|
+
var value = XUtilsCommon.getValueByPath(object, fieldOnly);
|
|
180
|
+
if (value !== null && value !== undefined) {
|
|
181
|
+
var valueStr = value.toString(); // TODO - spravnu konverziu
|
|
182
|
+
if (valueStr !== "") {
|
|
183
|
+
if (displayValue !== "") {
|
|
184
|
+
displayValue += " ";
|
|
185
|
+
}
|
|
186
|
+
if (prefix) {
|
|
187
|
+
displayValue += prefix;
|
|
188
|
+
}
|
|
189
|
+
displayValue += valueStr;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
195
|
+
finally {
|
|
196
|
+
try {
|
|
197
|
+
if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
|
|
198
|
+
}
|
|
199
|
+
finally { if (e_2) throw e_2.error; }
|
|
200
|
+
}
|
|
201
|
+
return displayValue;
|
|
202
|
+
};
|
|
171
203
|
XUtilsCommon.objectAsJSON = function (value) {
|
|
172
204
|
// sem treba dat nejaku pre nas vhodnu serializaciu
|
|
173
205
|
// zatial provizorne robene cez antipatern - modifikaciu prototype funcii primitivnych typov
|
|
@@ -191,7 +223,7 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
191
223
|
return json;
|
|
192
224
|
};
|
|
193
225
|
XUtilsCommon.arrayCreateMap = function (array, idField) {
|
|
194
|
-
var
|
|
226
|
+
var e_3, _a;
|
|
195
227
|
var idRowMap = new Map();
|
|
196
228
|
try {
|
|
197
229
|
for (var array_1 = __values(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
|
|
@@ -201,12 +233,12 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
201
233
|
}
|
|
202
234
|
}
|
|
203
235
|
}
|
|
204
|
-
catch (
|
|
236
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
205
237
|
finally {
|
|
206
238
|
try {
|
|
207
239
|
if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
|
|
208
240
|
}
|
|
209
|
-
finally { if (
|
|
241
|
+
finally { if (e_3) throw e_3.error; }
|
|
210
242
|
}
|
|
211
243
|
return idRowMap;
|
|
212
244
|
};
|
|
@@ -222,6 +254,61 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
222
254
|
}
|
|
223
255
|
return result;
|
|
224
256
|
};
|
|
257
|
+
XUtilsCommon.dateAddMonths = function (date, months) {
|
|
258
|
+
var result = null;
|
|
259
|
+
if (date !== null) {
|
|
260
|
+
result = new Date(date);
|
|
261
|
+
result.setMonth(result.getMonth() + months);
|
|
262
|
+
}
|
|
263
|
+
return result;
|
|
264
|
+
};
|
|
265
|
+
// helper method, because date1 === date2 compares pointers, not values (Date is not primitive type like string or number)
|
|
266
|
+
XUtilsCommon.dateEquals = function (date1, date2) {
|
|
267
|
+
var result = false;
|
|
268
|
+
if (date1 === null && date2 === null) {
|
|
269
|
+
result = true;
|
|
270
|
+
}
|
|
271
|
+
else if (date1 !== null && date2 !== null) {
|
|
272
|
+
result = (date1.getTime() === date2.getTime());
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
};
|
|
276
|
+
// solution from internet
|
|
277
|
+
XUtilsCommon.dateDiffInYears = function (dateOld, dateNew) {
|
|
278
|
+
var diff = null;
|
|
279
|
+
if (dateOld !== null && dateNew !== null) {
|
|
280
|
+
var yearNew = dateNew.getFullYear();
|
|
281
|
+
var monthNew = dateNew.getMonth();
|
|
282
|
+
var dayNew = dateNew.getDate();
|
|
283
|
+
var yearOld = dateOld.getFullYear();
|
|
284
|
+
var monthOld = dateOld.getMonth();
|
|
285
|
+
var dayOld = dateOld.getDate();
|
|
286
|
+
diff = yearNew - yearOld;
|
|
287
|
+
if (monthOld > monthNew) {
|
|
288
|
+
diff--;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
if (monthOld === monthNew) {
|
|
292
|
+
if (dayOld > dayNew) {
|
|
293
|
+
diff--;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return diff;
|
|
299
|
+
};
|
|
300
|
+
// returns month diff for 2 dates of type month (YYYY-MM-01) - days are ignored
|
|
301
|
+
XUtilsCommon.monthDiff = function (monthOld, monthNew) {
|
|
302
|
+
var diff = null;
|
|
303
|
+
if (monthOld !== null && monthNew !== null) {
|
|
304
|
+
var yearCountNew = monthNew.getFullYear();
|
|
305
|
+
var monthCountNew = monthNew.getMonth();
|
|
306
|
+
var yearCountOld = monthOld.getFullYear();
|
|
307
|
+
var monthCountOld = monthOld.getMonth();
|
|
308
|
+
diff = (yearCountNew - yearCountOld) * 12 + (monthCountNew - monthCountOld);
|
|
309
|
+
}
|
|
310
|
+
return diff;
|
|
311
|
+
};
|
|
225
312
|
XUtilsCommon.findFirstMatch = function (pattern, value) {
|
|
226
313
|
var match = pattern.exec(value);
|
|
227
314
|
return match != null ? match[0] : null;
|
|
@@ -6,20 +6,27 @@ export declare function stringAsDB(value: string | null): string;
|
|
|
6
6
|
export declare function intFromUI(stringValue: string): number | null | undefined;
|
|
7
7
|
export declare function numberAsUI(value: number | null, fractionDigits?: number): string;
|
|
8
8
|
export declare function numberFromModel(value: any): number | null;
|
|
9
|
+
export declare function numberFromString(valueString: string): number | null;
|
|
10
|
+
export declare enum XDateScale {
|
|
11
|
+
Date = 1,
|
|
12
|
+
Month = 2,
|
|
13
|
+
Year = 3
|
|
14
|
+
}
|
|
9
15
|
export declare function dateFromModel(value: any): Date | null;
|
|
10
|
-
export declare function dateFromUI(valueString: string): Date | null | undefined;
|
|
11
|
-
export declare function dateAsUI(value: Date | null): string;
|
|
16
|
+
export declare function dateFromUI(valueString: string, dateScale?: XDateScale): Date | null | undefined;
|
|
17
|
+
export declare function dateAsUI(value: Date | null, dateScale?: XDateScale): string;
|
|
12
18
|
export declare function datetimeAsUI(value: Date | null): string;
|
|
13
19
|
export declare function timeFromModel(value: any): Date | null;
|
|
14
|
-
export declare function dateFormatUI(): string;
|
|
15
|
-
export declare function dateFormatCalendar(): string;
|
|
20
|
+
export declare function dateFormatUI(dateScale?: XDateScale): string;
|
|
21
|
+
export declare function dateFormatCalendar(dateScale?: XDateScale): string;
|
|
16
22
|
export declare function datetimeFormatUI(): string;
|
|
17
23
|
export declare function intervalFromUI(valueString: string): IPostgresInterval | null | undefined;
|
|
18
24
|
export declare function intervalAsUI(valueInterval: IPostgresInterval | null): string;
|
|
19
25
|
export declare function booleanAsUIText(value: boolean | null): string;
|
|
20
26
|
export declare enum AsUIType {
|
|
21
27
|
Form = 1,
|
|
22
|
-
Text = 2
|
|
28
|
+
Text = 2,
|
|
29
|
+
Excel = 3
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* converts values of object
|
|
@@ -31,3 +38,4 @@ export declare enum AsUIType {
|
|
|
31
38
|
*/
|
|
32
39
|
export declare function convertObject(entity: string, object: any, fromModel: boolean, asUI: AsUIType | undefined): void;
|
|
33
40
|
export declare function convertValue(xField: XField, value: any, fromModel: boolean, asUI: AsUIType | undefined): any;
|
|
41
|
+
export declare function convertValueBase(fieldType: string, scale: number | undefined, value: any, fromModel: boolean, asUI: AsUIType | undefined): any;
|
|
@@ -27,7 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
30
|
+
exports.convertValueBase = exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.XDateScale = exports.numberFromString = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
31
31
|
var XUtilsCommon_1 = require("./XUtilsCommon");
|
|
32
32
|
var XLocale_1 = require("../components/XLocale");
|
|
33
33
|
var XUtilsMetadataCommon_1 = require("./XUtilsMetadataCommon");
|
|
@@ -95,6 +95,23 @@ function numberFromModel(value) {
|
|
|
95
95
|
return numberValue;
|
|
96
96
|
}
|
|
97
97
|
exports.numberFromModel = numberFromModel;
|
|
98
|
+
// konvertuje hodnotu napr. 12.34
|
|
99
|
+
function numberFromString(valueString) {
|
|
100
|
+
var numberValue = parseFloat(valueString);
|
|
101
|
+
if (isNaN(numberValue)) {
|
|
102
|
+
numberValue = null;
|
|
103
|
+
}
|
|
104
|
+
return numberValue;
|
|
105
|
+
}
|
|
106
|
+
exports.numberFromString = numberFromString;
|
|
107
|
+
// upresnenie typu datumu - pouzivame typ number, lebo zneuzivame atribut scale v TypeORM na zadanie upresnenia
|
|
108
|
+
var XDateScale;
|
|
109
|
+
(function (XDateScale) {
|
|
110
|
+
XDateScale[XDateScale["Date"] = 1] = "Date";
|
|
111
|
+
XDateScale[XDateScale["Month"] = 2] = "Month";
|
|
112
|
+
XDateScale[XDateScale["Year"] = 3] = "Year"; // yyyy
|
|
113
|
+
})(XDateScale = exports.XDateScale || (exports.XDateScale = {}));
|
|
114
|
+
//export type XDateType = "month" | "year" | "date";
|
|
98
115
|
// v modeli na klientovi by mal byt vzdy Date, teraz je tam niekedy string (z json-u zo servera) a niekedy Date (z komponentu)
|
|
99
116
|
// provizorne zatial takato konverzia
|
|
100
117
|
function dateFromModel(value) {
|
|
@@ -108,9 +125,10 @@ function dateFromModel(value) {
|
|
|
108
125
|
return dateValue;
|
|
109
126
|
}
|
|
110
127
|
exports.dateFromModel = dateFromModel;
|
|
111
|
-
function dateFromUI(valueString) {
|
|
128
|
+
function dateFromUI(valueString, dateScale) {
|
|
129
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
112
130
|
// converts valueString (e.g. 21.2.2024) into Date
|
|
113
|
-
// if
|
|
131
|
+
// if valueString is invalid, returns undefined
|
|
114
132
|
var valueDate = undefined;
|
|
115
133
|
if (valueString === '') {
|
|
116
134
|
valueDate = null;
|
|
@@ -120,22 +138,46 @@ function dateFromUI(valueString) {
|
|
|
120
138
|
var day = void 0;
|
|
121
139
|
var month = null;
|
|
122
140
|
var year = null;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
if (dateScale === XDateScale.Date) {
|
|
142
|
+
// format "dd.mm.yyyy"
|
|
143
|
+
var posDot = valueString.indexOf('.');
|
|
144
|
+
if (posDot === -1) {
|
|
145
|
+
day = intFromUI(valueString);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
day = intFromUI(valueString.substring(0, posDot));
|
|
149
|
+
var rest = valueString.substring(posDot + 1);
|
|
150
|
+
var posDot2 = rest.indexOf('.');
|
|
151
|
+
if (posDot2 === -1) {
|
|
152
|
+
month = intFromUI(rest);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
month = intFromUI(rest.substring(0, posDot2));
|
|
156
|
+
year = intFromUI(rest.substring(posDot2 + 1));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
126
159
|
}
|
|
127
|
-
else {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
132
|
-
month = intFromUI(
|
|
160
|
+
else if (dateScale === XDateScale.Month) {
|
|
161
|
+
// format "mm.yyyy"
|
|
162
|
+
day = 1;
|
|
163
|
+
var posDot = valueString.indexOf('.');
|
|
164
|
+
if (posDot === -1) {
|
|
165
|
+
month = intFromUI(valueString);
|
|
133
166
|
}
|
|
134
167
|
else {
|
|
135
|
-
month = intFromUI(
|
|
136
|
-
year = intFromUI(
|
|
168
|
+
month = intFromUI(valueString.substring(0, posDot));
|
|
169
|
+
year = intFromUI(valueString.substring(posDot + 1));
|
|
137
170
|
}
|
|
138
171
|
}
|
|
172
|
+
else if (dateScale === XDateScale.Year) {
|
|
173
|
+
// format "yyyy"
|
|
174
|
+
day = 1;
|
|
175
|
+
month = 1;
|
|
176
|
+
year = intFromUI(valueString);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
180
|
+
}
|
|
139
181
|
// doplnime mesiac a rok ak uzivatel nezadal (ak mame undefined, tak umyselne nedoplname)
|
|
140
182
|
if (month === null) {
|
|
141
183
|
month = XUtilsCommon_1.XUtilsCommon.today().getMonth() + 1; // o 1 mesiac viac (januar je 0)
|
|
@@ -163,9 +205,10 @@ function dateFromUI(valueString) {
|
|
|
163
205
|
return valueDate;
|
|
164
206
|
}
|
|
165
207
|
exports.dateFromUI = dateFromUI;
|
|
166
|
-
function dateAsUI(value) {
|
|
208
|
+
function dateAsUI(value, dateScale) {
|
|
209
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
167
210
|
if (value !== null) {
|
|
168
|
-
return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI());
|
|
211
|
+
return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI(dateScale));
|
|
169
212
|
}
|
|
170
213
|
else {
|
|
171
214
|
return "";
|
|
@@ -208,12 +251,40 @@ function timeFromModel(value) {
|
|
|
208
251
|
return timeValue;
|
|
209
252
|
}
|
|
210
253
|
exports.timeFromModel = timeFromModel;
|
|
211
|
-
function dateFormatUI() {
|
|
212
|
-
|
|
254
|
+
function dateFormatUI(dateScale) {
|
|
255
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
256
|
+
var format;
|
|
257
|
+
if (dateScale === XDateScale.Date) {
|
|
258
|
+
format = "dd.mm.yyyy";
|
|
259
|
+
}
|
|
260
|
+
else if (dateScale === XDateScale.Month) {
|
|
261
|
+
format = "mm.yyyy";
|
|
262
|
+
}
|
|
263
|
+
else if (dateScale === XDateScale.Year) {
|
|
264
|
+
format = "yyyy";
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
268
|
+
}
|
|
269
|
+
return format;
|
|
213
270
|
}
|
|
214
271
|
exports.dateFormatUI = dateFormatUI;
|
|
215
|
-
function dateFormatCalendar() {
|
|
216
|
-
|
|
272
|
+
function dateFormatCalendar(dateScale) {
|
|
273
|
+
if (dateScale === void 0) { dateScale = XDateScale.Date; }
|
|
274
|
+
var format;
|
|
275
|
+
if (dateScale === XDateScale.Date) {
|
|
276
|
+
format = "dd.mm.yy";
|
|
277
|
+
}
|
|
278
|
+
else if (dateScale === XDateScale.Month) {
|
|
279
|
+
format = "mm.yy";
|
|
280
|
+
}
|
|
281
|
+
else if (dateScale === XDateScale.Year) {
|
|
282
|
+
format = "yy";
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
throw "Unimplemented dateScale = " + dateScale;
|
|
286
|
+
}
|
|
287
|
+
return format;
|
|
217
288
|
}
|
|
218
289
|
exports.dateFormatCalendar = dateFormatCalendar;
|
|
219
290
|
function datetimeFormatUI() {
|
|
@@ -284,7 +355,8 @@ exports.booleanAsUIText = booleanAsUIText;
|
|
|
284
355
|
var AsUIType;
|
|
285
356
|
(function (AsUIType) {
|
|
286
357
|
AsUIType[AsUIType["Form"] = 1] = "Form";
|
|
287
|
-
AsUIType[AsUIType["Text"] = 2] = "Text";
|
|
358
|
+
AsUIType[AsUIType["Text"] = 2] = "Text";
|
|
359
|
+
AsUIType[AsUIType["Excel"] = 3] = "Excel"; // excel - nie vsetko konvertujeme do string-u, vecsinou zostavame pri typoch number, Date
|
|
288
360
|
})(AsUIType = exports.AsUIType || (exports.AsUIType = {}));
|
|
289
361
|
/**
|
|
290
362
|
* converts values of object
|
|
@@ -345,23 +417,27 @@ function convertObject(entity, object, fromModel, asUI) {
|
|
|
345
417
|
}
|
|
346
418
|
exports.convertObject = convertObject;
|
|
347
419
|
function convertValue(xField, value, fromModel, asUI) {
|
|
348
|
-
|
|
420
|
+
return convertValueBase(xField.type, xField.scale, value, fromModel, asUI);
|
|
421
|
+
}
|
|
422
|
+
exports.convertValue = convertValue;
|
|
423
|
+
function convertValueBase(fieldType, scale, value, fromModel, asUI) {
|
|
424
|
+
if (fieldType === "decimal") {
|
|
349
425
|
if (fromModel) {
|
|
350
426
|
value = numberFromModel(value);
|
|
351
427
|
}
|
|
352
|
-
if (asUI) {
|
|
353
|
-
value = numberAsUI(value,
|
|
428
|
+
if (asUI && asUI !== AsUIType.Excel) {
|
|
429
|
+
value = numberAsUI(value, scale);
|
|
354
430
|
}
|
|
355
431
|
}
|
|
356
|
-
else if (
|
|
432
|
+
else if (fieldType === "date") {
|
|
357
433
|
if (fromModel) {
|
|
358
434
|
value = dateFromModel(value);
|
|
359
435
|
}
|
|
360
|
-
if (asUI) {
|
|
361
|
-
value = dateAsUI(value);
|
|
436
|
+
if (asUI && (asUI !== AsUIType.Excel || scale === XDateScale.Month || scale === XDateScale.Year)) {
|
|
437
|
+
value = dateAsUI(value, scale);
|
|
362
438
|
}
|
|
363
439
|
}
|
|
364
|
-
else if (
|
|
440
|
+
else if (fieldType === "datetime") {
|
|
365
441
|
if (fromModel) {
|
|
366
442
|
value = dateFromModel(value);
|
|
367
443
|
}
|
|
@@ -369,25 +445,25 @@ function convertValue(xField, value, fromModel, asUI) {
|
|
|
369
445
|
value = datetimeAsUI(value);
|
|
370
446
|
}
|
|
371
447
|
}
|
|
372
|
-
else if (
|
|
448
|
+
else if (fieldType === "interval") {
|
|
373
449
|
// konverziu z modelu (json objekt-u) netreba
|
|
374
450
|
if (asUI) {
|
|
375
451
|
value = intervalAsUI(value);
|
|
376
452
|
}
|
|
377
453
|
}
|
|
378
|
-
else if (
|
|
454
|
+
else if (fieldType === "boolean") {
|
|
379
455
|
// konverziu z modelu (json objekt-u) netreba
|
|
380
456
|
// pre AsUIType.Form ponechame typ boolean (spracujeme neskor)
|
|
381
|
-
if (asUI === AsUIType.Text) {
|
|
457
|
+
if (asUI === AsUIType.Text || asUI === AsUIType.Excel) {
|
|
382
458
|
value = booleanAsUIText(value);
|
|
383
459
|
}
|
|
384
460
|
}
|
|
385
461
|
else {
|
|
386
462
|
// vsetko ostatne
|
|
387
|
-
if (asUI) {
|
|
388
|
-
value = value ? value.toString() : "";
|
|
463
|
+
if (asUI && asUI !== AsUIType.Excel) {
|
|
464
|
+
value = (value !== null && value !== undefined) ? value.toString() : "";
|
|
389
465
|
}
|
|
390
466
|
}
|
|
391
467
|
return value;
|
|
392
468
|
}
|
|
393
|
-
exports.
|
|
469
|
+
exports.convertValueBase = convertValueBase;
|
|
@@ -13,6 +13,7 @@ export declare class XUtilsMetadataCommon {
|
|
|
13
13
|
static getXField(xEntity: XEntity, field: string): XField;
|
|
14
14
|
static getXFieldByPathBase(xEntity: XEntity, path: string): XField | undefined;
|
|
15
15
|
static getXFieldByPath(xEntity: XEntity, path: string): XField;
|
|
16
|
+
static hasPathToManyAssoc(xEntity: XEntity, path: string): boolean;
|
|
16
17
|
static getXFieldByPathStr(entity: string, path: string): XField;
|
|
17
18
|
static getXAssocBase(xEntity: XEntity, assocField: string): XAssoc | undefined;
|
|
18
19
|
static getXAssocByPath(xEntity: XEntity, path: string): XAssoc;
|
|
@@ -91,6 +91,23 @@ var XUtilsMetadataCommon = /** @class */ (function () {
|
|
|
91
91
|
return XUtilsMetadataCommon.getXFieldByPath(xAssocEntity, restPath);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
// returns true if path contains some toMany assoc
|
|
95
|
+
XUtilsMetadataCommon.hasPathToManyAssoc = function (xEntity, path) {
|
|
96
|
+
var _a = __read(XUtilsCommon_1.XUtilsCommon.getFieldAndRestPath(path), 2), field = _a[0], restPath = _a[1];
|
|
97
|
+
if (restPath === null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
var xAssoc = XUtilsMetadataCommon.getXAssoc(xEntity, field);
|
|
102
|
+
if (xAssoc.relationType === "one-to-many" || xAssoc.relationType === "many-to-many") {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
var xAssocEntity = XUtilsMetadataCommon.getXEntity(xAssoc.entityName);
|
|
107
|
+
return XUtilsMetadataCommon.hasPathToManyAssoc(xAssocEntity, restPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
94
111
|
XUtilsMetadataCommon.getXFieldByPathStr = function (entity, path) {
|
|
95
112
|
return XUtilsMetadataCommon.getXFieldByPath(XUtilsMetadataCommon.getXEntity(entity), path);
|
|
96
113
|
};
|