@esolve/ng-esolve-connect 0.14.0 → 0.15.1
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/account/esolve-account.service.mjs +3 -3
- package/esm2020/lib/cart/esolve-cart-stock-item.model.mjs +7 -7
- package/esm2020/lib/category-tree/esolve-category-record.interface.mjs +1 -1
- package/esm2020/lib/category-tree/esolve-category-tree-item-record.interface.mjs +1 -1
- package/esm2020/lib/category-tree/esolve-category-tree-item.model.mjs +5 -5
- package/esm2020/lib/category-tree/esolve-category-tree.service.mjs +2 -2
- package/esm2020/lib/category-tree/esolve-subcategory-record.interface.mjs +1 -1
- package/esm2020/lib/enquiry/esolve-enquiry-response.interface.mjs +2 -0
- package/esm2020/lib/enquiry/esolve-enquiry-result.model.mjs +9 -0
- package/esm2020/lib/enquiry/esolve-enquiry.service.mjs +41 -0
- package/esm2020/lib/enquiry/index.mjs +4 -0
- package/esm2020/lib/manufacturers/esolve-manufacturer.model.mjs +8 -5
- package/esm2020/lib/ranges/esolve-range.model.mjs +3 -3
- package/esm2020/lib/shared/errors/esolve-error-handler.service.mjs +5 -2
- package/esm2020/lib/shared/errors/index.mjs +3 -0
- package/esm2020/lib/stock/esolve-colour-record.interface.mjs +2 -0
- package/esm2020/lib/stock/esolve-colour.model.mjs +8 -0
- package/esm2020/lib/stock/esolve-stock-base-record.interface.mjs +1 -1
- package/esm2020/lib/stock/esolve-stock-item-base.model.mjs +50 -7
- package/esm2020/lib/stock/esolve-stock-lead-times-record.interface.mjs +2 -0
- package/esm2020/lib/stock/esolve-stock-lead-times.model.mjs +9 -0
- package/esm2020/lib/stock/index.mjs +16 -9
- package/esm2020/public-api.mjs +4 -3
- package/fesm2015/esolve-ng-esolve-connect.mjs +800 -693
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +781 -677
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/account/esolve-account.service.d.ts +1 -1
- package/lib/cart/esolve-cart-stock-item.model.d.ts +1 -1
- package/lib/category-tree/esolve-category-record.interface.d.ts +1 -1
- package/lib/category-tree/esolve-category-tree-item-record.interface.d.ts +1 -0
- package/lib/category-tree/esolve-category-tree-item.model.d.ts +1 -1
- package/lib/category-tree/esolve-subcategory-record.interface.d.ts +1 -1
- package/lib/enquiry/esolve-enquiry-response.interface.d.ts +3 -0
- package/lib/enquiry/esolve-enquiry-result.model.d.ts +6 -0
- package/lib/enquiry/esolve-enquiry.service.d.ts +17 -0
- package/lib/enquiry/index.d.ts +3 -0
- package/lib/manufacturers/esolve-manufacturer.model.d.ts +2 -1
- package/lib/ranges/esolve-range.model.d.ts +1 -1
- package/lib/shared/errors/esolve-error-handler.service.d.ts +2 -1
- package/lib/shared/errors/index.d.ts +2 -0
- package/lib/stock/esolve-colour-record.interface.d.ts +5 -0
- package/lib/stock/esolve-colour.model.d.ts +7 -0
- package/lib/stock/esolve-stock-base-record.interface.d.ts +11 -0
- package/lib/stock/esolve-stock-item-base.model.d.ts +47 -1
- package/lib/stock/esolve-stock-lead-times-record.interface.d.ts +4 -0
- package/lib/stock/esolve-stock-lead-times.model.d.ts +6 -0
- package/lib/stock/index.d.ts +12 -8
- package/package.json +1 -1
- package/public-api.d.ts +2 -2
|
@@ -374,9 +374,12 @@ class EsolveHttpError {
|
|
|
374
374
|
|
|
375
375
|
class EsolveErrorHandlerService {
|
|
376
376
|
constructor() { }
|
|
377
|
-
|
|
377
|
+
throwError(code, message) {
|
|
378
378
|
throw new EsolveHttpError('error', message, code);
|
|
379
379
|
}
|
|
380
|
+
emitError(code, message) {
|
|
381
|
+
return throwError(new EsolveHttpError('error', message, code));
|
|
382
|
+
}
|
|
380
383
|
handleHttpPostError(service_type, errorRes) {
|
|
381
384
|
if (!(errorRes instanceof HttpErrorResponse) &&
|
|
382
385
|
!('service_type' in errorRes) &&
|
|
@@ -1524,7 +1527,7 @@ class EsolveAccountService {
|
|
|
1524
1527
|
}
|
|
1525
1528
|
loginGuard() {
|
|
1526
1529
|
if (this.user_id <= 0) {
|
|
1527
|
-
this.errorHandler.
|
|
1530
|
+
this.errorHandler.throwError('login_required', 'Login is required');
|
|
1528
1531
|
}
|
|
1529
1532
|
}
|
|
1530
1533
|
}
|
|
@@ -2076,447 +2079,280 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2076
2079
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2077
2080
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2078
2081
|
|
|
2079
|
-
class
|
|
2080
|
-
constructor(
|
|
2081
|
-
this.id = id;
|
|
2082
|
-
this.
|
|
2083
|
-
this.
|
|
2084
|
-
this.font_colour = font_colour;
|
|
2085
|
-
this.badge_colour = badge_colour;
|
|
2086
|
-
this.sort_priority = sort_priority;
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
/**
|
|
2091
|
-
* Price of eSolve stock item
|
|
2092
|
-
*/
|
|
2093
|
-
class EsolveStockPrice {
|
|
2094
|
-
/**
|
|
2095
|
-
* Create stock price instance
|
|
2096
|
-
* @param base_price Price without tax
|
|
2097
|
-
* @param base_price_with_tax Price with tax
|
|
2098
|
-
* @param sell_price Price without tax and with discounts applied if applicable
|
|
2099
|
-
* @param sell_price_with_tax Price with tax and with discounts applied if applicable
|
|
2100
|
-
*/
|
|
2101
|
-
constructor(
|
|
2102
|
-
/**
|
|
2103
|
-
* Price without tax
|
|
2104
|
-
*/
|
|
2105
|
-
base_price = 0,
|
|
2106
|
-
/**
|
|
2107
|
-
* Price with tax
|
|
2108
|
-
*/
|
|
2109
|
-
base_price_with_tax = 0,
|
|
2110
|
-
/**
|
|
2111
|
-
* Price without tax and with discounts applied if applicable
|
|
2112
|
-
*/
|
|
2113
|
-
sell_price = 0,
|
|
2114
|
-
/**
|
|
2115
|
-
* Price with tax and with discounts applied if applicable
|
|
2116
|
-
*/
|
|
2117
|
-
sell_price_with_tax = 0) {
|
|
2118
|
-
this.base_price = base_price;
|
|
2119
|
-
this.base_price_with_tax = base_price_with_tax;
|
|
2120
|
-
this.sell_price = sell_price;
|
|
2121
|
-
this.sell_price_with_tax = sell_price_with_tax;
|
|
2122
|
-
if ((this.base_price === 0) && (this.sell_price > 0)) {
|
|
2123
|
-
this.base_price = this.sell_price;
|
|
2124
|
-
this.base_price_with_tax = this.sell_price_with_tax;
|
|
2125
|
-
}
|
|
2126
|
-
else if ((this.base_price > 0) && (this.sell_price === 0)) {
|
|
2127
|
-
this.sell_price = this.base_price;
|
|
2128
|
-
this.sell_price_with_tax = this.base_price_with_tax;
|
|
2129
|
-
}
|
|
2082
|
+
class EsolveColour {
|
|
2083
|
+
constructor(record) {
|
|
2084
|
+
this.id = record.id ?? 0;
|
|
2085
|
+
this.colour = record.colour ?? '';
|
|
2086
|
+
this.description = record.description ?? '';
|
|
2130
2087
|
}
|
|
2131
2088
|
}
|
|
2132
2089
|
|
|
2133
|
-
class
|
|
2134
|
-
constructor(
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
this.
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
this.
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
this.
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
/**
|
|
2152
|
-
* Short description of stock item
|
|
2153
|
-
*/
|
|
2154
|
-
this.description = '';
|
|
2155
|
-
/**
|
|
2156
|
-
* Full description of stock item
|
|
2157
|
-
*/
|
|
2158
|
-
this.extended_description = '';
|
|
2159
|
-
/**
|
|
2160
|
-
* Active state
|
|
2161
|
-
*/
|
|
2162
|
-
this.active = false;
|
|
2163
|
-
/**
|
|
2164
|
-
* Featured state
|
|
2165
|
-
*/
|
|
2166
|
-
this.featured = false;
|
|
2167
|
-
/**
|
|
2168
|
-
* ID of default category linked to the stock item
|
|
2169
|
-
*/
|
|
2170
|
-
this.category_id = '';
|
|
2171
|
-
/**
|
|
2172
|
-
* ID of default subcategory linked to the stock item
|
|
2173
|
-
*/
|
|
2174
|
-
this.subcategory_id = 0;
|
|
2175
|
-
this.manufacturers_id = 0;
|
|
2176
|
-
this.ranges_id = 0;
|
|
2177
|
-
/**
|
|
2178
|
-
* Linked tags
|
|
2179
|
-
*/
|
|
2180
|
-
this.tags = [];
|
|
2181
|
-
/**
|
|
2182
|
-
* Linked topics
|
|
2183
|
-
*/
|
|
2184
|
-
this.topics = [];
|
|
2185
|
-
/**
|
|
2186
|
-
* Stock badges
|
|
2187
|
-
*/
|
|
2188
|
-
this.badges = [];
|
|
2189
|
-
/**
|
|
2190
|
-
* Image filename
|
|
2191
|
-
*/
|
|
2192
|
-
this.image_name = '';
|
|
2193
|
-
let seo_title = '';
|
|
2194
|
-
let seo_keywords = '';
|
|
2195
|
-
let base_price = 0;
|
|
2196
|
-
let base_price_with_tax = 0;
|
|
2197
|
-
let sell_price = 0;
|
|
2198
|
-
let sell_price_with_tax = 0;
|
|
2199
|
-
if (record) {
|
|
2200
|
-
this.id = +(record.id ?? 0);
|
|
2201
|
-
this.code = record.code ?? '';
|
|
2202
|
-
this.name = record.name ?? '';
|
|
2203
|
-
this.sef_name = record.sef_name ?? '';
|
|
2204
|
-
this.description = record.description ?? '';
|
|
2205
|
-
this.extended_description = record.extended_description ?? '';
|
|
2206
|
-
this.image_name = record.image_name ?? '';
|
|
2207
|
-
this.category_id = record.category_id ?? '';
|
|
2208
|
-
this.subcategory_id = +(record.subcategory_id ?? 0);
|
|
2209
|
-
this.manufacturers_id = +(record.manufacturers_id ?? 0);
|
|
2210
|
-
this.ranges_id = +(record.ranges_id ?? 0);
|
|
2211
|
-
this.active = !!+(record.is_active ?? false);
|
|
2212
|
-
this.featured = !!+(record.is_featured ?? false);
|
|
2213
|
-
base_price = +(record.regular_sellprice ?? 0);
|
|
2214
|
-
base_price_with_tax = +(record.regular_sellprice_inclusive ?? 0);
|
|
2215
|
-
sell_price = +(record.sellprice ?? 0);
|
|
2216
|
-
sell_price_with_tax = +(record.sellprice_inclusive ?? 0);
|
|
2217
|
-
if ((record.tags) && (record.tags.length > 0)) {
|
|
2218
|
-
for (const tag of record.tags) {
|
|
2219
|
-
this.tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
if ((record.topics) && (record.topics.length > 0)) {
|
|
2223
|
-
for (const topic of record.topics) {
|
|
2224
|
-
this.topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
if ((record.badges) && (record.badges.length > 0)) {
|
|
2228
|
-
for (const badge of record.badges) {
|
|
2229
|
-
this.badges.push(new EsolveStockBadge(+badge.id, badge.text, badge.identifier, badge.font_colour, badge.badge_colour, +badge.sort_priority));
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
if (record.custom_fields) {
|
|
2233
|
-
this.custom_fields = record.custom_fields;
|
|
2090
|
+
class EsolveCategoryTreeItem {
|
|
2091
|
+
constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
|
|
2092
|
+
this.type = type;
|
|
2093
|
+
this.esolve_id = esolve_id;
|
|
2094
|
+
this.parent_id = parent_id;
|
|
2095
|
+
this.description = description;
|
|
2096
|
+
this.sef_description = sef_description;
|
|
2097
|
+
this.short_description = short_description;
|
|
2098
|
+
this.sort_priority = sort_priority;
|
|
2099
|
+
this.active = active;
|
|
2100
|
+
this.display_only = display_only;
|
|
2101
|
+
this.image_name = image_name;
|
|
2102
|
+
this.id = '';
|
|
2103
|
+
this.image_path = '';
|
|
2104
|
+
if (this.type === 'category') {
|
|
2105
|
+
this.id = `<<CAT>>${this.esolve_id}`;
|
|
2106
|
+
if (children != null) {
|
|
2107
|
+
this.children = children;
|
|
2234
2108
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2109
|
+
this.image_path = '/images/categories/';
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
this.id = `<<SUB>>${this.esolve_id}`;
|
|
2113
|
+
this.image_path = '/images/subcategories/';
|
|
2237
2114
|
}
|
|
2238
|
-
this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax);
|
|
2239
2115
|
if (seo_title.trim() === '') {
|
|
2240
|
-
seo_title = this.
|
|
2116
|
+
seo_title = this.description;
|
|
2241
2117
|
}
|
|
2242
|
-
this.seo_details = new EsolveSeoInfo(seo_title,
|
|
2243
|
-
}
|
|
2244
|
-
/**
|
|
2245
|
-
* Path to tiny stock image
|
|
2246
|
-
*/
|
|
2247
|
-
get tiny_image_src() {
|
|
2248
|
-
return this.generateImagePath('tiny');
|
|
2249
|
-
}
|
|
2250
|
-
/**
|
|
2251
|
-
* Path to thumbnail stock image
|
|
2252
|
-
*/
|
|
2253
|
-
get thumbnail_image_src() {
|
|
2254
|
-
return this.generateImagePath('thumb');
|
|
2118
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2255
2119
|
}
|
|
2256
|
-
/**
|
|
2257
|
-
* Path to small stock image
|
|
2258
|
-
*/
|
|
2259
2120
|
get small_image_src() {
|
|
2260
|
-
return this.
|
|
2121
|
+
return this.getImagePath('small');
|
|
2261
2122
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
*/
|
|
2265
|
-
get big_image_src() {
|
|
2266
|
-
return this.generateImagePath('big');
|
|
2123
|
+
get thumbnail_image_src() {
|
|
2124
|
+
return this.getImagePath('thumb');
|
|
2267
2125
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
*/
|
|
2271
|
-
get original_image_src() {
|
|
2272
|
-
return this.generateImagePath('original');
|
|
2126
|
+
get tiny_image_src() {
|
|
2127
|
+
return this.getImagePath('tiny');
|
|
2273
2128
|
}
|
|
2274
|
-
|
|
2129
|
+
getImagePath(image_size) {
|
|
2275
2130
|
if (this.image_name !== '') {
|
|
2276
|
-
return
|
|
2131
|
+
return `${this.image_path}${image_size}/${this.image_name}`;
|
|
2277
2132
|
}
|
|
2278
2133
|
return '';
|
|
2279
2134
|
}
|
|
2280
2135
|
}
|
|
2281
2136
|
|
|
2282
|
-
class
|
|
2283
|
-
constructor(
|
|
2284
|
-
|
|
2137
|
+
class EsolveCategoryTreeService {
|
|
2138
|
+
constructor(config, http) {
|
|
2139
|
+
this.config = config;
|
|
2140
|
+
this.http = http;
|
|
2285
2141
|
}
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
this.
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2142
|
+
/**
|
|
2143
|
+
* Retrieves the category tree from eSolve instance and coverts it to the correct format.
|
|
2144
|
+
*/
|
|
2145
|
+
getCategoryTree() {
|
|
2146
|
+
return this.http
|
|
2147
|
+
.get(`${this.config.api_url}/get-tree.php`)
|
|
2148
|
+
.pipe(map((response) => {
|
|
2149
|
+
if (response.records === undefined) {
|
|
2150
|
+
throw response;
|
|
2295
2151
|
}
|
|
2296
|
-
|
|
2152
|
+
return this.processTree(response.records);
|
|
2153
|
+
}));
|
|
2297
2154
|
}
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
/**
|
|
2301
|
-
* Stock Item object. It can be a service or a product (physical and/or digital).
|
|
2302
|
-
*/
|
|
2303
|
-
class EsolveStockItem extends EsolveStockItemBase {
|
|
2304
2155
|
/**
|
|
2305
|
-
*
|
|
2156
|
+
* Retrieve the details of a category tree item from the eSolve instance and
|
|
2157
|
+
* converts it to the correct format.
|
|
2158
|
+
*
|
|
2159
|
+
* @param options Filter options
|
|
2306
2160
|
*/
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2161
|
+
getCategoryTreeItem(options) {
|
|
2162
|
+
let type;
|
|
2163
|
+
let esolve_id;
|
|
2164
|
+
let sef_description;
|
|
2165
|
+
if (options.id) {
|
|
2166
|
+
const categoryIdentifier = this.processID(options.id);
|
|
2167
|
+
if (categoryIdentifier) {
|
|
2168
|
+
type = categoryIdentifier.type;
|
|
2169
|
+
esolve_id = categoryIdentifier.esolve_id;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
else if (options.type) {
|
|
2173
|
+
type = options.type;
|
|
2174
|
+
if (options.esolve_id) {
|
|
2175
|
+
esolve_id = options.esolve_id;
|
|
2176
|
+
}
|
|
2177
|
+
else if (options.sef_description) {
|
|
2178
|
+
sef_description = options.sef_description;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
if (type && (esolve_id || sef_description)) {
|
|
2182
|
+
let params = new HttpParams();
|
|
2183
|
+
params = params.set('type', type);
|
|
2184
|
+
if (esolve_id) {
|
|
2185
|
+
params = params.set('id', esolve_id);
|
|
2186
|
+
}
|
|
2187
|
+
if (sef_description) {
|
|
2188
|
+
params = params.set('sef_description', sef_description);
|
|
2189
|
+
}
|
|
2190
|
+
return this.http
|
|
2191
|
+
.get(`${this.config.api_url}/get-tree-item.php`, { params })
|
|
2192
|
+
.pipe(map((response) => {
|
|
2193
|
+
if ((response.records === undefined) ||
|
|
2194
|
+
(response.records.length <= 0)) {
|
|
2195
|
+
throw response;
|
|
2196
|
+
}
|
|
2197
|
+
return this.processTreeItem(response.records[0]);
|
|
2198
|
+
}));
|
|
2199
|
+
}
|
|
2200
|
+
return throwError('Invalid options');
|
|
2323
2201
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2202
|
+
/**
|
|
2203
|
+
* Processes the eSolve tree records and converts them into the correct format.
|
|
2204
|
+
*
|
|
2205
|
+
* @param tree_records Records to process
|
|
2206
|
+
*/
|
|
2207
|
+
processTree(tree_records) {
|
|
2208
|
+
const tree_items = [];
|
|
2209
|
+
if (tree_records) {
|
|
2210
|
+
for (const tree_record of tree_records) {
|
|
2211
|
+
let esolve_id = '';
|
|
2212
|
+
let parent_id = '';
|
|
2213
|
+
let children = [];
|
|
2214
|
+
if (tree_record.type === 'category') {
|
|
2215
|
+
children = this.processTree(tree_record.children);
|
|
2216
|
+
esolve_id = tree_record.menu_id;
|
|
2217
|
+
parent_id = tree_record.owner_menu_id;
|
|
2218
|
+
}
|
|
2219
|
+
else {
|
|
2220
|
+
esolve_id = tree_record.id;
|
|
2221
|
+
parent_id = tree_record.menu_id;
|
|
2222
|
+
}
|
|
2223
|
+
tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children));
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
return tree_items;
|
|
2331
2227
|
}
|
|
2332
|
-
|
|
2228
|
+
processTreeItem(record) {
|
|
2229
|
+
return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, record.image, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2230
|
+
}
|
|
2231
|
+
processID(id) {
|
|
2232
|
+
let type;
|
|
2233
|
+
let esolve_id;
|
|
2234
|
+
const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
|
|
2235
|
+
const match_results = id.match(type_code_regex);
|
|
2236
|
+
if (match_results) {
|
|
2237
|
+
const type_code = match_results[0];
|
|
2238
|
+
type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
|
|
2239
|
+
esolve_id = id.replace(type_code_regex, '');
|
|
2240
|
+
return {
|
|
2241
|
+
type,
|
|
2242
|
+
esolve_id
|
|
2243
|
+
};
|
|
2244
|
+
}
|
|
2245
|
+
return null;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
EsolveCategoryTreeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2249
|
+
EsolveCategoryTreeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, providedIn: 'root' });
|
|
2250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, decorators: [{
|
|
2251
|
+
type: Injectable,
|
|
2252
|
+
args: [{
|
|
2253
|
+
providedIn: 'root',
|
|
2254
|
+
}]
|
|
2255
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2256
|
+
type: Inject,
|
|
2257
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
2258
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
2333
2259
|
|
|
2334
|
-
class
|
|
2335
|
-
constructor(
|
|
2336
|
-
|
|
2337
|
-
this.
|
|
2338
|
-
this.
|
|
2260
|
+
class EsolveManufacturer {
|
|
2261
|
+
constructor(id, manufacturer, sef_manufacturer, title, article, sort_priority, is_active, featured, image_name, seo_title = '', seo_keywords = '', seo_description = '') {
|
|
2262
|
+
this.id = id;
|
|
2263
|
+
this.manufacturer = manufacturer;
|
|
2264
|
+
this.sef_manufacturer = sef_manufacturer;
|
|
2265
|
+
this.title = title;
|
|
2266
|
+
this.article = article;
|
|
2267
|
+
this.sort_priority = sort_priority;
|
|
2268
|
+
this.is_active = is_active;
|
|
2269
|
+
this.featured = featured;
|
|
2270
|
+
this.image_name = image_name;
|
|
2271
|
+
this.image_path = '/images/manufacturers/';
|
|
2272
|
+
if (this.title.trim() === '') {
|
|
2273
|
+
this.title = this.manufacturer;
|
|
2274
|
+
}
|
|
2275
|
+
if (seo_title.trim() === '') {
|
|
2276
|
+
seo_title = this.title;
|
|
2277
|
+
}
|
|
2278
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2279
|
+
}
|
|
2280
|
+
get original_image_src() {
|
|
2281
|
+
return this.getImagePath('original');
|
|
2282
|
+
}
|
|
2283
|
+
get small_image_src() {
|
|
2284
|
+
return this.getImagePath('small');
|
|
2285
|
+
}
|
|
2286
|
+
get thumbnail_image_src() {
|
|
2287
|
+
return this.getImagePath('thumb');
|
|
2288
|
+
}
|
|
2289
|
+
get tiny_image_src() {
|
|
2290
|
+
return this.getImagePath('tiny');
|
|
2291
|
+
}
|
|
2292
|
+
getImagePath(image_size) {
|
|
2293
|
+
if (this.image_name !== '') {
|
|
2294
|
+
return `${this.image_path}${image_size}/${this.image_name}`;
|
|
2295
|
+
}
|
|
2296
|
+
return '';
|
|
2339
2297
|
}
|
|
2340
2298
|
}
|
|
2341
2299
|
|
|
2342
|
-
class
|
|
2300
|
+
class EsolveManufacturersService {
|
|
2343
2301
|
constructor(config, http) {
|
|
2344
2302
|
this.config = config;
|
|
2345
2303
|
this.http = http;
|
|
2346
2304
|
}
|
|
2347
|
-
|
|
2348
|
-
* Retrieves the stock record from the eSolve instance using the code.
|
|
2349
|
-
*
|
|
2350
|
-
* @param code eSolve stock code
|
|
2351
|
-
*/
|
|
2352
|
-
getStockItem(code) {
|
|
2305
|
+
getManufacturer(id) {
|
|
2353
2306
|
const params = new HttpParams({
|
|
2354
|
-
fromObject: {
|
|
2355
|
-
code
|
|
2356
|
-
}
|
|
2307
|
+
fromObject: { manufacturers_id: id }
|
|
2357
2308
|
});
|
|
2358
|
-
return this.
|
|
2359
|
-
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2360
|
-
throw response;
|
|
2361
|
-
}
|
|
2362
|
-
const stockRecord = response.records[0];
|
|
2363
|
-
return this.processStockItem(stockRecord);
|
|
2364
|
-
}));
|
|
2309
|
+
return this.getManufacturerSingle(params);
|
|
2365
2310
|
}
|
|
2366
|
-
|
|
2367
|
-
* Retrieves the stock record from the eSolve instance using the SEF name.
|
|
2368
|
-
*
|
|
2369
|
-
* @param sef_name SEF name of the stock item
|
|
2370
|
-
*/
|
|
2371
|
-
getStockItemFromSEF(sef_name) {
|
|
2311
|
+
getManufacturerFromSEF(sef_manufacturer) {
|
|
2372
2312
|
const params = new HttpParams({
|
|
2373
|
-
fromObject: {
|
|
2374
|
-
sef_name
|
|
2375
|
-
}
|
|
2313
|
+
fromObject: { sef_manufacturer }
|
|
2376
2314
|
});
|
|
2377
|
-
return this.
|
|
2378
|
-
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2379
|
-
throw response;
|
|
2380
|
-
}
|
|
2381
|
-
const stockRecord = response.records[0];
|
|
2382
|
-
return this.processStockItem(stockRecord);
|
|
2383
|
-
}));
|
|
2315
|
+
return this.getManufacturerSingle(params);
|
|
2384
2316
|
}
|
|
2385
|
-
|
|
2386
|
-
* Retrieves list of stock from the eSolve instance using info provided
|
|
2387
|
-
*
|
|
2388
|
-
* @param options Stock filter options
|
|
2389
|
-
*/
|
|
2390
|
-
getStockItems(options) {
|
|
2317
|
+
getManufacturers(options) {
|
|
2391
2318
|
let params = new HttpParams();
|
|
2392
|
-
if (options
|
|
2393
|
-
params = params.set('
|
|
2394
|
-
}
|
|
2395
|
-
if (options.rows) {
|
|
2396
|
-
params = params.set('rows', options.rows);
|
|
2397
|
-
}
|
|
2398
|
-
if (options.search_phrase) {
|
|
2399
|
-
params = params.set('search_phrase', options.search_phrase);
|
|
2400
|
-
}
|
|
2401
|
-
if (options.display_only) {
|
|
2402
|
-
params = params.set('display_only', options.display_only);
|
|
2403
|
-
}
|
|
2404
|
-
if (options.is_active) {
|
|
2405
|
-
params = params.set('is_active', options.is_active);
|
|
2406
|
-
}
|
|
2407
|
-
if (options.category_id) {
|
|
2408
|
-
params = params.set('category_id', options.category_id);
|
|
2409
|
-
}
|
|
2410
|
-
if (options.subcategory_id) {
|
|
2411
|
-
params = params.set('subcategory_id', options.subcategory_id);
|
|
2412
|
-
}
|
|
2413
|
-
if (options.manufacturers_id) {
|
|
2414
|
-
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
2415
|
-
}
|
|
2416
|
-
if (options.ranges_id) {
|
|
2417
|
-
params = params.set('ranges_id', options.ranges_id);
|
|
2418
|
-
}
|
|
2419
|
-
if (options.specials_id) {
|
|
2420
|
-
params = params.set('specials_id', options.specials_id);
|
|
2421
|
-
}
|
|
2422
|
-
if (options.tag_id_list) {
|
|
2423
|
-
if (options.tag_id_list.length > 0) {
|
|
2424
|
-
params = params.set('tag_id', options.tag_id_list.join(','));
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2427
|
-
if (options.topic_id_list) {
|
|
2428
|
-
if (options.topic_id_list.length > 0) {
|
|
2429
|
-
params = params.set('topic_id', options.topic_id_list.join(','));
|
|
2430
|
-
}
|
|
2319
|
+
if (options?.featured_only) {
|
|
2320
|
+
params = params.set('featured_only', options.featured_only);
|
|
2431
2321
|
}
|
|
2432
|
-
return this.
|
|
2433
|
-
|
|
2434
|
-
|
|
2322
|
+
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
2323
|
+
const manufacturers = [];
|
|
2324
|
+
for (const record of records) {
|
|
2325
|
+
manufacturers.push(this.processManufacturer(record));
|
|
2435
2326
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
});
|
|
2440
|
-
return new EsolveStockItemList(stockItems, +response.additional_data.total_records, options.page ?? 0);
|
|
2327
|
+
return manufacturers;
|
|
2328
|
+
}), catchError(() => {
|
|
2329
|
+
return of([]);
|
|
2441
2330
|
}));
|
|
2442
2331
|
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
*/
|
|
2448
|
-
getLinkedItems(code) {
|
|
2449
|
-
return this.http
|
|
2450
|
-
.get(`${this.config.api_url}/get-linked-items.php`, { params: { code } })
|
|
2451
|
-
.pipe(map((response) => {
|
|
2452
|
-
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2453
|
-
throw response;
|
|
2454
|
-
}
|
|
2455
|
-
return this.processLinkedItems(response.records);
|
|
2332
|
+
getManufacturerSingle(params) {
|
|
2333
|
+
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
2334
|
+
const record = records[0];
|
|
2335
|
+
return this.processManufacturer(record);
|
|
2456
2336
|
}));
|
|
2457
2337
|
}
|
|
2458
|
-
|
|
2459
|
-
* Retrieve list of stock items on a recipe from the eSolve API
|
|
2460
|
-
*
|
|
2461
|
-
* @param code Stock item code
|
|
2462
|
-
*/
|
|
2463
|
-
getRecipeItems(code) {
|
|
2338
|
+
getManufacturerRecords(params) {
|
|
2464
2339
|
return this.http
|
|
2465
|
-
.get(`${this.config.api_url}/get-
|
|
2340
|
+
.get(`${this.config.api_url}/get-manufacturers.php`, { params })
|
|
2466
2341
|
.pipe(map((response) => {
|
|
2467
|
-
if ((response.records === undefined) ||
|
|
2342
|
+
if ((response.records === undefined) ||
|
|
2343
|
+
(response.records.length <= 0)) {
|
|
2468
2344
|
throw response;
|
|
2469
2345
|
}
|
|
2470
|
-
return
|
|
2346
|
+
return response.records;
|
|
2471
2347
|
}));
|
|
2472
2348
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
*
|
|
2476
|
-
* @param record eSolve stock item record
|
|
2477
|
-
*/
|
|
2478
|
-
processStockItem(record) {
|
|
2479
|
-
return new EsolveStockItem(record);
|
|
2480
|
-
}
|
|
2481
|
-
/**
|
|
2482
|
-
* Processes the linked eSolve stock item records and converts them to objects.
|
|
2483
|
-
*
|
|
2484
|
-
* @param records Linked eSolve stock item records
|
|
2485
|
-
*/
|
|
2486
|
-
processLinkedItems(records) {
|
|
2487
|
-
const items = [];
|
|
2488
|
-
if (records.length > 0) {
|
|
2489
|
-
for (const record of records) {
|
|
2490
|
-
items.push(new EsolveLinkedStockItem(record));
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
return items;
|
|
2494
|
-
}
|
|
2495
|
-
/**
|
|
2496
|
-
* Processes the recipe eSolve stock item records and converts them to objects.
|
|
2497
|
-
*
|
|
2498
|
-
* @param records Recipe eSolve stock item records
|
|
2499
|
-
*/
|
|
2500
|
-
processRecipeItems(records) {
|
|
2501
|
-
const items = [];
|
|
2502
|
-
if (records.length > 0) {
|
|
2503
|
-
for (const record of records) {
|
|
2504
|
-
items.push(new EsolveRecipeStockItem(record));
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
return items;
|
|
2508
|
-
}
|
|
2509
|
-
/**
|
|
2510
|
-
* Retrieves stock records from HTTP params.
|
|
2511
|
-
* @param params HTTP client parameters
|
|
2512
|
-
*/
|
|
2513
|
-
getStockRecords(params) {
|
|
2514
|
-
return this.http.get(`${this.config.api_url}/get-items.php`, { params });
|
|
2349
|
+
processManufacturer(record) {
|
|
2350
|
+
return new EsolveManufacturer(+record.id, record.manufacturer, record.sef_manufacturer, record.title, record.article, +record.sort_priority, !!+record.is_active, !!+record.featured, record.image_name, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2515
2351
|
}
|
|
2516
2352
|
}
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2353
|
+
EsolveManufacturersService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2354
|
+
EsolveManufacturersService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, providedIn: 'root' });
|
|
2355
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, decorators: [{
|
|
2520
2356
|
type: Injectable,
|
|
2521
2357
|
args: [{
|
|
2522
2358
|
providedIn: 'root',
|
|
@@ -2526,369 +2362,594 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2526
2362
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2527
2363
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2528
2364
|
|
|
2529
|
-
class
|
|
2530
|
-
constructor(
|
|
2531
|
-
this.
|
|
2532
|
-
this.
|
|
2533
|
-
this.
|
|
2534
|
-
this.
|
|
2535
|
-
this.
|
|
2536
|
-
this.
|
|
2365
|
+
class EsolveRange {
|
|
2366
|
+
constructor(id, range, sef_range, manufacturers_id, title, article, is_active, featured, sort_priority, image_name, seo_title = '', seo_keywords = '', seo_description = '') {
|
|
2367
|
+
this.id = id;
|
|
2368
|
+
this.range = range;
|
|
2369
|
+
this.sef_range = sef_range;
|
|
2370
|
+
this.manufacturers_id = manufacturers_id;
|
|
2371
|
+
this.title = title;
|
|
2372
|
+
this.article = article;
|
|
2373
|
+
this.is_active = is_active;
|
|
2374
|
+
this.featured = featured;
|
|
2537
2375
|
this.sort_priority = sort_priority;
|
|
2538
|
-
this.active = active;
|
|
2539
|
-
this.display_only = display_only;
|
|
2540
2376
|
this.image_name = image_name;
|
|
2541
|
-
this.
|
|
2542
|
-
this.
|
|
2543
|
-
|
|
2544
|
-
this.id = `<<CAT>>${this.esolve_id}`;
|
|
2545
|
-
if (children != null) {
|
|
2546
|
-
this.children = children;
|
|
2547
|
-
}
|
|
2548
|
-
this.image_path = '/images/categories/';
|
|
2549
|
-
}
|
|
2550
|
-
else {
|
|
2551
|
-
this.id = `<<SUB>>${this.esolve_id}`;
|
|
2552
|
-
this.image_path = '/images/subcategories/';
|
|
2377
|
+
this.image_path = '/images/ranges/';
|
|
2378
|
+
if (this.title.trim() === '') {
|
|
2379
|
+
this.title = this.range;
|
|
2553
2380
|
}
|
|
2554
2381
|
if (seo_title.trim() === '') {
|
|
2555
|
-
seo_title = this.
|
|
2382
|
+
seo_title = this.title;
|
|
2556
2383
|
}
|
|
2557
2384
|
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2558
2385
|
}
|
|
2559
|
-
get
|
|
2560
|
-
return this.
|
|
2561
|
-
}
|
|
2562
|
-
get thumbnail_image_src() {
|
|
2563
|
-
return this.generateImagePath('thumb');
|
|
2564
|
-
}
|
|
2565
|
-
get tiny_image_src() {
|
|
2566
|
-
return this.generateImagePath('tiny');
|
|
2386
|
+
get image_src() {
|
|
2387
|
+
return this.getImagePath();
|
|
2567
2388
|
}
|
|
2568
|
-
|
|
2389
|
+
getImagePath() {
|
|
2569
2390
|
if (this.image_name !== '') {
|
|
2570
|
-
return `${this.image_path}${
|
|
2391
|
+
return `${this.image_path}${this.image_name}`;
|
|
2571
2392
|
}
|
|
2572
2393
|
return '';
|
|
2573
2394
|
}
|
|
2574
2395
|
}
|
|
2575
2396
|
|
|
2576
|
-
class
|
|
2397
|
+
class EsolveRangesService {
|
|
2577
2398
|
constructor(config, http) {
|
|
2578
2399
|
this.config = config;
|
|
2579
2400
|
this.http = http;
|
|
2580
2401
|
}
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2402
|
+
getRange(id) {
|
|
2403
|
+
const params = new HttpParams({
|
|
2404
|
+
fromObject: { ranges_id: id }
|
|
2405
|
+
});
|
|
2406
|
+
return this.getRangeSingle(params);
|
|
2407
|
+
}
|
|
2408
|
+
getRangeFromSEF(sef_range) {
|
|
2409
|
+
const params = new HttpParams({
|
|
2410
|
+
fromObject: { sef_range }
|
|
2411
|
+
});
|
|
2412
|
+
return this.getRangeSingle(params);
|
|
2413
|
+
}
|
|
2414
|
+
getRanges(options) {
|
|
2415
|
+
let params = new HttpParams();
|
|
2416
|
+
if (options?.featured_only) {
|
|
2417
|
+
params = params.set('featured_only', options.featured_only);
|
|
2418
|
+
}
|
|
2419
|
+
if (options?.manufacturers_id) {
|
|
2420
|
+
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
2421
|
+
}
|
|
2422
|
+
return this.getRangeRecords(params).pipe(map((records) => {
|
|
2423
|
+
const ranges = [];
|
|
2424
|
+
for (const record of records) {
|
|
2425
|
+
ranges.push(this.processRange(record));
|
|
2426
|
+
}
|
|
2427
|
+
return ranges;
|
|
2428
|
+
}), catchError(() => {
|
|
2429
|
+
return of([]);
|
|
2430
|
+
}));
|
|
2431
|
+
}
|
|
2432
|
+
getRangeSingle(params) {
|
|
2433
|
+
return this.getRangeRecords(params).pipe(map((records) => {
|
|
2434
|
+
const record = records[0];
|
|
2435
|
+
return this.processRange(record);
|
|
2436
|
+
}));
|
|
2437
|
+
}
|
|
2438
|
+
getRangeRecords(params) {
|
|
2585
2439
|
return this.http
|
|
2586
|
-
.get(`${this.config.api_url}/get-
|
|
2440
|
+
.get(`${this.config.api_url}/get-ranges.php`, { params })
|
|
2587
2441
|
.pipe(map((response) => {
|
|
2588
|
-
if (response.records === undefined)
|
|
2442
|
+
if ((response.records === undefined) ||
|
|
2443
|
+
(response.records.length <= 0)) {
|
|
2589
2444
|
throw response;
|
|
2590
2445
|
}
|
|
2591
|
-
return
|
|
2592
|
-
}));
|
|
2593
|
-
}
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2446
|
+
return response.records;
|
|
2447
|
+
}));
|
|
2448
|
+
}
|
|
2449
|
+
processRange(record) {
|
|
2450
|
+
return new EsolveRange(+record.id, record.range, record.sef_range, record.manufacturers_id, record.title, record.article, !!+record.is_active, !!+record.featured, +record.sort_priority, record.image_name, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
EsolveRangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2454
|
+
EsolveRangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, providedIn: 'root' });
|
|
2455
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, decorators: [{
|
|
2456
|
+
type: Injectable,
|
|
2457
|
+
args: [{
|
|
2458
|
+
providedIn: 'root',
|
|
2459
|
+
}]
|
|
2460
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2461
|
+
type: Inject,
|
|
2462
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
2463
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
2464
|
+
|
|
2465
|
+
class EsolveStockBadge {
|
|
2466
|
+
constructor(id, text, identifier, font_colour, badge_colour, sort_priority) {
|
|
2467
|
+
this.id = id;
|
|
2468
|
+
this.text = text;
|
|
2469
|
+
this.identifier = identifier;
|
|
2470
|
+
this.font_colour = font_colour;
|
|
2471
|
+
this.badge_colour = badge_colour;
|
|
2472
|
+
this.sort_priority = sort_priority;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* Price of eSolve stock item
|
|
2478
|
+
*/
|
|
2479
|
+
class EsolveStockPrice {
|
|
2480
|
+
/**
|
|
2481
|
+
* Create stock price instance
|
|
2482
|
+
* @param base_price Price without tax
|
|
2483
|
+
* @param base_price_with_tax Price with tax
|
|
2484
|
+
* @param sell_price Price without tax and with discounts applied if applicable
|
|
2485
|
+
* @param sell_price_with_tax Price with tax and with discounts applied if applicable
|
|
2486
|
+
*/
|
|
2487
|
+
constructor(
|
|
2488
|
+
/**
|
|
2489
|
+
* Price without tax
|
|
2490
|
+
*/
|
|
2491
|
+
base_price = 0,
|
|
2492
|
+
/**
|
|
2493
|
+
* Price with tax
|
|
2494
|
+
*/
|
|
2495
|
+
base_price_with_tax = 0,
|
|
2496
|
+
/**
|
|
2497
|
+
* Price without tax and with discounts applied if applicable
|
|
2498
|
+
*/
|
|
2499
|
+
sell_price = 0,
|
|
2500
|
+
/**
|
|
2501
|
+
* Price with tax and with discounts applied if applicable
|
|
2502
|
+
*/
|
|
2503
|
+
sell_price_with_tax = 0) {
|
|
2504
|
+
this.base_price = base_price;
|
|
2505
|
+
this.base_price_with_tax = base_price_with_tax;
|
|
2506
|
+
this.sell_price = sell_price;
|
|
2507
|
+
this.sell_price_with_tax = sell_price_with_tax;
|
|
2508
|
+
if ((this.base_price === 0) && (this.sell_price > 0)) {
|
|
2509
|
+
this.base_price = this.sell_price;
|
|
2510
|
+
this.base_price_with_tax = this.sell_price_with_tax;
|
|
2511
|
+
}
|
|
2512
|
+
else if ((this.base_price > 0) && (this.sell_price === 0)) {
|
|
2513
|
+
this.sell_price = this.base_price;
|
|
2514
|
+
this.sell_price_with_tax = this.base_price_with_tax;
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
class EsolveStockLeadTimes {
|
|
2520
|
+
constructor(lead_times) {
|
|
2521
|
+
this.min = 0;
|
|
2522
|
+
this.max = 0;
|
|
2523
|
+
this.min = lead_times.min;
|
|
2524
|
+
this.max = lead_times.max;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
class EsolveStockItemBase {
|
|
2529
|
+
constructor(record = {}) {
|
|
2530
|
+
/**
|
|
2531
|
+
* eSolve Generated ID
|
|
2532
|
+
*/
|
|
2533
|
+
this.id = 0;
|
|
2534
|
+
/**
|
|
2535
|
+
* Code identifying the stock item
|
|
2536
|
+
*/
|
|
2537
|
+
this.code = '';
|
|
2538
|
+
/**
|
|
2539
|
+
* Name of the stock item
|
|
2540
|
+
*/
|
|
2541
|
+
this.name = '';
|
|
2542
|
+
/**
|
|
2543
|
+
* Search engine friendly name
|
|
2544
|
+
*/
|
|
2545
|
+
this.sef_name = '';
|
|
2546
|
+
/**
|
|
2547
|
+
* Short description of stock item
|
|
2548
|
+
*/
|
|
2549
|
+
this.description = '';
|
|
2550
|
+
/**
|
|
2551
|
+
* Full description of stock item
|
|
2552
|
+
*/
|
|
2553
|
+
this.extended_description = '';
|
|
2554
|
+
/**
|
|
2555
|
+
* Active state
|
|
2556
|
+
*/
|
|
2557
|
+
this.active = false;
|
|
2558
|
+
/**
|
|
2559
|
+
* Featured state
|
|
2560
|
+
*/
|
|
2561
|
+
this.featured = false;
|
|
2562
|
+
/**
|
|
2563
|
+
* ID of default category linked to the stock item
|
|
2564
|
+
*
|
|
2565
|
+
* @deprecated Use `category.esolve_id` field instead
|
|
2566
|
+
*/
|
|
2567
|
+
this.category_id = '';
|
|
2568
|
+
/**
|
|
2569
|
+
* ID of default subcategory linked to the stock item
|
|
2570
|
+
*
|
|
2571
|
+
* @deprecated Use `subcategory.esolve_id` field instead
|
|
2572
|
+
*/
|
|
2573
|
+
this.subcategory_id = 0;
|
|
2574
|
+
/**
|
|
2575
|
+
* ID of linked manufacturer
|
|
2576
|
+
*
|
|
2577
|
+
* @deprecated Use `manufacturer.id` field instead
|
|
2578
|
+
*/
|
|
2579
|
+
this.manufacturers_id = 0;
|
|
2580
|
+
/**
|
|
2581
|
+
* ID of linked range
|
|
2582
|
+
*
|
|
2583
|
+
* @deprecated Use `range.id` field instead
|
|
2584
|
+
*/
|
|
2585
|
+
this.ranges_id = 0;
|
|
2586
|
+
/**
|
|
2587
|
+
* Linked tags
|
|
2588
|
+
*/
|
|
2589
|
+
this.tags = [];
|
|
2590
|
+
/**
|
|
2591
|
+
* Linked topics
|
|
2592
|
+
*/
|
|
2593
|
+
this.topics = [];
|
|
2594
|
+
/**
|
|
2595
|
+
* Stock badges
|
|
2596
|
+
*/
|
|
2597
|
+
this.badges = [];
|
|
2598
|
+
/**
|
|
2599
|
+
* Colours
|
|
2600
|
+
*/
|
|
2601
|
+
this.colours = [];
|
|
2602
|
+
/**
|
|
2603
|
+
* Image filename
|
|
2604
|
+
*/
|
|
2605
|
+
this.image_name = '';
|
|
2606
|
+
let seo_title = '';
|
|
2607
|
+
let seo_keywords = '';
|
|
2608
|
+
let base_price = 0;
|
|
2609
|
+
let base_price_with_tax = 0;
|
|
2610
|
+
let sell_price = 0;
|
|
2611
|
+
let sell_price_with_tax = 0;
|
|
2612
|
+
if (record) {
|
|
2613
|
+
this.id = +(record.id ?? 0);
|
|
2614
|
+
this.code = record.code ?? '';
|
|
2615
|
+
this.name = record.name ?? '';
|
|
2616
|
+
this.sef_name = record.sef_name ?? '';
|
|
2617
|
+
this.description = record.description ?? '';
|
|
2618
|
+
this.extended_description = record.extended_description ?? '';
|
|
2619
|
+
this.image_name = record.image_name ?? '';
|
|
2620
|
+
this.category_id = record.category_id ?? '';
|
|
2621
|
+
this.subcategory_id = +(record.subcategory_id ?? 0);
|
|
2622
|
+
this.manufacturers_id = +(record.manufacturers_id ?? 0);
|
|
2623
|
+
this.ranges_id = +(record.ranges_id ?? 0);
|
|
2624
|
+
this.active = !!+(record.is_active ?? false);
|
|
2625
|
+
this.featured = !!+(record.is_featured ?? false);
|
|
2626
|
+
base_price = +(record.regular_sellprice ?? 0);
|
|
2627
|
+
base_price_with_tax = +(record.regular_sellprice_inclusive ?? 0);
|
|
2628
|
+
sell_price = +(record.sellprice ?? 0);
|
|
2629
|
+
sell_price_with_tax = +(record.sellprice_inclusive ?? 0);
|
|
2630
|
+
if ((record.tags) && (record.tags.length > 0)) {
|
|
2631
|
+
for (const tag of record.tags) {
|
|
2632
|
+
this.tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
if ((record.topics) && (record.topics.length > 0)) {
|
|
2636
|
+
for (const topic of record.topics) {
|
|
2637
|
+
this.topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
|
|
2638
|
+
}
|
|
2609
2639
|
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
esolve_id = options.esolve_id;
|
|
2640
|
+
if ((record.badges) && (record.badges.length > 0)) {
|
|
2641
|
+
for (const badge of record.badges) {
|
|
2642
|
+
this.badges.push(new EsolveStockBadge(+badge.id, badge.text, badge.identifier, badge.font_colour, badge.badge_colour, +badge.sort_priority));
|
|
2643
|
+
}
|
|
2615
2644
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2645
|
+
if (record.category) {
|
|
2646
|
+
this.category = new EsolveCategoryTreeItem(record.category.type, record.category.id, record.category.parent_id, record.category.description, record.category.sef_description, record.category.short_description, record.category.sort_priority, record.category.active, record.category.display_only, record.category.image, record.category.seo_page_title, record.category.seo_keywords, record.category.seo_description);
|
|
2618
2647
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
let params = new HttpParams();
|
|
2622
|
-
params = params.set('type', type);
|
|
2623
|
-
if (esolve_id) {
|
|
2624
|
-
params = params.set('id', esolve_id);
|
|
2648
|
+
if (record.subcategory) {
|
|
2649
|
+
this.subcategory = new EsolveCategoryTreeItem(record.subcategory.type, record.subcategory.id, record.subcategory.parent_id, record.subcategory.description, record.subcategory.sef_description, record.subcategory.short_description, record.subcategory.sort_priority, record.subcategory.active, record.subcategory.display_only, record.subcategory.image, record.subcategory.seo_page_title, record.subcategory.seo_keywords, record.subcategory.seo_description);
|
|
2625
2650
|
}
|
|
2626
|
-
if (
|
|
2627
|
-
|
|
2651
|
+
if (record.manufacturer) {
|
|
2652
|
+
this.manufacturer = new EsolveManufacturer(record.manufacturer.id, record.manufacturer.manufacturer, record.manufacturer.sef_manufacturer, record.manufacturer.title, record.manufacturer.article, record.manufacturer.sort_priority, record.manufacturer.is_active, record.manufacturer.featured, record.manufacturer.image_name, record.manufacturer.seo_page_title, record.manufacturer.seo_keywords, record.manufacturer.seo_description);
|
|
2628
2653
|
}
|
|
2629
|
-
|
|
2630
|
-
.
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2654
|
+
if (record.range) {
|
|
2655
|
+
this.range = new EsolveRange(record.range.id, record.range.range, record.range.sef_range, record.range.manufacturers_id, record.range.title, record.range.article, record.range.is_active, record.range.featured, record.range.sort_priority, record.range.image_name, record.range.seo_page_title, record.range.seo_keywords, record.range.seo_description);
|
|
2656
|
+
}
|
|
2657
|
+
if (record.colours && record.colours.length > 0) {
|
|
2658
|
+
for (const colour of record.colours) {
|
|
2659
|
+
this.colours.push(new EsolveColour(colour));
|
|
2635
2660
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2661
|
+
}
|
|
2662
|
+
if (record.lead_times) {
|
|
2663
|
+
this.lead_times = new EsolveStockLeadTimes(record.lead_times);
|
|
2664
|
+
}
|
|
2665
|
+
if (record.custom_fields) {
|
|
2666
|
+
this.custom_fields = record.custom_fields;
|
|
2667
|
+
}
|
|
2668
|
+
seo_title = record.seo_page_title ?? '';
|
|
2669
|
+
seo_keywords = record.seo_keywords ?? '';
|
|
2638
2670
|
}
|
|
2639
|
-
|
|
2671
|
+
this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax);
|
|
2672
|
+
if (seo_title.trim() === '') {
|
|
2673
|
+
seo_title = this.name;
|
|
2674
|
+
}
|
|
2675
|
+
this.seo_details = new EsolveSeoInfo(seo_title, this.description, seo_keywords);
|
|
2640
2676
|
}
|
|
2641
2677
|
/**
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
2644
|
-
* @param tree_records Records to process
|
|
2678
|
+
* Path to tiny stock image
|
|
2645
2679
|
*/
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
if (tree_records) {
|
|
2649
|
-
for (const tree_record of tree_records) {
|
|
2650
|
-
let esolve_id = '';
|
|
2651
|
-
let parent_id = '';
|
|
2652
|
-
let children = [];
|
|
2653
|
-
if (tree_record.type === 'category') {
|
|
2654
|
-
children = this.processTree(tree_record.children);
|
|
2655
|
-
esolve_id = tree_record.menu_id;
|
|
2656
|
-
parent_id = tree_record.owner_menu_id;
|
|
2657
|
-
}
|
|
2658
|
-
else {
|
|
2659
|
-
esolve_id = tree_record.id;
|
|
2660
|
-
parent_id = tree_record.menu_id;
|
|
2661
|
-
}
|
|
2662
|
-
tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children));
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
return tree_items;
|
|
2666
|
-
}
|
|
2667
|
-
processTreeItem(record) {
|
|
2668
|
-
return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, '', record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2669
|
-
}
|
|
2670
|
-
processID(id) {
|
|
2671
|
-
let type;
|
|
2672
|
-
let esolve_id;
|
|
2673
|
-
const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
|
|
2674
|
-
const match_results = id.match(type_code_regex);
|
|
2675
|
-
if (match_results) {
|
|
2676
|
-
const type_code = match_results[0];
|
|
2677
|
-
type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
|
|
2678
|
-
esolve_id = id.replace(type_code_regex, '');
|
|
2679
|
-
return {
|
|
2680
|
-
type,
|
|
2681
|
-
esolve_id
|
|
2682
|
-
};
|
|
2683
|
-
}
|
|
2684
|
-
return null;
|
|
2680
|
+
get tiny_image_src() {
|
|
2681
|
+
return this.getImagePath('tiny');
|
|
2685
2682
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
args: [{
|
|
2692
|
-
providedIn: 'root',
|
|
2693
|
-
}]
|
|
2694
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2695
|
-
type: Inject,
|
|
2696
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
2697
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
2698
|
-
|
|
2699
|
-
class EsolveManufacturer {
|
|
2700
|
-
constructor(id, manufacturer, sef_manufacturer, title, article, sort_priority, is_active, featured, image_name, seo_title = '', seo_keywords = '', seo_description = '') {
|
|
2701
|
-
this.id = id;
|
|
2702
|
-
this.manufacturer = manufacturer;
|
|
2703
|
-
this.sef_manufacturer = sef_manufacturer;
|
|
2704
|
-
this.title = title;
|
|
2705
|
-
this.article = article;
|
|
2706
|
-
this.sort_priority = sort_priority;
|
|
2707
|
-
this.is_active = is_active;
|
|
2708
|
-
this.featured = featured;
|
|
2709
|
-
this.image_name = image_name;
|
|
2710
|
-
this.image_path = '/images/manufacturers/';
|
|
2711
|
-
if (this.title.trim() === '') {
|
|
2712
|
-
this.title = this.manufacturer;
|
|
2713
|
-
}
|
|
2714
|
-
if (seo_title.trim() === '') {
|
|
2715
|
-
seo_title = this.title;
|
|
2716
|
-
}
|
|
2717
|
-
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2683
|
+
/**
|
|
2684
|
+
* Path to thumbnail stock image
|
|
2685
|
+
*/
|
|
2686
|
+
get thumbnail_image_src() {
|
|
2687
|
+
return this.getImagePath('thumb');
|
|
2718
2688
|
}
|
|
2689
|
+
/**
|
|
2690
|
+
* Path to small stock image
|
|
2691
|
+
*/
|
|
2719
2692
|
get small_image_src() {
|
|
2720
|
-
return this.
|
|
2693
|
+
return this.getImagePath('small');
|
|
2721
2694
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2695
|
+
/**
|
|
2696
|
+
* Path to big stock image
|
|
2697
|
+
*/
|
|
2698
|
+
get big_image_src() {
|
|
2699
|
+
return this.getImagePath('big');
|
|
2724
2700
|
}
|
|
2725
|
-
|
|
2726
|
-
|
|
2701
|
+
/**
|
|
2702
|
+
* Path to original stock image
|
|
2703
|
+
*/
|
|
2704
|
+
get original_image_src() {
|
|
2705
|
+
return this.getImagePath('original');
|
|
2727
2706
|
}
|
|
2728
|
-
|
|
2707
|
+
getImagePath(image_size) {
|
|
2729
2708
|
if (this.image_name !== '') {
|
|
2730
|
-
return
|
|
2709
|
+
return `/images/stock/${image_size}/${this.image_name}`;
|
|
2731
2710
|
}
|
|
2732
2711
|
return '';
|
|
2733
2712
|
}
|
|
2734
2713
|
}
|
|
2735
2714
|
|
|
2736
|
-
class
|
|
2737
|
-
constructor(
|
|
2738
|
-
|
|
2739
|
-
this.http = http;
|
|
2740
|
-
}
|
|
2741
|
-
getManufacturer(id) {
|
|
2742
|
-
const params = new HttpParams({
|
|
2743
|
-
fromObject: { manufacturers_id: id }
|
|
2744
|
-
});
|
|
2745
|
-
return this.getManufacturerSingle(params);
|
|
2746
|
-
}
|
|
2747
|
-
getManufacturerFromSEF(sef_manufacturer) {
|
|
2748
|
-
const params = new HttpParams({
|
|
2749
|
-
fromObject: { sef_manufacturer }
|
|
2750
|
-
});
|
|
2751
|
-
return this.getManufacturerSingle(params);
|
|
2715
|
+
class EsolveStockGroupItem extends EsolveStockItemBase {
|
|
2716
|
+
constructor(record) {
|
|
2717
|
+
super(record);
|
|
2752
2718
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
class EsolveStockGroup {
|
|
2722
|
+
constructor(group, records = []) {
|
|
2723
|
+
this.group = group;
|
|
2724
|
+
this.items = [];
|
|
2725
|
+
if (records.length > 0) {
|
|
2760
2726
|
for (const record of records) {
|
|
2761
|
-
|
|
2762
|
-
}
|
|
2763
|
-
return manufacturers;
|
|
2764
|
-
}), catchError(() => {
|
|
2765
|
-
return of([]);
|
|
2766
|
-
}));
|
|
2767
|
-
}
|
|
2768
|
-
getManufacturerSingle(params) {
|
|
2769
|
-
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
2770
|
-
const record = records[0];
|
|
2771
|
-
return this.processManufacturer(record);
|
|
2772
|
-
}));
|
|
2773
|
-
}
|
|
2774
|
-
getManufacturerRecords(params) {
|
|
2775
|
-
return this.http
|
|
2776
|
-
.get(`${this.config.api_url}/get-manufacturers.php`, { params })
|
|
2777
|
-
.pipe(map((response) => {
|
|
2778
|
-
if ((response.records === undefined) ||
|
|
2779
|
-
(response.records.length <= 0)) {
|
|
2780
|
-
throw response;
|
|
2727
|
+
this.items.push(new EsolveStockGroupItem(record));
|
|
2781
2728
|
}
|
|
2782
|
-
|
|
2783
|
-
}));
|
|
2784
|
-
}
|
|
2785
|
-
processManufacturer(record) {
|
|
2786
|
-
return new EsolveManufacturer(+record.id, record.manufacturer, record.sef_manufacturer, record.title, record.article, +record.sort_priority, !!+record.is_active, !!+record.featured, record.image_name, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2729
|
+
}
|
|
2787
2730
|
}
|
|
2788
|
-
}
|
|
2789
|
-
EsolveManufacturersService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2790
|
-
EsolveManufacturersService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, providedIn: 'root' });
|
|
2791
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, decorators: [{
|
|
2792
|
-
type: Injectable,
|
|
2793
|
-
args: [{
|
|
2794
|
-
providedIn: 'root',
|
|
2795
|
-
}]
|
|
2796
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2797
|
-
type: Inject,
|
|
2798
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
2799
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
2731
|
+
}
|
|
2800
2732
|
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
this.image_name = image_name;
|
|
2813
|
-
this.image_path = '/images/ranges/';
|
|
2814
|
-
if (this.title.trim() === '') {
|
|
2815
|
-
this.title = this.range;
|
|
2816
|
-
}
|
|
2817
|
-
if (seo_title.trim() === '') {
|
|
2818
|
-
seo_title = this.title;
|
|
2733
|
+
/**
|
|
2734
|
+
* Stock Item object. It can be a service or a product (physical and/or digital).
|
|
2735
|
+
*/
|
|
2736
|
+
class EsolveStockItem extends EsolveStockItemBase {
|
|
2737
|
+
/**
|
|
2738
|
+
* Constructs an instance of EsolveStockItem
|
|
2739
|
+
*/
|
|
2740
|
+
constructor(record) {
|
|
2741
|
+
super(record);
|
|
2742
|
+
if (record?.group && record.grouped_items) {
|
|
2743
|
+
this.group = new EsolveStockGroup(record.group, record.grouped_items);
|
|
2819
2744
|
}
|
|
2820
|
-
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2821
2745
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
/**
|
|
2749
|
+
* Stock item object list
|
|
2750
|
+
*/
|
|
2751
|
+
class EsolveStockItemList {
|
|
2752
|
+
constructor(stock_items, total, page) {
|
|
2753
|
+
this.stock_items = stock_items;
|
|
2754
|
+
this.total = total;
|
|
2755
|
+
this.page = page;
|
|
2824
2756
|
}
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
class EsolveRecipeStockItem extends EsolveStockItemBase {
|
|
2760
|
+
constructor(record) {
|
|
2761
|
+
super(record);
|
|
2762
|
+
this.qty = 0;
|
|
2763
|
+
this.qty = +(record?.qty ?? 0);
|
|
2830
2764
|
}
|
|
2831
2765
|
}
|
|
2832
2766
|
|
|
2833
|
-
class
|
|
2767
|
+
class EsolveLinkedStockItem extends EsolveStockItemBase {
|
|
2768
|
+
constructor(record) {
|
|
2769
|
+
super(record);
|
|
2770
|
+
this.qty = 0;
|
|
2771
|
+
this.qty = +(record?.qty ?? 0);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
class EsolveStockService {
|
|
2834
2776
|
constructor(config, http) {
|
|
2835
2777
|
this.config = config;
|
|
2836
2778
|
this.http = http;
|
|
2837
2779
|
}
|
|
2838
|
-
|
|
2780
|
+
/**
|
|
2781
|
+
* Retrieves the stock record from the eSolve instance using the code.
|
|
2782
|
+
*
|
|
2783
|
+
* @param code eSolve stock code
|
|
2784
|
+
*/
|
|
2785
|
+
getStockItem(code) {
|
|
2839
2786
|
const params = new HttpParams({
|
|
2840
|
-
fromObject: {
|
|
2787
|
+
fromObject: {
|
|
2788
|
+
code
|
|
2789
|
+
}
|
|
2841
2790
|
});
|
|
2842
|
-
return this.
|
|
2791
|
+
return this.getStockRecords(params).pipe(map(response => {
|
|
2792
|
+
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2793
|
+
throw response;
|
|
2794
|
+
}
|
|
2795
|
+
const stockRecord = response.records[0];
|
|
2796
|
+
return this.processStockItem(stockRecord);
|
|
2797
|
+
}));
|
|
2843
2798
|
}
|
|
2844
|
-
|
|
2799
|
+
/**
|
|
2800
|
+
* Retrieves the stock record from the eSolve instance using the SEF name.
|
|
2801
|
+
*
|
|
2802
|
+
* @param sef_name SEF name of the stock item
|
|
2803
|
+
*/
|
|
2804
|
+
getStockItemFromSEF(sef_name) {
|
|
2845
2805
|
const params = new HttpParams({
|
|
2846
|
-
fromObject: {
|
|
2806
|
+
fromObject: {
|
|
2807
|
+
sef_name
|
|
2808
|
+
}
|
|
2847
2809
|
});
|
|
2848
|
-
return this.
|
|
2810
|
+
return this.getStockRecords(params).pipe(map(response => {
|
|
2811
|
+
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2812
|
+
throw response;
|
|
2813
|
+
}
|
|
2814
|
+
const stockRecord = response.records[0];
|
|
2815
|
+
return this.processStockItem(stockRecord);
|
|
2816
|
+
}));
|
|
2849
2817
|
}
|
|
2850
|
-
|
|
2818
|
+
/**
|
|
2819
|
+
* Retrieves list of stock from the eSolve instance using info provided
|
|
2820
|
+
*
|
|
2821
|
+
* @param options Stock filter options
|
|
2822
|
+
*/
|
|
2823
|
+
getStockItems(options) {
|
|
2851
2824
|
let params = new HttpParams();
|
|
2852
|
-
if (options
|
|
2853
|
-
params = params.set('
|
|
2825
|
+
if (options.page) {
|
|
2826
|
+
params = params.set('page', options.page);
|
|
2854
2827
|
}
|
|
2855
|
-
if (options
|
|
2828
|
+
if (options.rows) {
|
|
2829
|
+
params = params.set('rows', options.rows);
|
|
2830
|
+
}
|
|
2831
|
+
if (options.search_phrase) {
|
|
2832
|
+
params = params.set('search_phrase', options.search_phrase);
|
|
2833
|
+
}
|
|
2834
|
+
if (options.display_only) {
|
|
2835
|
+
params = params.set('display_only', options.display_only);
|
|
2836
|
+
}
|
|
2837
|
+
if (options.is_active) {
|
|
2838
|
+
params = params.set('is_active', options.is_active);
|
|
2839
|
+
}
|
|
2840
|
+
if (options.category_id) {
|
|
2841
|
+
params = params.set('category_id', options.category_id);
|
|
2842
|
+
}
|
|
2843
|
+
if (options.subcategory_id) {
|
|
2844
|
+
params = params.set('subcategory_id', options.subcategory_id);
|
|
2845
|
+
}
|
|
2846
|
+
if (options.manufacturers_id) {
|
|
2856
2847
|
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
2857
2848
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2849
|
+
if (options.ranges_id) {
|
|
2850
|
+
params = params.set('ranges_id', options.ranges_id);
|
|
2851
|
+
}
|
|
2852
|
+
if (options.specials_id) {
|
|
2853
|
+
params = params.set('specials_id', options.specials_id);
|
|
2854
|
+
}
|
|
2855
|
+
if (options.tag_id_list) {
|
|
2856
|
+
if (options.tag_id_list.length > 0) {
|
|
2857
|
+
params = params.set('tag_id', options.tag_id_list.join(','));
|
|
2862
2858
|
}
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2859
|
+
}
|
|
2860
|
+
if (options.topic_id_list) {
|
|
2861
|
+
if (options.topic_id_list.length > 0) {
|
|
2862
|
+
params = params.set('topic_id', options.topic_id_list.join(','));
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
return this.getStockRecords(params).pipe(map(response => {
|
|
2866
|
+
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2867
|
+
throw response;
|
|
2868
|
+
}
|
|
2869
|
+
const stockItems = [];
|
|
2870
|
+
response.records.forEach(stockRecord => {
|
|
2871
|
+
stockItems.push(this.processStockItem(stockRecord));
|
|
2872
|
+
});
|
|
2873
|
+
return new EsolveStockItemList(stockItems, +response.additional_data.total_records, options.page ?? 0);
|
|
2866
2874
|
}));
|
|
2867
2875
|
}
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2876
|
+
/**
|
|
2877
|
+
* Retrieve list of stock items linked to a stock item from the eSolve API
|
|
2878
|
+
*
|
|
2879
|
+
* @param code Stock item code
|
|
2880
|
+
*/
|
|
2881
|
+
getLinkedItems(code) {
|
|
2882
|
+
return this.http
|
|
2883
|
+
.get(`${this.config.api_url}/get-linked-items.php`, { params: { code } })
|
|
2884
|
+
.pipe(map((response) => {
|
|
2885
|
+
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2886
|
+
throw response;
|
|
2887
|
+
}
|
|
2888
|
+
return this.processLinkedItems(response.records);
|
|
2872
2889
|
}));
|
|
2873
2890
|
}
|
|
2874
|
-
|
|
2891
|
+
/**
|
|
2892
|
+
* Retrieve list of stock items on a recipe from the eSolve API
|
|
2893
|
+
*
|
|
2894
|
+
* @param code Stock item code
|
|
2895
|
+
*/
|
|
2896
|
+
getRecipeItems(code) {
|
|
2875
2897
|
return this.http
|
|
2876
|
-
.get(`${this.config.api_url}/get-
|
|
2898
|
+
.get(`${this.config.api_url}/get-recipe-items.php`, { params: { code } })
|
|
2877
2899
|
.pipe(map((response) => {
|
|
2878
|
-
if ((response.records === undefined) ||
|
|
2879
|
-
(response.records.length <= 0)) {
|
|
2900
|
+
if ((response.records === undefined) || (response.records.length <= 0)) {
|
|
2880
2901
|
throw response;
|
|
2881
2902
|
}
|
|
2882
|
-
return response.records;
|
|
2903
|
+
return this.processRecipeItems(response.records);
|
|
2883
2904
|
}));
|
|
2884
2905
|
}
|
|
2885
|
-
|
|
2886
|
-
|
|
2906
|
+
/**
|
|
2907
|
+
* Processes the eSolve stock item record and converts it to an object.
|
|
2908
|
+
*
|
|
2909
|
+
* @param record eSolve stock item record
|
|
2910
|
+
*/
|
|
2911
|
+
processStockItem(record) {
|
|
2912
|
+
return new EsolveStockItem(record);
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Processes the linked eSolve stock item records and converts them to objects.
|
|
2916
|
+
*
|
|
2917
|
+
* @param records Linked eSolve stock item records
|
|
2918
|
+
*/
|
|
2919
|
+
processLinkedItems(records) {
|
|
2920
|
+
const items = [];
|
|
2921
|
+
if (records.length > 0) {
|
|
2922
|
+
for (const record of records) {
|
|
2923
|
+
items.push(new EsolveLinkedStockItem(record));
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
return items;
|
|
2927
|
+
}
|
|
2928
|
+
/**
|
|
2929
|
+
* Processes the recipe eSolve stock item records and converts them to objects.
|
|
2930
|
+
*
|
|
2931
|
+
* @param records Recipe eSolve stock item records
|
|
2932
|
+
*/
|
|
2933
|
+
processRecipeItems(records) {
|
|
2934
|
+
const items = [];
|
|
2935
|
+
if (records.length > 0) {
|
|
2936
|
+
for (const record of records) {
|
|
2937
|
+
items.push(new EsolveRecipeStockItem(record));
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
return items;
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Retrieves stock records from HTTP params.
|
|
2944
|
+
* @param params HTTP client parameters
|
|
2945
|
+
*/
|
|
2946
|
+
getStockRecords(params) {
|
|
2947
|
+
return this.http.get(`${this.config.api_url}/get-items.php`, { params });
|
|
2887
2948
|
}
|
|
2888
2949
|
}
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2950
|
+
EsolveStockService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveStockService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2951
|
+
EsolveStockService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveStockService, providedIn: 'root' });
|
|
2952
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveStockService, decorators: [{
|
|
2892
2953
|
type: Injectable,
|
|
2893
2954
|
args: [{
|
|
2894
2955
|
providedIn: 'root',
|
|
@@ -2898,6 +2959,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2898
2959
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2899
2960
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2900
2961
|
|
|
2962
|
+
// Models
|
|
2963
|
+
|
|
2901
2964
|
class EsolveSpecialImage {
|
|
2902
2965
|
constructor(record) {
|
|
2903
2966
|
this.id = +record.id;
|
|
@@ -3087,33 +3150,33 @@ class EsolveCartStockItem {
|
|
|
3087
3150
|
* Path to tiny stock image
|
|
3088
3151
|
*/
|
|
3089
3152
|
get tiny_image_src() {
|
|
3090
|
-
return this.
|
|
3153
|
+
return this.getImagePath('tiny');
|
|
3091
3154
|
}
|
|
3092
3155
|
/**
|
|
3093
3156
|
* Path to thumbnail stock image
|
|
3094
3157
|
*/
|
|
3095
3158
|
get thumbnail_image_src() {
|
|
3096
|
-
return this.
|
|
3159
|
+
return this.getImagePath('thumb');
|
|
3097
3160
|
}
|
|
3098
3161
|
/**
|
|
3099
3162
|
* Path to small stock image
|
|
3100
3163
|
*/
|
|
3101
3164
|
get small_image_src() {
|
|
3102
|
-
return this.
|
|
3165
|
+
return this.getImagePath('small');
|
|
3103
3166
|
}
|
|
3104
3167
|
/**
|
|
3105
3168
|
* Path to big stock image
|
|
3106
3169
|
*/
|
|
3107
3170
|
get big_image_src() {
|
|
3108
|
-
return this.
|
|
3171
|
+
return this.getImagePath('big');
|
|
3109
3172
|
}
|
|
3110
3173
|
/**
|
|
3111
3174
|
* Path to original stock image
|
|
3112
3175
|
*/
|
|
3113
3176
|
get original_image_src() {
|
|
3114
|
-
return this.
|
|
3177
|
+
return this.getImagePath('original');
|
|
3115
3178
|
}
|
|
3116
|
-
|
|
3179
|
+
getImagePath(image_size) {
|
|
3117
3180
|
if (this.image_name !== '') {
|
|
3118
3181
|
return `/images/stock/${image_size}/${this.image_name}`;
|
|
3119
3182
|
}
|
|
@@ -3764,6 +3827,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
3764
3827
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
3765
3828
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
3766
3829
|
|
|
3830
|
+
class EsolveEnquiryResult extends EsolveResponseResult {
|
|
3831
|
+
constructor(response) {
|
|
3832
|
+
super(response);
|
|
3833
|
+
this.id = 0;
|
|
3834
|
+
this.id = +response.esolve_id;
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
class EsolveEnquiryService {
|
|
3839
|
+
constructor(config, http, errorHandler, responseHandler) {
|
|
3840
|
+
this.config = config;
|
|
3841
|
+
this.http = http;
|
|
3842
|
+
this.errorHandler = errorHandler;
|
|
3843
|
+
this.responseHandler = responseHandler;
|
|
3844
|
+
}
|
|
3845
|
+
send(form_data) {
|
|
3846
|
+
if (!form_data.has('email')) {
|
|
3847
|
+
return this.errorHandler.emitError('email_required', 'Email is required');
|
|
3848
|
+
}
|
|
3849
|
+
return this.http
|
|
3850
|
+
.post(`${this.config.api_url}/set-enquiry.php`, form_data, {
|
|
3851
|
+
responseType: 'json',
|
|
3852
|
+
observe: 'body',
|
|
3853
|
+
})
|
|
3854
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveEnquiryResult(response))), catchError((errorRes) => {
|
|
3855
|
+
return this.errorHandler.handleHttpPostError('set-enquiry', errorRes);
|
|
3856
|
+
}));
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
EsolveEnquiryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveEnquiryService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3860
|
+
EsolveEnquiryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveEnquiryService, providedIn: 'root' });
|
|
3861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveEnquiryService, decorators: [{
|
|
3862
|
+
type: Injectable,
|
|
3863
|
+
args: [{
|
|
3864
|
+
providedIn: 'root',
|
|
3865
|
+
}]
|
|
3866
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
3867
|
+
type: Inject,
|
|
3868
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
3869
|
+
}] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }]; } });
|
|
3870
|
+
|
|
3767
3871
|
/*
|
|
3768
3872
|
* Public API Surface of ng-esolve-connect
|
|
3769
3873
|
*/
|
|
@@ -3772,5 +3876,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
3772
3876
|
* Generated bundle index. Do not edit.
|
|
3773
3877
|
*/
|
|
3774
3878
|
|
|
3775
|
-
export { EsolveAccountService, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveCookieService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHeading, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaArticle, EsolveMediaService, 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, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
3879
|
+
export { EsolveAccountService, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHeading, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaArticle, EsolveMediaService, 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, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
3776
3880
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|