@veloceapps/sdk 6.0.0-14 → 6.0.0-15

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.
@@ -1118,6 +1118,8 @@
1118
1118
  this.metrics = __spreadArray(__spreadArray([], __read(this.metrics)), __read(metricKeys.map(function (metricKey) {
1119
1119
  return { key: metricKey, name: _this.getMetricName(metricKey), visible: false };
1120
1120
  })));
1121
+ // sort the metrics by the order of default metric rule names from the shopping cart settings
1122
+ this.metrics = this.sortMetrics();
1121
1123
  this.metrics = lodash.cloneDeep(this.metrics);
1122
1124
  this.searchControl.setValue('');
1123
1125
  if (!resetToDefault) {
@@ -1149,6 +1151,27 @@
1149
1151
  return result;
1150
1152
  }, []);
1151
1153
  };
1154
+ /**
1155
+ * Sorts the Metrics array by the order of the default metric rule names from the shopping cart settings.
1156
+ * If a metric is included in the list of default metrics, it raises the metric to the top of the metrics array.
1157
+ */
1158
+ MetricsComponent.prototype.sortMetrics = function () {
1159
+ var _this = this;
1160
+ return this.metrics.slice().sort(function (a, b) {
1161
+ var indexA = _this.defaultMetricRuleNames.indexOf(a.name);
1162
+ var indexB = _this.defaultMetricRuleNames.indexOf(b.name);
1163
+ if (indexA === -1 && indexB === -1) {
1164
+ return 0;
1165
+ }
1166
+ if (indexA === -1) {
1167
+ return 1;
1168
+ }
1169
+ if (indexB === -1) {
1170
+ return -1;
1171
+ }
1172
+ return indexA - indexB;
1173
+ });
1174
+ };
1152
1175
  return MetricsComponent;
1153
1176
  }());
1154
1177
  MetricsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MetricsComponent, deps: [{ token: i1__namespace$1.ContextService }, { token: i1__namespace$1.QuoteDraftService }, { token: i0__namespace.ChangeDetectorRef }, { token: i1__namespace$1.MetricsCalculationService }, { token: i1__namespace$1.FlowConfigurationService }, { token: i2__namespace.ShoppingCartSettingsApiService }], target: i0__namespace.ɵɵFactoryTarget.Component });