awing-library 2.1.95-beta → 2.1.96-beta

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.
@@ -123,35 +123,31 @@ var RowAdvanceContainer = function (_a) {
123
123
  };
124
124
  function getDetails(filterBy, groupBy, pageSize, pageIndex) {
125
125
  return __awaiter(this, void 0, void 0, function () {
126
- var params, error_1, error_2;
127
- return __generator(this, function (_a) {
128
- switch (_a.label) {
126
+ var groupByMapping, params, fetchFunction, error_1;
127
+ var _a;
128
+ return __generator(this, function (_b) {
129
+ switch (_b.label) {
129
130
  case 0:
131
+ groupByMapping = (_a = {},
132
+ _a[Enum_1.HEAD_CELL_NAMES.CAMPAIGN_CAMPAIGN] = Enum_1.HEAD_CELL_NAMES.CAMPAIGN,
133
+ _a[Enum_1.HEAD_CELL_NAMES.PLACE_CAMPAIGN] = Enum_1.HEAD_CELL_NAMES.PLACE,
134
+ _a[Enum_1.HEAD_CELL_NAMES.DOMAIN_CAMPAIGN] = Enum_1.HEAD_CELL_NAMES.DOMAIN,
135
+ _a);
136
+ groupBy = groupByMapping[groupBy] || groupBy;
130
137
  params = __assign(__assign({}, filterBy), { groupBy: groupBy, pageIndex: pageIndex, pageSize: pageSize });
131
- if (!groupBy) return [3 /*break*/, 5];
132
- _a.label = 1;
138
+ fetchFunction = groupBy ? pagingGroupBy : paging;
139
+ _b.label = 1;
133
140
  case 1:
134
- _a.trys.push([1, 3, , 4]);
135
- return [4 /*yield*/, pagingGroupBy(params, setDetails, handleLoading)];
141
+ _b.trys.push([1, 3, , 4]);
142
+ return [4 /*yield*/, fetchFunction(params, setDetails, handleLoading)];
136
143
  case 2:
137
- _a.sent();
144
+ _b.sent();
138
145
  return [3 /*break*/, 4];
139
146
  case 3:
140
- error_1 = _a.sent();
141
- console.log(error_1);
147
+ error_1 = _b.sent();
148
+ console.error(error_1);
142
149
  return [3 /*break*/, 4];
143
- case 4: return [3 /*break*/, 8];
144
- case 5:
145
- _a.trys.push([5, 7, , 8]);
146
- return [4 /*yield*/, paging(params, setDetails, handleLoading)];
147
- case 6:
148
- _a.sent();
149
- return [3 /*break*/, 8];
150
- case 7:
151
- error_2 = _a.sent();
152
- console.log(error_2);
153
- return [3 /*break*/, 8];
154
- case 8: return [2 /*return*/];
150
+ case 4: return [2 /*return*/];
155
151
  }
156
152
  });
157
153
  });
@@ -170,34 +166,36 @@ var RowAdvanceContainer = function (_a) {
170
166
  getDetails(filterByOfRowAdvance, groupNames[priorityGroupLevel], pages === null || pages === void 0 ? void 0 : pages.pageSize, pages === null || pages === void 0 ? void 0 : pages.pageIndex);
171
167
  }
172
168
  };
173
- var handleOnClickCampaignStatistic = function (value) {
174
- var _a, _b, _c;
175
- if (groupNames[priorityGroupLevel - 1] ===
176
- Enum_1.HEAD_CELL_NAMES.PLACE_CAMPAIGN) {
177
- filters.placeIds = [(_a = value === null || value === void 0 ? void 0 : value.place) === null || _a === void 0 ? void 0 : _a.placeId];
178
- }
179
- if (groupNames[priorityGroupLevel - 1] ===
180
- Enum_1.HEAD_CELL_NAMES.DOMAIN_CAMPAIGN) {
181
- filters.domainId = (_b = value === null || value === void 0 ? void 0 : value.domain) === null || _b === void 0 ? void 0 : _b.domainId;
182
- }
183
- if (groupNames[priorityGroupLevel - 1] ===
184
- Enum_1.HEAD_CELL_NAMES.CAMPAIGN_CAMPAIGN) {
185
- filters.campaignId = (_c = value === null || value === void 0 ? void 0 : value.campaign) === null || _c === void 0 ? void 0 : _c.campaignId;
186
- }
187
- if (filters.placeIds.includes(undefined)) {
169
+ var filterByIdAXN = function (value, groupName, filters) {
170
+ var _a, _b, _c, _d;
171
+ if ((_a = filters === null || filters === void 0 ? void 0 : filters.placeIds) === null || _a === void 0 ? void 0 : _a.includes(undefined)) {
188
172
  filters.placeIds = [];
189
173
  }
174
+ switch (groupName) {
175
+ case Enum_1.HEAD_CELL_NAMES.PLACE_CAMPAIGN:
176
+ return __assign(__assign({}, filters), { placeIds: [(_b = value === null || value === void 0 ? void 0 : value.place) === null || _b === void 0 ? void 0 : _b.placeId] });
177
+ case Enum_1.HEAD_CELL_NAMES.DOMAIN_CAMPAIGN:
178
+ return __assign(__assign({}, filters), { domainId: (_c = value === null || value === void 0 ? void 0 : value.domain) === null || _c === void 0 ? void 0 : _c.domainId });
179
+ case Enum_1.HEAD_CELL_NAMES.CAMPAIGN_CAMPAIGN:
180
+ return __assign(__assign({}, filters), { campaignId: (_d = value === null || value === void 0 ? void 0 : value.campaign) === null || _d === void 0 ? void 0 : _d.campaignId });
181
+ default:
182
+ return filters;
183
+ }
184
+ };
185
+ var handleOnClickCampaignStatistic = function (value) {
186
+ var groupName = groupNames[priorityGroupLevel - 1];
187
+ var filtersByAXN = filterByIdAXN(value, groupName, filters);
190
188
  if (!expandDisabled) {
191
189
  setOpen(!open);
192
- getDetails(filters, groupNames[priorityGroupLevel], pages === null || pages === void 0 ? void 0 : pages.pageSize, pages === null || pages === void 0 ? void 0 : pages.pageIndex);
190
+ getDetails(filtersByAXN, groupNames[priorityGroupLevel], pages === null || pages === void 0 ? void 0 : pages.pageSize, pages === null || pages === void 0 ? void 0 : pages.pageIndex);
193
191
  }
194
192
  };
195
193
  var expandDisabled = (groupNames === null || groupNames === void 0 ? void 0 : groupNames.length) === 0
196
194
  ? true
197
195
  : priorityGroupLevel === (groupNames === null || groupNames === void 0 ? void 0 : groupNames.length) + 1;
196
+ var conditionalExpand = headCells.length > 6 && headCells[4].id === Enum_1.HEAD_CELL_NAMES.IMPRESSION;
198
197
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(component_1.default, { stt: stt, row: row, options: options, headCells: headCells, priorityGroupLevel: priorityGroupLevel, groupNames: groupNames, handleOnClick: function () {
199
- headCells.length > 6 &&
200
- headCells[3].id === Enum_1.HEAD_CELL_NAMES.CAMPAIGN_CAMPAIGN
198
+ conditionalExpand
201
199
  ? handleOnClickCampaignStatistic(row)
202
200
  : handleOnClick(row);
203
201
  }, open: open, expandDisabled: expandDisabled }), open && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (loadingPage === null || loadingPage === void 0 ? void 0 : loadingPage.pages) ? ((0, jsx_runtime_1.jsx)(material_1.TableRow, { children: (0, jsx_runtime_1.jsx)(material_1.TableCell, { colSpan: headCells === null || headCells === void 0 ? void 0 : headCells.length, children: (0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {}) }) })) : ((0, jsx_runtime_1.jsx)(EnhancedPagination_1.default, { pageSize: pages === null || pages === void 0 ? void 0 : pages.pageSize, pageIndex: pages === null || pages === void 0 ? void 0 : pages.pageIndex, handleChangePage: handleChangePage, handleChangeRowsPerPage: handleChangeRowsPerPage, className: "".concat(classes.pagination, " ").concat((groupNames === null || groupNames === void 0 ? void 0 : groupNames.length) === 0
@@ -206,13 +204,16 @@ var RowAdvanceContainer = function (_a) {
206
204
  ? details === null || details === void 0 ? void 0 : details.totalItemCount
207
205
  : details === null || details === void 0 ? void 0 : details.total)) !== null && _b !== void 0 ? _b : 0, children: ((_c = details === null || details === void 0 ? void 0 : details.items) === null || _c === void 0 ? void 0 : _c.length) === 0 ? ((0, jsx_runtime_1.jsx)(NoDataTable_1.default, { colSpan: headCells === null || headCells === void 0 ? void 0 : headCells.length, title: t('Common.NoData') })) : ((_d = details === null || details === void 0 ? void 0 : details.items) === null || _d === void 0 ? void 0 : _d.map(function (item, i) {
208
206
  var filterBy = filterById(row === null || row === void 0 ? void 0 : row.groupKeyId, groupNames[priorityGroupLevel], filterByOfRowAdvance);
207
+ var filtersByAXN = filterByIdAXN(row, groupNames[priorityGroupLevel - 1], filters);
209
208
  var stt = (pages === null || pages === void 0 ? void 0 : pages.pageSize) * (pages === null || pages === void 0 ? void 0 : pages.pageIndex) +
210
209
  i +
211
210
  1;
212
211
  var key = (item === null || item === void 0 ? void 0 : item.groupKeyId)
213
212
  ? item === null || item === void 0 ? void 0 : item.groupKeyId
214
213
  : i;
215
- return ((0, jsx_runtime_1.jsx)(RowAdvanceContainer, { headCells: headCells, row: item, priorityGroupLevel: priorityGroupLevel + 1, stt: stt, groupNames: groupNames, options: options, filters: filterBy, serviceCampaignSchedule: serviceCampaignSchedule }, key));
214
+ return ((0, jsx_runtime_1.jsx)(RowAdvanceContainer, { headCells: headCells, row: item, priorityGroupLevel: priorityGroupLevel + 1, stt: stt, groupNames: groupNames, options: options, filters: conditionalExpand
215
+ ? filtersByAXN
216
+ : filterBy, serviceCampaignSchedule: serviceCampaignSchedule }, key));
216
217
  })) })) }))] }));
217
218
  };
218
219
  var filterById = function (id, groupName, filters) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.95-beta",
3
+ "version": "2.1.96-beta",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",