@crystaldesign/diva-archive 26.3.0-rc.8 → 26.3.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.
@@ -225,6 +225,7 @@ function useActions(_ref) {
225
225
  openModal = _useDivaCore$actions.openModal,
226
226
  userHasPermission = _useDivaCore$actions.userHasPermission,
227
227
  openSnackBar = _useDivaCore$actions.openSnackBar,
228
+ canAccessOrganization = _useDivaCore$actions.canAccessOrganization,
228
229
  _useDivaCore$handler = _useDivaCore.handler,
229
230
  reportHandler = _useDivaCore$handler.reportHandler,
230
231
  organizationHandler = _useDivaCore$handler.organizationHandler;
@@ -253,6 +254,9 @@ function useActions(_ref) {
253
254
  trashed: trashed
254
255
  }),
255
256
  hide: function hide(item, rowId) {
257
+ if (item.OrganizationId && !canAccessOrganization(item.OrganizationId)) {
258
+ return true;
259
+ }
256
260
  //irreverseble delete is visible if the user owns that basket
257
261
  if (item.SalespersonID === (user === null || user === void 0 ? void 0 : user._id)) {
258
262
  return false;
@@ -299,7 +303,8 @@ function useActions(_ref) {
299
303
  jwt: jwt,
300
304
  reportHandler: reportHandler,
301
305
  user: user,
302
- organizationHandler: organizationHandler
306
+ organizationHandler: organizationHandler,
307
+ canAccessOrganization: canAccessOrganization
303
308
  })
304
309
  };
305
310
  });
@@ -313,7 +318,10 @@ function useActions(_ref) {
313
318
  t: t,
314
319
  trashed: trashed
315
320
  }),
316
- disabled: false
321
+ disabled: false,
322
+ hide: function hide(item) {
323
+ return !!item.OrganizationId && !canAccessOrganization(item.OrganizationId);
324
+ }
317
325
  });
318
326
  return gridActions;
319
327
  }
@@ -332,10 +340,11 @@ function getAction(_ref2) {
332
340
  jwt = _ref2.jwt,
333
341
  reportHandler = _ref2.reportHandler,
334
342
  user = _ref2.user,
335
- organizationHandler = _ref2.organizationHandler;
343
+ organizationHandler = _ref2.organizationHandler,
344
+ canAccessOrganization = _ref2.canAccessOrganization;
336
345
  switch (action.type) {
337
346
  case 'basket':
338
- return openBasketAction(openComponent, organizationHandler, openModal, organization, t);
347
+ return openBasketAction(openComponent, organizationHandler, openModal, organization, canAccessOrganization, t);
339
348
  case 'pdf':
340
349
  return openPdfAction(openComponent, openSnackBar, toggleLoading, openModal, t, action, reportHandler);
341
350
  case 'planner':
@@ -359,7 +368,7 @@ function getAction(_ref2) {
359
368
  throw Error("".concat(action.type, " is not a valid action type"));
360
369
  }
361
370
  }
362
- function openBasketAction(openComponent, organizationHandler, openModal, organization, t) {
371
+ function openBasketAction(openComponent, organizationHandler, openModal, organization, canAccessOrganization, t) {
363
372
  var openInCurrentOrg = function openInCurrentOrg(item) {
364
373
  var params = {
365
374
  module: 'Basket',
@@ -380,25 +389,42 @@ function openBasketAction(openComponent, organizationHandler, openModal, organiz
380
389
  });
381
390
  };
382
391
  var openInTargetOrg = function openInTargetOrg(item) {
383
- var url = window.location.origin + '/seller?lang=de' + '&organizationId=' + item.OrganizationId + '&module=Basket&divaNr=' + item.DivaNr + '&check=1';
384
- openComponent({
385
- url: url,
386
- openInNewTab: true
387
- });
392
+ if (item.OrderStatus === 'SEND') {
393
+ var url = window.location.origin + '/seller?lang=de' + '&organizationId=' + item.OrganizationId + '&module=Basket&divaNr=' + item.DivaNr + '&assignNewDivaNr=true';
394
+ openComponent({
395
+ url: url,
396
+ openInNewTab: true
397
+ });
398
+ } else {
399
+ var _url = window.location.origin + '/seller?lang=de' + '&organizationId=' + item.OrganizationId + '&module=Basket&divaNr=' + item.DivaNr + '&check=1';
400
+ openComponent({
401
+ url: _url,
402
+ openInNewTab: true
403
+ });
404
+ }
388
405
  };
389
406
  return /*#__PURE__*/function () {
390
407
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
391
- var modaltitle;
408
+ var _organization$type, _organization$type$to, modaltitle, hasAccessToTargetOrg, organizationType, isWrapperLikeOrganization;
392
409
  return _regeneratorRuntime.wrap(function _callee$(_context) {
393
410
  while (1) switch (_context.prev = _context.next) {
394
411
  case 0:
395
412
  if (!(item.OrganizationId && item.OrganizationId !== organization._id)) {
396
- _context.next = 5;
413
+ _context.next = 10;
397
414
  break;
398
415
  }
399
416
  modaltitle = t('action.archive.edit.cannotopen');
400
- if (!(!(organization !== null && organization !== void 0 && organization.type) && !(organization !== null && organization !== void 0 && organization.parentType))) {
401
- _context.next = 4;
417
+ hasAccessToTargetOrg = canAccessOrganization(item.OrganizationId);
418
+ if (hasAccessToTargetOrg) {
419
+ _context.next = 5;
420
+ break;
421
+ }
422
+ return _context.abrupt("return", openInCurrentOrg(item));
423
+ case 5:
424
+ organizationType = organization === null || organization === void 0 || (_organization$type = organization.type) === null || _organization$type === void 0 || (_organization$type$to = _organization$type.toUpperCase) === null || _organization$type$to === void 0 ? void 0 : _organization$type$to.call(_organization$type);
425
+ isWrapperLikeOrganization = !(organization !== null && organization !== void 0 && organization.type) && !(organization !== null && organization !== void 0 && organization.parentType) || organizationType === 'SUPPLIER' || organizationType === 'SUPLIER';
426
+ if (!isWrapperLikeOrganization) {
427
+ _context.next = 9;
402
428
  break;
403
429
  }
404
430
  return _context.abrupt("return", openModal({
@@ -414,7 +440,7 @@ function openBasketAction(openComponent, organizationHandler, openModal, organiz
414
440
  }
415
441
  }
416
442
  }));
417
- case 4:
443
+ case 9:
418
444
  return _context.abrupt("return", openModal({
419
445
  title: modaltitle,
420
446
  rejectByIcon: true,
@@ -441,9 +467,9 @@ function openBasketAction(openComponent, organizationHandler, openModal, organiz
441
467
  }
442
468
  }
443
469
  }));
444
- case 5:
470
+ case 10:
445
471
  return _context.abrupt("return", openInCurrentOrg(item));
446
- case 6:
472
+ case 11:
447
473
  case "end":
448
474
  return _context.stop();
449
475
  }
@@ -799,9 +825,9 @@ function deleteAction(_ref9) {
799
825
  function triggerSendEmail(_ref11) {
800
826
  var sendEmail = _ref11.sendEmail;
801
827
  _ref11.t;
802
- var action = _ref11.action,
803
- organization = _ref11.organization,
804
- user = _ref11.user,
828
+ var action = _ref11.action;
829
+ _ref11.organization;
830
+ var user = _ref11.user,
805
831
  item = _ref11.item,
806
832
  callback = _ref11.callback;
807
833
  var to;
@@ -817,8 +843,6 @@ function triggerSendEmail(_ref11) {
817
843
  return getMailAddress(item.ClientEmail, required);
818
844
  } else if (mail == 'SELLER') {
819
845
  return getMailAddress(item.SalespersonEmail, required);
820
- } else if (mail == 'ORGANIZATION') {
821
- return getMailAddress(organization === null || organization === void 0 ? void 0 : organization.email, required);
822
846
  } else if (mail == 'USER') {
823
847
  return getMailAddress(user === null || user === void 0 ? void 0 : user.mainEmail, required);
824
848
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"useActions.d.ts","sourceRoot":"","sources":["../../../../src/useActions.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAiB,WAAW,EAAE,aAAa,EAA0B,MAAM,SAAS,CAAC;AAI5F,UAAU,KAAK;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7D;AAID,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,KAAK,iEA4E3E"}
1
+ {"version":3,"file":"useActions.d.ts","sourceRoot":"","sources":["../../../../src/useActions.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAiB,WAAW,EAAE,aAAa,EAA0B,MAAM,SAAS,CAAC;AAI5F,UAAU,KAAK;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAC7D;AAID,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,KAAK,iEAiF3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-archive",
3
- "version": "26.3.0-rc.8",
3
+ "version": "26.3.0",
4
4
  "license": "COMMERCIAL",
5
5
  "devDependencies": {
6
6
  "@testing-library/jest-dom": "^6.5.0",
@@ -15,10 +15,10 @@
15
15
  "react-dom": "^18.3.1"
16
16
  },
17
17
  "dependencies": {
18
- "@crystaldesign/grid": "26.3.0-rc.8",
18
+ "@crystaldesign/grid": "26.3.0",
19
19
  "flat": "^5.0.2"
20
20
  },
21
21
  "module": "build/esm/index.js",
22
22
  "types": "./build/types/archive/src/index.d.ts",
23
- "gitHead": "5a095195961416012032f298a9ed6841702d4a68"
23
+ "gitHead": "cf3302995a149aa3f95fd31b254e270a30507941"
24
24
  }