ui-soxo-bootstrap-core 2.6.20 → 2.6.22

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.
@@ -1,10 +1,10 @@
1
- import React, { useState, useEffect, useContext, useRef } from 'react';
1
+ import { useContext, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { Route, Switch } from 'react-router-dom';
4
4
 
5
5
  import { Skeleton } from 'antd';
6
6
 
7
- import { GlobalHeader, ChangePassword, useTranslation, GlobalContext, ModuleRoutes, SpotlightSearch, SettingsUtil, Profile, Card } from '../../lib';
7
+ import { Card, ChangePassword, GlobalContext, GlobalHeader, ModuleRoutes, Profile, SettingsUtil, SpotlightSearch, useTranslation } from '../../lib';
8
8
 
9
9
  import './landing-api.scss';
10
10
 
@@ -16,7 +16,7 @@ import ReportingDashboard from '../../modules/reporting/components/reporting-das
16
16
 
17
17
  import PropTypes from 'prop-types';
18
18
 
19
- import { MenusAPI, CoreScripts } from '../../models';
19
+ import { CoreScripts, MenusAPI } from '../../models';
20
20
 
21
21
  const motivatingMessages = [
22
22
  'Setting things up for a great start...',
@@ -159,7 +159,6 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
159
159
  * @param reports
160
160
  */
161
161
  async function loadMenus(reports) {
162
-
163
162
  setLoader(true);
164
163
 
165
164
  // setReports(report)
@@ -169,16 +168,12 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
169
168
  // console.log(result);
170
169
 
171
170
  if (result && Array.isArray(result.result) && result.result.length) {
172
-
173
171
  // setModules(result.result);
174
-
175
172
  // result.result.map((ele) => {
176
173
  // let languageString = JSON.parse(ele.attributes)
177
174
  // console.log('language_string', languageString);
178
175
  // if (languageString && languageString.languages) {
179
-
180
176
  // const language = i18n.language;
181
-
182
177
  // i18n.addResourceBundle(language, 'translation', languageString.languages[i18n.language]);
183
178
  // }
184
179
  // })
@@ -189,7 +184,6 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
189
184
  dispatch({ type: 'settings', payload: result.result.settings });
190
185
  }
191
186
 
192
-
193
187
  // Reports length
194
188
  if (reports.length) {
195
189
  reportMenus = [
@@ -224,7 +218,6 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
224
218
  //If there is no roles assigned to the user
225
219
  setAllModules([...coreModules]);
226
220
  }
227
-
228
221
  } else {
229
222
  // for nura
230
223
  if (result && result.result.menus && reportMenus) {
@@ -233,14 +226,10 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
233
226
  //If there is no roles assigned to the user
234
227
  setAllModules([...coreModules]);
235
228
  }
236
-
237
-
238
229
  }
239
230
  setLoader(false);
240
-
241
231
  }
242
232
 
243
-
244
233
  /**
245
234
  * Load the scripts
246
235
  *
@@ -505,16 +494,18 @@ function DefineRoute({ menus, CustomComponents, CustomModels, settings, callback
505
494
  function printRoute(menu, index, CustomComponents, CustomModels, callback) {
506
495
  // From the path we remove any query parameters that exist in the url
507
496
  //
508
- let paths;
497
+ let paths = [];
509
498
 
510
499
  //There will be path for normal menus
511
- if (menu.path) {
500
+ if (menu?.path) {
512
501
  paths = menu.path.split('?');
513
- } else {
514
- /** In case if there is no path , ie, in case of reports menu */
515
- menu.sub_menus.map((menus) => {
516
- paths = menus.path.split('?');
517
- });
502
+ } else if (Array.isArray(menu?.sub_menus)) {
503
+ for (const subMenu of menu.sub_menus) {
504
+ if (subMenu?.path) {
505
+ paths = subMenu.path.split('?');
506
+ break;
507
+ }
508
+ }
518
509
  }
519
510
 
520
511
  // Find the route path
package/core/lib/Store.js CHANGED
@@ -72,12 +72,16 @@ const initialTheme = () => {
72
72
  const initialState = {
73
73
  defaultBranch: {},
74
74
  theme: initialTheme(), // Set the initial theme from themes.json
75
+ settings: {},
75
76
  };
76
77
 
77
78
  /**
78
79
  * Context for sharing state accross app
79
80
  */
80
- export const GlobalContext = createContext(initialState);
81
+ export const GlobalContext = createContext({
82
+ ...initialState,
83
+ state: initialState,
84
+ });
81
85
 
82
86
  let app = {};
83
87
 
@@ -3,7 +3,7 @@
3
3
  * Global header component
4
4
  */
5
5
 
6
- import React, { useState, useEffect, useContext,useRef } from "react";
6
+ import React, { useState, useEffect, useContext, useRef } from "react";
7
7
 
8
8
  import { animationControls, motion, useAnimation } from "framer-motion";
9
9
 
@@ -11,11 +11,11 @@ import {
11
11
  boxVariants,
12
12
  } from "./animations"
13
13
 
14
- import { GlobalContext } from "./../../Store";
14
+ import { GlobalContext, GlobalProvider } from "./../../Store";
15
15
 
16
16
  import { Link, useLocation } from "react-router-dom";
17
17
 
18
- import { Typography, Avatar ,Input} from "antd";
18
+ import { Typography, Avatar, Input, Tooltip } from "antd";
19
19
 
20
20
 
21
21
 
@@ -31,6 +31,7 @@ import {
31
31
  MenuOutlined,
32
32
  UserOutlined,
33
33
  SettingOutlined,
34
+ QuestionOutlined,
34
35
  } from "@ant-design/icons";
35
36
 
36
37
  import { Drawer } from "antd";
@@ -58,7 +59,7 @@ const { Title } = Typography;
58
59
 
59
60
 
60
61
 
61
- export default function GlobalHeader({
62
+ function GlobalHeaderContent({
62
63
  loading,
63
64
  appSettings,
64
65
  children,
@@ -76,17 +77,18 @@ export default function GlobalHeader({
76
77
 
77
78
 
78
79
 
79
- const { isMobile, user = { locations: [] }, kiosk, state } = useContext(GlobalContext);
80
+ const { isMobile, user = { locations: [] }, kiosk, state, settings } = useContext(GlobalContext);
80
81
 
81
82
 
82
83
 
83
84
  const [visible, setVisible] = useState(false);
85
+ const helpDeskSetting = settings?.HELPATR || {}
84
86
 
85
87
  // Variable to handle toggling of menu
86
88
  const [collapsed, setCollapsed] = useState(false);
87
89
  // varibale handle branch switcher
88
90
 
89
-
91
+
90
92
 
91
93
  // const [searchModalVisible, setSearchModalVisible] = useState(false);
92
94
 
@@ -107,8 +109,8 @@ export default function GlobalHeader({
107
109
 
108
110
 
109
111
  }, []);
110
-
111
-
112
+
113
+
112
114
 
113
115
 
114
116
  /**
@@ -125,9 +127,9 @@ export default function GlobalHeader({
125
127
  // input to avoid typing
126
128
  SettingsUtil.openSpotlightModal();
127
129
  };
128
-
129
-
130
-
130
+
131
+
132
+
131
133
 
132
134
  /**
133
135
  * Function to remove toggling on mobile view
@@ -170,10 +172,10 @@ export default function GlobalHeader({
170
172
 
171
173
  }, [state.theme]);
172
174
 
173
-
174
-
175
-
176
-
175
+
176
+
177
+
178
+
177
179
 
178
180
 
179
181
  return (
@@ -196,7 +198,7 @@ export default function GlobalHeader({
196
198
  //whileHover="hover"
197
199
  //whileTap="tap"
198
200
  className={`left-bar ${!isConnected && !isMobile ? "" : "hide"}${!collapsed ? "open" : "close"}${kiosk && !isConnected ? "kioskon" : ""}`}
199
- // style={{ background: state.theme.colors.leftSectionBackground }}
201
+ // style={{ background: state.theme.colors.leftSectionBackground }}
200
202
  >
201
203
 
202
204
  {!isMobile && !isConnected ? (
@@ -288,34 +290,34 @@ export default function GlobalHeader({
288
290
  </div>
289
291
 
290
292
  {/* Page Menu Actions */}
291
-
293
+
292
294
  {user.role || user.id ? (
293
295
  <div className="page-menu">
294
- {/* Search Input in header start */}
295
- { !isMobile && (
296
-
296
+ {/* Search Input in header start */}
297
+ {!isMobile && (
298
+
297
299
  <div>
298
- <Input
299
- placeholder="Search (Shift + F)"
300
- prefix={<SearchOutlined />}
301
- onClick={openSearchModal}
302
-
303
- readOnly
304
- style={{ width: 250 }}
305
- />
306
-
307
-
308
- <SpotlightSearch ref={(elem) => SettingsUtil.registerModal(elem)} props={props}/>
309
-
300
+ <Input
301
+ placeholder="Search (Shift + F)"
302
+ prefix={<SearchOutlined />}
303
+ onClick={openSearchModal}
304
+
305
+ readOnly
306
+ style={{ width: 250 }}
307
+ />
308
+
309
+
310
+ <SpotlightSearch ref={(elem) => SettingsUtil.registerModal(elem)} props={props} />
311
+
310
312
  </div>
311
- )}
312
- {/* Search Input in header start */}
313
+ )}
314
+ {/* Search Input in header start */}
313
315
 
314
316
  {/** branchswitcher Option */}
315
317
  {/* branch switcher controlled with env for matria and nura */}
316
318
  {!process.env.REACT_APP_SHOW_BRANCH_SWITCHER ? (
317
- <div className="branch-switcher">{globalCustomerHeader()}</div>
318
- ):null}
319
+ <div className="branch-switcher">{globalCustomerHeader()}</div>
320
+ ) : null}
319
321
  {/* <div className="branch-switcher">{globalCustomerHeader()}</div> */}
320
322
 
321
323
 
@@ -342,7 +344,7 @@ export default function GlobalHeader({
342
344
  ) : null}
343
345
  {/* Configurator Actions Ends */}
344
346
 
345
-
347
+
346
348
 
347
349
 
348
350
 
@@ -355,6 +357,18 @@ export default function GlobalHeader({
355
357
 
356
358
  {/* Reload Button Ends */}
357
359
 
360
+ {/* Help-desk-btn */}
361
+ {helpDeskSetting?.showSupportBtn ? <Tooltip title={helpDeskSetting?.toolTipText}>
362
+ <span>
363
+ <Button
364
+ onClick={() => window.open(helpDeskSetting?.helpDeskLink ?? '', '_blank')}
365
+ icon={<QuestionOutlined />}
366
+ type="default"
367
+ size="small"
368
+ />
369
+ </span>
370
+ </Tooltip> : null}
371
+
358
372
  {/** Switch Languages starts */}
359
373
  {process.env.REACT_APP_ENABLE_LANGUAGE_SWITCHER ? <LanguageSwitcher /> : null}
360
374
  {/** Switch Languages ends */}
@@ -383,6 +397,22 @@ export default function GlobalHeader({
383
397
  }
384
398
 
385
399
 
400
+ export default function GlobalHeader(props) {
401
+ const context = useContext(GlobalContext);
402
+
403
+ if (context.dispatch) {
404
+ return <GlobalHeaderContent {...props} />;
405
+ }
406
+
407
+ return (
408
+ <GlobalProvider {...props} appSettings={props.appSettings}>
409
+ <GlobalHeaderContent {...props} />
410
+ </GlobalProvider>
411
+ );
412
+ }
413
+
414
+
415
+
386
416
  /**
387
417
  *
388
418
  * @returns
@@ -35,6 +35,8 @@ import { FieldCustomizer, TabCustomizer } from "./../../../../";
35
35
 
36
36
  import { prepareAndExecuteScript } from './../../../../utils/script.utils';
37
37
 
38
+ import AdvancedSearchSelect from "../../../../../modules/reporting/components/reporting-dashboard/adavance-search/advance-search";
39
+
38
40
  const { TextArea } = Input;
39
41
 
40
42
  const { Option } = Select;
@@ -59,8 +61,10 @@ function FormCreator({
59
61
  formContent = {},
60
62
  onSubmit,
61
63
  fields = [],
64
+ reportId,
62
65
  callback,
63
66
  layout,
67
+ onFormValuesChange,
64
68
  // Below are arguments for use in form display
65
69
  onFieldUpdate,
66
70
  // onListUpdate,
@@ -69,7 +73,6 @@ function FormCreator({
69
73
  const [form] = Form.useForm();
70
74
 
71
75
  let layoutValue;
72
-
73
76
  if (layout) {
74
77
  layoutValue = layout
75
78
  } else {
@@ -194,11 +197,15 @@ function FormCreator({
194
197
  values = await prepareAndExecuteScript(values, null, fieldConfiguration.on_change);
195
198
 
196
199
  }
200
+
201
+ if (onFormValuesChange) {
202
+ onFormValuesChange(values);
203
+ }
197
204
  }
198
205
 
199
206
  return (
200
207
  <section className="form-creator">
201
- <div>
208
+
202
209
  {/* <DragDropContext onDragEnd={onDragEnd}>
203
210
  <Droppable droppableId="droppable">
204
211
 
@@ -251,6 +258,8 @@ function FormCreator({
251
258
  });
252
259
 
253
260
  }}
261
+ // layout="inline"
262
+
254
263
  onFieldsChange={onFieldsChange}
255
264
 
256
265
  onValuesChange={onValuesChange}
@@ -265,6 +274,7 @@ function FormCreator({
265
274
  {/* Mapper maps each fields to build the form */}
266
275
  <FieldMapper
267
276
  fields={fields}
277
+ reportId={reportId}
268
278
  onChange={onChange}
269
279
  selectedInformation={selectedInformation}
270
280
  onUpload={onUpload}
@@ -278,7 +288,7 @@ function FormCreator({
278
288
  SUBMIT
279
289
  </Button>
280
290
  </Form>
281
- </div>
291
+
282
292
  {/* </div>)}
283
293
 
284
294
  </Droppable>
@@ -299,6 +309,7 @@ export default FormCreator;
299
309
  */
300
310
  function FieldMapper({
301
311
  fields = [],
312
+ reportId,
302
313
  onChange,
303
314
  selectedInformation,
304
315
  onUpload,
@@ -337,6 +348,7 @@ function FieldMapper({
337
348
  {/* Mapper maps each fields to build the form */}
338
349
  <FieldMapper
339
350
  fields={tab.fields}
351
+ reportId={reportId}
340
352
  onChange={onChange}
341
353
  onUpload={onUpload}
342
354
  onFieldUpdate={onFieldUpdate}
@@ -358,6 +370,7 @@ function FieldMapper({
358
370
  ?
359
371
  <UserInput
360
372
  onChange={onChange}
373
+ reportId={reportId}
361
374
  index={index}
362
375
  key={index}
363
376
  onUpload={onUpload}
@@ -371,6 +384,7 @@ function FieldMapper({
371
384
  } else {
372
385
  return <UserInput
373
386
  onChange={onChange}
387
+ reportId={reportId}
374
388
  key={index}
375
389
  selectedInformation={selectedInformation}
376
390
  index={index}
@@ -397,7 +411,7 @@ function FieldMapper({
397
411
  *
398
412
  * @param {*} param0
399
413
  */
400
- function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpdate, onFieldRemove, index }) {
414
+ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpdate, onFieldRemove, index, reportId }) {
401
415
 
402
416
  let props = {};
403
417
 
@@ -423,8 +437,11 @@ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpda
423
437
 
424
438
  switch (field.type) {
425
439
 
440
+ case 'search':
441
+ return <AdvancedSearchSelect {...field} reportId={reportId} style={{ width: '100%' }} />
442
+
426
443
  case 'number':
427
- return <InputNumber required={field.required} />
444
+ return <InputNumber required={field.required} />
428
445
 
429
446
  case 'input':
430
447
  return <Input required={field.required} />
@@ -459,7 +476,7 @@ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpda
459
476
  return <TextArea rows={4} required={field.required} />
460
477
 
461
478
  case 'boolean':
462
- return <Select style={{ width: 120 }} required={field.required}>
479
+ return <Select style={{ width: '120' }} required={field.required}>
463
480
  {[true, false].map((option, key) => <Option key={key} value={option}>{option ? 'Yes' : 'No'}</Option>)}
464
481
  </Select>
465
482
 
@@ -495,7 +512,7 @@ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpda
495
512
  return (
496
513
  <Select defaultValue={defaultValue}
497
514
  required={field.required}
498
- style={{ width: 120 }}
515
+ style={{ width: '120' }}
499
516
  onChange={(value) => onChange(field, value)}
500
517
  >
501
518
  {field.options.map((option, key) => (
@@ -605,7 +622,13 @@ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpda
605
622
  <FieldCustomizer field={field} onFieldUpdate={onFieldUpdate} index={index} onFieldRemove={onFieldRemove} />
606
623
  {/* Customizes the form Ends */}
607
624
 
608
- <Form.Item {...props} name={field.field} label={field.caption} rules={[{ required: field.required, message: field.placeholder || 'Please enter ' + field.caption }]}>
625
+ <Form.Item
626
+ {...props}
627
+ name={field.field}
628
+ label={field.caption}
629
+ rules={[{ required: field.required, message: field.placeholder || 'Please enter ' + field.caption }]}
630
+ style={{ marginBottom: '12px' }}
631
+ >
609
632
 
610
633
  {inputElement(field, onChange)}
611
634
  {/* <InputElement field={field} /> */}
@@ -1,31 +1,34 @@
1
1
  .form-creator {
2
- .ant-input-number {
3
- width: 100%;
4
- }
5
-
6
- .new-record {
7
- gap: 10px !important;
8
- }
2
+ .ant-input-number {
3
+ width: 100%;
4
+ }
9
5
 
10
- .form-item-element {
11
- position: relative;
12
- padding: 8px;
13
- border-radius: 4px;
14
- // border: 1px solid #e3e3e3;
15
- margin-bottom: 3px;
16
-
17
- .field-customizer {
18
- .actions {
19
- // display: none;
20
- float: right;
21
- // position: absolute;
22
- // right: 0px;
23
- }
24
- }
6
+ .new-record {
7
+ display: flex;
8
+ flex-wrap: wrap;
9
+ align-items: flex-start;
10
+ gap: 10px !important;
11
+ }
25
12
 
13
+ .form-item-element {
14
+ position: relative;
15
+ padding: 4px;
16
+ // border-radius: 4px;
17
+ // border: 1px solid #e3e3e3;
18
+ // margin-bottom: 3px;
19
+ min-width: 140px;
20
+ // flex: 0 1 auto;
21
+ .field-customizer {
22
+ .actions {
23
+ // display: none;
24
+ float: right;
25
+ // position: absolute;
26
+ // right: 0px;
27
+ }
26
28
  }
29
+ }
27
30
 
28
- .submit-button {
29
- margin-top: 10px;
30
- }
31
- }
31
+ .submit-button {
32
+ margin-top: 34px;
33
+ }
34
+ }