@easyquery/core 7.2.5-rc03 → 7.3.0-rc01
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* EasyQuery.JS Core v7.
|
|
3
|
+
* EasyQuery.JS Core v7.3.0-rc01
|
|
4
4
|
* Copyright 2024 Korzh.com
|
|
5
5
|
* Licensed under MIT
|
|
6
6
|
*
|
|
7
|
-
* Build time:
|
|
7
|
+
* Build time: 2/10/2024 10:51:56 AM
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
@@ -2937,6 +2937,7 @@ class Query {
|
|
|
2937
2937
|
*/
|
|
2938
2938
|
addColumn(descriptor, silent = false) {
|
|
2939
2939
|
let newColumn;
|
|
2940
|
+
const justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
|
|
2940
2941
|
if (descriptor.column) {
|
|
2941
2942
|
newColumn = descriptor.column;
|
|
2942
2943
|
}
|
|
@@ -2955,12 +2956,16 @@ class Query {
|
|
|
2955
2956
|
else if (typeof descriptor.constValue === 'undefined' && !descriptor.customSql) {
|
|
2956
2957
|
throw new Error('Not enought data for addColumn operation. One of the following options must be defined: attribute, attributeId, constValue or customSlq');
|
|
2957
2958
|
}
|
|
2958
|
-
if (attr
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2959
|
+
if (attr) {
|
|
2960
|
+
let checkedOption = justsorted ? attr.useInSorting : attr.useInResult;
|
|
2961
|
+
if (!checkedOption) {
|
|
2962
|
+
if (attr.lookupAttr) {
|
|
2963
|
+
attr = this.model.getAttributeById(attr.lookupAttr);
|
|
2964
|
+
checkedOption = justsorted ? attr.useInSorting : attr.useInResult;
|
|
2965
|
+
}
|
|
2966
|
+
if (!checkedOption) {
|
|
2967
|
+
throw new Error(`Can't use this attribute for a column`);
|
|
2968
|
+
}
|
|
2964
2969
|
}
|
|
2965
2970
|
}
|
|
2966
2971
|
if (descriptor.aggrFuncId && descriptor.customSql) {
|
|
@@ -3011,7 +3016,6 @@ class Query {
|
|
|
3011
3016
|
newColumn.enabled = core.utils.getIfDefined(descriptor.enabled, true);
|
|
3012
3017
|
newColumn.setReadOnly(core.utils.getIfDefined(descriptor.readonly, false));
|
|
3013
3018
|
}
|
|
3014
|
-
const justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
|
|
3015
3019
|
if (!justsorted) {
|
|
3016
3020
|
if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
|
|
3017
3021
|
this.columns.splice(descriptor.index, 0, newColumn);
|
|
@@ -3035,7 +3039,7 @@ class Query {
|
|
|
3035
3039
|
* const column = new Column();
|
|
3036
3040
|
* column.caption = "Company name";
|
|
3037
3041
|
*
|
|
3038
|
-
* query.
|
|
3042
|
+
* query.addColumnObj(column, 1)
|
|
3039
3043
|
*/
|
|
3040
3044
|
addColumnObj(column, index, author) {
|
|
3041
3045
|
let columns = this.columns;
|
|
@@ -3374,15 +3378,15 @@ class Query {
|
|
|
3374
3378
|
if (!model)
|
|
3375
3379
|
return '';
|
|
3376
3380
|
const getConditionGroupText = (group) => {
|
|
3377
|
-
let result = '', conjKey =
|
|
3381
|
+
let result = '', conjKey = 'Conj' + exports.equtils.linkTypeToStr(group.linkType), conjText = core.i18n.getText(conjKey), condText, i;
|
|
3378
3382
|
for (i = 0; i < group.getConditions().length; i++) {
|
|
3379
|
-
condText =
|
|
3383
|
+
condText = '';
|
|
3380
3384
|
let cond = group.getConditions()[i];
|
|
3381
|
-
if (cond.enabled || typeof (cond.enabled) ===
|
|
3385
|
+
if (cond.enabled || typeof (cond.enabled) === 'undefined') {
|
|
3382
3386
|
if (cond.isGroup()) {
|
|
3383
3387
|
condText = getConditionGroupText(cond);
|
|
3384
3388
|
if (condText) {
|
|
3385
|
-
condText =
|
|
3389
|
+
condText = '(' + condText + ')';
|
|
3386
3390
|
}
|
|
3387
3391
|
}
|
|
3388
3392
|
else {
|
|
@@ -3393,14 +3397,17 @@ class Query {
|
|
|
3393
3397
|
for (let pi = 0; pi < plen; pi++) {
|
|
3394
3398
|
let part = parts[pi];
|
|
3395
3399
|
let txt = part.text;
|
|
3396
|
-
if (part.type ==
|
|
3400
|
+
if (part.type == 'expression') {
|
|
3397
3401
|
let expr = cond.expressions[part.index];
|
|
3398
3402
|
if (expr.kind == exports.DataKind.Attribute || expr.tag == exports.ExprTag.EntityAttribute) {
|
|
3399
3403
|
let attr = model.getAttributeById(expr.value);
|
|
3400
3404
|
if (attr != null) {
|
|
3401
|
-
txt = model.getAttributeText(attr,
|
|
3405
|
+
txt = model.getAttributeText(attr, '{entity} {attr}');
|
|
3402
3406
|
}
|
|
3403
3407
|
}
|
|
3408
|
+
if (expr.kind == exports.DataKind.Query) {
|
|
3409
|
+
txt = ': (' + expr.subQuery.getConditionsText() + ')';
|
|
3410
|
+
}
|
|
3404
3411
|
else {
|
|
3405
3412
|
txt = expr.getText();
|
|
3406
3413
|
if (this.model.isDateMacro(txt) || this.model.isTimeMacro(txt)) {
|
|
@@ -3411,20 +3418,20 @@ class Query {
|
|
|
3411
3418
|
}
|
|
3412
3419
|
}
|
|
3413
3420
|
if (pi > 0)
|
|
3414
|
-
condText +=
|
|
3421
|
+
condText += ' ';
|
|
3415
3422
|
condText += txt;
|
|
3416
3423
|
}
|
|
3417
3424
|
}
|
|
3418
3425
|
}
|
|
3419
3426
|
if (condText) {
|
|
3420
3427
|
if (i > 0 && result) {
|
|
3421
|
-
result +=
|
|
3428
|
+
result += ' ' + conjText + ' ';
|
|
3422
3429
|
}
|
|
3423
3430
|
result += condText;
|
|
3424
3431
|
}
|
|
3425
3432
|
}
|
|
3426
3433
|
if (group.linkType == exports.LinkType.None || group.linkType == exports.LinkType.NotAll) {
|
|
3427
|
-
result =
|
|
3434
|
+
result = 'not ( " + result + " )';
|
|
3428
3435
|
}
|
|
3429
3436
|
return result;
|
|
3430
3437
|
};
|
|
@@ -4641,7 +4648,7 @@ class EqContext {
|
|
|
4641
4648
|
}
|
|
4642
4649
|
}
|
|
4643
4650
|
setOptions(options) {
|
|
4644
|
-
core.utils.
|
|
4651
|
+
core.utils.assign(this.options, options);
|
|
4645
4652
|
}
|
|
4646
4653
|
get backendInfo() {
|
|
4647
4654
|
return this._backendInfo;
|
|
@@ -4843,19 +4850,28 @@ class EqContext {
|
|
|
4843
4850
|
queryId: this.defaultQueryId,
|
|
4844
4851
|
modelId: this.defaultModelId,
|
|
4845
4852
|
success: () => {
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4853
|
+
//if we load query on start - then we should throw the 'ready' event only after its successful loading
|
|
4854
|
+
this.throwReady();
|
|
4855
|
+
},
|
|
4856
|
+
error: () => {
|
|
4857
|
+
//if the default query can't be loaded - we still throw the 'ready' event
|
|
4858
|
+
this.throwReady();
|
|
4849
4859
|
}
|
|
4850
4860
|
});
|
|
4851
4861
|
}
|
|
4852
4862
|
else {
|
|
4853
|
-
this.
|
|
4854
|
-
this.fireEvent('ready');
|
|
4863
|
+
this.throwReady();
|
|
4855
4864
|
}
|
|
4856
4865
|
}
|
|
4857
4866
|
});
|
|
4858
4867
|
}
|
|
4868
|
+
/**
|
|
4869
|
+
* Refreshes all widgets and raises 'ready' event
|
|
4870
|
+
*/
|
|
4871
|
+
throwReady() {
|
|
4872
|
+
this.refreshWidgets(exports.WidgetGroup.Query);
|
|
4873
|
+
this.fireEvent('ready');
|
|
4874
|
+
}
|
|
4859
4875
|
/**
|
|
4860
4876
|
* Clears the content of the current query
|
|
4861
4877
|
*/
|
|
@@ -5707,6 +5723,9 @@ class EqContext {
|
|
|
5707
5723
|
}
|
|
5708
5724
|
});
|
|
5709
5725
|
}
|
|
5726
|
+
else {
|
|
5727
|
+
console.error('No exporter for this format: ' + format);
|
|
5728
|
+
}
|
|
5710
5729
|
}
|
|
5711
5730
|
}
|
|
5712
5731
|
limitCustomSqlColumns() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* EasyQuery.JS Core v7.
|
|
3
|
+
* EasyQuery.JS Core v7.3.0-rc01
|
|
4
4
|
* Copyright 2024 Korzh.com
|
|
5
5
|
* Licensed under MIT
|
|
6
6
|
*
|
|
7
|
-
* Build time:
|
|
7
|
+
* Build time: 2/10/2024 10:51:56 AM
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { i18n, DataType, utils, ValueEditor, MetaEntity, MetaEntityAttr, EditorTag, MetaData, EventEmitter, AggregationSettings, HttpClient, EasyDataTable } from '@easydata/core';
|
|
@@ -2936,6 +2936,7 @@ class Query {
|
|
|
2936
2936
|
*/
|
|
2937
2937
|
addColumn(descriptor, silent = false) {
|
|
2938
2938
|
let newColumn;
|
|
2939
|
+
const justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
|
|
2939
2940
|
if (descriptor.column) {
|
|
2940
2941
|
newColumn = descriptor.column;
|
|
2941
2942
|
}
|
|
@@ -2954,12 +2955,16 @@ class Query {
|
|
|
2954
2955
|
else if (typeof descriptor.constValue === 'undefined' && !descriptor.customSql) {
|
|
2955
2956
|
throw new Error('Not enought data for addColumn operation. One of the following options must be defined: attribute, attributeId, constValue or customSlq');
|
|
2956
2957
|
}
|
|
2957
|
-
if (attr
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2958
|
+
if (attr) {
|
|
2959
|
+
let checkedOption = justsorted ? attr.useInSorting : attr.useInResult;
|
|
2960
|
+
if (!checkedOption) {
|
|
2961
|
+
if (attr.lookupAttr) {
|
|
2962
|
+
attr = this.model.getAttributeById(attr.lookupAttr);
|
|
2963
|
+
checkedOption = justsorted ? attr.useInSorting : attr.useInResult;
|
|
2964
|
+
}
|
|
2965
|
+
if (!checkedOption) {
|
|
2966
|
+
throw new Error(`Can't use this attribute for a column`);
|
|
2967
|
+
}
|
|
2963
2968
|
}
|
|
2964
2969
|
}
|
|
2965
2970
|
if (descriptor.aggrFuncId && descriptor.customSql) {
|
|
@@ -3010,7 +3015,6 @@ class Query {
|
|
|
3010
3015
|
newColumn.enabled = utils.getIfDefined(descriptor.enabled, true);
|
|
3011
3016
|
newColumn.setReadOnly(utils.getIfDefined(descriptor.readonly, false));
|
|
3012
3017
|
}
|
|
3013
|
-
const justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
|
|
3014
3018
|
if (!justsorted) {
|
|
3015
3019
|
if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
|
|
3016
3020
|
this.columns.splice(descriptor.index, 0, newColumn);
|
|
@@ -3034,7 +3038,7 @@ class Query {
|
|
|
3034
3038
|
* const column = new Column();
|
|
3035
3039
|
* column.caption = "Company name";
|
|
3036
3040
|
*
|
|
3037
|
-
* query.
|
|
3041
|
+
* query.addColumnObj(column, 1)
|
|
3038
3042
|
*/
|
|
3039
3043
|
addColumnObj(column, index, author) {
|
|
3040
3044
|
let columns = this.columns;
|
|
@@ -3373,15 +3377,15 @@ class Query {
|
|
|
3373
3377
|
if (!model)
|
|
3374
3378
|
return '';
|
|
3375
3379
|
const getConditionGroupText = (group) => {
|
|
3376
|
-
let result = '', conjKey =
|
|
3380
|
+
let result = '', conjKey = 'Conj' + equtils.linkTypeToStr(group.linkType), conjText = i18n.getText(conjKey), condText, i;
|
|
3377
3381
|
for (i = 0; i < group.getConditions().length; i++) {
|
|
3378
|
-
condText =
|
|
3382
|
+
condText = '';
|
|
3379
3383
|
let cond = group.getConditions()[i];
|
|
3380
|
-
if (cond.enabled || typeof (cond.enabled) ===
|
|
3384
|
+
if (cond.enabled || typeof (cond.enabled) === 'undefined') {
|
|
3381
3385
|
if (cond.isGroup()) {
|
|
3382
3386
|
condText = getConditionGroupText(cond);
|
|
3383
3387
|
if (condText) {
|
|
3384
|
-
condText =
|
|
3388
|
+
condText = '(' + condText + ')';
|
|
3385
3389
|
}
|
|
3386
3390
|
}
|
|
3387
3391
|
else {
|
|
@@ -3392,14 +3396,17 @@ class Query {
|
|
|
3392
3396
|
for (let pi = 0; pi < plen; pi++) {
|
|
3393
3397
|
let part = parts[pi];
|
|
3394
3398
|
let txt = part.text;
|
|
3395
|
-
if (part.type ==
|
|
3399
|
+
if (part.type == 'expression') {
|
|
3396
3400
|
let expr = cond.expressions[part.index];
|
|
3397
3401
|
if (expr.kind == DataKind.Attribute || expr.tag == ExprTag.EntityAttribute) {
|
|
3398
3402
|
let attr = model.getAttributeById(expr.value);
|
|
3399
3403
|
if (attr != null) {
|
|
3400
|
-
txt = model.getAttributeText(attr,
|
|
3404
|
+
txt = model.getAttributeText(attr, '{entity} {attr}');
|
|
3401
3405
|
}
|
|
3402
3406
|
}
|
|
3407
|
+
if (expr.kind == DataKind.Query) {
|
|
3408
|
+
txt = ': (' + expr.subQuery.getConditionsText() + ')';
|
|
3409
|
+
}
|
|
3403
3410
|
else {
|
|
3404
3411
|
txt = expr.getText();
|
|
3405
3412
|
if (this.model.isDateMacro(txt) || this.model.isTimeMacro(txt)) {
|
|
@@ -3410,20 +3417,20 @@ class Query {
|
|
|
3410
3417
|
}
|
|
3411
3418
|
}
|
|
3412
3419
|
if (pi > 0)
|
|
3413
|
-
condText +=
|
|
3420
|
+
condText += ' ';
|
|
3414
3421
|
condText += txt;
|
|
3415
3422
|
}
|
|
3416
3423
|
}
|
|
3417
3424
|
}
|
|
3418
3425
|
if (condText) {
|
|
3419
3426
|
if (i > 0 && result) {
|
|
3420
|
-
result +=
|
|
3427
|
+
result += ' ' + conjText + ' ';
|
|
3421
3428
|
}
|
|
3422
3429
|
result += condText;
|
|
3423
3430
|
}
|
|
3424
3431
|
}
|
|
3425
3432
|
if (group.linkType == LinkType.None || group.linkType == LinkType.NotAll) {
|
|
3426
|
-
result =
|
|
3433
|
+
result = 'not ( " + result + " )';
|
|
3427
3434
|
}
|
|
3428
3435
|
return result;
|
|
3429
3436
|
};
|
|
@@ -4640,7 +4647,7 @@ class EqContext {
|
|
|
4640
4647
|
}
|
|
4641
4648
|
}
|
|
4642
4649
|
setOptions(options) {
|
|
4643
|
-
utils.
|
|
4650
|
+
utils.assign(this.options, options);
|
|
4644
4651
|
}
|
|
4645
4652
|
get backendInfo() {
|
|
4646
4653
|
return this._backendInfo;
|
|
@@ -4842,19 +4849,28 @@ class EqContext {
|
|
|
4842
4849
|
queryId: this.defaultQueryId,
|
|
4843
4850
|
modelId: this.defaultModelId,
|
|
4844
4851
|
success: () => {
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4852
|
+
//if we load query on start - then we should throw the 'ready' event only after its successful loading
|
|
4853
|
+
this.throwReady();
|
|
4854
|
+
},
|
|
4855
|
+
error: () => {
|
|
4856
|
+
//if the default query can't be loaded - we still throw the 'ready' event
|
|
4857
|
+
this.throwReady();
|
|
4848
4858
|
}
|
|
4849
4859
|
});
|
|
4850
4860
|
}
|
|
4851
4861
|
else {
|
|
4852
|
-
this.
|
|
4853
|
-
this.fireEvent('ready');
|
|
4862
|
+
this.throwReady();
|
|
4854
4863
|
}
|
|
4855
4864
|
}
|
|
4856
4865
|
});
|
|
4857
4866
|
}
|
|
4867
|
+
/**
|
|
4868
|
+
* Refreshes all widgets and raises 'ready' event
|
|
4869
|
+
*/
|
|
4870
|
+
throwReady() {
|
|
4871
|
+
this.refreshWidgets(WidgetGroup.Query);
|
|
4872
|
+
this.fireEvent('ready');
|
|
4873
|
+
}
|
|
4858
4874
|
/**
|
|
4859
4875
|
* Clears the content of the current query
|
|
4860
4876
|
*/
|
|
@@ -5706,6 +5722,9 @@ class EqContext {
|
|
|
5706
5722
|
}
|
|
5707
5723
|
});
|
|
5708
5724
|
}
|
|
5725
|
+
else {
|
|
5726
|
+
console.error('No exporter for this format: ' + format);
|
|
5727
|
+
}
|
|
5709
5728
|
}
|
|
5710
5729
|
}
|
|
5711
5730
|
limitCustomSqlColumns() {
|
|
@@ -194,6 +194,10 @@ export declare class EqContext {
|
|
|
194
194
|
* to load the model with such ID.
|
|
195
195
|
*/
|
|
196
196
|
loadDefaultModel(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Refreshes all widgets and raises 'ready' event
|
|
199
|
+
*/
|
|
200
|
+
protected throwReady(): void;
|
|
197
201
|
/**
|
|
198
202
|
* Clears the content of the current query
|
|
199
203
|
*/
|
|
@@ -307,7 +307,7 @@ export declare class Query implements AggregationColumnStore {
|
|
|
307
307
|
* const column = new Column();
|
|
308
308
|
* column.caption = "Company name";
|
|
309
309
|
*
|
|
310
|
-
* query.
|
|
310
|
+
* query.addColumnObj(column, 1)
|
|
311
311
|
*/
|
|
312
312
|
addColumnObj(column: QueryColumn | QueryColumn[], index: any, author: any): void;
|
|
313
313
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyquery/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0-rc01",
|
|
4
4
|
"description": "EasyQuery.JS Community core modules",
|
|
5
5
|
"types": "./dist/types/public_api.d.ts",
|
|
6
6
|
"main": "./dist/easyquery.core.cjs.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "npm run clear && rollup -c",
|
|
11
11
|
"watch": "npm run clear && rollup -c -w",
|
|
12
12
|
"docs": "typedoc src/public_api.ts --out ./docs",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "vitest run"
|
|
14
14
|
},
|
|
15
15
|
"author": "Korzh.com",
|
|
16
16
|
"homepage": "https://korzh.com/easyquery/javascript",
|
|
@@ -30,8 +30,5 @@
|
|
|
30
30
|
"license": "LGPL-3.0",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|
|
33
|
-
]
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"@easydata/core": "^1.4.21"
|
|
36
|
-
}
|
|
33
|
+
]
|
|
37
34
|
}
|