@zeedhi/common 1.129.0 → 1.130.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/dist/zd-common.esm.js +102 -99
- package/dist/zd-common.umd.js +99 -96
- package/package.json +2 -2
- package/types/components/zd-tree/interfaces.d.ts +1 -1
- package/types/components/zd-tree/tree.d.ts +2 -2
- package/types/index.d.ts +1 -1
- package/types/utils/combine-urls/combine-urls.d.ts +2 -0
- package/types/utils/combine-urls/index.d.ts +1 -0
- package/types/utils/index.d.ts +2 -2
package/dist/zd-common.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, Messages, InstanceNotFoundError, ViewService, URL
|
|
1
|
+
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, Messages, InstanceNotFoundError, ViewService, URL, Http, Cookie, VersionService } from '@zeedhi/core';
|
|
2
2
|
import merge from 'lodash.merge';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
4
|
import debounce from 'lodash.debounce';
|
|
@@ -8124,6 +8124,97 @@ class IterablePageComponent extends ComponentRender {
|
|
|
8124
8124
|
}
|
|
8125
8125
|
}
|
|
8126
8126
|
|
|
8127
|
+
class DataValueOutHelper {
|
|
8128
|
+
static getFormParent(select) {
|
|
8129
|
+
let { formParent } = select;
|
|
8130
|
+
if (select.dataValueOutFormName) {
|
|
8131
|
+
try {
|
|
8132
|
+
formParent = Metadata.getInstance(select.dataValueOutFormName);
|
|
8133
|
+
}
|
|
8134
|
+
catch (error) {
|
|
8135
|
+
// instance not found, use input.formParent
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
return formParent;
|
|
8139
|
+
}
|
|
8140
|
+
static setDataValueOut(select, value) {
|
|
8141
|
+
const { dataValueOut } = select;
|
|
8142
|
+
if (dataValueOut && dataValueOut.length && typeof value === 'object') {
|
|
8143
|
+
const formParent = DataValueOutHelper.getFormParent(select);
|
|
8144
|
+
if (formParent) {
|
|
8145
|
+
dataValueOut.forEach((columns) => {
|
|
8146
|
+
const { column, columnOnForm } = columns;
|
|
8147
|
+
if (!column || !columnOnForm)
|
|
8148
|
+
return;
|
|
8149
|
+
const currentValue = value ? value[column] : null;
|
|
8150
|
+
if (!Utils.isEqual(formParent.value[columnOnForm], currentValue)) {
|
|
8151
|
+
formParent.value[columnOnForm] = currentValue;
|
|
8152
|
+
}
|
|
8153
|
+
});
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
}
|
|
8157
|
+
}
|
|
8158
|
+
|
|
8159
|
+
class DatasourceSearcher {
|
|
8160
|
+
constructor() {
|
|
8161
|
+
this.dsSearch = {
|
|
8162
|
+
SEARCH: (value, searchIn) => ({
|
|
8163
|
+
searchIn: [searchIn],
|
|
8164
|
+
search: String(value || ''),
|
|
8165
|
+
}),
|
|
8166
|
+
FILTER: (value, searchIn) => ({
|
|
8167
|
+
filter: {
|
|
8168
|
+
[searchIn]: value,
|
|
8169
|
+
},
|
|
8170
|
+
}),
|
|
8171
|
+
FIND: (value, searchIn) => ({
|
|
8172
|
+
find: {
|
|
8173
|
+
[searchIn]: value,
|
|
8174
|
+
},
|
|
8175
|
+
}),
|
|
8176
|
+
DYNAMIC_FILTER: (value, search_in) => {
|
|
8177
|
+
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
8178
|
+
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
8179
|
+
const dynamicFilter = { [search_in]: filter };
|
|
8180
|
+
return { dynamicFilter };
|
|
8181
|
+
},
|
|
8182
|
+
};
|
|
8183
|
+
}
|
|
8184
|
+
search(datasource, searchValue, searchIn, searchParam) {
|
|
8185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8186
|
+
// using filter/find/dynamicFilter should make only 1 request
|
|
8187
|
+
// using normal search should make one request per search value
|
|
8188
|
+
if (!Array.isArray(searchValue)) {
|
|
8189
|
+
return this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
8190
|
+
}
|
|
8191
|
+
if (searchParam !== 'SEARCH') {
|
|
8192
|
+
const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
8193
|
+
return items;
|
|
8194
|
+
}
|
|
8195
|
+
const searchedItems = [];
|
|
8196
|
+
const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
|
|
8197
|
+
const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
|
|
8198
|
+
searchedItems.push(item);
|
|
8199
|
+
}));
|
|
8200
|
+
yield Promise.all(promises);
|
|
8201
|
+
return searchedItems;
|
|
8202
|
+
});
|
|
8203
|
+
}
|
|
8204
|
+
searchRequest(datasource, searchValue, searchIn, searchParam) {
|
|
8205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8206
|
+
const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
|
|
8207
|
+
const cloneDatasource = DatasourceFactory.factory(config);
|
|
8208
|
+
const items = yield cloneDatasource.get();
|
|
8209
|
+
cloneDatasource.destroy();
|
|
8210
|
+
if (Array.isArray(searchValue)) {
|
|
8211
|
+
return items.filter((item) => searchValue.includes(item[searchIn]));
|
|
8212
|
+
}
|
|
8213
|
+
return items.filter((row) => row[searchIn] === searchValue);
|
|
8214
|
+
});
|
|
8215
|
+
}
|
|
8216
|
+
}
|
|
8217
|
+
|
|
8127
8218
|
class Icons {
|
|
8128
8219
|
/**
|
|
8129
8220
|
* Replace all the icons
|
|
@@ -8469,10 +8560,10 @@ class WatchURL {
|
|
|
8469
8560
|
const query = Router.getQuery();
|
|
8470
8561
|
if (!(query[param] == null && value == null) && query[param] !== value) {
|
|
8471
8562
|
if (value || typeof value === 'number') {
|
|
8472
|
-
URL
|
|
8563
|
+
URL.updateQueryString({ [param]: value }, replace);
|
|
8473
8564
|
}
|
|
8474
8565
|
else {
|
|
8475
|
-
URL
|
|
8566
|
+
URL.deleteQueryParam(param, replace);
|
|
8476
8567
|
}
|
|
8477
8568
|
}
|
|
8478
8569
|
}
|
|
@@ -9347,6 +9438,8 @@ class EmptyDataError extends Error {
|
|
|
9347
9438
|
}
|
|
9348
9439
|
}
|
|
9349
9440
|
|
|
9441
|
+
const combineURLs = (baseURL, relativeURL) => (`${baseURL.replace(/\/?$/, '')}/${relativeURL.replace(/^\/+/, '')}`);
|
|
9442
|
+
|
|
9350
9443
|
class Report {
|
|
9351
9444
|
constructor(iterable, title) {
|
|
9352
9445
|
this.endPoint = Config.reportsEndPoint;
|
|
@@ -9467,14 +9560,14 @@ class Report {
|
|
|
9467
9560
|
filter: JSON.stringify(row.filter),
|
|
9468
9561
|
metaData: JSON.stringify(row.metaData),
|
|
9469
9562
|
};
|
|
9470
|
-
const url =
|
|
9563
|
+
const url = combineURLs(this.endPoint, route);
|
|
9471
9564
|
const response = yield Http.post(url, {
|
|
9472
9565
|
origin,
|
|
9473
9566
|
requestType: 'Row',
|
|
9474
9567
|
row,
|
|
9475
9568
|
});
|
|
9476
9569
|
const reportFile = response.data.messages[0].message;
|
|
9477
|
-
return
|
|
9570
|
+
return combineURLs(this.fileEndPoint, reportFile);
|
|
9478
9571
|
});
|
|
9479
9572
|
}
|
|
9480
9573
|
}
|
|
@@ -9906,97 +9999,6 @@ class TreeDataStructure {
|
|
|
9906
9999
|
}
|
|
9907
10000
|
}
|
|
9908
10001
|
|
|
9909
|
-
class DataValueOutHelper {
|
|
9910
|
-
static getFormParent(select) {
|
|
9911
|
-
let { formParent } = select;
|
|
9912
|
-
if (select.dataValueOutFormName) {
|
|
9913
|
-
try {
|
|
9914
|
-
formParent = Metadata.getInstance(select.dataValueOutFormName);
|
|
9915
|
-
}
|
|
9916
|
-
catch (error) {
|
|
9917
|
-
// instance not found, use input.formParent
|
|
9918
|
-
}
|
|
9919
|
-
}
|
|
9920
|
-
return formParent;
|
|
9921
|
-
}
|
|
9922
|
-
static setDataValueOut(select, value) {
|
|
9923
|
-
const { dataValueOut } = select;
|
|
9924
|
-
if (dataValueOut && dataValueOut.length && typeof value === 'object') {
|
|
9925
|
-
const formParent = DataValueOutHelper.getFormParent(select);
|
|
9926
|
-
if (formParent) {
|
|
9927
|
-
dataValueOut.forEach((columns) => {
|
|
9928
|
-
const { column, columnOnForm } = columns;
|
|
9929
|
-
if (!column || !columnOnForm)
|
|
9930
|
-
return;
|
|
9931
|
-
const currentValue = value ? value[column] : null;
|
|
9932
|
-
if (!Utils.isEqual(formParent.value[columnOnForm], currentValue)) {
|
|
9933
|
-
formParent.value[columnOnForm] = currentValue;
|
|
9934
|
-
}
|
|
9935
|
-
});
|
|
9936
|
-
}
|
|
9937
|
-
}
|
|
9938
|
-
}
|
|
9939
|
-
}
|
|
9940
|
-
|
|
9941
|
-
class DatasourceSearcher {
|
|
9942
|
-
constructor() {
|
|
9943
|
-
this.dsSearch = {
|
|
9944
|
-
SEARCH: (value, searchIn) => ({
|
|
9945
|
-
searchIn: [searchIn],
|
|
9946
|
-
search: String(value || ''),
|
|
9947
|
-
}),
|
|
9948
|
-
FILTER: (value, searchIn) => ({
|
|
9949
|
-
filter: {
|
|
9950
|
-
[searchIn]: value,
|
|
9951
|
-
},
|
|
9952
|
-
}),
|
|
9953
|
-
FIND: (value, searchIn) => ({
|
|
9954
|
-
find: {
|
|
9955
|
-
[searchIn]: value,
|
|
9956
|
-
},
|
|
9957
|
-
}),
|
|
9958
|
-
DYNAMIC_FILTER: (value, search_in) => {
|
|
9959
|
-
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
9960
|
-
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
9961
|
-
const dynamicFilter = { [search_in]: filter };
|
|
9962
|
-
return { dynamicFilter };
|
|
9963
|
-
},
|
|
9964
|
-
};
|
|
9965
|
-
}
|
|
9966
|
-
search(datasource, searchValue, searchIn, searchParam) {
|
|
9967
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9968
|
-
// using filter/find/dynamicFilter should make only 1 request
|
|
9969
|
-
// using normal search should make one request per search value
|
|
9970
|
-
if (!Array.isArray(searchValue)) {
|
|
9971
|
-
return this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9972
|
-
}
|
|
9973
|
-
if (searchParam !== 'SEARCH') {
|
|
9974
|
-
const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9975
|
-
return items;
|
|
9976
|
-
}
|
|
9977
|
-
const searchedItems = [];
|
|
9978
|
-
const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
|
|
9979
|
-
const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
|
|
9980
|
-
searchedItems.push(item);
|
|
9981
|
-
}));
|
|
9982
|
-
yield Promise.all(promises);
|
|
9983
|
-
return searchedItems;
|
|
9984
|
-
});
|
|
9985
|
-
}
|
|
9986
|
-
searchRequest(datasource, searchValue, searchIn, searchParam) {
|
|
9987
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9988
|
-
const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
|
|
9989
|
-
const cloneDatasource = DatasourceFactory.factory(config);
|
|
9990
|
-
const items = yield cloneDatasource.get();
|
|
9991
|
-
cloneDatasource.destroy();
|
|
9992
|
-
if (Array.isArray(searchValue)) {
|
|
9993
|
-
return items.filter((item) => searchValue.includes(item[searchIn]));
|
|
9994
|
-
}
|
|
9995
|
-
return items.filter((row) => row[searchIn] === searchValue);
|
|
9996
|
-
});
|
|
9997
|
-
}
|
|
9998
|
-
}
|
|
9999
|
-
|
|
10000
10002
|
const uniqueBy = (a, key) => {
|
|
10001
10003
|
const seen = {};
|
|
10002
10004
|
return a.filter((item) => {
|
|
@@ -15071,11 +15073,12 @@ class Tree extends ComponentRender {
|
|
|
15071
15073
|
this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
|
|
15072
15074
|
this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
|
|
15073
15075
|
this.disableCheckbox = this.getInitValue('disableCheckbox', props.disableCheckbox, this.disableCheckbox);
|
|
15074
|
-
|
|
15076
|
+
const propAfterTitleSlot = props.afterTitleSlot || this.afterTitleSlot || [];
|
|
15077
|
+
this.afterTitleSlot = Array.isArray(propAfterTitleSlot) ? propAfterTitleSlot : [propAfterTitleSlot];
|
|
15075
15078
|
this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
|
|
15076
15079
|
this.titleSlot = props.titleSlot || this.titleSlot;
|
|
15077
|
-
if (
|
|
15078
|
-
this.createConditions(
|
|
15080
|
+
if (this.afterTitleSlot) {
|
|
15081
|
+
this.createConditions(this.afterTitleSlot);
|
|
15079
15082
|
}
|
|
15080
15083
|
if (props.titleSlot) {
|
|
15081
15084
|
this.createConditions(props.titleSlot);
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -8131,6 +8131,97 @@
|
|
|
8131
8131
|
}
|
|
8132
8132
|
}
|
|
8133
8133
|
|
|
8134
|
+
class DataValueOutHelper {
|
|
8135
|
+
static getFormParent(select) {
|
|
8136
|
+
let { formParent } = select;
|
|
8137
|
+
if (select.dataValueOutFormName) {
|
|
8138
|
+
try {
|
|
8139
|
+
formParent = core.Metadata.getInstance(select.dataValueOutFormName);
|
|
8140
|
+
}
|
|
8141
|
+
catch (error) {
|
|
8142
|
+
// instance not found, use input.formParent
|
|
8143
|
+
}
|
|
8144
|
+
}
|
|
8145
|
+
return formParent;
|
|
8146
|
+
}
|
|
8147
|
+
static setDataValueOut(select, value) {
|
|
8148
|
+
const { dataValueOut } = select;
|
|
8149
|
+
if (dataValueOut && dataValueOut.length && typeof value === 'object') {
|
|
8150
|
+
const formParent = DataValueOutHelper.getFormParent(select);
|
|
8151
|
+
if (formParent) {
|
|
8152
|
+
dataValueOut.forEach((columns) => {
|
|
8153
|
+
const { column, columnOnForm } = columns;
|
|
8154
|
+
if (!column || !columnOnForm)
|
|
8155
|
+
return;
|
|
8156
|
+
const currentValue = value ? value[column] : null;
|
|
8157
|
+
if (!core.Utils.isEqual(formParent.value[columnOnForm], currentValue)) {
|
|
8158
|
+
formParent.value[columnOnForm] = currentValue;
|
|
8159
|
+
}
|
|
8160
|
+
});
|
|
8161
|
+
}
|
|
8162
|
+
}
|
|
8163
|
+
}
|
|
8164
|
+
}
|
|
8165
|
+
|
|
8166
|
+
class DatasourceSearcher {
|
|
8167
|
+
constructor() {
|
|
8168
|
+
this.dsSearch = {
|
|
8169
|
+
SEARCH: (value, searchIn) => ({
|
|
8170
|
+
searchIn: [searchIn],
|
|
8171
|
+
search: String(value || ''),
|
|
8172
|
+
}),
|
|
8173
|
+
FILTER: (value, searchIn) => ({
|
|
8174
|
+
filter: {
|
|
8175
|
+
[searchIn]: value,
|
|
8176
|
+
},
|
|
8177
|
+
}),
|
|
8178
|
+
FIND: (value, searchIn) => ({
|
|
8179
|
+
find: {
|
|
8180
|
+
[searchIn]: value,
|
|
8181
|
+
},
|
|
8182
|
+
}),
|
|
8183
|
+
DYNAMIC_FILTER: (value, search_in) => {
|
|
8184
|
+
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
8185
|
+
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
8186
|
+
const dynamicFilter = { [search_in]: filter };
|
|
8187
|
+
return { dynamicFilter };
|
|
8188
|
+
},
|
|
8189
|
+
};
|
|
8190
|
+
}
|
|
8191
|
+
search(datasource, searchValue, searchIn, searchParam) {
|
|
8192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8193
|
+
// using filter/find/dynamicFilter should make only 1 request
|
|
8194
|
+
// using normal search should make one request per search value
|
|
8195
|
+
if (!Array.isArray(searchValue)) {
|
|
8196
|
+
return this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
8197
|
+
}
|
|
8198
|
+
if (searchParam !== 'SEARCH') {
|
|
8199
|
+
const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
8200
|
+
return items;
|
|
8201
|
+
}
|
|
8202
|
+
const searchedItems = [];
|
|
8203
|
+
const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
|
|
8204
|
+
const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
|
|
8205
|
+
searchedItems.push(item);
|
|
8206
|
+
}));
|
|
8207
|
+
yield Promise.all(promises);
|
|
8208
|
+
return searchedItems;
|
|
8209
|
+
});
|
|
8210
|
+
}
|
|
8211
|
+
searchRequest(datasource, searchValue, searchIn, searchParam) {
|
|
8212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8213
|
+
const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
|
|
8214
|
+
const cloneDatasource = core.DatasourceFactory.factory(config);
|
|
8215
|
+
const items = yield cloneDatasource.get();
|
|
8216
|
+
cloneDatasource.destroy();
|
|
8217
|
+
if (Array.isArray(searchValue)) {
|
|
8218
|
+
return items.filter((item) => searchValue.includes(item[searchIn]));
|
|
8219
|
+
}
|
|
8220
|
+
return items.filter((row) => row[searchIn] === searchValue);
|
|
8221
|
+
});
|
|
8222
|
+
}
|
|
8223
|
+
}
|
|
8224
|
+
|
|
8134
8225
|
class Icons {
|
|
8135
8226
|
/**
|
|
8136
8227
|
* Replace all the icons
|
|
@@ -9354,6 +9445,8 @@
|
|
|
9354
9445
|
}
|
|
9355
9446
|
}
|
|
9356
9447
|
|
|
9448
|
+
const combineURLs = (baseURL, relativeURL) => (`${baseURL.replace(/\/?$/, '')}/${relativeURL.replace(/^\/+/, '')}`);
|
|
9449
|
+
|
|
9357
9450
|
class Report {
|
|
9358
9451
|
constructor(iterable, title) {
|
|
9359
9452
|
this.endPoint = core.Config.reportsEndPoint;
|
|
@@ -9474,14 +9567,14 @@
|
|
|
9474
9567
|
filter: JSON.stringify(row.filter),
|
|
9475
9568
|
metaData: JSON.stringify(row.metaData),
|
|
9476
9569
|
};
|
|
9477
|
-
const url =
|
|
9570
|
+
const url = combineURLs(this.endPoint, route);
|
|
9478
9571
|
const response = yield core.Http.post(url, {
|
|
9479
9572
|
origin,
|
|
9480
9573
|
requestType: 'Row',
|
|
9481
9574
|
row,
|
|
9482
9575
|
});
|
|
9483
9576
|
const reportFile = response.data.messages[0].message;
|
|
9484
|
-
return
|
|
9577
|
+
return combineURLs(this.fileEndPoint, reportFile);
|
|
9485
9578
|
});
|
|
9486
9579
|
}
|
|
9487
9580
|
}
|
|
@@ -9913,97 +10006,6 @@
|
|
|
9913
10006
|
}
|
|
9914
10007
|
}
|
|
9915
10008
|
|
|
9916
|
-
class DataValueOutHelper {
|
|
9917
|
-
static getFormParent(select) {
|
|
9918
|
-
let { formParent } = select;
|
|
9919
|
-
if (select.dataValueOutFormName) {
|
|
9920
|
-
try {
|
|
9921
|
-
formParent = core.Metadata.getInstance(select.dataValueOutFormName);
|
|
9922
|
-
}
|
|
9923
|
-
catch (error) {
|
|
9924
|
-
// instance not found, use input.formParent
|
|
9925
|
-
}
|
|
9926
|
-
}
|
|
9927
|
-
return formParent;
|
|
9928
|
-
}
|
|
9929
|
-
static setDataValueOut(select, value) {
|
|
9930
|
-
const { dataValueOut } = select;
|
|
9931
|
-
if (dataValueOut && dataValueOut.length && typeof value === 'object') {
|
|
9932
|
-
const formParent = DataValueOutHelper.getFormParent(select);
|
|
9933
|
-
if (formParent) {
|
|
9934
|
-
dataValueOut.forEach((columns) => {
|
|
9935
|
-
const { column, columnOnForm } = columns;
|
|
9936
|
-
if (!column || !columnOnForm)
|
|
9937
|
-
return;
|
|
9938
|
-
const currentValue = value ? value[column] : null;
|
|
9939
|
-
if (!core.Utils.isEqual(formParent.value[columnOnForm], currentValue)) {
|
|
9940
|
-
formParent.value[columnOnForm] = currentValue;
|
|
9941
|
-
}
|
|
9942
|
-
});
|
|
9943
|
-
}
|
|
9944
|
-
}
|
|
9945
|
-
}
|
|
9946
|
-
}
|
|
9947
|
-
|
|
9948
|
-
class DatasourceSearcher {
|
|
9949
|
-
constructor() {
|
|
9950
|
-
this.dsSearch = {
|
|
9951
|
-
SEARCH: (value, searchIn) => ({
|
|
9952
|
-
searchIn: [searchIn],
|
|
9953
|
-
search: String(value || ''),
|
|
9954
|
-
}),
|
|
9955
|
-
FILTER: (value, searchIn) => ({
|
|
9956
|
-
filter: {
|
|
9957
|
-
[searchIn]: value,
|
|
9958
|
-
},
|
|
9959
|
-
}),
|
|
9960
|
-
FIND: (value, searchIn) => ({
|
|
9961
|
-
find: {
|
|
9962
|
-
[searchIn]: value,
|
|
9963
|
-
},
|
|
9964
|
-
}),
|
|
9965
|
-
DYNAMIC_FILTER: (value, search_in) => {
|
|
9966
|
-
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
9967
|
-
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
9968
|
-
const dynamicFilter = { [search_in]: filter };
|
|
9969
|
-
return { dynamicFilter };
|
|
9970
|
-
},
|
|
9971
|
-
};
|
|
9972
|
-
}
|
|
9973
|
-
search(datasource, searchValue, searchIn, searchParam) {
|
|
9974
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9975
|
-
// using filter/find/dynamicFilter should make only 1 request
|
|
9976
|
-
// using normal search should make one request per search value
|
|
9977
|
-
if (!Array.isArray(searchValue)) {
|
|
9978
|
-
return this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9979
|
-
}
|
|
9980
|
-
if (searchParam !== 'SEARCH') {
|
|
9981
|
-
const items = yield this.searchRequest(datasource, searchValue, searchIn, searchParam);
|
|
9982
|
-
return items;
|
|
9983
|
-
}
|
|
9984
|
-
const searchedItems = [];
|
|
9985
|
-
const promises = searchValue.map((value) => __awaiter(this, void 0, void 0, function* () {
|
|
9986
|
-
const [item] = yield this.searchRequest(datasource, value, searchIn, searchParam);
|
|
9987
|
-
searchedItems.push(item);
|
|
9988
|
-
}));
|
|
9989
|
-
yield Promise.all(promises);
|
|
9990
|
-
return searchedItems;
|
|
9991
|
-
});
|
|
9992
|
-
}
|
|
9993
|
-
searchRequest(datasource, searchValue, searchIn, searchParam) {
|
|
9994
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9995
|
-
const config = Object.assign(Object.assign(Object.assign({}, datasource.clone()), this.dsSearch[searchParam](searchValue, searchIn)), { lazyLoad: true, loadAll: Array.isArray(searchValue) });
|
|
9996
|
-
const cloneDatasource = core.DatasourceFactory.factory(config);
|
|
9997
|
-
const items = yield cloneDatasource.get();
|
|
9998
|
-
cloneDatasource.destroy();
|
|
9999
|
-
if (Array.isArray(searchValue)) {
|
|
10000
|
-
return items.filter((item) => searchValue.includes(item[searchIn]));
|
|
10001
|
-
}
|
|
10002
|
-
return items.filter((row) => row[searchIn] === searchValue);
|
|
10003
|
-
});
|
|
10004
|
-
}
|
|
10005
|
-
}
|
|
10006
|
-
|
|
10007
10009
|
const uniqueBy = (a, key) => {
|
|
10008
10010
|
const seen = {};
|
|
10009
10011
|
return a.filter((item) => {
|
|
@@ -15078,11 +15080,12 @@
|
|
|
15078
15080
|
this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
|
|
15079
15081
|
this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
|
|
15080
15082
|
this.disableCheckbox = this.getInitValue('disableCheckbox', props.disableCheckbox, this.disableCheckbox);
|
|
15081
|
-
|
|
15083
|
+
const propAfterTitleSlot = props.afterTitleSlot || this.afterTitleSlot || [];
|
|
15084
|
+
this.afterTitleSlot = Array.isArray(propAfterTitleSlot) ? propAfterTitleSlot : [propAfterTitleSlot];
|
|
15082
15085
|
this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
|
|
15083
15086
|
this.titleSlot = props.titleSlot || this.titleSlot;
|
|
15084
|
-
if (
|
|
15085
|
-
this.createConditions(
|
|
15087
|
+
if (this.afterTitleSlot) {
|
|
15088
|
+
this.createConditions(this.afterTitleSlot);
|
|
15086
15089
|
}
|
|
15087
15090
|
if (props.titleSlot) {
|
|
15088
15091
|
this.createConditions(props.titleSlot);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.130.0",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"lodash.times": "4.3.*",
|
|
44
44
|
"mockdate": "3.0.*"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2b561909b83bedc8f7c1c440e90cfe83f7ba90b6"
|
|
47
47
|
}
|
|
@@ -53,7 +53,7 @@ export interface ITree extends IComponentRender {
|
|
|
53
53
|
closedIconName?: string;
|
|
54
54
|
allowMultiSelect?: boolean;
|
|
55
55
|
allowDragDrop?: boolean;
|
|
56
|
-
afterTitleSlot?: ITreeConditionComponent;
|
|
56
|
+
afterTitleSlot?: ITreeConditionComponent | ITreeConditionComponent[];
|
|
57
57
|
toolbarSlot?: IComponentRender[];
|
|
58
58
|
titleSlot?: ITreeConditionComponent[];
|
|
59
59
|
events?: ITreeEvents;
|
|
@@ -20,7 +20,7 @@ export declare class Tree extends ComponentRender implements ITree {
|
|
|
20
20
|
/** Allow dragging nodes */
|
|
21
21
|
allowDragDrop: boolean;
|
|
22
22
|
/** Render a component in front of the node title */
|
|
23
|
-
afterTitleSlot?: ITreeConditionComponent;
|
|
23
|
+
afterTitleSlot?: ITreeConditionComponent[];
|
|
24
24
|
/**
|
|
25
25
|
* Components that will be rendered on toolbar slot
|
|
26
26
|
*/
|
|
@@ -62,7 +62,7 @@ export declare class Tree extends ComponentRender implements ITree {
|
|
|
62
62
|
/**
|
|
63
63
|
* Components that will be rendered on title slot
|
|
64
64
|
*/
|
|
65
|
-
titleSlot
|
|
65
|
+
titleSlot: ITreeConditionComponent[];
|
|
66
66
|
/** Datasource object */
|
|
67
67
|
datasource?: Datasource;
|
|
68
68
|
/** Datasource parent field */
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './combine-urls';
|
package/types/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
export * from './data-value-out';
|
|
2
|
+
export * from './datasource-searcher';
|
|
1
3
|
export * from './icons/icons';
|
|
2
4
|
export * from './themes/themes';
|
|
3
5
|
export * from './watch-url/watch-url';
|
|
4
6
|
export * from './report';
|
|
5
7
|
export * from './tree-data-structure';
|
|
6
|
-
export * from './data-value-out';
|
|
7
|
-
export * from './datasource-searcher';
|
|
8
8
|
export * from './unique-by';
|