jamespot-front-business 1.1.28 → 1.1.30

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 } from 'jamespot-user-api';
3
+ import jamespot, { jEnsure, formatImgUrl, UserLevel, StudioApplicationStatus } 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$f = {
62
+ const initialState$g = {
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$f,
73
+ initialState: initialState$g,
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$e = {
94
+ const initialState$f = {
95
95
  description: '',
96
96
  right: {
97
97
  manage: false,
@@ -105,7 +105,7 @@ const initialState$e = {
105
105
  };
106
106
  const AssetReservationConfigurationSlice = createSlice({
107
107
  name: 'configuration',
108
- initialState: initialState$e,
108
+ initialState: initialState$f,
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$d = {
129
+ const initialState$e = {
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$d,
141
+ initialState: initialState$e,
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$c = {
234
+ const initialState$d = {
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$c,
297
+ initialState: initialState$d,
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$b = {
460
+ const initialState$c = {
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$b,
482
+ initialState: initialState$c,
483
483
  reducers: {
484
484
  setEditBookmark: (state, action) => {
485
485
  state.bookmark = Object.assign({}, action.payload);
@@ -532,7 +532,7 @@ const Bookmark = {
532
532
  getRTHandlers: getRTHandlers,
533
533
  };
534
534
 
535
- const initialState$a = {
535
+ const initialState$b = {
536
536
  loading: 'idle',
537
537
  access: { createCategory: false },
538
538
  };
@@ -560,7 +560,7 @@ const fetchFaqConfig = createAsyncThunk('faqConfig/fetch', () => __awaiter(void
560
560
  }));
561
561
  const FaqConfigSlice = createSlice({
562
562
  name: 'config',
563
- initialState: initialState$a,
563
+ initialState: initialState$b,
564
564
  reducers: {},
565
565
  extraReducers: (builder) => {
566
566
  builder
@@ -592,7 +592,7 @@ const FaqConfigSlice = createSlice({
592
592
  },
593
593
  });
594
594
 
595
- const initialState$9 = {
595
+ const initialState$a = {
596
596
  loading: 'idle',
597
597
  categories: null,
598
598
  };
@@ -604,7 +604,7 @@ const fetchFaqCategories = createAsyncThunk('faqCategories/fetch', () => __await
604
604
  }));
605
605
  const FaqCategoriesSlice = createSlice({
606
606
  name: 'categories',
607
- initialState: initialState$9,
607
+ initialState: initialState$a,
608
608
  reducers: {},
609
609
  extraReducers: (builder) => {
610
610
  builder
@@ -625,13 +625,13 @@ const FaqCategoriesSlice = createSlice({
625
625
  },
626
626
  });
627
627
 
628
- const joinedReducers$4 = combineReducers({
628
+ const joinedReducers$5 = combineReducers({
629
629
  [FaqConfigSlice.name]: FaqConfigSlice.reducer,
630
630
  [FaqCategoriesSlice.name]: FaqCategoriesSlice.reducer,
631
631
  });
632
632
  const FaqSlice = {
633
633
  name: 'faq',
634
- reducer: joinedReducers$4,
634
+ reducer: joinedReducers$5,
635
635
  };
636
636
  const selectFaqConfig = (state) => {
637
637
  return state.faq.config;
@@ -886,7 +886,7 @@ const initialMap = {
886
886
  illustration: '',
887
887
  assignLicense: false,
888
888
  };
889
- const initialState$8 = {
889
+ const initialState$9 = {
890
890
  map: Object.assign({}, initialMap),
891
891
  loading: 'idle',
892
892
  status: undefined,
@@ -930,13 +930,13 @@ const createMap = createAsyncThunk('mapCreate/create', ({ map, jlandUrlBase }, {
930
930
  }));
931
931
  const MapCreateSlice = createSlice({
932
932
  name: 'mapCreate',
933
- initialState: initialState$8,
933
+ initialState: initialState$9,
934
934
  reducers: {
935
935
  setMap: (state, action) => {
936
936
  state.map = action.payload;
937
937
  },
938
938
  resetCreateMapState: () => {
939
- return initialState$8;
939
+ return initialState$9;
940
940
  },
941
941
  },
942
942
  extraReducers: (builder) => {
@@ -966,13 +966,13 @@ const selectJLandAvailableLicenses = function selectJLandAvailableLicenses(state
966
966
  const selectMapCreate = function selectMapCreate(state) {
967
967
  return state.jland.mapCreate;
968
968
  };
969
- const joinedReducers$3 = combineReducers({
969
+ const joinedReducers$4 = combineReducers({
970
970
  [JLandMapListSlice.name]: JLandMapListSlice.reducer,
971
971
  [MapCreateSlice.name]: MapCreateSlice.reducer,
972
972
  });
973
973
  const jlandSlice = {
974
974
  name: 'jland',
975
- reducer: joinedReducers$3,
975
+ reducer: joinedReducers$4,
976
976
  };
977
977
  const jland = {
978
978
  slice: jlandSlice,
@@ -1023,10 +1023,10 @@ const Model = {
1023
1023
  selectors: Object.assign(Object.assign({}, selectors), { selectByIds }),
1024
1024
  };
1025
1025
 
1026
- const initialState$7 = {};
1026
+ const initialState$8 = {};
1027
1027
  const NetworkStaticsSlice = createSlice({
1028
1028
  name: 'statics',
1029
- initialState: initialState$7,
1029
+ initialState: initialState$8,
1030
1030
  reducers: {
1031
1031
  initNetworkStatics: (_, { payload }) => {
1032
1032
  return payload;
@@ -1034,12 +1034,12 @@ const NetworkStaticsSlice = createSlice({
1034
1034
  },
1035
1035
  });
1036
1036
 
1037
- const joinedReducers$2 = combineReducers({
1037
+ const joinedReducers$3 = combineReducers({
1038
1038
  [NetworkStaticsSlice.name]: NetworkStaticsSlice.reducer,
1039
1039
  });
1040
1040
  const NetworkSlice = {
1041
1041
  name: 'network',
1042
- reducer: joinedReducers$2,
1042
+ reducer: joinedReducers$3,
1043
1043
  };
1044
1044
  const selectNetworkStatics = (state) => {
1045
1045
  return state.network.statics;
@@ -1082,7 +1082,7 @@ const fetchRecentFiles = createAsyncThunk('/fetchRecentFiles', (_, { extra, getS
1082
1082
  return yield jApi.wedoc.getFiles(Object.assign(Object.assign({}, initialQuery), { filters, limit: 4 }));
1083
1083
  }));
1084
1084
 
1085
- const initialState$6 = {
1085
+ const initialState$7 = {
1086
1086
  entities: [],
1087
1087
  nbEntities: 0,
1088
1088
  entitiesRecent: [],
@@ -1094,7 +1094,7 @@ const initialState$6 = {
1094
1094
  };
1095
1095
  const WedocAppSlice = createSlice({
1096
1096
  name: 'wedoc',
1097
- initialState: initialState$6,
1097
+ initialState: initialState$7,
1098
1098
  reducers: {
1099
1099
  update: (state, action) => {
1100
1100
  state.entities = [
@@ -1167,14 +1167,14 @@ const fetchRequest = createAsyncThunk('/fetchRequest', ({ uri, idUser }, { extra
1167
1167
  return yield jApi.wedoc.getAccessRequest(uri, idUser);
1168
1168
  }));
1169
1169
 
1170
- const initialState$5 = {
1170
+ const initialState$6 = {
1171
1171
  entities: [],
1172
1172
  nbEntities: 0,
1173
1173
  loading: 'idle',
1174
1174
  };
1175
1175
  const ShareSlice = createSlice({
1176
1176
  name: 'share',
1177
- initialState: initialState$5,
1177
+ initialState: initialState$6,
1178
1178
  reducers: {
1179
1179
  remove: (state, action) => {
1180
1180
  state.entities = [
@@ -1212,7 +1212,7 @@ const Share = {
1212
1212
  },
1213
1213
  };
1214
1214
 
1215
- const initialState$4 = {
1215
+ const initialState$5 = {
1216
1216
  channels: undefined,
1217
1217
  loading: 'idle',
1218
1218
  loadingChannelDeletion: 'idle',
@@ -1255,7 +1255,7 @@ const deleteChannel = createAsyncThunk('/deleteChannel', ({ channel }, { extra,
1255
1255
  }));
1256
1256
  const ChannelsListSlice = createSlice({
1257
1257
  name: 'channelsList',
1258
- initialState: Object.assign({}, initialState$4),
1258
+ initialState: Object.assign({}, initialState$5),
1259
1259
  reducers: {},
1260
1260
  extraReducers: (builder) => {
1261
1261
  builder
@@ -1300,12 +1300,12 @@ function isChannelConfigured(channel) {
1300
1300
  }
1301
1301
  }
1302
1302
 
1303
- const joinedReducers$1 = combineReducers({
1303
+ const joinedReducers$2 = combineReducers({
1304
1304
  [ChannelsListSlice.name]: ChannelsListSlice.reducer,
1305
1305
  });
1306
1306
  const TVDisplaySlice = {
1307
1307
  name: 'tvDisplay',
1308
- reducer: joinedReducers$1,
1308
+ reducer: joinedReducers$2,
1309
1309
  };
1310
1310
  const selectChannelsList = function selectChannelsList(state) {
1311
1311
  return state.tvDisplay.channelsList;
@@ -1324,10 +1324,10 @@ const TVDisplay = {
1324
1324
  },
1325
1325
  };
1326
1326
 
1327
- const initialState$3 = {};
1327
+ const initialState$4 = {};
1328
1328
  const TinyMCEOptionsSlice = createSlice({
1329
1329
  name: 'options',
1330
- initialState: initialState$3,
1330
+ initialState: initialState$4,
1331
1331
  reducers: {
1332
1332
  initOptions: (_, { payload }) => {
1333
1333
  return { common: payload };
@@ -1335,12 +1335,12 @@ const TinyMCEOptionsSlice = createSlice({
1335
1335
  },
1336
1336
  });
1337
1337
 
1338
- const joinedReducers = combineReducers({
1338
+ const joinedReducers$1 = combineReducers({
1339
1339
  [TinyMCEOptionsSlice.name]: TinyMCEOptionsSlice.reducer,
1340
1340
  });
1341
1341
  const TinyMCESlice = {
1342
1342
  name: 'tinymce',
1343
- reducer: joinedReducers,
1343
+ reducer: joinedReducers$1,
1344
1344
  };
1345
1345
  const selectTinyMCECommonOptions = (state) => {
1346
1346
  return state.tinymce.options.common;
@@ -1353,7 +1353,7 @@ const TinyMCE = {
1353
1353
  },
1354
1354
  };
1355
1355
 
1356
- const initialState$2 = {
1356
+ const initialState$3 = {
1357
1357
  id: 0,
1358
1358
  mainType: 'user',
1359
1359
  type: 'user',
@@ -1367,7 +1367,7 @@ const initialState$2 = {
1367
1367
  };
1368
1368
  const slice = createSlice({
1369
1369
  name: 'userCurrent',
1370
- initialState: initialState$2,
1370
+ initialState: initialState$3,
1371
1371
  reducers: {
1372
1372
  init: (_, { payload }) => {
1373
1373
  return payload;
@@ -1585,7 +1585,7 @@ function widgetDefinition(name) {
1585
1585
 
1586
1586
  const MODE_EDIT = 'edit';
1587
1587
  const MODE_VIEW = 'view';
1588
- const initialState$1 = {
1588
+ const initialState$2 = {
1589
1589
  token: undefined,
1590
1590
  ids: {},
1591
1591
  layers: {},
@@ -1597,7 +1597,7 @@ const initialState$1 = {
1597
1597
  };
1598
1598
  const widgetsSlice = createSlice({
1599
1599
  name: 'widgets',
1600
- initialState: initialState$1,
1600
+ initialState: initialState$2,
1601
1601
  reducers: {
1602
1602
  registerWidget: (state, action) => {
1603
1603
  const { uniqid, widget } = action.payload;
@@ -1739,12 +1739,12 @@ const Widget = {
1739
1739
  },
1740
1740
  };
1741
1741
 
1742
- const initialState = {
1742
+ const initialState$1 = {
1743
1743
  editors: [],
1744
1744
  };
1745
1745
  const editorsSlice = createSlice({
1746
1746
  name: 'editors',
1747
- initialState,
1747
+ initialState: initialState$1,
1748
1748
  reducers: {
1749
1749
  registerEditor: (state, action) => {
1750
1750
  const { uniqid, name } = action.payload;
@@ -1794,5 +1794,255 @@ const WidgetEditor = {
1794
1794
  },
1795
1795
  };
1796
1796
 
1797
- export { Application, AssetReservation, Bookmark, Faq, MODE_EDIT, MODE_VIEW, Model, Network, Share, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, jland, slice };
1797
+ const AUDIENCE = {
1798
+ ALL: '1',
1799
+ CUSTOM: '0',
1800
+ };
1801
+ var StatusType;
1802
+ (function (StatusType) {
1803
+ StatusType["draft"] = "draft";
1804
+ StatusType["installed"] = "installed";
1805
+ StatusType["suspended"] = "suspended";
1806
+ })(StatusType || (StatusType = {}));
1807
+ const APP_STATUS_TYPE = {
1808
+ DRAFT: StatusType.draft,
1809
+ INSTALLED: StatusType.installed,
1810
+ SUSPENDED: StatusType.suspended,
1811
+ };
1812
+ var AppFormItemType;
1813
+ (function (AppFormItemType) {
1814
+ AppFormItemType["TITLE"] = "TITLE";
1815
+ AppFormItemType["IMAGE"] = "IMAGE";
1816
+ AppFormItemType["DESCRIPTION"] = "DESCRIPTION";
1817
+ AppFormItemType["IDUSER"] = "IDUSER";
1818
+ AppFormItemType["PUBLISHTO"] = "PUBLISHTO";
1819
+ AppFormItemType["SENDALERTTOSUBSCRIBERS"] = "SENDALERTTOSUBSCRIBERS";
1820
+ AppFormItemType["RECEIVEACOPY"] = "RECEIVEACOPY";
1821
+ AppFormItemType["TEXT"] = "TEXT";
1822
+ AppFormItemType["TEXTAREA"] = "TEXTAREA";
1823
+ AppFormItemType["TEXTAREAHTML"] = "TEXTAREAHTML";
1824
+ AppFormItemType["DATE"] = "DATE";
1825
+ AppFormItemType["DATETIME"] = "DATETIME";
1826
+ AppFormItemType["RANGE"] = "RANGE";
1827
+ AppFormItemType["NUMBER"] = "NUMBER";
1828
+ AppFormItemType["URL"] = "URL";
1829
+ AppFormItemType["EMAIL"] = "EMAIL";
1830
+ AppFormItemType["SELECT"] = "SELECT";
1831
+ AppFormItemType["CHECKBOX"] = "CHECKBOX";
1832
+ AppFormItemType["TOGGLE"] = "TOGGLE";
1833
+ AppFormItemType["RADIO"] = "RADIO";
1834
+ AppFormItemType["TAGS"] = "TAGS";
1835
+ AppFormItemType["ADDFILEATTACHMENT"] = "ADDFILEATTACHMENT";
1836
+ AppFormItemType["AUDIENCE"] = "AUDIENCE";
1837
+ AppFormItemType["CODEHTML"] = "CODEHTML";
1838
+ AppFormItemType["DATECREATION"] = "DATECREATION";
1839
+ AppFormItemType["USERLINK"] = "USERLINK";
1840
+ AppFormItemType["CONTENTLINK"] = "CONTENTLINK";
1841
+ })(AppFormItemType || (AppFormItemType = {}));
1842
+ const AppFormPrimaryList = [AppFormItemType.DESCRIPTION];
1843
+ const AppFormNotFields = [AppFormItemType.AUDIENCE, AppFormItemType.RANGE];
1844
+ const AppFormFixedHeadList = {
1845
+ create: [AppFormItemType.TITLE],
1846
+ popup: [AppFormItemType.TITLE],
1847
+ edit: [AppFormItemType.TITLE],
1848
+ list: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
1849
+ filter: [AppFormItemType.TITLE, AppFormItemType.IDUSER],
1850
+ view: [AppFormItemType.TITLE],
1851
+ };
1852
+ const AppFormFixedFootList4View = {
1853
+ create: [AppFormItemType.PUBLISHTO, AppFormItemType.SENDALERTTOSUBSCRIBERS, AppFormItemType.RECEIVEACOPY],
1854
+ popup: [AppFormItemType.PUBLISHTO],
1855
+ edit: [AppFormItemType.PUBLISHTO],
1856
+ list: [AppFormItemType.DATECREATION],
1857
+ filter: [AppFormItemType.DATECREATION],
1858
+ view: [],
1859
+ };
1860
+ const AppFormFixedList = [
1861
+ AppFormItemType.TITLE,
1862
+ AppFormItemType.PUBLISHTO,
1863
+ AppFormItemType.SENDALERTTOSUBSCRIBERS,
1864
+ AppFormItemType.RECEIVEACOPY,
1865
+ AppFormItemType.IDUSER,
1866
+ AppFormItemType.DATECREATION,
1867
+ ];
1868
+ const AppFormUniqueList = [AppFormItemType.DESCRIPTION, AppFormItemType.IMAGE];
1869
+ const AppFormBannedFromViews = new Map();
1870
+ AppFormBannedFromViews.set(AppFormItemType.IMAGE, ['list', 'filter', 'view']);
1871
+ const AppListFilter = [
1872
+ AppFormItemType.TITLE,
1873
+ AppFormItemType.DESCRIPTION,
1874
+ AppFormItemType.TEXT,
1875
+ AppFormItemType.TEXTAREA,
1876
+ AppFormItemType.TEXTAREAHTML,
1877
+ AppFormItemType.DATE,
1878
+ AppFormItemType.DATETIME,
1879
+ AppFormItemType.RANGE,
1880
+ AppFormItemType.NUMBER,
1881
+ AppFormItemType.URL,
1882
+ AppFormItemType.EMAIL,
1883
+ AppFormItemType.SELECT,
1884
+ AppFormItemType.TOGGLE,
1885
+ AppFormItemType.CHECKBOX,
1886
+ AppFormItemType.RADIO,
1887
+ AppFormItemType.TAGS,
1888
+ AppFormItemType.PUBLISHTO,
1889
+ AppFormItemType.SENDALERTTOSUBSCRIBERS,
1890
+ AppFormItemType.RECEIVEACOPY,
1891
+ AppFormItemType.ADDFILEATTACHMENT,
1892
+ AppFormItemType.CODEHTML,
1893
+ AppFormItemType.IDUSER,
1894
+ AppFormItemType.DATECREATION,
1895
+ AppFormItemType.USERLINK,
1896
+ AppFormItemType.CONTENTLINK,
1897
+ ];
1898
+ const AppFormNoFixedValueList = {
1899
+ create: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
1900
+ popup: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
1901
+ edit: [AppFormItemType.IMAGE, AppFormItemType.ADDFILEATTACHMENT, AppFormItemType.CODEHTML],
1902
+ list: AppListFilter,
1903
+ filter: AppListFilter,
1904
+ view: AppListFilter,
1905
+ };
1906
+ const AppFormNoAsFieldList = AppFormFixedList.concat(AppFormNotFields)
1907
+ .concat(AppFormItemType.IDUSER)
1908
+ .concat(AppFormItemType.TITLE);
1909
+ const AppFormFieldOnlyInView = [AppFormItemType.CODEHTML];
1910
+ const AppFormNonPrimaryList = AppFormNoAsFieldList.concat(AppFormFieldOnlyInView).concat(AppFormPrimaryList);
1911
+ const STUDIO_VIEW = {
1912
+ SOLR: '1',
1913
+ NOT_SOLR: '0',
1914
+ };
1915
+
1916
+ function InstalledAppStudioAdapter(serverApp, serverApps) {
1917
+ const { version, dateCreation } = serverApp.manifest;
1918
+ const appTypeServer = serverApp.typeModel;
1919
+ const studioApp = {
1920
+ idApp: serverApp.idApp,
1921
+ status: _formatStatus(serverApp),
1922
+ manifest: {
1923
+ appShortName: serverApp.name,
1924
+ appName: serverApp.label,
1925
+ description: serverApp.description,
1926
+ author: serverApp.author,
1927
+ cssColor: appTypeServer.cssColor,
1928
+ cssClass: { label: appTypeServer.cssClass, value: appTypeServer.cssClass },
1929
+ version: version,
1930
+ dateCreation: dateCreation,
1931
+ checkAccess: serverApp.checkAccess,
1932
+ attrExposed: serverApp.attrExposed,
1933
+ viewSolr: serverApp.view,
1934
+ typeLabel: appTypeServer.typeLabel,
1935
+ },
1936
+ };
1937
+ const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
1938
+ if (!inWorkAppVersion)
1939
+ return studioApp;
1940
+ const inWorkApp = DraftAppStudioAdapter(inWorkAppVersion);
1941
+ if (!inWorkApp)
1942
+ return studioApp;
1943
+ studioApp.inWorkVersion = inWorkApp;
1944
+ return studioApp;
1945
+ }
1946
+ function DraftAppStudioAdapter(serverApp) {
1947
+ if (!serverApp.value)
1948
+ return undefined;
1949
+ const parsedJson = JSON.parse(serverApp.value);
1950
+ return {
1951
+ idApp: serverApp.idApp,
1952
+ status: _formatStatus(serverApp),
1953
+ manifest: parsedJson.manifest,
1954
+ };
1955
+ }
1956
+ function _formatStatus(serverApp) {
1957
+ return serverApp.status === StudioApplicationStatus.installed
1958
+ ? serverApp.suspended
1959
+ ? StatusType.suspended
1960
+ : StatusType.installed
1961
+ : StatusType.draft;
1962
+ }
1963
+ function _findAssociatedDraft(idApp, serverApps) {
1964
+ const draft = serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.saved);
1965
+ return draft;
1966
+ }
1967
+ function _findAssociatedInstalled(idApp, serverApps) {
1968
+ return !!serverApps.find((app) => app.idApp === idApp && app.status === StudioApplicationStatus.installed);
1969
+ }
1970
+ function serverAppsToStudioApps(serverApps) {
1971
+ const studioApps = serverApps
1972
+ .map((serverApp) => {
1973
+ if (serverApp.status === StudioApplicationStatus.installed) {
1974
+ return InstalledAppStudioAdapter(serverApp, serverApps);
1975
+ }
1976
+ else {
1977
+ if (_findAssociatedInstalled(serverApp.idApp, serverApps))
1978
+ return undefined;
1979
+ return DraftAppStudioAdapter(serverApp);
1980
+ }
1981
+ })
1982
+ .filter((app) => app !== undefined);
1983
+ return studioApps;
1984
+ }
1985
+
1986
+ const initialState = {
1987
+ studioAppsList: [],
1988
+ loadingStudioAppsList: 'idle',
1989
+ };
1990
+ const fetchStudioAppsList = createAsyncThunk('studio/appsList', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
1991
+ const jApi = extra.jApi;
1992
+ return yield new Promise((resolve, rejectWithValue) => {
1993
+ jApi.application
1994
+ .list()
1995
+ .then((res) => __awaiter(void 0, void 0, void 0, function* () {
1996
+ const coreApps = yield Promise.all(res.result.map((app) => __awaiter(void 0, void 0, void 0, function* () { return (yield jApi.application.get(app.idApp, app.status)).result; })));
1997
+ resolve(coreApps);
1998
+ }))
1999
+ .catch((e) => {
2000
+ var _a, _b;
2001
+ rejectWithValue({ error: (_a = e.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = e.errorMsg) !== null && _b !== void 0 ? _b : 'Error retrieving applications' });
2002
+ });
2003
+ });
2004
+ }));
2005
+ const StudioAppsListSlice = createSlice({
2006
+ name: 'studioAppsList',
2007
+ initialState,
2008
+ reducers: {},
2009
+ extraReducers: (builder) => {
2010
+ builder
2011
+ .addCase(fetchStudioAppsList.pending, (state) => {
2012
+ if (state.loadingStudioAppsList === 'idle')
2013
+ state.loadingStudioAppsList = 'pending';
2014
+ })
2015
+ .addCase(fetchStudioAppsList.fulfilled, (state, action) => {
2016
+ if (state.loadingStudioAppsList === 'pending')
2017
+ state.loadingStudioAppsList = 'idle';
2018
+ state.studioAppsList = serverAppsToStudioApps(action.payload);
2019
+ })
2020
+ .addCase(fetchStudioAppsList.rejected, (state) => {
2021
+ if (state.loadingStudioAppsList === 'pending')
2022
+ state.loadingStudioAppsList = 'idle';
2023
+ });
2024
+ },
2025
+ });
2026
+
2027
+ const joinedReducers = combineReducers$1({
2028
+ [StudioAppsListSlice.name]: StudioAppsListSlice.reducer,
2029
+ });
2030
+ const selectStudioAppsList = function selectStudioAppsList(state) {
2031
+ return state.studio.studioAppsList;
2032
+ };
2033
+ const studioSlice = {
2034
+ name: 'studio',
2035
+ reducer: joinedReducers,
2036
+ };
2037
+ const studio = {
2038
+ slice: studioSlice,
2039
+ actions: {
2040
+ fetchStudioAppsList,
2041
+ },
2042
+ selectors: {
2043
+ selectStudioAppsList,
2044
+ },
2045
+ };
2046
+
2047
+ export { APP_STATUS_TYPE, AUDIENCE, AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedFootList4View, AppFormFixedHeadList, AppFormFixedList, AppFormItemType, AppFormNoAsFieldList, AppFormNoFixedValueList, AppFormNonPrimaryList, AppFormNotFields, AppFormPrimaryList, AppFormUniqueList, Application, AssetReservation, Bookmark, Faq, MODE_EDIT, MODE_VIEW, Model, Network, STUDIO_VIEW, Share, StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, jland, slice, studio };
1798
2048
  //# sourceMappingURL=esm.js.map