jamespot-front-business 1.1.89 → 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/cjs.js +430 -194
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +423 -196
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +5938 -2011
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -105,7 +105,7 @@ const oneMonthAgo$2 = () => {
|
|
|
105
105
|
date.setMonth(date.getMonth() - 1);
|
|
106
106
|
return date;
|
|
107
107
|
};
|
|
108
|
-
const initialState$
|
|
108
|
+
const initialState$r = {
|
|
109
109
|
data: [],
|
|
110
110
|
loading: 'idle',
|
|
111
111
|
page: 1,
|
|
@@ -137,7 +137,7 @@ const fetchLogsNavigation = toolkit.createAsyncThunk('admin/fetchLogsNavigation'
|
|
|
137
137
|
}));
|
|
138
138
|
const adminLogsNavigationSlice = toolkit.createSlice({
|
|
139
139
|
name: 'logsNavigation',
|
|
140
|
-
initialState: initialState$
|
|
140
|
+
initialState: initialState$r,
|
|
141
141
|
reducers: {
|
|
142
142
|
setNavigationOrder: (state, action) => {
|
|
143
143
|
state.orders = [...action.payload];
|
|
@@ -175,7 +175,7 @@ const oneMonthAgo$1 = () => {
|
|
|
175
175
|
date.setMonth(date.getMonth() - 1);
|
|
176
176
|
return date;
|
|
177
177
|
};
|
|
178
|
-
const initialState$
|
|
178
|
+
const initialState$q = {
|
|
179
179
|
data: [],
|
|
180
180
|
loading: 'idle',
|
|
181
181
|
page: 1,
|
|
@@ -207,7 +207,7 @@ const fetchLogsObjects = toolkit.createAsyncThunk('admin/fetchLogsObjects', (par
|
|
|
207
207
|
}));
|
|
208
208
|
const adminLogsObjectsSlice = toolkit.createSlice({
|
|
209
209
|
name: 'logsObjects',
|
|
210
|
-
initialState: initialState$
|
|
210
|
+
initialState: initialState$q,
|
|
211
211
|
reducers: {
|
|
212
212
|
setObjectsOrder: (state, action) => {
|
|
213
213
|
state.orders = [...action.payload];
|
|
@@ -244,7 +244,7 @@ const oneMonthAgo = () => {
|
|
|
244
244
|
date.setMonth(date.getMonth() - 1);
|
|
245
245
|
return date;
|
|
246
246
|
};
|
|
247
|
-
const initialState$
|
|
247
|
+
const initialState$p = {
|
|
248
248
|
data: [],
|
|
249
249
|
loading: 'idle',
|
|
250
250
|
page: 1,
|
|
@@ -276,7 +276,7 @@ const fetchLogsSearch = toolkit.createAsyncThunk('admin/fetchLogsSearch', (param
|
|
|
276
276
|
}));
|
|
277
277
|
const adminLogsSearchSlice = toolkit.createSlice({
|
|
278
278
|
name: 'logsSearch',
|
|
279
|
-
initialState: initialState$
|
|
279
|
+
initialState: initialState$p,
|
|
280
280
|
reducers: {
|
|
281
281
|
setSearchOrder: (state, action) => {
|
|
282
282
|
state.orders = [...action.payload];
|
|
@@ -329,7 +329,7 @@ const AdminLogs = {
|
|
|
329
329
|
selectors: { selectAdminLogsNavigation, selectAdminLogsObjects, selectAdminLogsSearch },
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
const initialState$
|
|
332
|
+
const initialState$o = {
|
|
333
333
|
animationConfiguration: null,
|
|
334
334
|
isActiveForCurrentUser: false,
|
|
335
335
|
isInitialized: false,
|
|
@@ -337,7 +337,7 @@ const initialState$n = {
|
|
|
337
337
|
};
|
|
338
338
|
const animationsListSlice = toolkit.createSlice({
|
|
339
339
|
name: 'animationsList',
|
|
340
|
-
initialState: initialState$
|
|
340
|
+
initialState: initialState$o,
|
|
341
341
|
reducers: {},
|
|
342
342
|
extraReducers: (builder) => {
|
|
343
343
|
builder.addCase(fetchCurrentAnimation.fulfilled, (state, action) => {
|
|
@@ -572,7 +572,7 @@ const Application = {
|
|
|
572
572
|
selectors: selectors$2,
|
|
573
573
|
};
|
|
574
574
|
|
|
575
|
-
const initialState$
|
|
575
|
+
const initialState$n = {
|
|
576
576
|
entities: [],
|
|
577
577
|
loading: 'idle',
|
|
578
578
|
nbResults: 0,
|
|
@@ -588,7 +588,7 @@ const fetchBookableAsset = toolkit.createAsyncThunk('BookableAsset/fetchBookable
|
|
|
588
588
|
}));
|
|
589
589
|
const BookableAssetSlice = toolkit.createSlice({
|
|
590
590
|
name: 'bookableAsset',
|
|
591
|
-
initialState: initialState$
|
|
591
|
+
initialState: initialState$n,
|
|
592
592
|
reducers: {},
|
|
593
593
|
extraReducers: (builder) => {
|
|
594
594
|
builder
|
|
@@ -609,7 +609,7 @@ const BookableAssetSlice = toolkit.createSlice({
|
|
|
609
609
|
const fetchConfiguration = toolkit.createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
610
610
|
return yield extra.jApi.assetReservation.configuration();
|
|
611
611
|
}));
|
|
612
|
-
const initialState$
|
|
612
|
+
const initialState$m = {
|
|
613
613
|
description: '',
|
|
614
614
|
right: {
|
|
615
615
|
manage: false,
|
|
@@ -623,7 +623,7 @@ const initialState$l = {
|
|
|
623
623
|
};
|
|
624
624
|
const AssetReservationConfigurationSlice = toolkit.createSlice({
|
|
625
625
|
name: 'configuration',
|
|
626
|
-
initialState: initialState$
|
|
626
|
+
initialState: initialState$m,
|
|
627
627
|
reducers: {},
|
|
628
628
|
extraReducers: (builder) => {
|
|
629
629
|
builder
|
|
@@ -644,7 +644,7 @@ const initForm = {
|
|
|
644
644
|
hourStart: '',
|
|
645
645
|
hourEnd: '',
|
|
646
646
|
};
|
|
647
|
-
const initialState$
|
|
647
|
+
const initialState$l = {
|
|
648
648
|
entities: [],
|
|
649
649
|
loading: 'idle',
|
|
650
650
|
nbResults: 0,
|
|
@@ -660,7 +660,7 @@ const fetchReservation = toolkit.createAsyncThunk('Reservation/fetchReservation'
|
|
|
660
660
|
}));
|
|
661
661
|
const ReservationSlice = toolkit.createSlice({
|
|
662
662
|
name: 'reservation',
|
|
663
|
-
initialState: initialState$
|
|
663
|
+
initialState: initialState$l,
|
|
664
664
|
reducers: {
|
|
665
665
|
setForm: (state, action) => {
|
|
666
666
|
state.form = action.payload;
|
|
@@ -716,181 +716,7 @@ const AssetReservation = {
|
|
|
716
716
|
},
|
|
717
717
|
};
|
|
718
718
|
|
|
719
|
-
const initialState$
|
|
720
|
-
loading: 'idle',
|
|
721
|
-
comments: [],
|
|
722
|
-
};
|
|
723
|
-
const fetchComments = toolkit.createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
724
|
-
var _a;
|
|
725
|
-
try {
|
|
726
|
-
const res = yield extra.jApi.article.getComments(params, {
|
|
727
|
-
format: 'raw-list',
|
|
728
|
-
formatExtension: ['actions'],
|
|
729
|
-
});
|
|
730
|
-
return { idArticle: params.idArticle, list: res.result };
|
|
731
|
-
}
|
|
732
|
-
catch (error) {
|
|
733
|
-
dispatch(Toast.actions.error({ label: (_a = error.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
|
|
734
|
-
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
|
|
735
|
-
}
|
|
736
|
-
}));
|
|
737
|
-
const deleteComment = toolkit.createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
738
|
-
var _b;
|
|
739
|
-
try {
|
|
740
|
-
yield extra.jApi.article.deleteComment(params.idComment);
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
catch (error) {
|
|
744
|
-
dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
|
|
745
|
-
return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
|
|
746
|
-
}
|
|
747
|
-
}));
|
|
748
|
-
const CommentListSlice = toolkit.createSlice({
|
|
749
|
-
name: 'commentList',
|
|
750
|
-
initialState: initialState$j,
|
|
751
|
-
reducers: {
|
|
752
|
-
discardComments: (state, action) => {
|
|
753
|
-
state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
|
|
754
|
-
},
|
|
755
|
-
hydrateComment: (state, action) => {
|
|
756
|
-
const { idArticle, list } = action.payload;
|
|
757
|
-
const hasList = state.comments.find((c) => c.idArticle === idArticle);
|
|
758
|
-
if (!hasList) {
|
|
759
|
-
state.comments = [
|
|
760
|
-
...state.comments.filter((c) => c.idArticle !== idArticle),
|
|
761
|
-
{
|
|
762
|
-
idArticle,
|
|
763
|
-
list: Array.isArray(list) ? list : [],
|
|
764
|
-
},
|
|
765
|
-
];
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
const initialUris = [];
|
|
769
|
-
const allUris = state.comments.reduce((uris, c) => {
|
|
770
|
-
return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
|
|
771
|
-
}, initialUris);
|
|
772
|
-
const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
|
|
773
|
-
state.comments = state.comments.map((c) => {
|
|
774
|
-
return c.idArticle === idArticle
|
|
775
|
-
? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
|
|
776
|
-
});
|
|
777
|
-
},
|
|
778
|
-
updateComment: (state, action) => {
|
|
779
|
-
state.comments = state.comments.map((c) => {
|
|
780
|
-
const { idArticle, idComment, data } = action.payload;
|
|
781
|
-
return c.idArticle === idArticle
|
|
782
|
-
? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
|
|
783
|
-
});
|
|
784
|
-
},
|
|
785
|
-
},
|
|
786
|
-
extraReducers: (builder) => {
|
|
787
|
-
builder
|
|
788
|
-
.addCase(fetchComments.pending, (state) => {
|
|
789
|
-
state.loading = 'pending';
|
|
790
|
-
})
|
|
791
|
-
.addCase(fetchComments.fulfilled, (state, action) => {
|
|
792
|
-
state.loading = 'idle';
|
|
793
|
-
state.comments = [
|
|
794
|
-
...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
|
|
795
|
-
{
|
|
796
|
-
idArticle: action.payload.idArticle,
|
|
797
|
-
list: action.payload.list.reverse(),
|
|
798
|
-
},
|
|
799
|
-
];
|
|
800
|
-
})
|
|
801
|
-
.addCase(fetchComments.rejected, (state) => {
|
|
802
|
-
state.loading = 'idle';
|
|
803
|
-
})
|
|
804
|
-
.addCase(deleteComment.pending, (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: true }) : comment) });
|
|
810
|
-
});
|
|
811
|
-
})
|
|
812
|
-
.addCase(deleteComment.rejected, (state, action) => {
|
|
813
|
-
state.comments = state.comments.map((c) => {
|
|
814
|
-
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
815
|
-
return c;
|
|
816
|
-
}
|
|
817
|
-
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) });
|
|
818
|
-
});
|
|
819
|
-
});
|
|
820
|
-
},
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
const getCommentRTHandlers = function (dispatch, idArticle) {
|
|
824
|
-
const addCommentHandler = function (message) {
|
|
825
|
-
if (message.namespace === 'JAMESPOT' &&
|
|
826
|
-
message.function === 'comment-create' &&
|
|
827
|
-
message.object.idArticle === idArticle) {
|
|
828
|
-
dispatch(fetchComments({ idArticle }));
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
|
-
const deleteCommentHandler = function (message) {
|
|
832
|
-
if (message.namespace === 'JAMESPOT' &&
|
|
833
|
-
message.function === 'comment-delete' &&
|
|
834
|
-
Number(message.object.idArticle) === idArticle) {
|
|
835
|
-
dispatch(fetchComments({ idArticle }));
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
return [
|
|
839
|
-
{
|
|
840
|
-
namespace: 'JAMESPOT',
|
|
841
|
-
function: 'comment-create',
|
|
842
|
-
handler: addCommentHandler,
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
namespace: 'JAMESPOT',
|
|
846
|
-
function: 'comment-delete',
|
|
847
|
-
handler: deleteCommentHandler,
|
|
848
|
-
},
|
|
849
|
-
];
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
|
|
853
|
-
const commentLikeHandler = function (message) {
|
|
854
|
-
if (message.namespace === 'CUSTOM-ACTION' &&
|
|
855
|
-
(message.function === 'add' || message.function === 'remove') &&
|
|
856
|
-
message.object.type === 'sociallike' &&
|
|
857
|
-
message.object.targetId &&
|
|
858
|
-
idComments &&
|
|
859
|
-
idComments.includes(message.object.targetId)) {
|
|
860
|
-
dispatch(fetchComments({ idArticle }));
|
|
861
|
-
}
|
|
862
|
-
};
|
|
863
|
-
return idComments
|
|
864
|
-
? [
|
|
865
|
-
{ namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
|
|
866
|
-
{ namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
|
|
867
|
-
]
|
|
868
|
-
: [];
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
const CommentReducer = redux.combineReducers({
|
|
872
|
-
[CommentListSlice.name]: CommentListSlice.reducer,
|
|
873
|
-
});
|
|
874
|
-
const commentSlice = {
|
|
875
|
-
name: 'comment',
|
|
876
|
-
reducer: CommentReducer,
|
|
877
|
-
};
|
|
878
|
-
const selectCommentList = (state, idArticle, limit = 0) => {
|
|
879
|
-
const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
|
|
880
|
-
const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
|
|
881
|
-
return limit !== 0 ? list.slice(-limit) : list;
|
|
882
|
-
};
|
|
883
|
-
const Comment = {
|
|
884
|
-
slice: commentSlice,
|
|
885
|
-
actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
|
|
886
|
-
selectors: {
|
|
887
|
-
commentList: selectCommentList,
|
|
888
|
-
},
|
|
889
|
-
getCommentRTHandlers,
|
|
890
|
-
getCommentsLikeRTHandlers,
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
const initialState$i = {
|
|
719
|
+
const initialState$k = {
|
|
894
720
|
loading: 'idle',
|
|
895
721
|
reports: [],
|
|
896
722
|
page: 1,
|
|
@@ -903,7 +729,7 @@ const initialState$i = {
|
|
|
903
729
|
};
|
|
904
730
|
const contentReportSlice = toolkit.createSlice({
|
|
905
731
|
name: 'contentReport',
|
|
906
|
-
initialState: initialState$
|
|
732
|
+
initialState: initialState$k,
|
|
907
733
|
reducers: {
|
|
908
734
|
setTab: (state, action) => {
|
|
909
735
|
state.tab = action.payload;
|
|
@@ -1009,7 +835,7 @@ const ContentReport = {
|
|
|
1009
835
|
selectors: { selectContentReport },
|
|
1010
836
|
};
|
|
1011
837
|
|
|
1012
|
-
const initialState$
|
|
838
|
+
const initialState$j = {
|
|
1013
839
|
bookmarks: [],
|
|
1014
840
|
loading: 'idle',
|
|
1015
841
|
status: undefined,
|
|
@@ -1072,7 +898,7 @@ const deleteBookmark = toolkit.createAsyncThunk('bookmarkList/deleteBookmark', (
|
|
|
1072
898
|
}));
|
|
1073
899
|
const BookmarkListSlice = toolkit.createSlice({
|
|
1074
900
|
name: 'bookmarkList',
|
|
1075
|
-
initialState: initialState$
|
|
901
|
+
initialState: initialState$j,
|
|
1076
902
|
reducers: {
|
|
1077
903
|
resetAddBookmarkStatus: (state, action) => {
|
|
1078
904
|
if (state.add[action.payload]) {
|
|
@@ -1235,7 +1061,7 @@ const getBookmarkRTHandlers = function (dispatch) {
|
|
|
1235
1061
|
];
|
|
1236
1062
|
};
|
|
1237
1063
|
|
|
1238
|
-
const initialState$
|
|
1064
|
+
const initialState$i = {
|
|
1239
1065
|
bookmark: undefined,
|
|
1240
1066
|
status: undefined,
|
|
1241
1067
|
loading: 'idle',
|
|
@@ -1257,7 +1083,7 @@ const editBookmark = toolkit.createAsyncThunk('bookmarkEdit/editBookmark', (book
|
|
|
1257
1083
|
}));
|
|
1258
1084
|
const BookmarkEditSlice = toolkit.createSlice({
|
|
1259
1085
|
name: 'bookmarkEdit',
|
|
1260
|
-
initialState: initialState$
|
|
1086
|
+
initialState: initialState$i,
|
|
1261
1087
|
reducers: {
|
|
1262
1088
|
setEditBookmark: (state, action) => {
|
|
1263
1089
|
state.bookmark = Object.assign({}, action.payload);
|
|
@@ -1316,6 +1142,407 @@ const Bookmark = {
|
|
|
1316
1142
|
getRTHandlers: getBookmarkRTHandlers,
|
|
1317
1143
|
};
|
|
1318
1144
|
|
|
1145
|
+
const initialState$h = {
|
|
1146
|
+
loading: 'idle',
|
|
1147
|
+
comments: [],
|
|
1148
|
+
};
|
|
1149
|
+
const fetchComments = toolkit.createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1150
|
+
var _a;
|
|
1151
|
+
try {
|
|
1152
|
+
const res = yield extra.jApi.article.getComments(params, {
|
|
1153
|
+
format: 'raw-list',
|
|
1154
|
+
formatExtension: ['actions'],
|
|
1155
|
+
});
|
|
1156
|
+
return { idArticle: params.idArticle, list: res.result };
|
|
1157
|
+
}
|
|
1158
|
+
catch (error) {
|
|
1159
|
+
dispatch(Toast.actions.error({ label: (_a = error.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
|
|
1160
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
|
|
1161
|
+
}
|
|
1162
|
+
}));
|
|
1163
|
+
const deleteComment = toolkit.createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1164
|
+
var _b;
|
|
1165
|
+
try {
|
|
1166
|
+
yield extra.jApi.article.deleteComment(params.idComment);
|
|
1167
|
+
return true;
|
|
1168
|
+
}
|
|
1169
|
+
catch (error) {
|
|
1170
|
+
dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
|
|
1171
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
|
|
1172
|
+
}
|
|
1173
|
+
}));
|
|
1174
|
+
const CommentListSlice = toolkit.createSlice({
|
|
1175
|
+
name: 'commentList',
|
|
1176
|
+
initialState: initialState$h,
|
|
1177
|
+
reducers: {
|
|
1178
|
+
discardComments: (state, action) => {
|
|
1179
|
+
state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
|
|
1180
|
+
},
|
|
1181
|
+
hydrateComment: (state, action) => {
|
|
1182
|
+
const { idArticle, list } = action.payload;
|
|
1183
|
+
const hasList = state.comments.find((c) => c.idArticle === idArticle);
|
|
1184
|
+
if (!hasList) {
|
|
1185
|
+
state.comments = [
|
|
1186
|
+
...state.comments.filter((c) => c.idArticle !== idArticle),
|
|
1187
|
+
{
|
|
1188
|
+
idArticle,
|
|
1189
|
+
list: Array.isArray(list) ? list : [],
|
|
1190
|
+
},
|
|
1191
|
+
];
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
const initialUris = [];
|
|
1195
|
+
const allUris = state.comments.reduce((uris, c) => {
|
|
1196
|
+
return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
|
|
1197
|
+
}, initialUris);
|
|
1198
|
+
const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
|
|
1199
|
+
state.comments = state.comments.map((c) => {
|
|
1200
|
+
return c.idArticle === idArticle
|
|
1201
|
+
? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
|
|
1202
|
+
});
|
|
1203
|
+
},
|
|
1204
|
+
updateComment: (state, action) => {
|
|
1205
|
+
state.comments = state.comments.map((c) => {
|
|
1206
|
+
const { idArticle, idComment, data } = action.payload;
|
|
1207
|
+
return c.idArticle === idArticle
|
|
1208
|
+
? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
|
|
1209
|
+
});
|
|
1210
|
+
},
|
|
1211
|
+
},
|
|
1212
|
+
extraReducers: (builder) => {
|
|
1213
|
+
builder
|
|
1214
|
+
.addCase(fetchComments.pending, (state) => {
|
|
1215
|
+
state.loading = 'pending';
|
|
1216
|
+
})
|
|
1217
|
+
.addCase(fetchComments.fulfilled, (state, action) => {
|
|
1218
|
+
state.loading = 'idle';
|
|
1219
|
+
state.comments = [
|
|
1220
|
+
...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
|
|
1221
|
+
{
|
|
1222
|
+
idArticle: action.payload.idArticle,
|
|
1223
|
+
list: action.payload.list.reverse(),
|
|
1224
|
+
},
|
|
1225
|
+
];
|
|
1226
|
+
})
|
|
1227
|
+
.addCase(fetchComments.rejected, (state) => {
|
|
1228
|
+
state.loading = 'idle';
|
|
1229
|
+
})
|
|
1230
|
+
.addCase(deleteComment.pending, (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: true }) : comment) });
|
|
1236
|
+
});
|
|
1237
|
+
})
|
|
1238
|
+
.addCase(deleteComment.rejected, (state, action) => {
|
|
1239
|
+
state.comments = state.comments.map((c) => {
|
|
1240
|
+
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
1241
|
+
return c;
|
|
1242
|
+
}
|
|
1243
|
+
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) });
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
},
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
const getCommentRTHandlers = function (dispatch, idArticle) {
|
|
1250
|
+
const addCommentHandler = function (message) {
|
|
1251
|
+
if (message.namespace === 'JAMESPOT' &&
|
|
1252
|
+
message.function === 'comment-create' &&
|
|
1253
|
+
message.object.idArticle === idArticle) {
|
|
1254
|
+
dispatch(fetchComments({ idArticle }));
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
const deleteCommentHandler = function (message) {
|
|
1258
|
+
if (message.namespace === 'JAMESPOT' &&
|
|
1259
|
+
message.function === 'comment-delete' &&
|
|
1260
|
+
Number(message.object.idArticle) === idArticle) {
|
|
1261
|
+
dispatch(fetchComments({ idArticle }));
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
return [
|
|
1265
|
+
{
|
|
1266
|
+
namespace: 'JAMESPOT',
|
|
1267
|
+
function: 'comment-create',
|
|
1268
|
+
handler: addCommentHandler,
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
namespace: 'JAMESPOT',
|
|
1272
|
+
function: 'comment-delete',
|
|
1273
|
+
handler: deleteCommentHandler,
|
|
1274
|
+
},
|
|
1275
|
+
];
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1278
|
+
const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
|
|
1279
|
+
const commentLikeHandler = function (message) {
|
|
1280
|
+
if (message.namespace === 'CUSTOM-ACTION' &&
|
|
1281
|
+
(message.function === 'add' || message.function === 'remove') &&
|
|
1282
|
+
message.object.type === 'sociallike' &&
|
|
1283
|
+
message.object.targetId &&
|
|
1284
|
+
idComments &&
|
|
1285
|
+
idComments.includes(message.object.targetId)) {
|
|
1286
|
+
dispatch(fetchComments({ idArticle }));
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
return idComments
|
|
1290
|
+
? [
|
|
1291
|
+
{ namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
|
|
1292
|
+
{ namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
|
|
1293
|
+
]
|
|
1294
|
+
: [];
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
const CommentReducer = redux.combineReducers({
|
|
1298
|
+
[CommentListSlice.name]: CommentListSlice.reducer,
|
|
1299
|
+
});
|
|
1300
|
+
const commentSlice = {
|
|
1301
|
+
name: 'comment',
|
|
1302
|
+
reducer: CommentReducer,
|
|
1303
|
+
};
|
|
1304
|
+
const selectCommentList = (state, idArticle, limit = 0) => {
|
|
1305
|
+
const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
|
|
1306
|
+
const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
|
|
1307
|
+
return limit !== 0 ? list.slice(-limit) : list;
|
|
1308
|
+
};
|
|
1309
|
+
const Comment = {
|
|
1310
|
+
slice: commentSlice,
|
|
1311
|
+
actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
|
|
1312
|
+
selectors: {
|
|
1313
|
+
commentList: selectCommentList,
|
|
1314
|
+
},
|
|
1315
|
+
getCommentRTHandlers,
|
|
1316
|
+
getCommentsLikeRTHandlers,
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
const ExtraBotConst = {
|
|
1320
|
+
route: 'extra-bot',
|
|
1321
|
+
moduleName: 'ExtraBotHook',
|
|
1322
|
+
configurationType: 'extraBot',
|
|
1323
|
+
listLimit: 20,
|
|
1324
|
+
listDefaultPage: 1,
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
const initialState$g = {
|
|
1328
|
+
global: {
|
|
1329
|
+
loading: 'idle',
|
|
1330
|
+
},
|
|
1331
|
+
listAll: {
|
|
1332
|
+
loading: 'idle',
|
|
1333
|
+
data: [],
|
|
1334
|
+
limit: ExtraBotConst.listLimit,
|
|
1335
|
+
nbResults: 0,
|
|
1336
|
+
page: ExtraBotConst.listDefaultPage,
|
|
1337
|
+
filters: [],
|
|
1338
|
+
orders: [],
|
|
1339
|
+
},
|
|
1340
|
+
listMines: {
|
|
1341
|
+
loading: 'idle',
|
|
1342
|
+
data: [],
|
|
1343
|
+
limit: ExtraBotConst.listLimit,
|
|
1344
|
+
nbResults: 0,
|
|
1345
|
+
page: ExtraBotConst.listDefaultPage,
|
|
1346
|
+
filters: [],
|
|
1347
|
+
orders: [],
|
|
1348
|
+
},
|
|
1349
|
+
formModal: {
|
|
1350
|
+
open: false,
|
|
1351
|
+
mode: 'create',
|
|
1352
|
+
type: 'all',
|
|
1353
|
+
extraBot: undefined,
|
|
1354
|
+
},
|
|
1355
|
+
};
|
|
1356
|
+
const fetchExtraBotListAll = toolkit.createAsyncThunk('extraBot/fetchAll', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1357
|
+
const state = getState().extraBot.listAll;
|
|
1358
|
+
try {
|
|
1359
|
+
return (yield extra.jApi.extraBot.list('all', {
|
|
1360
|
+
limit: state.limit,
|
|
1361
|
+
page: state.page,
|
|
1362
|
+
filters: state.filters,
|
|
1363
|
+
orders: state.orders,
|
|
1364
|
+
})).result;
|
|
1365
|
+
}
|
|
1366
|
+
catch (err) {
|
|
1367
|
+
if (!isAbortError(err)) {
|
|
1368
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1369
|
+
}
|
|
1370
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
|
|
1371
|
+
}
|
|
1372
|
+
}));
|
|
1373
|
+
const fetchExtraBotListMines = toolkit.createAsyncThunk('extraBot/fetchMines', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1374
|
+
const state = getState().extraBot.listMines;
|
|
1375
|
+
try {
|
|
1376
|
+
return (yield extra.jApi.extraBot.list('mines', {
|
|
1377
|
+
limit: state.limit,
|
|
1378
|
+
page: state.page,
|
|
1379
|
+
filters: state.filters,
|
|
1380
|
+
orders: state.orders,
|
|
1381
|
+
})).result;
|
|
1382
|
+
}
|
|
1383
|
+
catch (err) {
|
|
1384
|
+
if (!isAbortError(err)) {
|
|
1385
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1386
|
+
}
|
|
1387
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
|
|
1388
|
+
}
|
|
1389
|
+
}));
|
|
1390
|
+
const toggleExtraBotActivation = toolkit.createAsyncThunk('extraBot/toggleActivation', (extraBot, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1391
|
+
try {
|
|
1392
|
+
const enabled = !extraBot.enabled;
|
|
1393
|
+
const res = (yield extra.jApi.article.update(Object.assign(Object.assign({}, extraBot), { enabled }), { format: jamespot.Format.VIEW })).result;
|
|
1394
|
+
dispatch(Toast.actions.success({
|
|
1395
|
+
label: enabled ? 'APP_ExtraBot_Toast_ActivationSuccess' : 'APP_ExtraBot_Toast_DeactivationSuccess',
|
|
1396
|
+
}));
|
|
1397
|
+
return res;
|
|
1398
|
+
}
|
|
1399
|
+
catch (err) {
|
|
1400
|
+
if (!isAbortError(err)) {
|
|
1401
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1402
|
+
}
|
|
1403
|
+
return rejectWithValue({ error: 1, errorMsg: 'Failed to change extra bot activation' });
|
|
1404
|
+
}
|
|
1405
|
+
}));
|
|
1406
|
+
const saveExtraBot = toolkit.createAsyncThunk('extraBot/save', ({ extraBot }, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1407
|
+
try {
|
|
1408
|
+
const data = Object.assign(Object.assign({}, extraBot), { type: ExtraBotConst.configurationType, publishTo: '' });
|
|
1409
|
+
let res;
|
|
1410
|
+
let user;
|
|
1411
|
+
delete data.avatar;
|
|
1412
|
+
if (extraBot.uri) {
|
|
1413
|
+
res = (yield extra.jApi.article.update(data, { format: jamespot.Format.VIEW }))
|
|
1414
|
+
.result;
|
|
1415
|
+
user = (yield extra.jApi.extraBot.updateBot(res.uri)).result;
|
|
1416
|
+
}
|
|
1417
|
+
else {
|
|
1418
|
+
res = (yield extra.jApi.article.create(Object.assign({}, data), jamespot.Format.VIEW)).result[0];
|
|
1419
|
+
if (!res) {
|
|
1420
|
+
throw new Error('ExtraBot configuration creation failed');
|
|
1421
|
+
}
|
|
1422
|
+
user = (yield extra.jApi.extraBot.createBot(res.uri)).result;
|
|
1423
|
+
res._user = user;
|
|
1424
|
+
}
|
|
1425
|
+
const label = extraBot.uri ? 'APP_ExtraBot_Toast_SaveEdit' : 'APP_ExtraBot_Toast_SaveCreate';
|
|
1426
|
+
dispatch(Toast.actions.success({ label }));
|
|
1427
|
+
return res;
|
|
1428
|
+
}
|
|
1429
|
+
catch (err) {
|
|
1430
|
+
if (!isAbortError(err)) {
|
|
1431
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1432
|
+
}
|
|
1433
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot' });
|
|
1434
|
+
}
|
|
1435
|
+
}));
|
|
1436
|
+
const updateListBotProperty = (state, extraBotUri, property, value) => {
|
|
1437
|
+
const listAllExtraBot = state.listAll.data.find((eb) => eb.uri === extraBotUri);
|
|
1438
|
+
const listMinesExtraBot = state.listMines.data.find((eb) => eb.uri === extraBotUri);
|
|
1439
|
+
if (listAllExtraBot) {
|
|
1440
|
+
listAllExtraBot[property] = value;
|
|
1441
|
+
}
|
|
1442
|
+
if (listMinesExtraBot) {
|
|
1443
|
+
listMinesExtraBot[property] = value;
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
const extraBotSlice = toolkit.createSlice({
|
|
1447
|
+
name: 'extraBot',
|
|
1448
|
+
initialState: initialState$g,
|
|
1449
|
+
reducers: {
|
|
1450
|
+
setListAllOrder: (state, action) => {
|
|
1451
|
+
state.listAll.orders = [...action.payload];
|
|
1452
|
+
state.listAll.page = ExtraBotConst.listDefaultPage;
|
|
1453
|
+
},
|
|
1454
|
+
setListAllFilter: (state, action) => {
|
|
1455
|
+
state.listAll.filters = [...action.payload];
|
|
1456
|
+
state.listAll.page = ExtraBotConst.listDefaultPage;
|
|
1457
|
+
},
|
|
1458
|
+
setListAllPage: (state, action) => {
|
|
1459
|
+
state.listAll.page = action.payload;
|
|
1460
|
+
},
|
|
1461
|
+
setListMinesOrder: (state, action) => {
|
|
1462
|
+
state.listMines.orders = [...action.payload];
|
|
1463
|
+
state.listMines.page = ExtraBotConst.listDefaultPage;
|
|
1464
|
+
},
|
|
1465
|
+
setListMinesFilter: (state, action) => {
|
|
1466
|
+
state.listMines.filters = [...action.payload];
|
|
1467
|
+
state.listMines.page = ExtraBotConst.listDefaultPage;
|
|
1468
|
+
},
|
|
1469
|
+
setListMinesPage: (state, action) => {
|
|
1470
|
+
state.listMines.page = action.payload;
|
|
1471
|
+
},
|
|
1472
|
+
openFormModal: (state, action) => {
|
|
1473
|
+
state.formModal.open = true;
|
|
1474
|
+
state.formModal.mode = action.payload.mode;
|
|
1475
|
+
state.formModal.type = action.payload.type;
|
|
1476
|
+
state.formModal.extraBot = action.payload.extraBot;
|
|
1477
|
+
},
|
|
1478
|
+
closeFormModal: (state) => {
|
|
1479
|
+
state.formModal.open = false;
|
|
1480
|
+
},
|
|
1481
|
+
},
|
|
1482
|
+
extraReducers: (builder) => {
|
|
1483
|
+
builder
|
|
1484
|
+
.addCase(fetchExtraBotListAll.pending, (state) => {
|
|
1485
|
+
state.listAll.loading = 'pending';
|
|
1486
|
+
})
|
|
1487
|
+
.addCase(fetchExtraBotListAll.fulfilled, (state, action) => {
|
|
1488
|
+
var _a;
|
|
1489
|
+
state.listAll.data = action.payload.data;
|
|
1490
|
+
state.listAll.nbResults = action.payload.cnt;
|
|
1491
|
+
state.listAll.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
|
|
1492
|
+
state.listAll.page = action.payload.page;
|
|
1493
|
+
state.listAll.loading = 'idle';
|
|
1494
|
+
})
|
|
1495
|
+
.addCase(fetchExtraBotListAll.rejected, (state) => {
|
|
1496
|
+
state.listAll.loading = 'idle';
|
|
1497
|
+
})
|
|
1498
|
+
.addCase(fetchExtraBotListMines.pending, (state) => {
|
|
1499
|
+
state.listMines.loading = 'pending';
|
|
1500
|
+
})
|
|
1501
|
+
.addCase(fetchExtraBotListMines.fulfilled, (state, action) => {
|
|
1502
|
+
var _a;
|
|
1503
|
+
state.listMines.data = action.payload.data;
|
|
1504
|
+
state.listMines.nbResults = action.payload.cnt;
|
|
1505
|
+
state.listMines.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
|
|
1506
|
+
state.listMines.page = action.payload.page;
|
|
1507
|
+
state.listMines.loading = 'idle';
|
|
1508
|
+
})
|
|
1509
|
+
.addCase(fetchExtraBotListMines.rejected, (state) => {
|
|
1510
|
+
state.listMines.loading = 'idle';
|
|
1511
|
+
})
|
|
1512
|
+
.addCase(toggleExtraBotActivation.pending, (state) => {
|
|
1513
|
+
state.global.loading = 'pending';
|
|
1514
|
+
})
|
|
1515
|
+
.addCase(toggleExtraBotActivation.fulfilled, (state, action) => {
|
|
1516
|
+
state.global.loading = 'idle';
|
|
1517
|
+
const extraBot = action.payload;
|
|
1518
|
+
updateListBotProperty(state, extraBot.uri, 'enabled', extraBot.enabled);
|
|
1519
|
+
})
|
|
1520
|
+
.addCase(toggleExtraBotActivation.rejected, (state) => {
|
|
1521
|
+
state.global.loading = 'idle';
|
|
1522
|
+
})
|
|
1523
|
+
.addCase(saveExtraBot.pending, (state) => {
|
|
1524
|
+
state.global.loading = 'pending';
|
|
1525
|
+
})
|
|
1526
|
+
.addCase(saveExtraBot.fulfilled, (state, _action) => {
|
|
1527
|
+
state.global.loading = 'idle';
|
|
1528
|
+
state.formModal.open = false;
|
|
1529
|
+
})
|
|
1530
|
+
.addCase(saveExtraBot.rejected, (state) => {
|
|
1531
|
+
state.global.loading = 'idle';
|
|
1532
|
+
});
|
|
1533
|
+
},
|
|
1534
|
+
});
|
|
1535
|
+
const selectExtraBotListAll = (state) => state.extraBot.listAll;
|
|
1536
|
+
const selectExtraBotListMines = (state) => state.extraBot.listMines;
|
|
1537
|
+
const ExtraBot = {
|
|
1538
|
+
slice: extraBotSlice,
|
|
1539
|
+
actions: Object.assign({ fetchExtraBotListAll,
|
|
1540
|
+
fetchExtraBotListMines,
|
|
1541
|
+
toggleExtraBotActivation,
|
|
1542
|
+
saveExtraBot }, extraBotSlice.actions),
|
|
1543
|
+
selectors: { selectExtraBotListAll, selectExtraBotListMines },
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1319
1546
|
const initialState$f = {
|
|
1320
1547
|
loading: 'idle',
|
|
1321
1548
|
access: { createCategory: false },
|
|
@@ -5781,6 +6008,7 @@ exports.Bookmark = Bookmark;
|
|
|
5781
6008
|
exports.Comment = Comment;
|
|
5782
6009
|
exports.ContentReport = ContentReport;
|
|
5783
6010
|
exports.ExtraAppFieldsItemViews = ExtraAppFieldsItemViews;
|
|
6011
|
+
exports.ExtraBot = ExtraBot;
|
|
5784
6012
|
exports.Faq = Faq;
|
|
5785
6013
|
exports.Hook = Hook;
|
|
5786
6014
|
exports.MagicPad = MagicPad;
|
|
@@ -5806,6 +6034,9 @@ exports.adminLogsSlice = adminLogsSlice;
|
|
|
5806
6034
|
exports.animationsReducer = animationsReducer;
|
|
5807
6035
|
exports.animationsSlice = animationsSlice;
|
|
5808
6036
|
exports.contentReportSlice = contentReportSlice;
|
|
6037
|
+
exports.extraBotSlice = extraBotSlice;
|
|
6038
|
+
exports.fetchExtraBotListAll = fetchExtraBotListAll;
|
|
6039
|
+
exports.fetchExtraBotListMines = fetchExtraBotListMines;
|
|
5809
6040
|
exports.fetchMediaLibraryConfig = fetchMediaLibraryConfig;
|
|
5810
6041
|
exports.fetchMediaLibraryFilesStats = fetchMediaLibraryFilesStats;
|
|
5811
6042
|
exports.fetchMediaLibraryFolders = fetchMediaLibraryFolders;
|
|
@@ -5818,8 +6049,13 @@ exports.jland = jland;
|
|
|
5818
6049
|
exports.magicPadSlice = magicPadSlice;
|
|
5819
6050
|
exports.mediaLibraryReducer = mediaLibraryReducer;
|
|
5820
6051
|
exports.mediaLibrarySlice = mediaLibrarySlice;
|
|
6052
|
+
exports.saveExtraBot = saveExtraBot;
|
|
6053
|
+
exports.selectExtraBotListAll = selectExtraBotListAll;
|
|
6054
|
+
exports.selectExtraBotListMines = selectExtraBotListMines;
|
|
5821
6055
|
exports.slice = slice$1;
|
|
5822
6056
|
exports.studio = studio;
|
|
6057
|
+
exports.toggleExtraBotActivation = toggleExtraBotActivation;
|
|
6058
|
+
exports.updateListBotProperty = updateListBotProperty;
|
|
5823
6059
|
exports.updateStatus = updateStatus;
|
|
5824
6060
|
exports.updateWidgetContent = updateWidgetContent;
|
|
5825
6061
|
exports.viewsList = viewsList;
|