@zohodesk/library-platform 1.0.0-exp.5 → 1.0.0-exp.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.
Files changed (77) hide show
  1. package/es/bc/zlist/Constants.js +6 -1
  2. package/es/bc/zrecord/Constants.js +5 -0
  3. package/es/cc/fields/boolean/Model.js +3 -1
  4. package/es/cc/fields/field/Types.js +1 -0
  5. package/es/cc/table-connected/Properties.js +9 -0
  6. package/es/desk-frameworks/table-connected/frameworks/ListSdkFactory.js +17 -3
  7. package/es/desk-frameworks/table-connected/frameworks/TableConnectedView.js +1 -0
  8. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +1 -1
  9. package/es/library/dot/legacy-to-new-arch/table-field-components/avatar-lookup-field/frameworks/ui/AvatarLookupField.js +12 -0
  10. package/es/library/dot/legacy-to-new-arch/table-field-components/avatar-lookup-field/frameworks/ui/AvatarLookupFieldView.js +18 -0
  11. package/es/library/dot/legacy-to-new-arch/{field-components/lookup-field → table-field-components/avatar-lookup-field}/frameworks/ui/LookupField.js +3 -2
  12. package/es/library/dot/legacy-to-new-arch/{field-components/lookup-field → table-field-components/avatar-lookup-field}/frameworks/ui/LookupFieldView.js +1 -2
  13. package/es/library/dot/legacy-to-new-arch/table-field-components/lookup-field copy/frameworks/ui/LookupField.js +12 -0
  14. package/es/library/dot/legacy-to-new-arch/table-field-components/lookup-field copy/frameworks/ui/LookupFieldView.js +18 -0
  15. package/es/platform/data-broker/http-template/deleteRecord.js +27 -0
  16. package/es/platform/data-broker/http-template/deleteRecords.js +1 -1
  17. package/es/platform/zfield/entities/api-template/APITemplate.js +26 -3
  18. package/es/platform/zhttp/adapters/controllers/FetchController.js +3 -1
  19. package/es/platform/zhttp/usecases/interactors/FetchUseCase.js +47 -19
  20. package/es/platform/zlist/adapters/controllers/DeleteSingleRecordController.js +23 -0
  21. package/es/platform/zlist/adapters/controllers/RecordExecuteFailedController.js +25 -0
  22. package/es/platform/zlist/adapters/controllers/RecordExecuteSucceededController.js +25 -0
  23. package/es/platform/zlist/adapters/gateways/Service.js +12 -0
  24. package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +3 -1
  25. package/es/platform/zlist/adapters/presenters/translators/fields/BooleanFieldTranslator.js +2 -1
  26. package/es/platform/zlist/entities/List.js +90 -2
  27. package/es/platform/zlist/entities/interfaces/RecordExecuteAfterMetaData.js +1 -0
  28. package/es/platform/zlist/frameworks/EventHandlersFactory.js +11 -1
  29. package/es/platform/zlist/usecases/interactors/DeleteSingleRecordUseCase.js +19 -0
  30. package/es/platform/zlist/usecases/interactors/RecordExecuteFailedUseCase.js +22 -0
  31. package/es/platform/zlist/usecases/interactors/RecordExecuteSucceededUseCase.js +22 -0
  32. package/es/platform/zlist/usecases/interfaces/input/DeleteSingleRecordUseCaseInput.js +1 -0
  33. package/es/platform/zlist/usecases/interfaces/input/RecordExecuteFailedUseCaseInput.js +1 -0
  34. package/es/platform/zlist/usecases/interfaces/input/RecordExecuteSucceededUseCaseInput.js +1 -0
  35. package/es/platform/zrecord/adapters/controllers/SetRecordsController.js +29 -0
  36. package/es/platform/zrecord/adapters/gateways/Service.js +4 -0
  37. package/es/platform/zrecord/entities/APITemplate.js +25 -3
  38. package/es/platform/zrecord/entities/RecordsManager.js +247 -37
  39. package/es/platform/zrecord/entities/interfaces/MetaData.js +1 -1
  40. package/es/platform/zrecord/frameworks/ActionsHandlersFactory.js +4 -1
  41. package/es/platform/zrecord/usecases/interactors/ExecuteActionUseCase.js +6 -2
  42. package/es/platform/zrecord/usecases/interactors/FailureUseCase.js +7 -5
  43. package/es/platform/zrecord/usecases/interactors/FetchMoreUseCase.js +1 -1
  44. package/es/platform/zrecord/usecases/interactors/NoContentUseCase.js +1 -0
  45. package/es/platform/zrecord/usecases/interactors/SetRecordsUseCase.js +22 -0
  46. package/es/platform/zrecord/usecases/interactors/SuccessUseCase.js +11 -4
  47. package/es/platform/zrecord/usecases/interfaces/input/SetRecordsInputModel.js +1 -0
  48. package/package.json +1 -1
  49. package/es/library/behaviours/sort-by/adapters/controllers/Initialize.js +0 -14
  50. package/es/library/custom-component/adapters/gateways/validator/jsonValidator.js +0 -5
  51. package/es/library/custom-component/entities/getRef.js +0 -10
  52. package/es/library/dot/components/action-location/adapters/gateway/RepositoryOld.js +0 -32
  53. package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxField.js +0 -13
  54. package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/CheckboxFieldView.js +0 -19
  55. package/es/library/dot/legacy-to-new-arch/field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +0 -29
  56. package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailField.js +0 -11
  57. package/es/library/dot/legacy-to-new-arch/field-components/email-field/frameworks/ui/EmailFieldView.js +0 -15
  58. package/es/library/dot/legacy-to-new-arch/field-components/index.js +0 -15
  59. package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectField.js +0 -11
  60. package/es/library/dot/legacy-to-new-arch/field-components/multiselect-field/frameworks/ui/MultiSelectFieldView.js +0 -21
  61. package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneField.js +0 -11
  62. package/es/library/dot/legacy-to-new-arch/field-components/phone-field/frameworks/ui/PhoneFieldView.js +0 -22
  63. package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListField.js +0 -11
  64. package/es/library/dot/legacy-to-new-arch/field-components/picklist-field/frameworks/ui/PickListFieldView.js +0 -19
  65. package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/EventHandlersFactory.js +0 -29
  66. package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchField.js +0 -13
  67. package/es/library/dot/legacy-to-new-arch/field-components/switch-field/frameworks/ui/SwitchFieldView.js +0 -18
  68. package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/EventHandlersFactory.js +0 -26
  69. package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextField.js +0 -13
  70. package/es/library/dot/legacy-to-new-arch/field-components/text-field/frameworks/ui/TextFieldView.js +0 -16
  71. package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/EventHandlersFactory.js +0 -26
  72. package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlField.js +0 -13
  73. package/es/library/dot/legacy-to-new-arch/field-components/url-field/frameworks/ui/UrlFieldView.js +0 -18
  74. package/es/platform/zfield/entities/interfaces/FieldTypes.js +0 -20
  75. package/es/platform/zfield/usecases/entity-factory/FieldBuilder.js +0 -109
  76. package/es/platform/zfield/usecases/entity-factory/FieldFactory.js +0 -10
  77. package/es/platform/zfield/usecases/entity-factory/FieldsManagerBuilder.js +0 -49
@@ -1,4 +1,9 @@
1
1
  export const ZLIST_DELETE_RECORDS = 'ZLIST#DELETE_RECORDS';
2
+ export const ZLIST_DELETE_RECORD = 'ZLIST#DELETE_RECORD';
2
3
  export const ZLIST_RECORD_UPDATE = 'ZLIST#RECORD_UPDATE';
3
4
  export const ZLIST_FETCH_MORE = 'ZLIST#FETCH_MORE';
4
- export const ZLIST_FETCH_SORTED = 'ZLIST#FETCH_SORTED';
5
+ export const ZLIST_FETCH_SORTED = 'ZLIST#FETCH_SORTED';
6
+ export const ZLIST_RECORD_UPDATE_SUCCEEDED = 'ZLIST#RECORD_UPDATE_SUCCEEDED';
7
+ export const ZLIST_RECORD_UPDATE_FAILED = 'ZLIST#RECORD_UPDATE_FAILED';
8
+ export const ZLIST_RECORD_DELETE_SUCCEEDED = 'ZLIST#RECORD_DELETE_SUCCEEDED';
9
+ export const ZLIST_RECORD_DELETE_FAILED = 'ZLIST#RECORD_DELETE_FAILED';
@@ -1,16 +1,21 @@
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
3
  export const RECORD_EXECUTE = 'RECORD#EXECUTE';
4
+ export const RECORD_EXECUTE_SUCCEEDED = 'RECORD#EXECUTE_SUCCEEDED';
5
+ export const RECORD_EXECUTE_FAILED = 'RECORD#EXECUTE_FAILED';
4
6
  export const RECORD_REFETCH = 'RECORD#REFETCH';
5
7
  export const RECORD_FETCH_MORE = 'RECORD#FETCH_MORE';
6
8
  export const RECORD_FIELD_CHANGE = 'RECORD#FIELD_CHANGE';
7
9
  export const RECORD_LOCAL_UPDATE = 'RECORD#LOCAL_UPDATE';
8
10
  export const RECORD_LOCAL_MULTIPLE_DELETE = 'RECORD#LOCAL_MULTIPLE_DELETE';
9
11
  export const APPEND_RECORDS = 'RECORD#APPEND_RECORDS';
12
+ export const SET_RECORDS = 'RECORD#SET_RECORDS';
10
13
  export class RecordApiActionName {}
11
14
 
12
15
  _defineProperty(RecordApiActionName, "GET_RECORDS", 'getRecords');
13
16
 
14
17
  _defineProperty(RecordApiActionName, "DELETE_RECORDS", 'deleteRecords');
15
18
 
19
+ _defineProperty(RecordApiActionName, "DELETE_RECORD", 'deleteRecord');
20
+
16
21
  _defineProperty(RecordApiActionName, "UPDATE_RECORD", 'updateRecord');
@@ -2,10 +2,12 @@ export default function BooleanFieldModel(_ref) {
2
2
  let {
3
3
  name,
4
4
  value,
5
- uiType
5
+ uiType,
6
+ appendToActionPayload
6
7
  } = _ref;
7
8
  return {
8
9
  name,
10
+ appendToActionPayload,
9
11
  type: uiType,
10
12
  value
11
13
  };
@@ -1,6 +1,7 @@
1
1
  var Types = /*#__PURE__*/function (Types) {
2
2
  Types["CheckboxField"] = "CheckboxField";
3
3
  Types["SwitchField"] = "SwitchField";
4
+ Types["AvatarLookupField"] = "AvatarLookupField";
4
5
  Types["SingleLineField"] = "SingleLineField";
5
6
  Types["MultiLineField"] = "MultiLineField";
6
7
  Types["EmailField"] = "EmailField";
@@ -10,6 +10,15 @@ export default { ...ZListProperties,
10
10
  }
11
11
  }
12
12
  },
13
+ isFlexibleColumns: {
14
+ required: false,
15
+ defaultValue: false,
16
+ typeMetadata: {
17
+ schema: {
18
+ type: 'boolean'
19
+ }
20
+ }
21
+ },
13
22
  selectionConfig: {
14
23
  required: false,
15
24
  defaultValue: {
@@ -1,4 +1,4 @@
1
- import { ZLIST_DELETE_RECORDS, ZLIST_RECORD_UPDATE } from "../../../bc/zlist/Constants";
1
+ import { ZLIST_DELETE_RECORD, ZLIST_DELETE_RECORDS, ZLIST_RECORD_UPDATE } from "../../../bc/zlist/Constants";
2
2
  /* eslint-disable max-lines-per-function */
3
3
 
4
4
  export default class ListSdkFactory {
@@ -15,6 +15,21 @@ export default class ListSdkFactory {
15
15
  return (_state$behaviours = state.behaviours) === null || _state$behaviours === void 0 ? void 0 : _state$behaviours.zrecord.records;
16
16
  },
17
17
 
18
+ getRecord(recordId) {
19
+ var _state$behaviours2, _state$behaviours2$zr;
20
+
21
+ return (_state$behaviours2 = state.behaviours) === null || _state$behaviours2 === void 0 ? void 0 : (_state$behaviours2$zr = _state$behaviours2.zrecord.records) === null || _state$behaviours2$zr === void 0 ? void 0 : _state$behaviours2$zr.find(r => r.id === recordId);
22
+ },
23
+
24
+ deleteRecord(recordId) {
25
+ dispatch({
26
+ type: ZLIST_DELETE_RECORD,
27
+ payload: {
28
+ recordId
29
+ }
30
+ });
31
+ },
32
+
18
33
  deleteRecords(recordIds) {
19
34
  dispatch({
20
35
  type: ZLIST_DELETE_RECORDS,
@@ -34,8 +49,7 @@ export default class ListSdkFactory {
34
49
  });
35
50
  }
36
51
 
37
- },
38
- zrecord: {}
52
+ }
39
53
  };
40
54
  }
41
55
 
@@ -22,6 +22,7 @@ function View(_ref, ref) {
22
22
  }, /*#__PURE__*/React.createElement(TableList, {
23
23
  data: data,
24
24
  hasRowActions: hasRowActions,
25
+ isFlexibleColumns: properties.isFlexibleColumns,
25
26
  isLoading: isLoading,
26
27
  emptyStateUiType: emptyStateUiType,
27
28
  selectionConfig: properties.selectionConfig
@@ -23,7 +23,7 @@
23
23
  height: calc(100% - (var(--zd_size100)))
24
24
  }
25
25
  .emptyContent {
26
- padding: var(--zd_size100) 0 var(--zd_size60)
26
+ padding: var(--zd_size160) 0 var(--zd_size60)
27
27
  }
28
28
  .actions {
29
29
  gap: var(--zd_size8)
@@ -0,0 +1,12 @@
1
+ import { createCustomComponent } from "../../../../../../custom-component";
2
+ import LookupProperties from "../../../../../../../cc/fields/lookup/Properties";
3
+ import LookupEvents from "../../../../../../../cc/fields/lookup/Events";
4
+ import { AvatarLookupFieldView } from "./AvatarLookupFieldView";
5
+ const AvatarLookupField = createCustomComponent({
6
+ name: 'AvatarLookupField',
7
+ View: AvatarLookupFieldView,
8
+ properties: LookupProperties,
9
+ events: LookupEvents,
10
+ eventHandlers: {}
11
+ });
12
+ export default AvatarLookupField;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Avatar } from "../../../..";
3
+ export function AvatarLookupFieldView(_ref, ref) {
4
+ let {
5
+ state
6
+ } = _ref;
7
+ const {
8
+ name,
9
+ photoURL
10
+ } = state.properties.value;
11
+ return /*#__PURE__*/React.createElement(Avatar, {
12
+ getRef: ref,
13
+ name: name,
14
+ label: name,
15
+ imageSrc: photoURL,
16
+ tooltip: ""
17
+ });
18
+ }
@@ -1,11 +1,12 @@
1
1
  import { createCustomComponent } from "../../../../../../custom-component";
2
2
  import LookupProperties from "../../../../../../../cc/fields/lookup/Properties";
3
+ import LookupEvents from "../../../../../../../cc/fields/lookup/Events";
3
4
  import { LookupFieldView } from "./LookupFieldView";
4
5
  const LookupField = createCustomComponent({
5
6
  name: 'LookupField',
6
7
  View: LookupFieldView,
7
8
  properties: LookupProperties,
8
- actions: [],
9
- actionHandlers: {}
9
+ events: LookupEvents,
10
+ eventHandlers: {}
10
11
  });
11
12
  export default LookupField;
@@ -2,8 +2,7 @@ import React from 'react';
2
2
  import { Avatar } from "../../../..";
3
3
  export function LookupFieldView(_ref, ref) {
4
4
  let {
5
- state,
6
- helpers
5
+ state
7
6
  } = _ref;
8
7
  const {
9
8
  name,
@@ -0,0 +1,12 @@
1
+ import { createCustomComponent } from "../../../../../../custom-component";
2
+ import LookupProperties from "../../../../../../../cc/fields/lookup/Properties";
3
+ import LookupEvents from "../../../../../../../cc/fields/lookup/Events";
4
+ import { LookupFieldView } from "./LookupFieldView";
5
+ const LookupField = createCustomComponent({
6
+ name: 'LookupField',
7
+ View: LookupFieldView,
8
+ properties: LookupProperties,
9
+ events: LookupEvents,
10
+ eventHandlers: {}
11
+ });
12
+ export default LookupField;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Avatar } from "../../../..";
3
+ export function LookupFieldView(_ref, ref) {
4
+ let {
5
+ state
6
+ } = _ref;
7
+ const {
8
+ name,
9
+ photoURL
10
+ } = state.properties.value;
11
+ return /*#__PURE__*/React.createElement(Avatar, {
12
+ getRef: ref,
13
+ name: name,
14
+ label: name,
15
+ imageSrc: photoURL,
16
+ tooltip: ""
17
+ });
18
+ }
@@ -0,0 +1,27 @@
1
+ const deleteRecord = {
2
+ name: 'records',
3
+ api: '/api/v1/{{moduleName}}/moveToTrash',
4
+ parameters: `{}`,
5
+ type: 'POST',
6
+ transformer: data => data,
7
+ requestBody: '{ "recordIds": ["{{recordId}}"] }',
8
+ properties: {
9
+ moduleName: {
10
+ required: true,
11
+ typeMetadata: {
12
+ schema: {
13
+ type: 'string'
14
+ }
15
+ }
16
+ },
17
+ recordId: {
18
+ required: true,
19
+ typeMetadata: {
20
+ schema: {
21
+ type: 'string'
22
+ }
23
+ }
24
+ }
25
+ }
26
+ };
27
+ export default deleteRecord;
@@ -4,7 +4,7 @@ const deleteRecords = {
4
4
  parameters: `{}`,
5
5
  type: 'POST',
6
6
  transformer: data => data,
7
- requestBody: '{ "entityIds": {{recordIds}} }',
7
+ requestBody: '{ "recordIds": {{recordIds}} }',
8
8
  // REVIEW: Is `entityIds` applicable to all modules? To be confirmed with backend team
9
9
  properties: {
10
10
  moduleName: {
@@ -16,8 +16,11 @@ class APITemplate {
16
16
 
17
17
  _defineProperty(this, "helper", void 0);
18
18
 
19
+ _defineProperty(this, "getResponseInTemplate", void 0);
20
+
19
21
  this.input = input;
20
22
  this.api = input.api;
23
+ this.getResponseInTemplate = input.getResponse;
21
24
  this.payload = input.requestBody;
22
25
  this.parameters = input.parameters;
23
26
  this.type = API_METHODS[input.type];
@@ -30,7 +33,7 @@ class APITemplate {
30
33
 
31
34
  getPayload(obj) {
32
35
  if (this.payload) {
33
- return JSON.parse(this.helper.replaceTemplateVariables(this.payload, obj));
36
+ return this.helper.replaceTemplateVariables(this.payload, obj);
34
37
  } else {
35
38
  return `{}`;
36
39
  }
@@ -47,15 +50,35 @@ class APITemplate {
47
50
  constructURL(obj) {
48
51
  const queryObj = JSON.parse(this.getParameter(obj));
49
52
  const query = this.helper.objectToQueryString(queryObj);
53
+
54
+ if (query === '') {
55
+ return this.getApi(obj);
56
+ }
57
+
50
58
  return `${this.getApi(obj)}?${query}`;
51
- }
59
+ } // eslint-disable-next-line max-lines-per-function
60
+
52
61
 
53
62
  getApiDetails(obj) {
54
- return {
63
+ const apiDetails = {
55
64
  url: this.constructURL(obj),
56
65
  type: this.type,
66
+ method: this.type,
57
67
  payload: this.getPayload(obj)
58
68
  };
69
+
70
+ if (this.getResponseInTemplate) {
71
+ apiDetails.getResponse = () => {
72
+ const payload = JSON.parse(this.getPayload(obj));
73
+ const params = JSON.parse(this.getParameter(obj));
74
+ return this.getResponseInTemplate({
75
+ payload,
76
+ params
77
+ });
78
+ };
79
+ }
80
+
81
+ return apiDetails;
59
82
  }
60
83
 
61
84
  getTransformer() {
@@ -17,12 +17,14 @@ class FetchController {
17
17
  const {
18
18
  url,
19
19
  method,
20
- headers
20
+ headers,
21
+ getResponse
21
22
  } = payload;
22
23
  this.fetchUseCase.execute({
23
24
  url,
24
25
  method,
25
26
  headers,
27
+ getResponse,
26
28
  metaData,
27
29
  dispatch,
28
30
  payload: payload.payload
@@ -11,7 +11,8 @@ class FetchUseCase extends AbstractUseCase {
11
11
  } = this.dependencies;
12
12
  const {
13
13
  url,
14
- method = 'GET'
14
+ method = 'GET',
15
+ getResponse
15
16
  } = inputModel;
16
17
  const {
17
18
  metaData,
@@ -32,27 +33,54 @@ class FetchUseCase extends AbstractUseCase {
32
33
  });
33
34
 
34
35
  try {
35
- const response = await fetchGateWay.fetch(url, {
36
- headers,
37
- method,
38
- body: method === "GET" ? null : payload
39
- });
36
+ // NOTE: getResponse is hacky solution to get the data using function call instead of fetch, So any handling added to here needs to be added to fetch and vise versa
37
+ if (typeof getResponse === 'function') {
38
+ const data = await getResponse();
40
39
 
41
- if (response.status === 204) {
42
- dispatch({
43
- type: FETCH_SUCCESS_NO_CONTENT,
44
- payload: {},
45
- metaData
46
- });
40
+ if (data === undefined) {
41
+ dispatch({
42
+ type: FETCH_SUCCESS_NO_CONTENT,
43
+ payload: {},
44
+ metaData
45
+ });
46
+ } else {
47
+ dispatch({
48
+ type: FETCH_SUCCESS,
49
+ payload: {
50
+ response: data
51
+ },
52
+ metaData
53
+ });
54
+ }
47
55
  } else {
48
- const data = await response.json();
49
- dispatch({
50
- type: FETCH_SUCCESS,
51
- payload: {
52
- response: data
53
- },
54
- metaData
56
+ const response = await fetchGateWay.fetch(url, {
57
+ headers,
58
+ method,
59
+ body: method === 'GET' ? null : payload
55
60
  });
61
+
62
+ if (response.status === 204) {
63
+ dispatch({
64
+ type: FETCH_SUCCESS_NO_CONTENT,
65
+ payload: {},
66
+ metaData
67
+ });
68
+ } else if (response.status === 200 && method === 'DELETE') {
69
+ dispatch({
70
+ type: FETCH_SUCCESS,
71
+ payload: {},
72
+ metaData
73
+ });
74
+ } else {
75
+ const data = await response.json();
76
+ dispatch({
77
+ type: FETCH_SUCCESS,
78
+ payload: {
79
+ response: data
80
+ },
81
+ metaData
82
+ });
83
+ }
56
84
  }
57
85
  } catch (e) {
58
86
  dispatch({
@@ -0,0 +1,23 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class DeleteSingleRecordController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ dispatch,
8
+ action
9
+ } = event;
10
+ const {
11
+ recordId
12
+ } = action.payload;
13
+ const {
14
+ deleteSingleRecordUseCase
15
+ } = this.service;
16
+ deleteSingleRecordUseCase.updateDependency(state, updateState);
17
+ deleteSingleRecordUseCase.execute({
18
+ dispatch,
19
+ recordId
20
+ });
21
+ }
22
+
23
+ }
@@ -0,0 +1,25 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class RecordExecuteFailedController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ dispatch,
8
+ action
9
+ } = event;
10
+ const {
11
+ payload,
12
+ metaData
13
+ } = action;
14
+ const {
15
+ recordExecuteFailedUseCase
16
+ } = this.service;
17
+ recordExecuteFailedUseCase.updateDependency(state, updateState);
18
+ recordExecuteFailedUseCase.execute({
19
+ dispatch,
20
+ payload,
21
+ metaData
22
+ });
23
+ }
24
+
25
+ }
@@ -0,0 +1,25 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class RecordExecuteSucceededController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ dispatch,
8
+ action
9
+ } = event;
10
+ const {
11
+ payload,
12
+ metaData
13
+ } = action;
14
+ const {
15
+ recordExecuteSucceededUseCase
16
+ } = this.service;
17
+ recordExecuteSucceededUseCase.updateDependency(state, updateState);
18
+ recordExecuteSucceededUseCase.execute({
19
+ dispatch,
20
+ payload,
21
+ metaData
22
+ });
23
+ }
24
+
25
+ }
@@ -7,6 +7,9 @@ import FieldChangeUseCase from "../../usecases/interactors/FieldChangeUseCase";
7
7
  import DeleteMultipleRecordUseCase from "../../usecases/interactors/DeleteMultipleRecordUseCase";
8
8
  import SortUseCase from "../../usecases/interactors/SortUseCase";
9
9
  import RecordUpdateUseCase from "../../usecases/interactors/RecordUpdateUseCase";
10
+ import DeleteSingleRecordUseCase from "../../usecases/interactors/DeleteSingleRecordUseCase";
11
+ import RecordExecuteSucceededUseCase from "../../usecases/interactors/RecordExecuteSucceededUseCase";
12
+ import RecordExecuteFailedUseCase from "../../usecases/interactors/RecordExecuteFailedUseCase";
10
13
 
11
14
  class Service {
12
15
  constructor(dependencies) {
@@ -22,6 +25,12 @@ class Service {
22
25
 
23
26
  _defineProperty(this, "deleteMultipleRecordUseCase", void 0);
24
27
 
28
+ _defineProperty(this, "deleteSingleRecordUseCase", void 0);
29
+
30
+ _defineProperty(this, "recordExecuteSucceededUseCase", void 0);
31
+
32
+ _defineProperty(this, "recordExecuteFailedUseCase", void 0);
33
+
25
34
  _defineProperty(this, "sortUseCase", void 0);
26
35
 
27
36
  _defineProperty(this, "recordUpdateUseCase", void 0);
@@ -32,6 +41,9 @@ class Service {
32
41
  this.fieldChangeUseCase = new FieldChangeUseCase(this.dependencies);
33
42
  this.sortUseCase = new SortUseCase(this.dependencies);
34
43
  this.deleteMultipleRecordUseCase = new DeleteMultipleRecordUseCase(this.dependencies);
44
+ this.deleteSingleRecordUseCase = new DeleteSingleRecordUseCase(this.dependencies);
45
+ this.recordExecuteSucceededUseCase = new RecordExecuteSucceededUseCase(this.dependencies);
46
+ this.recordExecuteFailedUseCase = new RecordExecuteFailedUseCase(this.dependencies);
35
47
  this.recordUpdateUseCase = new RecordUpdateUseCase(this.dependencies);
36
48
  }
37
49
 
@@ -26,7 +26,9 @@ function ColumnTranslator(field, record, fieldUiMapping) {
26
26
  return EmptyViewModel(type);
27
27
  }
28
28
 
29
- return fieldTranslator(field, value);
29
+ return fieldTranslator(field, value, {
30
+ recordId: record.id
31
+ });
30
32
  }
31
33
 
32
34
  export default ColumnTranslator;
@@ -1,7 +1,7 @@
1
1
  import FieldTypes from "../../../../../../cc/fields/field/Types";
2
2
  import BooleanFieldModel from "../../../../../../cc/fields/boolean/Model";
3
3
 
4
- const BooleanFieldTranslator = (field, value) => {
4
+ const BooleanFieldTranslator = (field, value, appendToActionPayload) => {
5
5
  const {
6
6
  uiType,
7
7
  name
@@ -16,6 +16,7 @@ const BooleanFieldTranslator = (field, value) => {
16
16
  return BooleanFieldModel({
17
17
  uiType: uiType || FieldTypes.CheckboxField,
18
18
  name,
19
+ appendToActionPayload,
19
20
  value
20
21
  });
21
22
  };
@@ -1,5 +1,6 @@
1
1
  import { RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_REFETCH, RecordApiActionName } from "../../../bc/zrecord/Constants";
2
2
  import { FIELD_EXECUTE, FIELD_REFETCH } from "../../../bc/zfield/Constants";
3
+ import { ZLIST_RECORD_DELETE_FAILED, ZLIST_RECORD_DELETE_SUCCEEDED, ZLIST_RECORD_UPDATE_FAILED, ZLIST_RECORD_UPDATE_SUCCEEDED } from "../../../bc/zlist/Constants";
3
4
 
4
5
  class List {
5
6
  constructor(limit, sortBy, filter, headers) {
@@ -10,14 +11,12 @@ class List {
10
11
  }
11
12
 
12
13
  createApiProps() {
13
- let from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
14
14
  const {
15
15
  filter,
16
16
  limit,
17
17
  sortBy
18
18
  } = this;
19
19
  return {
20
- from,
21
20
  limit,
22
21
  sortBy,
23
22
  ...filter
@@ -106,6 +105,95 @@ class List {
106
105
  };
107
106
  }
108
107
 
108
+ getDeleteSingleRecordAction(recordId) {
109
+ const props = this.createApiProps();
110
+ return {
111
+ type: RECORD_EXECUTE,
112
+ payload: {
113
+ actionName: RecordApiActionName.DELETE_RECORD,
114
+ props: { ...props,
115
+ recordId
116
+ },
117
+ apiName: 'records'
118
+ },
119
+ metaData: {
120
+ headers: this.headers
121
+ }
122
+ };
123
+ }
124
+
125
+ getRecordExecuteSucceededActions(payload, metaData) {
126
+ const {
127
+ actionName
128
+ } = metaData;
129
+ const actions = [];
130
+
131
+ if (actionName === RecordApiActionName.DELETE_RECORD) {
132
+ const {
133
+ recordId
134
+ } = payload;
135
+ actions.push({
136
+ type: ZLIST_RECORD_DELETE_SUCCEEDED,
137
+ payload: {
138
+ recordId
139
+ }
140
+ });
141
+ }
142
+
143
+ if (actionName === RecordApiActionName.UPDATE_RECORD) {
144
+ const {
145
+ recordId,
146
+ record
147
+ } = payload;
148
+ actions.push({
149
+ type: ZLIST_RECORD_UPDATE_SUCCEEDED,
150
+ payload: {
151
+ recordId,
152
+ record
153
+ }
154
+ });
155
+ }
156
+
157
+ return actions;
158
+ }
159
+
160
+ getRecordExecuteFailedActions(payload, metaData) {
161
+ const {
162
+ actionName
163
+ } = metaData;
164
+ const actions = [];
165
+
166
+ if (actionName === RecordApiActionName.DELETE_RECORD) {
167
+ const {
168
+ recordId,
169
+ error
170
+ } = payload;
171
+ actions.push({
172
+ type: ZLIST_RECORD_DELETE_FAILED,
173
+ payload: {
174
+ recordId,
175
+ error
176
+ }
177
+ });
178
+ }
179
+
180
+ if (actionName === RecordApiActionName.UPDATE_RECORD) {
181
+ const {
182
+ recordId,
183
+ error
184
+ } = payload;
185
+ actions.push({
186
+ type: ZLIST_RECORD_UPDATE_FAILED,
187
+ payload: {
188
+ recordId,
189
+ error
190
+ }
191
+ });
192
+ }
193
+
194
+ return actions;
195
+ }
196
+
109
197
  getDeleteMultipleRecordAction(recordIds) {
110
198
  const props = this.createApiProps();
111
199
  return {