jamespot-front-business 1.3.5 → 1.3.6
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 +48 -11
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +48 -11
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +49 -150
- package/package.json +2 -2
package/dist/esm.js
CHANGED
|
@@ -1136,17 +1136,27 @@ const initialState$k = {
|
|
|
1136
1136
|
types: [],
|
|
1137
1137
|
pendingStatusChanges: [],
|
|
1138
1138
|
};
|
|
1139
|
+
let fetchTimeout = null;
|
|
1140
|
+
const debounceFetch = (dispatch, params, delay = 500) => {
|
|
1141
|
+
if (fetchTimeout)
|
|
1142
|
+
clearTimeout(fetchTimeout);
|
|
1143
|
+
fetchTimeout = setTimeout(() => {
|
|
1144
|
+
dispatch(fetchEvents(params));
|
|
1145
|
+
}, delay);
|
|
1146
|
+
};
|
|
1139
1147
|
const fetchEvents = createAsyncThunk('calendarEvents/fetchEvents', async (params, { extra, rejectWithValue, dispatch, signal, getState }) => {
|
|
1140
1148
|
const state = getState().calendar.events;
|
|
1141
1149
|
if (!params.dates && !state.dates) {
|
|
1142
1150
|
return rejectWithValue({ error: 1, errorMsg: 'Dates must be set' });
|
|
1143
1151
|
}
|
|
1152
|
+
let types = params.types ?? state.types;
|
|
1153
|
+
types = types.includes('socialEvent') ? [...types, 'recurringEvent'] : [...types];
|
|
1144
1154
|
try {
|
|
1145
1155
|
const payload = {
|
|
1146
1156
|
dateStart: params.dates?.start ?? state.dates?.start ?? '',
|
|
1147
1157
|
dateEnd: params.dates?.end ?? state.dates?.end ?? '',
|
|
1148
1158
|
statuses: state.statuses,
|
|
1149
|
-
types
|
|
1159
|
+
types,
|
|
1150
1160
|
};
|
|
1151
1161
|
const res = await extra.jApi.calendar.listEvents(payload, {
|
|
1152
1162
|
format: 'raw-view',
|
|
@@ -1162,11 +1172,11 @@ const fetchEvents = createAsyncThunk('calendarEvents/fetchEvents', async (params
|
|
|
1162
1172
|
}
|
|
1163
1173
|
});
|
|
1164
1174
|
const setDates = createAsyncThunk('calendarEvents/setDates', async (params, { dispatch }) => {
|
|
1165
|
-
dispatch
|
|
1175
|
+
debounceFetch(dispatch, { dates: params });
|
|
1166
1176
|
return true;
|
|
1167
1177
|
});
|
|
1168
1178
|
const setTypes = createAsyncThunk('calendarEvents/setTypes', async (params, { dispatch }) => {
|
|
1169
|
-
dispatch
|
|
1179
|
+
debounceFetch(dispatch, { types: params });
|
|
1170
1180
|
return true;
|
|
1171
1181
|
});
|
|
1172
1182
|
const changeResponse = createAsyncThunk('calendarEvents/changeResponse', async (params, { dispatch, extra, signal, rejectWithValue }) => {
|
|
@@ -1265,19 +1275,33 @@ const CalendarEventsSlice = createSlice({
|
|
|
1265
1275
|
}
|
|
1266
1276
|
state.pendingStatusChanges = state.pendingStatusChanges.filter((e) => e.requestId !== action.meta.requestId);
|
|
1267
1277
|
}
|
|
1278
|
+
})
|
|
1279
|
+
.addCase(setDates.pending, (state, action) => {
|
|
1280
|
+
state.dates = { start: action.meta.arg.start, end: action.meta.arg.end };
|
|
1281
|
+
state.loading = 'pending';
|
|
1282
|
+
})
|
|
1283
|
+
.addCase(setTypes.pending, (state, action) => {
|
|
1284
|
+
state.types = action.meta.arg;
|
|
1285
|
+
state.loading = 'pending';
|
|
1268
1286
|
});
|
|
1269
1287
|
},
|
|
1270
1288
|
});
|
|
1271
1289
|
|
|
1272
|
-
const isCalendarEvent = (type) => ['socialEvent', 'meeting', 'animatedMeeting'].includes(type);
|
|
1290
|
+
const isCalendarEvent = (type) => ['socialEvent', 'meeting', 'animatedMeeting', 'recurringEvent', 'recurringEventOccurrence'].includes(type);
|
|
1273
1291
|
const getCalendarRTHandlers = function (dispatch, jApi) {
|
|
1274
1292
|
const addEventHandler = function (message) {
|
|
1275
1293
|
if (message.namespace === 'JAMESPOT' &&
|
|
1276
1294
|
message.function === 'article-create' &&
|
|
1277
1295
|
isCalendarEvent(message.object.type)) {
|
|
1278
|
-
|
|
1296
|
+
if (message.object.type === 'recurringEvent') {
|
|
1297
|
+
dispatch(fetchEvents({}));
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
|
|
1279
1301
|
.then((res) => {
|
|
1280
|
-
|
|
1302
|
+
if (!('hideFromCalendar' in res.result) || !res.result.hideFromCalendar) {
|
|
1303
|
+
dispatch(CalendarEventsSlice.actions.addEvent(res.result));
|
|
1304
|
+
}
|
|
1281
1305
|
})
|
|
1282
1306
|
.catch((e) => {
|
|
1283
1307
|
dispatch(Toast.actions.error({ label: getErrorMessage(e) }));
|
|
@@ -1288,6 +1312,10 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
|
|
|
1288
1312
|
if (message.namespace === 'JAMESPOT' &&
|
|
1289
1313
|
message.function === 'article-delete' &&
|
|
1290
1314
|
isCalendarEvent(message.object.type)) {
|
|
1315
|
+
if (message.object.type === 'recurringEvent') {
|
|
1316
|
+
dispatch(fetchEvents({}));
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1291
1319
|
dispatch(CalendarEventsSlice.actions.removeEvent({ uri: message.object.uri }));
|
|
1292
1320
|
}
|
|
1293
1321
|
};
|
|
@@ -1295,9 +1323,18 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
|
|
|
1295
1323
|
if (message.namespace === 'JAMESPOT' &&
|
|
1296
1324
|
message.function === 'article-update' &&
|
|
1297
1325
|
isCalendarEvent(message.object.type)) {
|
|
1298
|
-
|
|
1326
|
+
if (message.object.type === 'recurringEvent') {
|
|
1327
|
+
dispatch(fetchEvents({}));
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
jApi.article.get({ uri: message.object.uri }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
|
|
1299
1331
|
.then((res) => {
|
|
1300
|
-
|
|
1332
|
+
if ('hideFromCalendar' in res.result && res.result.hideFromCalendar) {
|
|
1333
|
+
dispatch(CalendarEventsSlice.actions.removeEvent({ uri: message.object.uri }));
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
dispatch(CalendarEventsSlice.actions.updateEvent(res.result));
|
|
1337
|
+
}
|
|
1301
1338
|
})
|
|
1302
1339
|
.catch((e) => {
|
|
1303
1340
|
dispatch(Toast.actions.error({ label: getErrorMessage(e) }));
|
|
@@ -1305,12 +1342,12 @@ const getCalendarRTHandlers = function (dispatch, jApi) {
|
|
|
1305
1342
|
}
|
|
1306
1343
|
};
|
|
1307
1344
|
const updateResponseHandler = function (message) {
|
|
1308
|
-
if (
|
|
1345
|
+
if (message.namespace === 'CUSTOM-ACTION' &&
|
|
1309
1346
|
(message.function === 'update' || message.function === 'remove') &&
|
|
1310
1347
|
message.object.targetType &&
|
|
1311
1348
|
message.object.targetId &&
|
|
1312
|
-
isCalendarEvent(message.object.targetType))
|
|
1313
|
-
jApi.article.get({ idArticle: message.object.targetId }, { format: 'raw-view', formatExtension: ['socialEventRecord'] })
|
|
1349
|
+
isCalendarEvent(message.object.targetType)) {
|
|
1350
|
+
jApi.article.get({ idArticle: message.object.targetId }, { format: 'raw-view', formatExtension: ['socialEventRecord', 'recurringEventRecord'] })
|
|
1314
1351
|
.then((res) => {
|
|
1315
1352
|
dispatch(CalendarEventsSlice.actions.updateEvent(res.result));
|
|
1316
1353
|
})
|