jamespot-front-business 1.1.88 → 1.1.90

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/esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createEntityAdapter, createSlice, createAsyncThunk, combineReducers } from '@reduxjs/toolkit';
2
2
  import { combineReducers as combineReducers$1 } from 'redux';
3
- import jamespot, { jEnsure, formatImgUrl, UserLevel, WidgetsName, StudioApplicationStatus } from 'jamespot-user-api';
3
+ import jamespot, { jEnsure, Format, formatImgUrl, UserLevel, WidgetsName, StudioApplicationStatus } from 'jamespot-user-api';
4
4
  import { v4 } from 'uuid';
5
5
 
6
6
  /******************************************************************************
@@ -97,7 +97,7 @@ const oneMonthAgo$2 = () => {
97
97
  date.setMonth(date.getMonth() - 1);
98
98
  return date;
99
99
  };
100
- const initialState$q = {
100
+ const initialState$r = {
101
101
  data: [],
102
102
  loading: 'idle',
103
103
  page: 1,
@@ -129,7 +129,7 @@ const fetchLogsNavigation = createAsyncThunk('admin/fetchLogsNavigation', (param
129
129
  }));
130
130
  const adminLogsNavigationSlice = createSlice({
131
131
  name: 'logsNavigation',
132
- initialState: initialState$q,
132
+ initialState: initialState$r,
133
133
  reducers: {
134
134
  setNavigationOrder: (state, action) => {
135
135
  state.orders = [...action.payload];
@@ -167,7 +167,7 @@ const oneMonthAgo$1 = () => {
167
167
  date.setMonth(date.getMonth() - 1);
168
168
  return date;
169
169
  };
170
- const initialState$p = {
170
+ const initialState$q = {
171
171
  data: [],
172
172
  loading: 'idle',
173
173
  page: 1,
@@ -199,7 +199,7 @@ const fetchLogsObjects = createAsyncThunk('admin/fetchLogsObjects', (params, { e
199
199
  }));
200
200
  const adminLogsObjectsSlice = createSlice({
201
201
  name: 'logsObjects',
202
- initialState: initialState$p,
202
+ initialState: initialState$q,
203
203
  reducers: {
204
204
  setObjectsOrder: (state, action) => {
205
205
  state.orders = [...action.payload];
@@ -236,7 +236,7 @@ const oneMonthAgo = () => {
236
236
  date.setMonth(date.getMonth() - 1);
237
237
  return date;
238
238
  };
239
- const initialState$o = {
239
+ const initialState$p = {
240
240
  data: [],
241
241
  loading: 'idle',
242
242
  page: 1,
@@ -268,7 +268,7 @@ const fetchLogsSearch = createAsyncThunk('admin/fetchLogsSearch', (params, { ext
268
268
  }));
269
269
  const adminLogsSearchSlice = createSlice({
270
270
  name: 'logsSearch',
271
- initialState: initialState$o,
271
+ initialState: initialState$p,
272
272
  reducers: {
273
273
  setSearchOrder: (state, action) => {
274
274
  state.orders = [...action.payload];
@@ -321,7 +321,7 @@ const AdminLogs = {
321
321
  selectors: { selectAdminLogsNavigation, selectAdminLogsObjects, selectAdminLogsSearch },
322
322
  };
323
323
 
324
- const initialState$n = {
324
+ const initialState$o = {
325
325
  animationConfiguration: null,
326
326
  isActiveForCurrentUser: false,
327
327
  isInitialized: false,
@@ -329,7 +329,7 @@ const initialState$n = {
329
329
  };
330
330
  const animationsListSlice = createSlice({
331
331
  name: 'animationsList',
332
- initialState: initialState$n,
332
+ initialState: initialState$o,
333
333
  reducers: {},
334
334
  extraReducers: (builder) => {
335
335
  builder.addCase(fetchCurrentAnimation.fulfilled, (state, action) => {
@@ -564,7 +564,7 @@ const Application = {
564
564
  selectors: selectors$2,
565
565
  };
566
566
 
567
- const initialState$m = {
567
+ const initialState$n = {
568
568
  entities: [],
569
569
  loading: 'idle',
570
570
  nbResults: 0,
@@ -580,7 +580,7 @@ const fetchBookableAsset = createAsyncThunk('BookableAsset/fetchBookableAsset',
580
580
  }));
581
581
  const BookableAssetSlice = createSlice({
582
582
  name: 'bookableAsset',
583
- initialState: initialState$m,
583
+ initialState: initialState$n,
584
584
  reducers: {},
585
585
  extraReducers: (builder) => {
586
586
  builder
@@ -601,7 +601,7 @@ const BookableAssetSlice = createSlice({
601
601
  const fetchConfiguration = createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
602
602
  return yield extra.jApi.assetReservation.configuration();
603
603
  }));
604
- const initialState$l = {
604
+ const initialState$m = {
605
605
  description: '',
606
606
  right: {
607
607
  manage: false,
@@ -615,7 +615,7 @@ const initialState$l = {
615
615
  };
616
616
  const AssetReservationConfigurationSlice = createSlice({
617
617
  name: 'configuration',
618
- initialState: initialState$l,
618
+ initialState: initialState$m,
619
619
  reducers: {},
620
620
  extraReducers: (builder) => {
621
621
  builder
@@ -636,7 +636,7 @@ const initForm = {
636
636
  hourStart: '',
637
637
  hourEnd: '',
638
638
  };
639
- const initialState$k = {
639
+ const initialState$l = {
640
640
  entities: [],
641
641
  loading: 'idle',
642
642
  nbResults: 0,
@@ -652,7 +652,7 @@ const fetchReservation = createAsyncThunk('Reservation/fetchReservation', (viewM
652
652
  }));
653
653
  const ReservationSlice = createSlice({
654
654
  name: 'reservation',
655
- initialState: initialState$k,
655
+ initialState: initialState$l,
656
656
  reducers: {
657
657
  setForm: (state, action) => {
658
658
  state.form = action.payload;
@@ -708,181 +708,7 @@ const AssetReservation = {
708
708
  },
709
709
  };
710
710
 
711
- const initialState$j = {
712
- loading: 'idle',
713
- comments: [],
714
- };
715
- const fetchComments = createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
716
- var _a;
717
- try {
718
- const res = yield extra.jApi.article.getComments(params, {
719
- format: 'raw-list',
720
- formatExtension: ['socialActions'],
721
- });
722
- return { idArticle: params.idArticle, list: res.result };
723
- }
724
- catch (error) {
725
- dispatch(Toast.actions.error({ label: (_a = error.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
726
- return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
727
- }
728
- }));
729
- const deleteComment = createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
730
- var _b;
731
- try {
732
- yield extra.jApi.article.deleteComment(params.idComment);
733
- return true;
734
- }
735
- catch (error) {
736
- dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
737
- return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
738
- }
739
- }));
740
- const CommentListSlice = createSlice({
741
- name: 'commentList',
742
- initialState: initialState$j,
743
- reducers: {
744
- discardComments: (state, action) => {
745
- state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
746
- },
747
- hydrateComment: (state, action) => {
748
- const { idArticle, list } = action.payload;
749
- const hasList = state.comments.find((c) => c.idArticle === idArticle);
750
- if (!hasList) {
751
- state.comments = [
752
- ...state.comments.filter((c) => c.idArticle !== idArticle),
753
- {
754
- idArticle,
755
- list: Array.isArray(list) ? list : [],
756
- },
757
- ];
758
- return;
759
- }
760
- const initialUris = [];
761
- const allUris = state.comments.reduce((uris, c) => {
762
- return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
763
- }, initialUris);
764
- const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
765
- state.comments = state.comments.map((c) => {
766
- return c.idArticle === idArticle
767
- ? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
768
- });
769
- },
770
- updateComment: (state, action) => {
771
- state.comments = state.comments.map((c) => {
772
- const { idArticle, idComment, data } = action.payload;
773
- return c.idArticle === idArticle
774
- ? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
775
- });
776
- },
777
- },
778
- extraReducers: (builder) => {
779
- builder
780
- .addCase(fetchComments.pending, (state) => {
781
- state.loading = 'pending';
782
- })
783
- .addCase(fetchComments.fulfilled, (state, action) => {
784
- state.loading = 'idle';
785
- state.comments = [
786
- ...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
787
- {
788
- idArticle: action.payload.idArticle,
789
- list: action.payload.list.reverse(),
790
- },
791
- ];
792
- })
793
- .addCase(fetchComments.rejected, (state) => {
794
- state.loading = 'idle';
795
- })
796
- .addCase(deleteComment.pending, (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: true }) : comment) });
802
- });
803
- })
804
- .addCase(deleteComment.rejected, (state, action) => {
805
- state.comments = state.comments.map((c) => {
806
- if (c.idArticle !== action.meta.arg.idArticle) {
807
- return c;
808
- }
809
- 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) });
810
- });
811
- });
812
- },
813
- });
814
-
815
- const getCommentRTHandlers = function (dispatch, idArticle) {
816
- const addCommentHandler = function (message) {
817
- if (message.namespace === 'JAMESPOT' &&
818
- message.function === 'comment-create' &&
819
- message.object.idArticle === idArticle) {
820
- dispatch(fetchComments({ idArticle }));
821
- }
822
- };
823
- const deleteCommentHandler = function (message) {
824
- if (message.namespace === 'JAMESPOT' &&
825
- message.function === 'comment-delete' &&
826
- Number(message.object.idArticle) === idArticle) {
827
- dispatch(fetchComments({ idArticle }));
828
- }
829
- };
830
- return [
831
- {
832
- namespace: 'JAMESPOT',
833
- function: 'comment-create',
834
- handler: addCommentHandler,
835
- },
836
- {
837
- namespace: 'JAMESPOT',
838
- function: 'comment-delete',
839
- handler: deleteCommentHandler,
840
- },
841
- ];
842
- };
843
-
844
- const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
845
- const commentLikeHandler = function (message) {
846
- if (message.namespace === 'CUSTOM-ACTION' &&
847
- (message.function === 'add' || message.function === 'remove') &&
848
- message.object.type === 'sociallike' &&
849
- message.object.targetId &&
850
- idComments &&
851
- idComments.includes(message.object.targetId)) {
852
- dispatch(fetchComments({ idArticle }));
853
- }
854
- };
855
- return idComments
856
- ? [
857
- { namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
858
- { namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
859
- ]
860
- : [];
861
- };
862
-
863
- const CommentReducer = combineReducers$1({
864
- [CommentListSlice.name]: CommentListSlice.reducer,
865
- });
866
- const commentSlice = {
867
- name: 'comment',
868
- reducer: CommentReducer,
869
- };
870
- const selectCommentList = (state, idArticle, limit = 0) => {
871
- const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
872
- const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
873
- return limit !== 0 ? list.slice(-limit) : list;
874
- };
875
- const Comment = {
876
- slice: commentSlice,
877
- actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
878
- selectors: {
879
- commentList: selectCommentList,
880
- },
881
- getCommentRTHandlers,
882
- getCommentsLikeRTHandlers,
883
- };
884
-
885
- const initialState$i = {
711
+ const initialState$k = {
886
712
  loading: 'idle',
887
713
  reports: [],
888
714
  page: 1,
@@ -895,7 +721,7 @@ const initialState$i = {
895
721
  };
896
722
  const contentReportSlice = createSlice({
897
723
  name: 'contentReport',
898
- initialState: initialState$i,
724
+ initialState: initialState$k,
899
725
  reducers: {
900
726
  setTab: (state, action) => {
901
727
  state.tab = action.payload;
@@ -1001,7 +827,7 @@ const ContentReport = {
1001
827
  selectors: { selectContentReport },
1002
828
  };
1003
829
 
1004
- const initialState$h = {
830
+ const initialState$j = {
1005
831
  bookmarks: [],
1006
832
  loading: 'idle',
1007
833
  status: undefined,
@@ -1064,7 +890,7 @@ const deleteBookmark = createAsyncThunk('bookmarkList/deleteBookmark', (bookmark
1064
890
  }));
1065
891
  const BookmarkListSlice = createSlice({
1066
892
  name: 'bookmarkList',
1067
- initialState: initialState$h,
893
+ initialState: initialState$j,
1068
894
  reducers: {
1069
895
  resetAddBookmarkStatus: (state, action) => {
1070
896
  if (state.add[action.payload]) {
@@ -1227,7 +1053,7 @@ const getBookmarkRTHandlers = function (dispatch) {
1227
1053
  ];
1228
1054
  };
1229
1055
 
1230
- const initialState$g = {
1056
+ const initialState$i = {
1231
1057
  bookmark: undefined,
1232
1058
  status: undefined,
1233
1059
  loading: 'idle',
@@ -1249,7 +1075,7 @@ const editBookmark = createAsyncThunk('bookmarkEdit/editBookmark', (bookmark, {
1249
1075
  }));
1250
1076
  const BookmarkEditSlice = createSlice({
1251
1077
  name: 'bookmarkEdit',
1252
- initialState: initialState$g,
1078
+ initialState: initialState$i,
1253
1079
  reducers: {
1254
1080
  setEditBookmark: (state, action) => {
1255
1081
  state.bookmark = Object.assign({}, action.payload);
@@ -1308,6 +1134,407 @@ const Bookmark = {
1308
1134
  getRTHandlers: getBookmarkRTHandlers,
1309
1135
  };
1310
1136
 
1137
+ const initialState$h = {
1138
+ loading: 'idle',
1139
+ comments: [],
1140
+ };
1141
+ const fetchComments = createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1142
+ var _a;
1143
+ try {
1144
+ const res = yield extra.jApi.article.getComments(params, {
1145
+ format: 'raw-list',
1146
+ formatExtension: ['actions'],
1147
+ });
1148
+ return { idArticle: params.idArticle, list: res.result };
1149
+ }
1150
+ catch (error) {
1151
+ dispatch(Toast.actions.error({ label: (_a = error.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
1152
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
1153
+ }
1154
+ }));
1155
+ const deleteComment = createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1156
+ var _b;
1157
+ try {
1158
+ yield extra.jApi.article.deleteComment(params.idComment);
1159
+ return true;
1160
+ }
1161
+ catch (error) {
1162
+ dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
1163
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
1164
+ }
1165
+ }));
1166
+ const CommentListSlice = createSlice({
1167
+ name: 'commentList',
1168
+ initialState: initialState$h,
1169
+ reducers: {
1170
+ discardComments: (state, action) => {
1171
+ state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
1172
+ },
1173
+ hydrateComment: (state, action) => {
1174
+ const { idArticle, list } = action.payload;
1175
+ const hasList = state.comments.find((c) => c.idArticle === idArticle);
1176
+ if (!hasList) {
1177
+ state.comments = [
1178
+ ...state.comments.filter((c) => c.idArticle !== idArticle),
1179
+ {
1180
+ idArticle,
1181
+ list: Array.isArray(list) ? list : [],
1182
+ },
1183
+ ];
1184
+ return;
1185
+ }
1186
+ const initialUris = [];
1187
+ const allUris = state.comments.reduce((uris, c) => {
1188
+ return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
1189
+ }, initialUris);
1190
+ const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
1191
+ state.comments = state.comments.map((c) => {
1192
+ return c.idArticle === idArticle
1193
+ ? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
1194
+ });
1195
+ },
1196
+ updateComment: (state, action) => {
1197
+ state.comments = state.comments.map((c) => {
1198
+ const { idArticle, idComment, data } = action.payload;
1199
+ return c.idArticle === idArticle
1200
+ ? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
1201
+ });
1202
+ },
1203
+ },
1204
+ extraReducers: (builder) => {
1205
+ builder
1206
+ .addCase(fetchComments.pending, (state) => {
1207
+ state.loading = 'pending';
1208
+ })
1209
+ .addCase(fetchComments.fulfilled, (state, action) => {
1210
+ state.loading = 'idle';
1211
+ state.comments = [
1212
+ ...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
1213
+ {
1214
+ idArticle: action.payload.idArticle,
1215
+ list: action.payload.list.reverse(),
1216
+ },
1217
+ ];
1218
+ })
1219
+ .addCase(fetchComments.rejected, (state) => {
1220
+ state.loading = 'idle';
1221
+ })
1222
+ .addCase(deleteComment.pending, (state, action) => {
1223
+ state.comments = state.comments.map((c) => {
1224
+ if (c.idArticle !== action.meta.arg.idArticle) {
1225
+ return c;
1226
+ }
1227
+ 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) });
1228
+ });
1229
+ })
1230
+ .addCase(deleteComment.rejected, (state, action) => {
1231
+ state.comments = state.comments.map((c) => {
1232
+ if (c.idArticle !== action.meta.arg.idArticle) {
1233
+ return c;
1234
+ }
1235
+ 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) });
1236
+ });
1237
+ });
1238
+ },
1239
+ });
1240
+
1241
+ const getCommentRTHandlers = function (dispatch, idArticle) {
1242
+ const addCommentHandler = function (message) {
1243
+ if (message.namespace === 'JAMESPOT' &&
1244
+ message.function === 'comment-create' &&
1245
+ message.object.idArticle === idArticle) {
1246
+ dispatch(fetchComments({ idArticle }));
1247
+ }
1248
+ };
1249
+ const deleteCommentHandler = function (message) {
1250
+ if (message.namespace === 'JAMESPOT' &&
1251
+ message.function === 'comment-delete' &&
1252
+ Number(message.object.idArticle) === idArticle) {
1253
+ dispatch(fetchComments({ idArticle }));
1254
+ }
1255
+ };
1256
+ return [
1257
+ {
1258
+ namespace: 'JAMESPOT',
1259
+ function: 'comment-create',
1260
+ handler: addCommentHandler,
1261
+ },
1262
+ {
1263
+ namespace: 'JAMESPOT',
1264
+ function: 'comment-delete',
1265
+ handler: deleteCommentHandler,
1266
+ },
1267
+ ];
1268
+ };
1269
+
1270
+ const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
1271
+ const commentLikeHandler = function (message) {
1272
+ if (message.namespace === 'CUSTOM-ACTION' &&
1273
+ (message.function === 'add' || message.function === 'remove') &&
1274
+ message.object.type === 'sociallike' &&
1275
+ message.object.targetId &&
1276
+ idComments &&
1277
+ idComments.includes(message.object.targetId)) {
1278
+ dispatch(fetchComments({ idArticle }));
1279
+ }
1280
+ };
1281
+ return idComments
1282
+ ? [
1283
+ { namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
1284
+ { namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
1285
+ ]
1286
+ : [];
1287
+ };
1288
+
1289
+ const CommentReducer = combineReducers$1({
1290
+ [CommentListSlice.name]: CommentListSlice.reducer,
1291
+ });
1292
+ const commentSlice = {
1293
+ name: 'comment',
1294
+ reducer: CommentReducer,
1295
+ };
1296
+ const selectCommentList = (state, idArticle, limit = 0) => {
1297
+ const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
1298
+ const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
1299
+ return limit !== 0 ? list.slice(-limit) : list;
1300
+ };
1301
+ const Comment = {
1302
+ slice: commentSlice,
1303
+ actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
1304
+ selectors: {
1305
+ commentList: selectCommentList,
1306
+ },
1307
+ getCommentRTHandlers,
1308
+ getCommentsLikeRTHandlers,
1309
+ };
1310
+
1311
+ const ExtraBotConst = {
1312
+ route: 'extra-bot',
1313
+ moduleName: 'ExtraBotHook',
1314
+ configurationType: 'extraBot',
1315
+ listLimit: 20,
1316
+ listDefaultPage: 1,
1317
+ };
1318
+
1319
+ const initialState$g = {
1320
+ global: {
1321
+ loading: 'idle',
1322
+ },
1323
+ listAll: {
1324
+ loading: 'idle',
1325
+ data: [],
1326
+ limit: ExtraBotConst.listLimit,
1327
+ nbResults: 0,
1328
+ page: ExtraBotConst.listDefaultPage,
1329
+ filters: [],
1330
+ orders: [],
1331
+ },
1332
+ listMines: {
1333
+ loading: 'idle',
1334
+ data: [],
1335
+ limit: ExtraBotConst.listLimit,
1336
+ nbResults: 0,
1337
+ page: ExtraBotConst.listDefaultPage,
1338
+ filters: [],
1339
+ orders: [],
1340
+ },
1341
+ formModal: {
1342
+ open: false,
1343
+ mode: 'create',
1344
+ type: 'all',
1345
+ extraBot: undefined,
1346
+ },
1347
+ };
1348
+ const fetchExtraBotListAll = createAsyncThunk('extraBot/fetchAll', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
1349
+ const state = getState().extraBot.listAll;
1350
+ try {
1351
+ return (yield extra.jApi.extraBot.list('all', {
1352
+ limit: state.limit,
1353
+ page: state.page,
1354
+ filters: state.filters,
1355
+ orders: state.orders,
1356
+ })).result;
1357
+ }
1358
+ catch (err) {
1359
+ if (!isAbortError(err)) {
1360
+ dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
1361
+ }
1362
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
1363
+ }
1364
+ }));
1365
+ const fetchExtraBotListMines = createAsyncThunk('extraBot/fetchMines', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
1366
+ const state = getState().extraBot.listMines;
1367
+ try {
1368
+ return (yield extra.jApi.extraBot.list('mines', {
1369
+ limit: state.limit,
1370
+ page: state.page,
1371
+ filters: state.filters,
1372
+ orders: state.orders,
1373
+ })).result;
1374
+ }
1375
+ catch (err) {
1376
+ if (!isAbortError(err)) {
1377
+ dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
1378
+ }
1379
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
1380
+ }
1381
+ }));
1382
+ const toggleExtraBotActivation = createAsyncThunk('extraBot/toggleActivation', (extraBot, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1383
+ try {
1384
+ const enabled = !extraBot.enabled;
1385
+ const res = (yield extra.jApi.article.update(Object.assign(Object.assign({}, extraBot), { enabled }), { format: Format.VIEW })).result;
1386
+ dispatch(Toast.actions.success({
1387
+ label: enabled ? 'APP_ExtraBot_Toast_ActivationSuccess' : 'APP_ExtraBot_Toast_DeactivationSuccess',
1388
+ }));
1389
+ return res;
1390
+ }
1391
+ catch (err) {
1392
+ if (!isAbortError(err)) {
1393
+ dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
1394
+ }
1395
+ return rejectWithValue({ error: 1, errorMsg: 'Failed to change extra bot activation' });
1396
+ }
1397
+ }));
1398
+ const saveExtraBot = createAsyncThunk('extraBot/save', ({ extraBot }, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1399
+ try {
1400
+ const data = Object.assign(Object.assign({}, extraBot), { type: ExtraBotConst.configurationType, publishTo: '' });
1401
+ let res;
1402
+ let user;
1403
+ delete data.avatar;
1404
+ if (extraBot.uri) {
1405
+ res = (yield extra.jApi.article.update(data, { format: Format.VIEW }))
1406
+ .result;
1407
+ user = (yield extra.jApi.extraBot.updateBot(res.uri)).result;
1408
+ }
1409
+ else {
1410
+ res = (yield extra.jApi.article.create(Object.assign({}, data), Format.VIEW)).result[0];
1411
+ if (!res) {
1412
+ throw new Error('ExtraBot configuration creation failed');
1413
+ }
1414
+ user = (yield extra.jApi.extraBot.createBot(res.uri)).result;
1415
+ res._user = user;
1416
+ }
1417
+ const label = extraBot.uri ? 'APP_ExtraBot_Toast_SaveEdit' : 'APP_ExtraBot_Toast_SaveCreate';
1418
+ dispatch(Toast.actions.success({ label }));
1419
+ return res;
1420
+ }
1421
+ catch (err) {
1422
+ if (!isAbortError(err)) {
1423
+ dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
1424
+ }
1425
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot' });
1426
+ }
1427
+ }));
1428
+ const updateListBotProperty = (state, extraBotUri, property, value) => {
1429
+ const listAllExtraBot = state.listAll.data.find((eb) => eb.uri === extraBotUri);
1430
+ const listMinesExtraBot = state.listMines.data.find((eb) => eb.uri === extraBotUri);
1431
+ if (listAllExtraBot) {
1432
+ listAllExtraBot[property] = value;
1433
+ }
1434
+ if (listMinesExtraBot) {
1435
+ listMinesExtraBot[property] = value;
1436
+ }
1437
+ };
1438
+ const extraBotSlice = createSlice({
1439
+ name: 'extraBot',
1440
+ initialState: initialState$g,
1441
+ reducers: {
1442
+ setListAllOrder: (state, action) => {
1443
+ state.listAll.orders = [...action.payload];
1444
+ state.listAll.page = ExtraBotConst.listDefaultPage;
1445
+ },
1446
+ setListAllFilter: (state, action) => {
1447
+ state.listAll.filters = [...action.payload];
1448
+ state.listAll.page = ExtraBotConst.listDefaultPage;
1449
+ },
1450
+ setListAllPage: (state, action) => {
1451
+ state.listAll.page = action.payload;
1452
+ },
1453
+ setListMinesOrder: (state, action) => {
1454
+ state.listMines.orders = [...action.payload];
1455
+ state.listMines.page = ExtraBotConst.listDefaultPage;
1456
+ },
1457
+ setListMinesFilter: (state, action) => {
1458
+ state.listMines.filters = [...action.payload];
1459
+ state.listMines.page = ExtraBotConst.listDefaultPage;
1460
+ },
1461
+ setListMinesPage: (state, action) => {
1462
+ state.listMines.page = action.payload;
1463
+ },
1464
+ openFormModal: (state, action) => {
1465
+ state.formModal.open = true;
1466
+ state.formModal.mode = action.payload.mode;
1467
+ state.formModal.type = action.payload.type;
1468
+ state.formModal.extraBot = action.payload.extraBot;
1469
+ },
1470
+ closeFormModal: (state) => {
1471
+ state.formModal.open = false;
1472
+ },
1473
+ },
1474
+ extraReducers: (builder) => {
1475
+ builder
1476
+ .addCase(fetchExtraBotListAll.pending, (state) => {
1477
+ state.listAll.loading = 'pending';
1478
+ })
1479
+ .addCase(fetchExtraBotListAll.fulfilled, (state, action) => {
1480
+ var _a;
1481
+ state.listAll.data = action.payload.data;
1482
+ state.listAll.nbResults = action.payload.cnt;
1483
+ state.listAll.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
1484
+ state.listAll.page = action.payload.page;
1485
+ state.listAll.loading = 'idle';
1486
+ })
1487
+ .addCase(fetchExtraBotListAll.rejected, (state) => {
1488
+ state.listAll.loading = 'idle';
1489
+ })
1490
+ .addCase(fetchExtraBotListMines.pending, (state) => {
1491
+ state.listMines.loading = 'pending';
1492
+ })
1493
+ .addCase(fetchExtraBotListMines.fulfilled, (state, action) => {
1494
+ var _a;
1495
+ state.listMines.data = action.payload.data;
1496
+ state.listMines.nbResults = action.payload.cnt;
1497
+ state.listMines.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
1498
+ state.listMines.page = action.payload.page;
1499
+ state.listMines.loading = 'idle';
1500
+ })
1501
+ .addCase(fetchExtraBotListMines.rejected, (state) => {
1502
+ state.listMines.loading = 'idle';
1503
+ })
1504
+ .addCase(toggleExtraBotActivation.pending, (state) => {
1505
+ state.global.loading = 'pending';
1506
+ })
1507
+ .addCase(toggleExtraBotActivation.fulfilled, (state, action) => {
1508
+ state.global.loading = 'idle';
1509
+ const extraBot = action.payload;
1510
+ updateListBotProperty(state, extraBot.uri, 'enabled', extraBot.enabled);
1511
+ })
1512
+ .addCase(toggleExtraBotActivation.rejected, (state) => {
1513
+ state.global.loading = 'idle';
1514
+ })
1515
+ .addCase(saveExtraBot.pending, (state) => {
1516
+ state.global.loading = 'pending';
1517
+ })
1518
+ .addCase(saveExtraBot.fulfilled, (state, _action) => {
1519
+ state.global.loading = 'idle';
1520
+ state.formModal.open = false;
1521
+ })
1522
+ .addCase(saveExtraBot.rejected, (state) => {
1523
+ state.global.loading = 'idle';
1524
+ });
1525
+ },
1526
+ });
1527
+ const selectExtraBotListAll = (state) => state.extraBot.listAll;
1528
+ const selectExtraBotListMines = (state) => state.extraBot.listMines;
1529
+ const ExtraBot = {
1530
+ slice: extraBotSlice,
1531
+ actions: Object.assign({ fetchExtraBotListAll,
1532
+ fetchExtraBotListMines,
1533
+ toggleExtraBotActivation,
1534
+ saveExtraBot }, extraBotSlice.actions),
1535
+ selectors: { selectExtraBotListAll, selectExtraBotListMines },
1536
+ };
1537
+
1311
1538
  const initialState$f = {
1312
1539
  loading: 'idle',
1313
1540
  access: { createCategory: false },
@@ -4184,19 +4411,18 @@ function renderWidget(fieldType, fieldProperties) {
4184
4411
  return '';
4185
4412
  const isMultiple = optionEditor.value.canSelectMultiple;
4186
4413
  const options = optionEditor.value.propertyOptions;
4187
- const hasDefaultValue = optionEditor.value.defaultSelectOption;
4188
- const defaultValue = optionEditor.value.defaultSelectOptionValue.value;
4189
- const userCanModifiyByComment = optionEditor.value.userCanModifiyByComment;
4414
+ const hasDefaultValue = optionEditor.value.defaultSelectOption && optionEditor.value.defaultSelectOptionValue.value;
4415
+ const userCanModifyByComment = optionEditor.value.userCanModifyByComment;
4190
4416
  return `<widget form="select" ${isMultiple ? 'multiple="1"' : ''}>
4191
4417
  <options>
4192
4418
  ${options
4193
4419
  .map((option) => `<option value="${option.value}" label="${option.title}"></option>`)
4194
4420
  .join('')}
4195
4421
  </options>
4196
- ${hasDefaultValue || userCanModifiyByComment
4422
+ ${hasDefaultValue || userCanModifyByComment
4197
4423
  ? `<params>
4198
- ${hasDefaultValue ? `<param key="defaultValue" value="${defaultValue}"/>` : ''}
4199
- ${userCanModifiyByComment ? `<param key="explain" value="1"/>` : ''}
4424
+ ${hasDefaultValue ? `<param key="defaultValue" value="${optionEditor.value.defaultSelectOptionValue.value}"/>` : ''}
4425
+ ${userCanModifyByComment ? `<param key="explain" value="1"/>` : ''}
4200
4426
  </params>`
4201
4427
  : ''}
4202
4428
  </widget>`;
@@ -4486,12 +4712,12 @@ function renderDisplayAttr(fieldId, view) {
4486
4712
  }
4487
4713
  else if (view.type === ExtraAppFieldsItemViews.RECEIVEACOPY) {
4488
4714
  if (view.value) {
4489
- xml += `<input type="hidden" name="alertAuthor[jamespot]"><input type="hidden" name="alertAuthor[]" value="1">`;
4715
+ xml += `<input type="hidden" name="alertAuthor[jamespot]"><input type="hidden" ng-model="form.alertAuthor" name="alertAuthor[]" value="1">`;
4490
4716
  }
4491
4717
  }
4492
4718
  else if (view.type === ExtraAppFieldsItemViews.SENDALERTTOSUBSCRIBERS) {
4493
4719
  if (view.value) {
4494
- xml += `<input type="hidden" name="sendAlert[jamespot]"><input type="hidden" name="sendAlert[]" value="1">`;
4720
+ xml += `<input type="hidden" name="sendAlert[jamespot]"><input type="hidden" ng-model="form.sendAlert" name="sendAlert[]" value="1">`;
4495
4721
  }
4496
4722
  }
4497
4723
  else {
@@ -5752,5 +5978,5 @@ const studio = {
5752
5978
  },
5753
5979
  };
5754
5980
 
5755
- export { APP_STATUS_TYPE, AUDIENCE, AdminLogs, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, ContentReport, Description, Element, ExtraAppFieldsItemViews, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, adminLogsReducer, adminLogsSlice, animationsReducer, animationsSlice, contentReportSlice, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, fetchReports, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, slice$1 as slice, studio, updateStatus, updateWidgetContent, viewsList };
5981
+ export { APP_STATUS_TYPE, AUDIENCE, AdminLogs, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, ContentReport, Description, Element, ExtraAppFieldsItemViews, ExtraBot, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, adminLogsReducer, adminLogsSlice, animationsReducer, animationsSlice, contentReportSlice, extraBotSlice, fetchExtraBotListAll, fetchExtraBotListMines, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, fetchReports, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, saveExtraBot, selectExtraBotListAll, selectExtraBotListMines, slice$1 as slice, studio, toggleExtraBotActivation, updateListBotProperty, updateStatus, updateWidgetContent, viewsList };
5756
5982
  //# sourceMappingURL=esm.js.map