jamespot-front-business 1.1.17 → 1.1.19

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 { jEnsure, UserLevel } from 'jamespot-user-api';
3
+ import { jEnsure, formatImgUrl, UserLevel } from 'jamespot-user-api';
4
4
 
5
5
  const adapter$1 = createEntityAdapter({
6
6
  selectId: (app) => app.name,
@@ -59,7 +59,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
59
59
  });
60
60
  }
61
61
 
62
- const initialState$9 = {
62
+ const initialState$b = {
63
63
  entities: [],
64
64
  loading: 'idle',
65
65
  nbResults: 0,
@@ -70,7 +70,7 @@ const fetchBookableAsset = createAsyncThunk('BookableAsset/fetchBookableAsset',
70
70
  }));
71
71
  const BookableAssetSlice = createSlice({
72
72
  name: 'bookableAsset',
73
- initialState: initialState$9,
73
+ initialState: initialState$b,
74
74
  reducers: {},
75
75
  extraReducers: (builder) => {
76
76
  builder
@@ -91,7 +91,7 @@ const BookableAssetSlice = createSlice({
91
91
  const fetchConfiguration = createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
92
92
  return yield extra.jApi.assetReservation.configuration();
93
93
  }));
94
- const initialState$8 = {
94
+ const initialState$a = {
95
95
  description: '',
96
96
  right: {
97
97
  manage: false,
@@ -105,7 +105,7 @@ const initialState$8 = {
105
105
  };
106
106
  const AssetReservationConfigurationSlice = createSlice({
107
107
  name: 'configuration',
108
- initialState: initialState$8,
108
+ initialState: initialState$a,
109
109
  reducers: {},
110
110
  extraReducers: (builder) => {
111
111
  builder
@@ -126,7 +126,7 @@ const initForm = {
126
126
  hourStart: '',
127
127
  hourEnd: '',
128
128
  };
129
- const initialState$7 = {
129
+ const initialState$9 = {
130
130
  entities: [],
131
131
  loading: 'idle',
132
132
  nbResults: 0,
@@ -138,7 +138,7 @@ const fetchReservation = createAsyncThunk('Reservation/fetchReservation', (viewM
138
138
  }));
139
139
  const ReservationSlice = createSlice({
140
140
  name: 'reservation',
141
- initialState: initialState$7,
141
+ initialState: initialState$9,
142
142
  reducers: {
143
143
  setForm: (state, action) => {
144
144
  state.form = action.payload;
@@ -231,7 +231,7 @@ const Toast = {
231
231
  selectors: selectors$1,
232
232
  };
233
233
 
234
- const initialState$6 = {
234
+ const initialState$8 = {
235
235
  bookmarks: [],
236
236
  loading: 'idle',
237
237
  status: undefined,
@@ -294,7 +294,7 @@ const deleteBookmark = createAsyncThunk('bookmarkList/deleteBookmark', (bookmark
294
294
  }));
295
295
  const BookmarkListSlice = createSlice({
296
296
  name: 'bookmarkList',
297
- initialState: initialState$6,
297
+ initialState: initialState$8,
298
298
  reducers: {
299
299
  resetAddBookmarkStatus: (state, action) => {
300
300
  if (state.add[action.payload]) {
@@ -457,7 +457,7 @@ const getRTHandlers = function (dispatch) {
457
457
  ];
458
458
  };
459
459
 
460
- const initialState$5 = {
460
+ const initialState$7 = {
461
461
  bookmark: undefined,
462
462
  status: undefined,
463
463
  loading: 'idle',
@@ -479,7 +479,7 @@ const editBookmark = createAsyncThunk('bookmarkEdit/editBookmark', (bookmark, {
479
479
  }));
480
480
  const BookmarkEditSlice = createSlice({
481
481
  name: 'bookmarkEdit',
482
- initialState: initialState$5,
482
+ initialState: initialState$7,
483
483
  reducers: {
484
484
  setEditBookmark: (state, action) => {
485
485
  state.bookmark = Object.assign({}, action.payload);
@@ -767,7 +767,7 @@ const initialMap = {
767
767
  illustration: '',
768
768
  assignLicense: false,
769
769
  };
770
- const initialState$4 = {
770
+ const initialState$6 = {
771
771
  map: Object.assign({}, initialMap),
772
772
  loading: 'idle',
773
773
  status: undefined,
@@ -811,13 +811,13 @@ const createMap = createAsyncThunk('mapCreate/create', ({ map, jlandUrlBase }, {
811
811
  }));
812
812
  const MapCreateSlice = createSlice({
813
813
  name: 'mapCreate',
814
- initialState: initialState$4,
814
+ initialState: initialState$6,
815
815
  reducers: {
816
816
  setMap: (state, action) => {
817
817
  state.map = action.payload;
818
818
  },
819
819
  resetCreateMapState: () => {
820
- return initialState$4;
820
+ return initialState$6;
821
821
  },
822
822
  },
823
823
  extraReducers: (builder) => {
@@ -875,6 +875,14 @@ const adapter = createEntityAdapter({
875
875
  selectId: (model) => model.type,
876
876
  sortComparer: (a, b) => a.label.localeCompare(b.label),
877
877
  });
878
+ const getModelIconSrc = (model, size) => {
879
+ const imgProps = {
880
+ from: "imagestatic",
881
+ size: size !== null && size !== void 0 ? size : 'fitx600',
882
+ uri: `icons/${model && model.icon ? model.icon : `article`}-white`,
883
+ };
884
+ return formatImgUrl(imgProps);
885
+ };
878
886
  const slice$1 = createSlice({
879
887
  name: 'models',
880
888
  initialState: adapter.getInitialState(),
@@ -885,13 +893,169 @@ const slice$1 = createSlice({
885
893
  },
886
894
  });
887
895
  const selectors = adapter.getSelectors((state) => state.entities.models);
896
+ const utils = {
897
+ getModelIconSrc
898
+ };
888
899
  const selectByIds = (state, types) => types.map(type => state.entities.models.entities[type]).filter(model => !!model);
889
900
  const Model = {
890
901
  slice: slice$1,
891
902
  actions: Object.assign({}, slice$1.actions),
903
+ utils,
892
904
  selectors: Object.assign(Object.assign({}, selectors), { selectByIds }),
893
905
  };
894
906
 
907
+ const initialQuery = {
908
+ query: '',
909
+ filters: [],
910
+ limit: 20,
911
+ orders: [{ name: 'dateCreation', sort: 'DESC' }],
912
+ page: 1,
913
+ };
914
+ const fetchFiles = createAsyncThunk('/fetchFiles', ({ page, query, sort }, { extra, getState }) => __awaiter(void 0, void 0, void 0, function* () {
915
+ const jApi = extra.jApi;
916
+ const state = getState();
917
+ const filters = state.wedoc.tab === 'my-documents' ? [{ name: 'idUser', value: '0' }] : [];
918
+ const orders = [{ name: 'dateCreation', sort }];
919
+ const resolvePage = query !== state.wedoc.query ? 1 : page;
920
+ return yield jApi.wedoc.getFiles(Object.assign(Object.assign({}, initialQuery), { filters, query, orders, page: resolvePage, limit: 12 }));
921
+ }));
922
+ const fetchRecentFiles = createAsyncThunk('/fetchRecentFiles', (_, { extra, getState }) => __awaiter(void 0, void 0, void 0, function* () {
923
+ const jApi = extra.jApi;
924
+ const state = getState();
925
+ const filters = state.wedoc.tab === 'my-documents' ? [{ name: 'idUser', value: '0' }] : [];
926
+ return yield jApi.wedoc.getFiles(Object.assign(Object.assign({}, initialQuery), { filters, limit: 4 }));
927
+ }));
928
+
929
+ const initialState$5 = {
930
+ entities: [],
931
+ nbEntities: 0,
932
+ entitiesRecent: [],
933
+ tab: 'my-documents',
934
+ loading: 'idle',
935
+ loadingRecent: 'idle',
936
+ query: '',
937
+ page: 1
938
+ };
939
+ const WedocAppSlice = createSlice({
940
+ name: 'wedoc',
941
+ initialState: initialState$5,
942
+ reducers: {
943
+ update: (state, action) => {
944
+ state.entities = [
945
+ ...state.entities.map((file) => file.id === action.payload.id ? Object.assign(Object.assign({}, file), action.payload) : file)
946
+ ];
947
+ },
948
+ setQuery: (state, action) => {
949
+ state.query = action.payload;
950
+ },
951
+ setTab: (state, action) => {
952
+ state.tab = action.payload;
953
+ },
954
+ },
955
+ extraReducers: (builder) => {
956
+ builder
957
+ .addCase(fetchFiles.pending, (state) => {
958
+ state.loading = 'pending';
959
+ })
960
+ .addCase(fetchFiles.fulfilled, (state, action) => {
961
+ state.loading = 'idle';
962
+ state.entities = action.payload.result.data;
963
+ state.nbEntities = action.payload.result.cnt;
964
+ state.page = action.payload.result.page;
965
+ })
966
+ .addCase(fetchFiles.rejected, (state) => {
967
+ state.loading = 'idle';
968
+ })
969
+ .addCase(fetchRecentFiles.pending, (state) => {
970
+ state.loadingRecent = 'pending';
971
+ })
972
+ .addCase(fetchRecentFiles.fulfilled, (state, action) => {
973
+ state.loadingRecent = 'idle';
974
+ state.entitiesRecent = action.payload.result.data;
975
+ })
976
+ .addCase(fetchRecentFiles.rejected, (state) => {
977
+ state.loadingRecent = 'idle';
978
+ });
979
+ },
980
+ });
981
+
982
+ const WedocApp = {
983
+ slice: WedocAppSlice,
984
+ selectors: {
985
+ getFiles: (state) => {
986
+ return {
987
+ entities: state.wedoc.entities,
988
+ nbEntities: state.wedoc.nbEntities,
989
+ loading: state.wedoc.loading === 'pending',
990
+ tab: state.wedoc.tab,
991
+ query: state.wedoc.query,
992
+ page: state.wedoc.page
993
+ };
994
+ },
995
+ getRecent: (state) => {
996
+ return {
997
+ entities: state.wedoc.entitiesRecent,
998
+ loading: state.wedoc.loadingRecent === 'pending',
999
+ tab: state.wedoc.tab,
1000
+ };
1001
+ },
1002
+ },
1003
+ actions: {
1004
+ fetchFiles,
1005
+ fetchRecentFiles
1006
+ },
1007
+ };
1008
+
1009
+ const fetchRequest = createAsyncThunk('/fetchRequest', ({ uri, idUser }, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
1010
+ const jApi = extra.jApi;
1011
+ return yield jApi.share.getObjectAccessRequest(uri, idUser);
1012
+ }));
1013
+
1014
+ const initialState$4 = {
1015
+ entities: [],
1016
+ nbEntities: 0,
1017
+ loading: 'idle',
1018
+ };
1019
+ const ShareSlice = createSlice({
1020
+ name: 'share',
1021
+ initialState: initialState$4,
1022
+ reducers: {
1023
+ remove: (state, action) => {
1024
+ state.entities = [
1025
+ ...state.entities.filter((entity) => entity.id !== action.payload)
1026
+ ];
1027
+ },
1028
+ },
1029
+ extraReducers: (builder) => {
1030
+ builder
1031
+ .addCase(fetchRequest.pending, (state) => {
1032
+ state.loading = 'pending';
1033
+ })
1034
+ .addCase(fetchRequest.fulfilled, (state, action) => {
1035
+ state.loading = 'idle';
1036
+ state.entities = action.payload.result;
1037
+ })
1038
+ .addCase(fetchRequest.rejected, (state) => {
1039
+ state.loading = 'idle';
1040
+ });
1041
+ },
1042
+ });
1043
+
1044
+ const Share = {
1045
+ slice: ShareSlice,
1046
+ selectors: {
1047
+ requests: (state) => {
1048
+ return {
1049
+ loading: state.share.loading,
1050
+ entities: state.share.entities
1051
+ };
1052
+ },
1053
+ },
1054
+ actions: {
1055
+ fetchRequest,
1056
+ },
1057
+ };
1058
+
895
1059
  const initialState$3 = {
896
1060
  channels: undefined,
897
1061
  loading: 'idle',
@@ -905,6 +1069,7 @@ const fetchChannels = createAsyncThunk('/fetchChannels', (page, { extra }) => __
905
1069
  type: 'tvDisplayChannel',
906
1070
  format: 'raw-list',
907
1071
  page: askedPage,
1072
+ orders: [{ name: 'id', sort: 'DESC' }],
908
1073
  };
909
1074
  jApi.article
910
1075
  .list(config)
@@ -917,6 +1082,21 @@ const fetchChannels = createAsyncThunk('/fetchChannels', (page, { extra }) => __
917
1082
  });
918
1083
  });
919
1084
  }));
1085
+ const deleteChannel = createAsyncThunk('/deleteChannel', ({ channel }, { extra, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1086
+ const jApi = extra.jApi;
1087
+ return yield new Promise((resolve, reject) => {
1088
+ jApi.article
1089
+ .delete(channel.id)
1090
+ .then((response) => {
1091
+ resolve(response.result);
1092
+ dispatch(fetchChannels());
1093
+ })
1094
+ .catch((ex) => {
1095
+ var _a, _b;
1096
+ reject({ error: (_a = ex.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = ex.errorMsg) !== null && _b !== void 0 ? _b : 'Error deleting channel' });
1097
+ });
1098
+ });
1099
+ }));
920
1100
  const ChannelsListSlice = createSlice({
921
1101
  name: 'channelsList',
922
1102
  initialState: Object.assign({}, initialState$3),
@@ -938,6 +1118,19 @@ const ChannelsListSlice = createSlice({
938
1118
  if (state.loading === 'pending') {
939
1119
  state.loading = 'idle';
940
1120
  }
1121
+ })
1122
+ .addCase(deleteChannel.pending, (state) => {
1123
+ state.loadingChannelDeletion = 'pending';
1124
+ })
1125
+ .addCase(deleteChannel.fulfilled, (state) => {
1126
+ if (state.loadingChannelDeletion === 'pending') {
1127
+ state.loadingChannelDeletion = 'idle';
1128
+ }
1129
+ })
1130
+ .addCase(deleteChannel.rejected, (state) => {
1131
+ if (state.loadingChannelDeletion === 'pending') {
1132
+ state.loadingChannelDeletion = 'idle';
1133
+ }
941
1134
  });
942
1135
  },
943
1136
  });
@@ -947,7 +1140,7 @@ function isChannelConfigured(channel) {
947
1140
  return !!channel.tvChannelBackgroundColor && !!channel.tvChannelGroupTarget;
948
1141
  }
949
1142
  else {
950
- return !!channel.tvChannelBackgroundColor && channel.tvChannelNumImages !== 0;
1143
+ return channel.tvChannelNumImages !== 0;
951
1144
  }
952
1145
  }
953
1146
 
@@ -965,6 +1158,7 @@ const TVDisplay = {
965
1158
  slice: TVDisplaySlice,
966
1159
  actions: {
967
1160
  fetchChannels,
1161
+ deleteChannel,
968
1162
  },
969
1163
  selectors: {
970
1164
  selectChannelsList,
@@ -1413,5 +1607,5 @@ const WidgetEditor = {
1413
1607
  },
1414
1608
  };
1415
1609
 
1416
- export { Application, AssetReservation, Bookmark, MODE_EDIT, MODE_VIEW, Model, TVDisplay, Toast, UserCurrent, Widget, WidgetEditor, actions, jland, slice };
1610
+ export { Application, AssetReservation, Bookmark, MODE_EDIT, MODE_VIEW, Model, Share, TVDisplay, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, jland, slice };
1417
1611
  //# sourceMappingURL=esm.js.map