@zohodesk/library-platform 1.1.3-exp.3 → 1.1.3-temp-1

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.
Files changed (72) hide show
  1. package/es/bc/zlist/Constants.js +3 -1
  2. package/es/bc/zrecord/Constants.js +3 -1
  3. package/es/cc/table-connected/Properties.js +16 -0
  4. package/es/cc/table-list/Constants.js +4 -0
  5. package/es/cc/table-list/Properties.js +25 -0
  6. package/es/cc/table-list/row/Properties.js +44 -0
  7. package/es/index.js +2 -1
  8. package/es/library/dot/components/table-list/frameworks/hooks/useDropIndicator.js +8 -0
  9. package/es/library/dot/components/table-list/frameworks/hooks/useRowData.js +8 -0
  10. package/es/library/dot/components/table-list/frameworks/hooks/useTableRowReorder.js +105 -0
  11. package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +85 -15
  12. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +241 -1
  13. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +28 -4
  14. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +25 -9
  15. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -2
  16. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +50 -8
  17. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js +6 -1
  18. package/es/library/dot/components/table-list/frameworks/utils/getHeaderClasses.js +37 -0
  19. package/es/library/dot/components/table-list/frameworks/utils/getTableListClassName.js +37 -0
  20. package/es/library/dot/components/table-list/frameworks/utils/reOrder.js +90 -0
  21. package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +1 -1
  22. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +96 -0
  23. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/EventHandlersFactory.js +11 -3
  24. package/es/platform/client-actions/template-resolver/index.js +1 -0
  25. package/es/platform/client-actions/translators/context-resolver/index.js +6 -6
  26. package/es/platform/components/table-connected/adapters/controllers/ReOrderFinishController.js +21 -0
  27. package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +14 -0
  28. package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +5 -2
  29. package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +4 -2
  30. package/es/platform/components/table-connected/frameworks/TableConnectedView.js +5 -1
  31. package/es/platform/data-source/http-template/reOrderRecord.js +44 -0
  32. package/es/platform/data-source/index.js +2 -0
  33. package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +1 -2
  34. package/es/platform/sdk/domain/entities/ResourceManager.js +1 -1
  35. package/es/platform/zform/adapters/presenter/FormTranslator.js +6 -127
  36. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +32 -0
  37. package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +20 -0
  38. package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +30 -0
  39. package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +21 -0
  40. package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +21 -0
  41. package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +30 -0
  42. package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +30 -0
  43. package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +30 -0
  44. package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +29 -0
  45. package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +30 -0
  46. package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +30 -0
  47. package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +30 -0
  48. package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +29 -0
  49. package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +30 -0
  50. package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +27 -0
  51. package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +30 -0
  52. package/es/platform/zform/adapters/presenter/translators/fields/index.js +15 -0
  53. package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +3 -1
  54. package/es/platform/zform/domain/ZField.js +66 -17
  55. package/es/platform/zform/domain/ZSection.js +20 -7
  56. package/es/platform/zlist/adapters/controllers/ReOrderController.js +25 -0
  57. package/es/platform/zlist/adapters/controllers/ReOrderFailedController.js +26 -0
  58. package/es/platform/zlist/adapters/gateways/Repository.js +7 -0
  59. package/es/platform/zlist/adapters/gateways/Service.js +8 -0
  60. package/es/platform/zlist/adapters/presenters/TableTranslator.js +6 -2
  61. package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +9 -10
  62. package/es/platform/zlist/adapters/presenters/utils/DefaultClientActions.js +1 -1
  63. package/es/platform/zlist/applications/interfaces/input/ReOrderRecordUseCaseInput.js +1 -0
  64. package/es/platform/zlist/applications/usecases/ReOrderFailedUseCase.js +22 -0
  65. package/es/platform/zlist/applications/usecases/ReOrderUseCase.js +25 -0
  66. package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +24 -3
  67. package/es/platform/zlist/domain/entities/List.js +66 -2
  68. package/es/platform/zlist/frameworks/EventHandlersFactory.js +7 -3
  69. package/es/platform/zlist/frameworks/ZListBehaviourFactory.js +2 -1
  70. package/es/platform/zrecord/domain/entities/GetReOrderRecordsStrategy.js +40 -0
  71. package/es/platform/zrecord/domain/entities/RecordsManager.js +3 -1
  72. package/package.json +6 -3
@@ -0,0 +1,90 @@
1
+ function reorderImmutableArray(arr, fromIndex, toIndex) {
2
+ const start = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
3
+
4
+ if (start >= 0 && start < arr.length) {
5
+ const end = toIndex < 0 ? arr.length + toIndex : toIndex;
6
+ const [item] = arr.splice(start, 1);
7
+ arr.splice(end, 0, item);
8
+ }
9
+ }
10
+
11
+ export function reorderArray(arr, fromIndex, toIndex) {
12
+ const copy = [...arr];
13
+ reorderImmutableArray(copy, fromIndex, toIndex);
14
+ return copy;
15
+ }
16
+ export function parseCssNumberWithUnit(value) {
17
+ if (typeof value !== "string") return null;
18
+ const regex = /^(-?\d+(\.\d+)?)([a-z%]*)$/i;
19
+ const match = value.trim().match(regex);
20
+ if (!match) return null;
21
+ return {
22
+ number: parseFloat(match[1]),
23
+ unit: match[3] || ""
24
+ };
25
+ }
26
+ export function setTableInteractionClass(ref, className, add) {
27
+ if (ref.current) {
28
+ if (add && !ref.current.classList.contains(className)) {
29
+ ref.current.classList.add(className);
30
+ } else if (!add && ref.current.classList.contains(className)) {
31
+ ref.current.classList.remove(className);
32
+ }
33
+ }
34
+ }
35
+ export function adjustHelperElementPosition(ref, draggingClass) {
36
+ if (ref.current) {
37
+ const TableScrollLeft = ref.current.scrollLeft;
38
+ const helperElement = ref.current.querySelector(`.${draggingClass}`);
39
+
40
+ if (helperElement) {
41
+ const helperLeft = parseCssNumberWithUnit(helperElement.style.left);
42
+
43
+ if (helperLeft && helperLeft.unit === 'px') {
44
+ helperElement.style.left = `${helperLeft.number + TableScrollLeft}px`;
45
+ }
46
+
47
+ helperElement.scrollLeft = TableScrollLeft;
48
+ }
49
+ }
50
+ }
51
+ export function getDropIndicator(_ref) {
52
+ let {
53
+ index,
54
+ oldIndex,
55
+ newIndex,
56
+ rowsLength
57
+ } = _ref;
58
+ const isMovingDown = newIndex > oldIndex;
59
+ let dropIndex, normalizedDropIndex, dropPosition;
60
+
61
+ if (index === newIndex && newIndex === 0) {
62
+ normalizedDropIndex = 1;
63
+ dropPosition = 'downward';
64
+ } else if (index === newIndex && newIndex === rowsLength - 1) {
65
+ normalizedDropIndex = rowsLength - 2;
66
+ dropPosition = 'upward';
67
+ } else {
68
+ if (isMovingDown) {
69
+ dropIndex = newIndex < index ? newIndex : newIndex + 1;
70
+ } else {
71
+ dropIndex = newIndex <= index ? newIndex - 1 : newIndex;
72
+ }
73
+
74
+ normalizedDropIndex = dropIndex;
75
+ dropPosition = isMovingDown ? 'downward' : 'upward';
76
+
77
+ if (dropIndex < 0) {
78
+ normalizedDropIndex = 0;
79
+ dropPosition = 'downward';
80
+ } else if (dropIndex >= rowsLength) {
81
+ normalizedDropIndex = rowsLength - 1;
82
+ dropPosition = 'upward';
83
+ }
84
+ }
85
+
86
+ return {
87
+ index: normalizedDropIndex,
88
+ position: dropPosition
89
+ };
90
+ }
@@ -27,7 +27,7 @@ function TextAreaView(_ref, ref) {
27
27
  text: value,
28
28
  isReadOnly: readonly,
29
29
  isDisabled: disabled,
30
- animated: true,
30
+ animated: !readonly && !disabled,
31
31
  size: "xsmall",
32
32
  customAttributes: {
33
33
  required
@@ -0,0 +1,96 @@
1
+ import { createCustomComponent } from "../../../../../../library/custom-component";
2
+ import ActionEventMediatorProperties from "../../../../cc/action-event-mediator/Properties";
3
+ import EventHandlersFactory from "./EventHandlersFactory";
4
+ import ActionEventMediatorView from "./ActionEventMediatorView"; // import ClientActionsSDKFactory from '../../../../behaviour/zclient-actions/frameworks/sdk/ClientActionsSDKFactory'; TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
5
+
6
+ import ClientActionsBehaviourFactory from "../../../../behaviour/zclient-actions/frameworks/ClientActionsBehaviourFactory";
7
+ import getClientActions from "../../../../../data-source/http-template/getClientActions";
8
+ import ClientActionsTranslator from "../../../../translators/client-actions-translator";
9
+ import FetchGateWay from "../../../../../zhttp/adapters/gateway/FetchGateWay";
10
+ import APITemplate from "../../../../../zdata-source/domain/entities/APITemplate";
11
+ import TemplateHelpers from "../../../../../zdata-source/adapters/gateways/TemplateHelpers";
12
+ ;
13
+ const windowWrapper = window;
14
+ const ClientActionsAdapterUtils = {
15
+ getClientActionsAPIDetails(args) {
16
+ const apiTemplate = new APITemplate(getClientActions, new TemplateHelpers());
17
+ args.servicePrefix = 'supportapi/zd';
18
+ args.orgName = windowWrapper.currentOrg.portalName;
19
+ const apiDetails = apiTemplate.getApiDetails(args);
20
+ apiDetails.options = {
21
+ headers: {
22
+ orgId: windowWrapper.currentOrg.id
23
+ },
24
+ method: apiDetails.method
25
+ };
26
+ return apiDetails;
27
+ },
28
+
29
+ transform(input) {
30
+ return ClientActionsTranslator.transform(input, {
31
+ departmentName: windowWrapper.currentDepartment.sanitizedName,
32
+ orgId: windowWrapper.currentOrg.id,
33
+ orgName: windowWrapper.currentOrg.portalName,
34
+ servicePrefix: 'supportapi/zd'
35
+ });
36
+ }
37
+
38
+ };
39
+ const ClientActionsAdapter = {
40
+ createEventHandler(clientScript) {
41
+ return event => {
42
+ let response = {
43
+ event: event,
44
+ sdk: {}
45
+ }; // response.sdks.clientActions = ClientActionsSDKFactory.create({ TODO: Add support for returning clientActionsSDK factory when client actions SDK is merged to V2
46
+ // state: event.state,
47
+ // dispatch: event.dispatch
48
+ // });
49
+
50
+ clientScript(response);
51
+ };
52
+ },
53
+
54
+ createActionToEventHandlers(clientScripts) {
55
+ const actionEventHandlers = {};
56
+ Object.keys(clientScripts).map(targetEvent => {
57
+ const clientScript = clientScripts[targetEvent];
58
+ actionEventHandlers[targetEvent] = ClientActionsAdapter.createEventHandler(clientScript);
59
+ });
60
+ return actionEventHandlers;
61
+ },
62
+
63
+ fetchClientActions(args) {
64
+ const apiDetails = ClientActionsAdapterUtils.getClientActionsAPIDetails(args);
65
+ const fetchGateway = new FetchGateWay(window.fetch.bind(window));
66
+ return fetchGateway.fetch(apiDetails.url, apiDetails.options).then(response => {
67
+ return response.json();
68
+ }).then(response => {
69
+ if (response.errorCode) {
70
+ return Promise.reject(response);
71
+ } else {
72
+ const actions = ClientActionsAdapterUtils.transform(response);
73
+ return Promise.resolve(actions);
74
+ }
75
+ });
76
+ },
77
+
78
+ getClientActionComponent: clientScripts => {
79
+ return createCustomComponent({
80
+ name: 'ClientActionsAdapter',
81
+ properties: ActionEventMediatorProperties,
82
+ setInitialState: () => ({
83
+ handlers: {}
84
+ }),
85
+ eventHandlers: { ...EventHandlersFactory.createClientActionsAdapterEventHandlers(),
86
+ ...ClientActionsAdapter.createActionToEventHandlers(clientScripts)
87
+ },
88
+ behaviours: [ClientActionsBehaviourFactory.create({
89
+ getClientActions: getClientActions
90
+ })],
91
+ View: ActionEventMediatorView
92
+ });
93
+ }
94
+ };
95
+ export const getClientActionsAdapter = ClientActionsAdapter.getClientActionComponent;
96
+ export const fetchClientActions = ClientActionsAdapter.fetchClientActions;
@@ -9,6 +9,14 @@ import PropertiesChangeController from "../../adapters/controllers/PropertiesCha
9
9
  import LifeCycleEvents from "../../../../../../cc/component/LifeCycleEventsEnum";
10
10
  export default class EventHandlersFactory {
11
11
  static create() {
12
+ return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ActionEventMediator');
13
+ }
14
+
15
+ static createClientActionsAdapterEventHandlers() {
16
+ return EventHandlersFactory.createClientActionsLifeCycleEventHandlers('ClientActionsAdapter');
17
+ }
18
+
19
+ static createClientActionsLifeCycleEventHandlers(componentName) {
12
20
  const repository = new Repository();
13
21
  const presenter = new Presenter();
14
22
  const dependencies = {
@@ -22,9 +30,9 @@ export default class EventHandlersFactory {
22
30
  const unmountController = new UnmountController(destroyUseCase);
23
31
  const propertiesChangeController = new PropertiesChangeController(propertiesChangeUseCase);
24
32
  return {
25
- [`ActionEventMediator#${LifeCycleEvents.MOUNT}`]: initializeController.handle,
26
- [`ActionEventMediator#${LifeCycleEvents.UPDATE_PROPERTIES}`]: propertiesChangeController.handle,
27
- [`ActionEventMediator#${LifeCycleEvents.UN_MOUNT}`]: unmountController.handle
33
+ [`${componentName}#${LifeCycleEvents.MOUNT}`]: initializeController.handle,
34
+ [`${componentName}#${LifeCycleEvents.UPDATE_PROPERTIES}`]: propertiesChangeController.handle,
35
+ [`${componentName}#${LifeCycleEvents.UN_MOUNT}`]: unmountController.handle
28
36
  };
29
37
  }
30
38
 
@@ -22,6 +22,7 @@ export default class TemplateResolver {
22
22
  }
23
23
 
24
24
  static replaceContextVariablesInObject(properties, replacementObj) {
25
+ if (!properties) return {};
25
26
  const replaced = {};
26
27
  Object.entries(properties).forEach(_ref => {
27
28
  let [key, value] = _ref;
@@ -4,7 +4,7 @@ export class ActionContextResolver {
4
4
 
5
5
  static resolveContextInEventMappingPayload(eventMapping, context) {
6
6
  return { ...eventMapping,
7
- payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.payloadValueMappingMeta, context)
7
+ payloadValueMapping: TemplateResolver.replaceContextVariablesInObject(eventMapping.payloadValueMapping, context)
8
8
  };
9
9
  }
10
10
 
@@ -14,9 +14,9 @@ export class ActionContextResolver {
14
14
  pattern
15
15
  } = condition;
16
16
  const resolvedFields = fields.map(field => {
17
- const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(","), templateContext);
17
+ const resolvedValue = TemplateResolver.replaceContextVariables(field.value.join(','), templateContext);
18
18
  return { ...field,
19
- value: resolvedValue.split(",")
19
+ value: resolvedValue.split(',')
20
20
  };
21
21
  });
22
22
  return { ...condition,
@@ -31,10 +31,10 @@ export class ActionContextResolver {
31
31
 
32
32
  static resolveAction(action, context) {
33
33
  const eventMappings = action.uiComponentMapping.eventMappings;
34
- const conditions = action.conditionsMeta;
34
+ const conditions = action.conditions;
35
35
  const resolvedEventMappings = eventMappings.map(eventMapping => this.resolveContextInEventMappingPayload(eventMapping, context));
36
- const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.propertiesValueMappingMeta, context);
37
- const resolveConditionValues = this.resolveConditionValueContext(conditions, context);
36
+ const resolvedProperty = this.resolveContextInProperties(action.uiComponentMapping.propertiesValueMapping, context);
37
+ const resolveConditionValues = conditions ? this.resolveConditionValueContext(conditions, context) : conditions;
38
38
  return { ...action,
39
39
  conditions: resolveConditionValues,
40
40
  uiComponentMapping: { ...action.uiComponentMapping,
@@ -0,0 +1,21 @@
1
+ import AbstractController from "./AbstractController";
2
+ import { ZLIST_RECORD_REORDER } from "../../../../../bc/zlist/Constants";
3
+ export class ReOrderFinishController extends AbstractController {
4
+ handle(event) {
5
+ const {
6
+ dispatch
7
+ } = event;
8
+ const {
9
+ oldIndex,
10
+ newIndex
11
+ } = event.action.payload;
12
+ dispatch({
13
+ type: ZLIST_RECORD_REORDER,
14
+ payload: {
15
+ oldIndex,
16
+ newIndex
17
+ }
18
+ });
19
+ }
20
+
21
+ }
@@ -15,6 +15,7 @@ import DeleteMultipleRecordUseCase from "../../../../zlist/applications/usecases
15
15
  import RecordUpdateUseCase from "../../../../zlist/applications/usecases/RecordUpdateUseCase";
16
16
  import UpdateMultipleRecordUseCase from "../../../../zlist/applications/usecases/UpdateMultipleRecordUseCase";
17
17
  import GetContextUseCase from "../../../../zlist/applications/usecases/GetContextUseCase";
18
+ import ReOrderUseCase from "../../../../zlist/applications/usecases/ReOrderUseCase";
18
19
  export class SmartTableResource extends AbstractResource {
19
20
  initialize() {}
20
21
 
@@ -234,4 +235,17 @@ export class SmartTableResource extends AbstractResource {
234
235
  });
235
236
  }
236
237
 
238
+ reOrderRecord(fromIndex, toIndex) {
239
+ const {
240
+ dispatch
241
+ } = this.dependencies;
242
+ const dependencies = this.getListDependencies();
243
+ const usecase = this.createUseCase(dependencies, ReOrderUseCase);
244
+ usecase.execute({
245
+ newIndex: toIndex,
246
+ oldIndex: fromIndex,
247
+ dispatch
248
+ });
249
+ }
250
+
237
251
  }
@@ -10,6 +10,7 @@ import ResizeStartController from "../adapters/controllers/ResizeStartController
10
10
  import ResizeByMouseController from "../adapters/controllers/ResizeByMouseController";
11
11
  import ResizeEndController from "../adapters/controllers/ResizeEndController";
12
12
  import { ResizeFinishController } from "../adapters/controllers/ResizeFinishController";
13
+ import { ReOrderFinishController } from "../adapters/controllers/ReOrderFinishController";
13
14
  import ScrollController from "../adapters/controllers/ScrollController";
14
15
  import ColumnChooserUpdateController from "../adapters/controllers/ColumnChooserUpdateController";
15
16
  import ColumnChooserOpenedController from "../adapters/controllers/ColumnChooserOpenedController";
@@ -18,7 +19,8 @@ const {
18
19
  TABLE_LIST_RESIZE_START_REQUESTED,
19
20
  TABLE_LIST_RESIZE_MOVE_REQUESTED,
20
21
  TABLE_LIST_RESIZE_END_REQUESTED,
21
- TABLE_LIST_SCROLLED
22
+ TABLE_LIST_SCROLLED,
23
+ TABLE_LIST_ROW_DRAG_END
22
24
  } = TableListEventConstants;
23
25
 
24
26
  function createHandlerWithSdk(handler) {
@@ -92,7 +94,8 @@ export default class EventHandlersFactory {
92
94
  type: SmartTableConstants.Events.SELECTION_LIMIT_EXCEEDED,
93
95
  payload: action.payload
94
96
  });
95
- }
97
+ },
98
+ [TABLE_LIST_ROW_DRAG_END]: new ReOrderFinishController().handle
96
99
  };
97
100
  }
98
101
 
@@ -15,7 +15,8 @@ export default class ListSdkFactory {
15
15
  updateRecords: function (recordsMap) {
16
16
  let shouldFetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
17
17
  return smartTable.updateRecords(recordsMap, shouldFetch);
18
- }
18
+ },
19
+ reOrderRecord: (fromIndex, toIndex) => smartTable.reOrderRecord(fromIndex, toIndex)
19
20
  };
20
21
  }
21
22
 
@@ -47,7 +48,8 @@ export default class ListSdkFactory {
47
48
  selectRecords: selectionSdks.selectRecords,
48
49
  deselectRecords: selectionSdks.deselectRecords,
49
50
  selectAllRecords: selectionSdks.selectAllRecords,
50
- deselectAllRecords: selectionSdks.deselectAllRecords
51
+ deselectAllRecords: selectionSdks.deselectAllRecords,
52
+ reOrderRecord: recordSdks.reOrderRecord
51
53
  }
52
54
  };
53
55
  }
@@ -8,6 +8,7 @@ function View(_ref, ref) {
8
8
  } = _ref;
9
9
  const {
10
10
  isLoading,
11
+ isReOrderLoading,
11
12
  data = [],
12
13
  rowActionsConfig,
13
14
  rowCursor,
@@ -15,7 +16,8 @@ function View(_ref, ref) {
15
16
  selection,
16
17
  emptyStateUiType,
17
18
  focussedRow,
18
- keyboardControlsConfig
19
+ keyboardControlsConfig,
20
+ reOrderConfig
19
21
  } = state.viewModel;
20
22
  const {
21
23
  resizerState
@@ -28,6 +30,8 @@ function View(_ref, ref) {
28
30
  autoColumnSizing
29
31
  } = preferences ? preferences : {};
30
32
  return /*#__PURE__*/React.createElement(TableList, {
33
+ reOrderConfig: reOrderConfig,
34
+ isReOrderLoading: isReOrderLoading,
31
35
  data: data,
32
36
  rowCursor: rowCursor,
33
37
  sortBy: sortBy,
@@ -0,0 +1,44 @@
1
+ const reOrderRecord = {
2
+ name: 'records',
3
+ api: '/{{servicePrefix}}/{{orgName}}/api/v1/{{moduleName}}/reorder',
4
+ parameters: `{}`,
5
+ type: 'POST',
6
+ transformer: data => data,
7
+ getResponse: _ref => {
8
+ let {
9
+ payload
10
+ } = _ref;
11
+ let {
12
+ oldIndex,
13
+ newIndex
14
+ } = payload;
15
+ return {
16
+ oldIndex,
17
+ newIndex,
18
+ status: 'success'
19
+ }; // return Promise.reject({
20
+ // status: 500,
21
+ // error: "Something went wrong",
22
+ // });
23
+ },
24
+ requestBody: '{ "oldIndex": {{oldIndex}}, "newIndex": {{newIndex}} }',
25
+ properties: {
26
+ moduleName: {
27
+ required: true,
28
+ typeMetadata: {
29
+ schema: {
30
+ type: 'string'
31
+ }
32
+ }
33
+ },
34
+ recordId: {
35
+ required: true,
36
+ typeMetadata: {
37
+ schema: {
38
+ type: 'string'
39
+ }
40
+ }
41
+ }
42
+ }
43
+ };
44
+ export default reOrderRecord;
@@ -5,6 +5,7 @@ import deleteRecords from "./http-template/deleteRecords";
5
5
  import getAvailableFields from "./http-template/getAvailableFields";
6
6
  import getSelectedFields from "./http-template/getSelectedFields";
7
7
  import getClientActions from "./http-template/getClientActions";
8
+ import reOrderRecord from "./http-template/reOrderRecord";
8
9
  import { RecordApiActionName } from "../../bc/zrecord/Constants";
9
10
  import deleteRecord from "./http-template/deleteRecord";
10
11
  import fetchMyLayouts from "./http-template/fetchMyFormLayout";
@@ -22,6 +23,7 @@ let dataSource = {
22
23
  [RecordApiActionName.DELETE_RECORD]: deleteRecord,
23
24
  [RecordApiActionName.CREATE_RECORD]: createRecord,
24
25
  [RecordApiActionName.GET_CLIENTACTIONS]: getClientActions,
26
+ [RecordApiActionName.GET_REORDERRECORD]: reOrderRecord,
25
27
  getAvailableFields,
26
28
  getSelectedFields,
27
29
  updateSelectedFields,
@@ -1,7 +1,6 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import { SdkResourceDependencies } from "../../../domain/entities/interfaces/SdkResourceDependencies";
4
- export { SdkResourceDependencies };
3
+ // export { SdkResourceDependencies };
5
4
  export class AbstractResource {
6
5
  constructor() {
7
6
  _defineProperty(this, "dependencies", void 0);
@@ -78,7 +78,7 @@ export class ResourceManager {
78
78
  resourceInstances
79
79
  } = this;
80
80
  const instance = (_resourceInstances$re3 = resourceInstances[resourceName]) === null || _resourceInstances$re3 === void 0 ? void 0 : _resourceInstances$re3[instanceName];
81
- instance.updateDependencies({
81
+ instance && instance.updateDependencies({
82
82
  state,
83
83
  dispatch,
84
84
  updateState
@@ -1,3 +1,4 @@
1
+ import SectionTranslator from "./translators/SectionTranslator";
1
2
  let fieldTypeToUIType = {
2
3
  Text: 'TextBox',
3
4
  Textarea: 'TextArea',
@@ -45,133 +46,11 @@ export default class FormTranslator {
45
46
  }
46
47
  };
47
48
  } else {
48
- let sections = state.behaviours.zform.sections.map(section => {
49
- return {
50
- type: uiMapping.sections[section.id],
51
- id: section.id + '',
52
- title: section.i18NLabel,
53
- description: '',
54
- //section.description,
55
- isVisible: section.visibility,
56
- fields: section.fields.map(field => {
57
- let type = uiMapping.fields[field.apiName] || fieldTypeToUIType[field.type];
58
-
59
- if (field.type == 'DateTime' || field.type == 'Date') {
60
- let value = field.value;
61
- return {
62
- id: field.id,
63
- label: field.i18NLabel,
64
- type,
65
- value: value || '',
66
- //state.behaviours.zform.values[field.apiName],
67
- name: field.apiName,
68
- // placeholder: field.i18NLabel,//field.placeholder,
69
- required: field.isMandatory,
70
- isVisible: field.visibility
71
- };
72
- } else if (field.type == 'Picklist') {
73
- let value = field.value;
74
- let errorMessage = field.errorMessage || '';
75
- return {
76
- id: field.id,
77
- label: field.i18NLabel,
78
- options: field.pickListValues.map(picklistValue => {
79
- return {
80
- value: picklistValue.value,
81
- label: picklistValue.value
82
- };
83
- }),
84
- type,
85
- subType: field.subType.toLowerCase(),
86
- value: value || '',
87
- //state.behaviours.zform.values[field.apiName],
88
- name: field.apiName,
89
- // placeholder: field.i18NLabel,//field.placeholder,
90
- required: field.isMandatory,
91
- isVisible: field.visibility,
92
- errorMessage
93
- };
94
- } else if (field.type == 'Multiselect') {
95
- let value = field.value;
96
- let errorMessage = field.errorMessage || '';
97
- return {
98
- id: field.id,
99
- label: field.i18NLabel,
100
- options: field.pickListValues ? field.pickListValues.map(picklistValue => {
101
- return {
102
- value: picklistValue.value,
103
- label: picklistValue.value
104
- };
105
- }) : [],
106
- type,
107
- subType: field.subType,
108
- value: value || [],
109
- //state.behaviours.zform.values[field.apiName],
110
- name: field.apiName,
111
- // placeholder: field.i18NLabel,//field.placeholder,
112
- required: field.isMandatory,
113
- isVisible: field.visibility,
114
- errorMessage
115
- };
116
- } else if (field.type == 'Boolean') {
117
- let value = field.value;
118
- return {
119
- id: field.id,
120
- label: field.i18NLabel,
121
- type,
122
- value: value || false,
123
- name: field.apiName,
124
- // placeholder: field.i18NLabel,//field.placeholder,
125
- required: field.isMandatory,
126
- isVisible: field.visibility
127
- };
128
- } else if (field.type == 'Text') {
129
- let value = field.value;
130
- let errorMessage = field.errorMessage || '';
131
- return {
132
- type,
133
- value: value || '',
134
- //state.behaviours.zform.values[field.apiName],
135
- name: field.apiName,
136
- id: field.id,
137
- label: field.i18NLabel,
138
- tooltip: '',
139
- //field.tooltip,
140
- ePHI: false,
141
- //field.ePHI,
142
- placeholder: field.i18NLabel,
143
- //field.placeholder,
144
- required: field.isMandatory,
145
- isVisible: field.visibility,
146
- errorMessage
147
- };
148
- } else {
149
- let value = field.value;
150
- let errorMessage = field.errorMessage || '';
151
- const fieldModified = {
152
- type,
153
- value: value || '',
154
- //state.behaviours.zform.values[field.apiName],
155
- name: field.apiName,
156
- id: field.id,
157
- label: field.i18NLabel,
158
- tooltip: '',
159
- //field.tooltip,
160
- placeholder: field.i18NLabel,
161
- //field.placeholder,
162
- required: field.isMandatory,
163
- isVisible: field.visibility,
164
- errorMessage
165
- };
166
-
167
- if (ePHIFields[field.type]) {
168
- fieldModified.ePHI = true;
169
- }
170
-
171
- return fieldModified;
172
- }
173
- })
174
- };
49
+ let sections = SectionTranslator({
50
+ state,
51
+ fieldTypeToUIType,
52
+ ePHIFields,
53
+ uiMapping
175
54
  });
176
55
  return { ...state,
177
56
  viewModel: {
@@ -0,0 +1,32 @@
1
+ import * as FieldTranslators from "./fields";
2
+
3
+ const SectionTranslator = _ref => {
4
+ let {
5
+ state,
6
+ fieldTypeToUIType,
7
+ ePHIFields,
8
+ uiMapping
9
+ } = _ref;
10
+ let sections = state.behaviours.zform.sections.map(section => {
11
+ return {
12
+ type: uiMapping.sections[section.id],
13
+ id: section.id + '',
14
+ title: section.i18NLabel,
15
+ description: section.description,
16
+ //section.description,
17
+ // isVisible: section.visibility,
18
+ isVisible: section.isVisible,
19
+ fields: section.fields.map(field => {
20
+ const fieldTranslator = FieldTranslators[field.type];
21
+ let type = uiMapping.fields[field.apiName] || fieldTypeToUIType[field.type];
22
+ return fieldTranslator({
23
+ field,
24
+ type
25
+ });
26
+ })
27
+ };
28
+ });
29
+ return sections;
30
+ };
31
+
32
+ export default SectionTranslator;
@@ -0,0 +1,20 @@
1
+ const BooleanFieldTranslator = _ref => {
2
+ let {
3
+ field,
4
+ type
5
+ } = _ref;
6
+ return {
7
+ id: field.id,
8
+ label: field.i18NLabel,
9
+ type,
10
+ value: field.value,
11
+ name: field.apiName,
12
+ // placeholder: field.i18NLabel,//field.placeholder,
13
+ required: field.isMandatory,
14
+ readonly: field.isReadOnly,
15
+ // visibility: field.isVisible
16
+ isVisible: field.isVisible
17
+ };
18
+ };
19
+
20
+ export default BooleanFieldTranslator;