ng-easycommerce 0.0.482 → 0.0.484

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/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ # version 0.0.483
2
+ - Se cambia funcionamiento del filtro atributos para que apunte a otro endpoint y sea dinámico actualizandose cuando se seleccione una categoría.
3
+ # version 0.0.483
4
+ - Se cambia el parametro `createAt` por `dateCreate` en los filtros sort.
1
5
  # version 0.0.482
2
6
  - Se agregar la posibilidad de elegir que filtros sort se deben mostrar en el frontend a través de las constantes.
3
7
  - Se agrega la posibilidad de filtrar sobre la vista de productos directamente en el componente collection-ec. Por el momento el campo que se toma en cuenta es `dateCreate` de las variantes. *Queda pendiente medir la performance cuando se trate de filtrar muchos articulos*
@@ -965,6 +965,7 @@
965
965
  var _this = this;
966
966
  this.connection = connection;
967
967
  this.constants = constants;
968
+ this.filtersSubject = new rxjs.BehaviorSubject([]);
968
969
  this.categoriesSubject = new rxjs.BehaviorSubject([]);
969
970
  this.attributesSubject = new rxjs.BehaviorSubject([]);
970
971
  this.sectionsSubject = new rxjs.BehaviorSubject([]);
@@ -1047,6 +1048,10 @@
1047
1048
  this.pageContentByCodeApi = function (code) { return _this.cmsBase() + '/' + _this.constants.getChannel() + '/page/' + code; };
1048
1049
  this.taxonsApi = function () { return _this.shopApi() + '/taxons/' + '?locale=' + _this.constants.getLocale(); };
1049
1050
  this.attributesApi = function () { return _this.shopApi() + '/attributes-list' + '?locale=' + _this.constants.getLocale(); };
1051
+ this.attributesApi2 = function (filters) {
1052
+ if (filters === void 0) { filters = ''; }
1053
+ return 'shop-api/' + _this.constants.getChannel() + '/product-search/' + '?locale=' + _this.constants.getLocale() + '&limit=1&page=1' + filters;
1054
+ };
1050
1055
  /**
1051
1056
  * @public
1052
1057
  * UTILS
@@ -1135,7 +1140,7 @@
1135
1140
  var _this = this;
1136
1141
  return __generator(this, function (_a) {
1137
1142
  switch (_a.label) {
1138
- case 0: return [4 /*yield*/, this.connection.get(this.attributesApi()).pipe(operators.map(function (response) { return _this.appendPaths(false, (response.items || response)); }))
1143
+ case 0: return [4 /*yield*/, this.connection.get(this.attributesApi2()).pipe(operators.map(function (response) { return _this.appendPaths(false, (response.attributes[0] || response)); }))
1139
1144
  .toPromise().then(function (response) {
1140
1145
  response.forEach(function (element) { return _this.data.push(element); });
1141
1146
  _this.attributesSubject.next(_this.addAttributesSlug(response));
@@ -1148,6 +1153,24 @@
1148
1153
  });
1149
1154
  });
1150
1155
  };
1156
+ OptionsService.prototype.getAttributes2 = function (extra_params) {
1157
+ return __awaiter(this, void 0, void 0, function () {
1158
+ var _this = this;
1159
+ return __generator(this, function (_a) {
1160
+ switch (_a.label) {
1161
+ case 0: return [4 /*yield*/, this.connection.get(this.attributesApi2(extra_params)).pipe(operators.map(function (response) { return _this.appendPaths(false, (response.attributes[0] || response)); }))
1162
+ .toPromise().then(function (response) {
1163
+ response.forEach(function (element) { return _this.data.push(element); });
1164
+ _this.attributesSubject.next(_this.addAttributesSlug(response));
1165
+ }).catch(function () { return _this.attributesSubject.next([]); })];
1166
+ case 1:
1167
+ _a.sent();
1168
+ this.optionLoaded2('attributes');
1169
+ return [2 /*return*/];
1170
+ }
1171
+ });
1172
+ });
1173
+ };
1151
1174
  OptionsService.prototype.appendPaths = function (isCategory, response) {
1152
1175
  var _this = this;
1153
1176
  var result = response.map(function (subelement) {
@@ -1218,6 +1241,12 @@
1218
1241
  state.options[key] = true;
1219
1242
  this.readySubject.next({ options: state.options, readyAll: allReady(state.options) });
1220
1243
  };
1244
+ OptionsService.prototype.optionLoaded2 = function (key) {
1245
+ var allReady = function (options) { return Object.keys(options).every(function (option_key) { return state.options[option_key]; }); };
1246
+ var state = this.readySubject.value;
1247
+ state.options[key] = true;
1248
+ // this.readySubject.next({ options: state.options, readyAll: allReady(state.options) })
1249
+ };
1221
1250
  OptionsService.ctorParameters = function () { return [
1222
1251
  { type: ConnectionService },
1223
1252
  { type: Constants }
@@ -1461,7 +1490,7 @@
1461
1490
  _this.translate = function (value) {
1462
1491
  switch (value) {
1463
1492
  case 'price': return 'price';
1464
- case 'created-date': return 'createdAt';
1493
+ case 'created-date': return 'dateCreate';
1465
1494
  case 'alphabetical-order': return 'name';
1466
1495
  }
1467
1496
  };
@@ -1873,6 +1902,9 @@
1873
1902
  });
1874
1903
  if (search_value)
1875
1904
  extra_params += ('&criteria[search][type]=contains&criteria[search][value]=' + search_value);
1905
+ if (extra_params != '') {
1906
+ _this.options.getAttributes2(extra_params);
1907
+ }
1876
1908
  return _this.productsFilterApi(extra_params);
1877
1909
  };
1878
1910
  this.finished = function () { return _this.pagination.finished$; };