jamespot-front-business 1.1.82 → 1.1.83

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/dist/cjs.js CHANGED
@@ -718,6 +718,17 @@ const fetchComments = toolkit.createAsyncThunk('commentList/fetchCommentList', (
718
718
  return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
719
719
  }
720
720
  }));
721
+ const deleteComment = toolkit.createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
722
+ var _b;
723
+ try {
724
+ yield extra.jApi.article.deleteComment(params.idComment);
725
+ return true;
726
+ }
727
+ catch (error) {
728
+ dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
729
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
730
+ }
731
+ }));
721
732
  const CommentListSlice = toolkit.createSlice({
722
733
  name: 'commentList',
723
734
  initialState: initialState$i,
@@ -773,6 +784,22 @@ const CommentListSlice = toolkit.createSlice({
773
784
  })
774
785
  .addCase(fetchComments.rejected, (state) => {
775
786
  state.loading = 'idle';
787
+ })
788
+ .addCase(deleteComment.pending, (state, action) => {
789
+ state.comments = state.comments.map((c) => {
790
+ if (c.idArticle !== action.meta.arg.idArticle) {
791
+ return c;
792
+ }
793
+ return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: true }) : comment) });
794
+ });
795
+ })
796
+ .addCase(deleteComment.rejected, (state, action) => {
797
+ state.comments = state.comments.map((c) => {
798
+ if (c.idArticle !== action.meta.arg.idArticle) {
799
+ return c;
800
+ }
801
+ return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: false }) : comment) });
802
+ });
776
803
  });
777
804
  },
778
805
  });
@@ -834,13 +861,12 @@ const commentSlice = {
834
861
  };
835
862
  const selectCommentList = (state, idArticle, limit = 0) => {
836
863
  const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
837
- const dataList = data && Array.isArray(data.list) ? data.list : [];
838
- const list = [...dataList].sort((c1, c2) => c1.id - c2.id);
864
+ const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
839
865
  return limit !== 0 ? list.slice(-limit) : list;
840
866
  };
841
867
  const Comment = {
842
868
  slice: commentSlice,
843
- actions: Object.assign({ fetchComments }, CommentListSlice.actions),
869
+ actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
844
870
  selectors: {
845
871
  commentList: selectCommentList,
846
872
  },
@@ -4277,13 +4303,43 @@ const specialAttrName = ['title', 'alertAuthor', 'sendAlert'];
4277
4303
  const ignoredFields = ['edito'];
4278
4304
  function updateViewsFromFields(clonedApp, appFields) {
4279
4305
  return Object.assign({}, ...viewsList.map((view) => {
4306
+ var _a, _b, _c, _d, _e, _f;
4280
4307
  const viewItems = {};
4308
+ let viewMissingOptionalFields = [];
4309
+ if (((_a = MapExtraFieldsWithView[view]) === null || _a === void 0 ? void 0 : _a.optional) !== undefined) {
4310
+ viewMissingOptionalFields = viewMissingOptionalFields.concat((_c = (_b = MapExtraFieldsWithView[view]) === null || _b === void 0 ? void 0 : _b.optional) !== null && _c !== void 0 ? _c : []);
4311
+ }
4312
+ let viewMissingFixedFields = [];
4313
+ if (((_d = MapExtraFieldsWithView[view]) === null || _d === void 0 ? void 0 : _d.fixed) !== undefined) {
4314
+ viewMissingFixedFields = viewMissingFixedFields.concat((_f = (_e = MapExtraFieldsWithView[view]) === null || _e === void 0 ? void 0 : _e.fixed) !== null && _f !== void 0 ? _f : []);
4315
+ }
4281
4316
  Object.entries(clonedApp.views[view]).forEach(([fieldId, field]) => {
4282
4317
  if (field.isFixed) {
4283
4318
  viewItems[fieldId] = field;
4319
+ viewMissingFixedFields.splice(viewMissingFixedFields.findIndex((fieldType) => fieldType === field.type), 1);
4284
4320
  }
4285
4321
  if (field.isOptional) {
4286
4322
  viewItems[fieldId] = field;
4323
+ viewMissingOptionalFields.splice(viewMissingOptionalFields.findIndex((fieldType) => fieldType === field.type), 1);
4324
+ }
4325
+ });
4326
+ const missingFieldsSet = new Set(viewMissingFixedFields.concat(viewMissingOptionalFields));
4327
+ const fieldTypeHandlers = {
4328
+ [ExtraAppFieldsItemViews.CREATIONDATE]: () => getDateCreationToView(false),
4329
+ [ExtraAppFieldsItemViews.TITLE]: () => getTitleToView({ ref: 'title', fixedValue: undefined }),
4330
+ [ExtraAppFieldsItemViews.USER]: () => getUserToView(false),
4331
+ [ExtraAppFieldsItemViews.RECEIVEACOPY]: () => getAlertAuthorToView({ ref: 'alertAuthor', fixedValue: undefined }),
4332
+ [ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS]: () => getSendAlertToView({ ref: 'sendAlert', fixedValue: undefined }),
4333
+ [ExtraAppFieldsItemViews.PUBLISHTO]: () => getPublishToToView({ ref: 'publishTo', fixedValue: undefined }),
4334
+ };
4335
+ missingFieldsSet.forEach((fieldType) => {
4336
+ const handler = fieldTypeHandlers[fieldType];
4337
+ if (handler) {
4338
+ const [localFieldId, localField] = handler();
4339
+ viewItems[localFieldId] = localField;
4340
+ }
4341
+ else {
4342
+ console.error('ExtraAppFieldsItemViews does not have this field type: ' + fieldType);
4287
4343
  }
4288
4344
  });
4289
4345
  appFields.forEach((field, idx) => {
@@ -4392,16 +4448,20 @@ function buildView(appS, registeredFields, displayName, displayValue, tables, st
4392
4448
  if (fieldIdx === -1 && fixedInfo) {
4393
4449
  switch (fixedInfo.ref) {
4394
4450
  case 'title':
4395
- addTitleToView(newName, appS, fixedInfo);
4451
+ const [localFieldIdTitle, localFieldTitle] = getTitleToView(fixedInfo);
4452
+ appS.views[newName][localFieldIdTitle] = localFieldTitle;
4396
4453
  break;
4397
4454
  case 'alertAuthor':
4398
- addAlertAuthorToView(newName, appS, fixedInfo);
4455
+ const [localFieldIdAlertAuthor, localFieldAlertAuthor] = getAlertAuthorToView(fixedInfo);
4456
+ appS.views[newName][localFieldIdAlertAuthor] = localFieldAlertAuthor;
4399
4457
  break;
4400
4458
  case 'sendAlert':
4401
- addSendAlertToView(newName, appS, fixedInfo);
4459
+ const [localFieldIdSendAlert, localFieldSendAlert] = getSendAlertToView(fixedInfo);
4460
+ appS.views[newName][localFieldIdSendAlert] = localFieldSendAlert;
4402
4461
  break;
4403
4462
  case 'publishTo':
4404
- addPublishToToView(newName, appS, fixedInfo);
4463
+ const [localFieldIdPublishTo, localFieldPublishTo] = getPublishToToView(fixedInfo);
4464
+ appS.views[newName][localFieldIdPublishTo] = localFieldPublishTo;
4405
4465
  break;
4406
4466
  default:
4407
4467
  console.error('fixed field info with unsupported ref ', fixedInfo);
@@ -4434,15 +4494,18 @@ function buildFilterView(appS, registeredFields, attrExposed, tables, state) {
4434
4494
  function addFieldToViewFromRef(appS, registeredFields, tables, viewName, fieldRef, index, state) {
4435
4495
  switch (fieldRef) {
4436
4496
  case 'title':
4437
- addTitleToView(viewName, appS, { ref: 'title', fixedValue: undefined });
4497
+ const [fieldIDTitle, fieldInfoTitle] = getTitleToView({ ref: 'title', fixedValue: undefined });
4498
+ appS['views'][viewName][fieldIDTitle] = fieldInfoTitle;
4438
4499
  break;
4439
4500
  case 'iduser':
4440
4501
  case 'idUser':
4441
- addUserToView(viewName, appS);
4502
+ const [fieldIDIdUser, fieldInfoIdUser] = getUserToView();
4503
+ appS['views'][viewName][fieldIDIdUser] = fieldInfoIdUser;
4442
4504
  break;
4443
4505
  case 'datecreation':
4444
4506
  case 'dateCreation':
4445
- addDateCreationToView(viewName, appS);
4507
+ const [fieldIDDateCreation, fieldInfoDateCreation] = getDateCreationToView();
4508
+ appS['views'][viewName][fieldIDDateCreation] = fieldInfoDateCreation;
4446
4509
  break;
4447
4510
  default:
4448
4511
  defaultFieldCreation(appS, registeredFields, tables, viewName, fieldRef, index, state);
@@ -4682,85 +4745,97 @@ function getFormItemType(installedField) {
4682
4745
  ':' +
4683
4746
  JSON.stringify(installedField));
4684
4747
  }
4685
- function addTitleToView(newName, appS, fixedInfo) {
4748
+ function getTitleToView(fixedInfo, isUsed = true) {
4686
4749
  var _a;
4687
- const fieldId = 'title';
4688
- appS.views[newName][fieldId] = {
4689
- type: ExtraAppFieldsItemViews.TITLE,
4690
- properties: [],
4691
- isUsed: true,
4692
- isOptional: false,
4693
- isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
4694
- isFixed: true,
4695
- value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
4696
- pos: 0,
4697
- };
4750
+ return [
4751
+ 'title',
4752
+ {
4753
+ type: ExtraAppFieldsItemViews.TITLE,
4754
+ properties: [],
4755
+ isUsed: isUsed,
4756
+ isOptional: false,
4757
+ isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
4758
+ isFixed: true,
4759
+ value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : null,
4760
+ pos: 0,
4761
+ },
4762
+ ];
4698
4763
  }
4699
- function addAlertAuthorToView(newName, appS, fixedInfo) {
4700
- const fieldId = 'alertAuthor';
4701
- appS.views[newName][fieldId] = {
4702
- type: ExtraAppFieldsItemViews.RECEIVEACOPY,
4703
- properties: [],
4704
- isUsed: true,
4705
- isOptional: true,
4706
- isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
4707
- isFixed: false,
4708
- value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
4709
- pos: 300,
4710
- };
4764
+ function getAlertAuthorToView(fixedInfo, isUsed = true) {
4765
+ return [
4766
+ 'alertAuthor',
4767
+ {
4768
+ type: ExtraAppFieldsItemViews.RECEIVEACOPY,
4769
+ properties: [],
4770
+ isUsed: isUsed,
4771
+ isOptional: true,
4772
+ isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
4773
+ isFixed: false,
4774
+ value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
4775
+ pos: 300,
4776
+ },
4777
+ ];
4711
4778
  }
4712
- function addSendAlertToView(newName, appS, fixedInfo) {
4713
- const fieldId = 'sendAlert';
4714
- appS.views[newName][fieldId] = {
4715
- type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
4716
- properties: [],
4717
- isUsed: true,
4718
- isOptional: true,
4719
- isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
4720
- isFixed: false,
4721
- value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
4722
- pos: 200,
4723
- };
4779
+ function getSendAlertToView(fixedInfo, isUsed = true) {
4780
+ return [
4781
+ 'sendAlert',
4782
+ {
4783
+ type: ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS,
4784
+ properties: [],
4785
+ isUsed: isUsed,
4786
+ isOptional: true,
4787
+ isLockedValue: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined,
4788
+ isFixed: false,
4789
+ value: (fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== undefined ? fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue : true,
4790
+ pos: 200,
4791
+ },
4792
+ ];
4724
4793
  }
4725
- function addPublishToToView(newName, appS, fixedInfo) {
4794
+ function getPublishToToView(fixedInfo, isUsed = true) {
4726
4795
  var _a;
4727
- const fieldId = 'publishTo';
4728
- appS.views[newName][fieldId] = {
4729
- type: ExtraAppFieldsItemViews.PUBLISHTO,
4730
- properties: [],
4731
- isUsed: true,
4732
- isOptional: true,
4733
- isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
4734
- isFixed: false,
4735
- value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : [],
4736
- pos: 100,
4737
- };
4796
+ return [
4797
+ 'publishTo',
4798
+ {
4799
+ type: ExtraAppFieldsItemViews.PUBLISHTO,
4800
+ properties: [],
4801
+ isUsed: isUsed,
4802
+ isOptional: true,
4803
+ isLockedValue: !!(fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue),
4804
+ isFixed: false,
4805
+ value: (_a = fixedInfo === null || fixedInfo === void 0 ? void 0 : fixedInfo.fixedValue) !== null && _a !== void 0 ? _a : [],
4806
+ pos: 100,
4807
+ },
4808
+ ];
4738
4809
  }
4739
- function addUserToView(newName, appS) {
4740
- const fieldId = 'user';
4741
- appS.views[newName][fieldId] = {
4742
- type: ExtraAppFieldsItemViews.USER,
4743
- properties: [],
4744
- isUsed: true,
4745
- isOptional: false,
4746
- isLockedValue: false,
4747
- isFixed: true,
4748
- value: null,
4749
- pos: 1,
4750
- };
4810
+ function getUserToView(isUsed = true) {
4811
+ return [
4812
+ 'user',
4813
+ {
4814
+ type: ExtraAppFieldsItemViews.USER,
4815
+ properties: [],
4816
+ isUsed: isUsed,
4817
+ isOptional: false,
4818
+ isLockedValue: false,
4819
+ isFixed: true,
4820
+ value: null,
4821
+ pos: 1,
4822
+ },
4823
+ ];
4751
4824
  }
4752
- function addDateCreationToView(newName, appS) {
4753
- const fieldId = 'dateCreation';
4754
- appS.views[newName][fieldId] = {
4755
- type: ExtraAppFieldsItemViews.CREATIONDATE,
4756
- properties: [],
4757
- isUsed: true,
4758
- isOptional: true,
4759
- isLockedValue: false,
4760
- isFixed: false,
4761
- value: null,
4762
- pos: 100,
4763
- };
4825
+ function getDateCreationToView(isUsed = true) {
4826
+ return [
4827
+ 'dateCreation',
4828
+ {
4829
+ type: ExtraAppFieldsItemViews.CREATIONDATE,
4830
+ properties: [],
4831
+ isUsed: isUsed,
4832
+ isOptional: true,
4833
+ isLockedValue: false,
4834
+ isFixed: false,
4835
+ value: null,
4836
+ pos: 100,
4837
+ },
4838
+ ];
4764
4839
  }
4765
4840
 
4766
4841
  function InstalledAppStudioAdapter(serverApp, serverApps, state) {