@esolve/ng-esolve-connect 0.20.9 → 0.21.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/esm2020/lib/shared/filters/classes/esolve-multiple-select-filter.model.mjs +30 -0
- package/esm2020/lib/shared/filters/classes/esolve-range-filter.model.mjs +45 -0
- package/esm2020/lib/shared/filters/classes/esolve-single-select-filter.model.mjs +33 -0
- package/esm2020/lib/shared/filters/classes/index.mjs +5 -0
- package/esm2020/lib/shared/filters/esolve-filter-factory.mjs +60 -0
- package/esm2020/lib/shared/filters/index.mjs +5 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-filter-definitions.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-filter-record.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-filter.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-range-filter-record.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-select-filter-record.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/esolve-select-filter.interface.mjs +2 -0
- package/esm2020/lib/shared/filters/interfaces/index.mjs +8 -0
- package/esm2020/lib/shared/filters/types/esolve-filter-list.type.mjs +2 -0
- package/esm2020/lib/shared/filters/types/esolve-filter-record-list.type.mjs +2 -0
- package/esm2020/lib/shared/filters/types/esolve-filter-type.type.mjs +2 -0
- package/esm2020/lib/shared/filters/types/esolve-range-filter-type.type.mjs +2 -0
- package/esm2020/lib/shared/filters/types/esolve-select-filter-type.type.mjs +2 -0
- package/esm2020/lib/shared/filters/types/index.mjs +7 -0
- package/esm2020/lib/stock/esolve-stock.service.mjs +47 -8
- package/esm2020/lib/stock/interfaces/esolve-stock-filter-options.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-item-options.interface.mjs +1 -1
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/esolve-ng-esolve-connect.mjs +217 -8
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +219 -8
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/shared/filters/classes/esolve-multiple-select-filter.model.d.ts +14 -0
- package/lib/shared/filters/classes/esolve-range-filter.model.d.ts +18 -0
- package/lib/shared/filters/classes/esolve-single-select-filter.model.d.ts +15 -0
- package/lib/shared/filters/classes/index.d.ts +3 -0
- package/lib/shared/filters/esolve-filter-factory.d.ts +13 -0
- package/lib/shared/filters/index.d.ts +4 -0
- package/lib/shared/filters/interfaces/esolve-filter-definitions.interface.d.ts +6 -0
- package/lib/shared/filters/interfaces/esolve-filter-record.interface.d.ts +5 -0
- package/lib/shared/filters/interfaces/esolve-filter.interface.d.ts +10 -0
- package/lib/shared/filters/interfaces/esolve-range-filter-record.interface.d.ts +7 -0
- package/lib/shared/filters/interfaces/esolve-select-filter-record.interface.d.ts +6 -0
- package/lib/shared/filters/interfaces/esolve-select-filter.interface.d.ts +4 -0
- package/lib/shared/filters/interfaces/index.d.ts +6 -0
- package/lib/shared/filters/types/esolve-filter-list.type.d.ts +2 -0
- package/lib/shared/filters/types/esolve-filter-record-list.type.d.ts +2 -0
- package/lib/shared/filters/types/esolve-filter-type.type.d.ts +3 -0
- package/lib/shared/filters/types/esolve-range-filter-type.type.d.ts +1 -0
- package/lib/shared/filters/types/esolve-select-filter-type.type.d.ts +1 -0
- package/lib/shared/filters/types/index.d.ts +5 -0
- package/lib/stock/esolve-stock.service.d.ts +3 -0
- package/lib/stock/interfaces/esolve-stock-filter-options.interface.d.ts +7 -0
- package/lib/stock/interfaces/esolve-stock-item-options.interface.d.ts +5 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -327,6 +327,176 @@ class EsolveResult {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
class EsolveMultipleSelectFilter {
|
|
331
|
+
constructor(field, options) {
|
|
332
|
+
this.field = field;
|
|
333
|
+
this.type = 'multiple';
|
|
334
|
+
this.options = [];
|
|
335
|
+
if (options) {
|
|
336
|
+
this.options = options;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
setValue(values) {
|
|
340
|
+
this.values = values;
|
|
341
|
+
}
|
|
342
|
+
toHttpParams(http_params) {
|
|
343
|
+
if (!this.values) {
|
|
344
|
+
throw new Error('No values set');
|
|
345
|
+
}
|
|
346
|
+
const base_property = `filter[${this.field}]`;
|
|
347
|
+
const type_property = base_property + '[type]';
|
|
348
|
+
const values_property = base_property + '[values][]';
|
|
349
|
+
const params = {
|
|
350
|
+
[type_property]: this.type,
|
|
351
|
+
[values_property]: this.values,
|
|
352
|
+
};
|
|
353
|
+
if (http_params) {
|
|
354
|
+
return http_params.appendAll(params);
|
|
355
|
+
}
|
|
356
|
+
return params;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
class EsolveRangeFilter {
|
|
361
|
+
constructor(field, min = 0, max = 0) {
|
|
362
|
+
this.field = field;
|
|
363
|
+
this.type = 'range';
|
|
364
|
+
this.min = 0;
|
|
365
|
+
this.max = 0;
|
|
366
|
+
this.options = {
|
|
367
|
+
min: 0,
|
|
368
|
+
max: 0,
|
|
369
|
+
};
|
|
370
|
+
this.options.min = min;
|
|
371
|
+
this.options.max = max;
|
|
372
|
+
if ((max > 0) && (min > max)) {
|
|
373
|
+
this.options.min = max;
|
|
374
|
+
this.options.max = min;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
setValue(min, max) {
|
|
378
|
+
this.min = min;
|
|
379
|
+
this.max = max;
|
|
380
|
+
if ((max > 0) && (min > max)) {
|
|
381
|
+
this.min = max;
|
|
382
|
+
this.max = min;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
toHttpParams(http_params) {
|
|
386
|
+
if (this.min <= 0 && this.max <= 0) {
|
|
387
|
+
throw new Error('No values set');
|
|
388
|
+
}
|
|
389
|
+
const base_property = `filter[${this.field}]`;
|
|
390
|
+
const type_property = base_property + '[type]';
|
|
391
|
+
const min_property = base_property + '[min]';
|
|
392
|
+
const max_property = base_property + '[max]';
|
|
393
|
+
const params = {
|
|
394
|
+
[type_property]: this.type,
|
|
395
|
+
[min_property]: this.min,
|
|
396
|
+
[max_property]: this.max,
|
|
397
|
+
};
|
|
398
|
+
if (http_params) {
|
|
399
|
+
return http_params.appendAll(params);
|
|
400
|
+
}
|
|
401
|
+
return params;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
class EsolveSingleSelectFilter {
|
|
406
|
+
constructor(field, options_or_value) {
|
|
407
|
+
this.field = field;
|
|
408
|
+
this.type = 'single';
|
|
409
|
+
this.options = [];
|
|
410
|
+
if (Array.isArray(options_or_value)) {
|
|
411
|
+
this.options = options_or_value;
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
this.setValue(options_or_value);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
setValue(value) {
|
|
418
|
+
this.value = value;
|
|
419
|
+
}
|
|
420
|
+
toHttpParams(http_params) {
|
|
421
|
+
if (!this.value) {
|
|
422
|
+
throw new Error('No values set');
|
|
423
|
+
}
|
|
424
|
+
const base_property = `filter[${this.field}]`;
|
|
425
|
+
const type_property = base_property + '[type]';
|
|
426
|
+
const values_property = base_property + '[value]';
|
|
427
|
+
const params = {
|
|
428
|
+
[type_property]: this.type,
|
|
429
|
+
[values_property]: this.value,
|
|
430
|
+
};
|
|
431
|
+
if (http_params) {
|
|
432
|
+
return http_params.appendAll(params);
|
|
433
|
+
}
|
|
434
|
+
return params;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Classes
|
|
439
|
+
|
|
440
|
+
// Interfaces
|
|
441
|
+
|
|
442
|
+
// Types
|
|
443
|
+
|
|
444
|
+
var EsolveFilterFactory;
|
|
445
|
+
(function (EsolveFilterFactory) {
|
|
446
|
+
function createRangeWithValue(field, min = 0, max = 0) {
|
|
447
|
+
const filter = new EsolveRangeFilter(field);
|
|
448
|
+
filter.setValue(min, max);
|
|
449
|
+
return filter;
|
|
450
|
+
}
|
|
451
|
+
EsolveFilterFactory.createRangeWithValue = createRangeWithValue;
|
|
452
|
+
function createSingleSelectWithValue(field, value) {
|
|
453
|
+
const filter = new EsolveSingleSelectFilter(field, value);
|
|
454
|
+
return filter;
|
|
455
|
+
}
|
|
456
|
+
EsolveFilterFactory.createSingleSelectWithValue = createSingleSelectWithValue;
|
|
457
|
+
function createMultipleSelectWithValue(field, value) {
|
|
458
|
+
const filter = new EsolveMultipleSelectFilter(field);
|
|
459
|
+
filter.setValue(value);
|
|
460
|
+
return filter;
|
|
461
|
+
}
|
|
462
|
+
EsolveFilterFactory.createMultipleSelectWithValue = createMultipleSelectWithValue;
|
|
463
|
+
function covertFromObj(obj) {
|
|
464
|
+
const filters = [];
|
|
465
|
+
for (const field in obj) {
|
|
466
|
+
const value = obj[field];
|
|
467
|
+
let filter = null;
|
|
468
|
+
if (Array.isArray(value)) {
|
|
469
|
+
filter = createMultipleSelectWithValue(field, value);
|
|
470
|
+
}
|
|
471
|
+
else if (typeof value === 'object') {
|
|
472
|
+
filter = createRangeWithValue(field, value.min, value.max);
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
filter = createSingleSelectWithValue(field, value);
|
|
476
|
+
}
|
|
477
|
+
if (filter) {
|
|
478
|
+
filters.push(filter);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return filters;
|
|
482
|
+
}
|
|
483
|
+
EsolveFilterFactory.covertFromObj = covertFromObj;
|
|
484
|
+
function convertToHttpParams(filters, http_params) {
|
|
485
|
+
if (http_params) {
|
|
486
|
+
for (const filter of filters) {
|
|
487
|
+
http_params = filter.toHttpParams(http_params);
|
|
488
|
+
}
|
|
489
|
+
return http_params;
|
|
490
|
+
}
|
|
491
|
+
let params = {};
|
|
492
|
+
for (const filter of filters) {
|
|
493
|
+
params = Object.assign(Object.assign({}, params), filter.toHttpParams());
|
|
494
|
+
}
|
|
495
|
+
return params;
|
|
496
|
+
}
|
|
497
|
+
EsolveFilterFactory.convertToHttpParams = convertToHttpParams;
|
|
498
|
+
})(EsolveFilterFactory || (EsolveFilterFactory = {}));
|
|
499
|
+
|
|
330
500
|
class EsolveResponseResult {
|
|
331
501
|
constructor(response) {
|
|
332
502
|
this.success_log = [];
|
|
@@ -3351,15 +3521,18 @@ class EsolveStockService {
|
|
|
3351
3521
|
if (options.specials_id) {
|
|
3352
3522
|
params = params.set('specials_id', options.specials_id);
|
|
3353
3523
|
}
|
|
3354
|
-
if (options.tag_id_list) {
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3524
|
+
if (options.tag_id_list && options.tag_id_list.length > 0) {
|
|
3525
|
+
params = params.set('tag_id', options.tag_id_list.join(','));
|
|
3526
|
+
}
|
|
3527
|
+
if (options.topic_id_list && options.topic_id_list.length > 0) {
|
|
3528
|
+
params = params.set('topic_id', options.topic_id_list.join(','));
|
|
3358
3529
|
}
|
|
3359
|
-
if (options.
|
|
3360
|
-
|
|
3361
|
-
|
|
3530
|
+
if (options.filters) {
|
|
3531
|
+
let filters = options.filters;
|
|
3532
|
+
if (!Array.isArray(filters)) {
|
|
3533
|
+
filters = EsolveFilterFactory.covertFromObj(filters);
|
|
3362
3534
|
}
|
|
3535
|
+
params = EsolveFilterFactory.convertToHttpParams(filters, params);
|
|
3363
3536
|
}
|
|
3364
3537
|
return this.getStockRecords(params).pipe(map(response => {
|
|
3365
3538
|
var _a;
|
|
@@ -3483,6 +3656,42 @@ class EsolveStockService {
|
|
|
3483
3656
|
return collection;
|
|
3484
3657
|
}));
|
|
3485
3658
|
}
|
|
3659
|
+
getStockFilters(options) {
|
|
3660
|
+
var _a, _b, _c, _d;
|
|
3661
|
+
let params = new HttpParams({
|
|
3662
|
+
fromObject: {
|
|
3663
|
+
category_id: (_a = options.category_id) !== null && _a !== void 0 ? _a : '',
|
|
3664
|
+
subcategory_id: (_b = options.subcategory_id) !== null && _b !== void 0 ? _b : 0,
|
|
3665
|
+
ranges_id: (_c = options.ranges_id) !== null && _c !== void 0 ? _c : 0,
|
|
3666
|
+
manufacturers_id: (_d = options.manufacturers_id) !== null && _d !== void 0 ? _d : 0,
|
|
3667
|
+
fields: options.fields.join(','),
|
|
3668
|
+
},
|
|
3669
|
+
});
|
|
3670
|
+
return this.http
|
|
3671
|
+
.get(`${this.config.api_url}/get-item-filters.php`, { params })
|
|
3672
|
+
.pipe(map((response) => {
|
|
3673
|
+
if (response.records === undefined) {
|
|
3674
|
+
throw response;
|
|
3675
|
+
}
|
|
3676
|
+
const filters = [];
|
|
3677
|
+
for (const record of response.records) {
|
|
3678
|
+
let filter = null;
|
|
3679
|
+
if (record.type === 'range') {
|
|
3680
|
+
filter = new EsolveRangeFilter(record.field, +record.min, +record.max);
|
|
3681
|
+
}
|
|
3682
|
+
else if (record.type === 'single') {
|
|
3683
|
+
filter = new EsolveSingleSelectFilter(record.field, record.values);
|
|
3684
|
+
}
|
|
3685
|
+
else if (record.type === 'multiple') {
|
|
3686
|
+
filter = new EsolveMultipleSelectFilter(record.field, record.values);
|
|
3687
|
+
}
|
|
3688
|
+
if (filter) {
|
|
3689
|
+
filters.push(filter);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
return filters;
|
|
3693
|
+
}));
|
|
3694
|
+
}
|
|
3486
3695
|
/**
|
|
3487
3696
|
* Processes the eSolve stock item record and converts it to an object.
|
|
3488
3697
|
*
|
|
@@ -4581,5 +4790,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
4581
4790
|
* Generated bundle index. Do not edit.
|
|
4582
4791
|
*/
|
|
4583
4792
|
|
|
4584
|
-
export { ESOLVE_CONNECT_CONFIG, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
4793
|
+
export { ESOLVE_CONNECT_CONFIG, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
4585
4794
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|