@zohodesk/library-platform 1.0.2-exp.1.2 → 1.0.2-exp.1.4
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/es/cc/fields/formula/Events.js +3 -0
- package/es/cc/fields/formula/Model.js +14 -0
- package/es/cc/fields/formula/Properties.js +3 -0
- package/es/cc/fields/index.js +1 -0
- package/es/library/custom-component/domain/entities/DefaultSlotNameAppend.js +10 -0
- package/es/library/custom-component/domain/entities/Properties.js +2 -0
- package/es/library/custom-component/frameworks/ui/CreateCustomComponent.js +0 -13
- package/es/library/custom-component/frameworks/ui/__testcases__/CreateSlotComponent.spec.js +211 -0
- package/es/platform/data-source/http-template/getAvailableFields.js +4 -3
- package/es/platform/data-source/http-template/getClientActions.js +1 -1
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +1 -1
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +3 -1
- package/es/platform/zlist/adapters/presenters/translators/fields/FormulaFieldTranslator.js +26 -0
- package/es/platform/zlist/adapters/presenters/translators/fields/index.js +2 -1
- package/es/platform/zlist/adapters/presenters/utils/calculateFieldWidths.js +2 -2
- package/package.json +1 -1
package/es/cc/fields/index.js
CHANGED
|
@@ -16,4 +16,5 @@ export { default as ColouredMultiSelectFieldProperties } from "./coloured-multi-
|
|
|
16
16
|
export { default as ColouredPickListFieldProperties } from "./coloured-pick-list/Properties";
|
|
17
17
|
export { default as TextFieldProperties } from "./text/Properties";
|
|
18
18
|
export { default as UrlFieldProperties } from "./url/Properties";
|
|
19
|
+
export { default as FormulaFieldProperties } from "./formula/Properties";
|
|
19
20
|
export { default as FieldTypes } from "./field/Types";
|
|
@@ -3,6 +3,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
3
3
|
import Property from "./Property";
|
|
4
4
|
import defaultAppendToActionPayload from "./DefaultAppendToActionPayload";
|
|
5
5
|
import getRefPropertySchema from "../../../../cc/component/properties/getRefPropertySchema";
|
|
6
|
+
import defaultSlotNameAppend from "./DefaultSlotNameAppend";
|
|
6
7
|
export default class Properties {
|
|
7
8
|
constructor(properties, componentName) {
|
|
8
9
|
this.componentName = componentName;
|
|
@@ -12,6 +13,7 @@ export default class Properties {
|
|
|
12
13
|
this.data = properties;
|
|
13
14
|
this.data.set('appendToActionPayload', new Property(defaultAppendToActionPayload));
|
|
14
15
|
this.data.set('getRef', new Property(getRefPropertySchema));
|
|
16
|
+
typeof properties.get("slotName") === "undefined" && this.data.set('slotName', new Property(defaultSlotNameAppend));
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
getAllPropertiesValue() {
|
|
@@ -16,19 +16,6 @@ function discardChildren(props) {
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
const createCustomComponent = input => {
|
|
19
|
-
var _input$properties, _input$properties$slo;
|
|
20
|
-
|
|
21
|
-
input.properties = { ...(input.properties || {}),
|
|
22
|
-
slotName: {
|
|
23
|
-
required: ((_input$properties = input.properties) === null || _input$properties === void 0 ? void 0 : (_input$properties$slo = _input$properties.slotName) === null || _input$properties$slo === void 0 ? void 0 : _input$properties$slo.required) || false,
|
|
24
|
-
typeMetadata: {
|
|
25
|
-
schema: {
|
|
26
|
-
type: "string"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
19
|
class Component extends React.Component {
|
|
33
20
|
constructor(props) {
|
|
34
21
|
super(props);
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import React, { Component } from "react";
|
|
3
|
+
import createCustomComponent from "../CreateCustomComponent.tsx";
|
|
4
|
+
import ComponentRegistry from "../ComponentRegistry";
|
|
5
|
+
import { render, cleanup } from '@testing-library/react';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
const Parent = createCustomComponent({
|
|
8
|
+
name: "parent",
|
|
9
|
+
View: (_ref, ref) => {
|
|
10
|
+
let {
|
|
11
|
+
slotChildren
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
child = null,
|
|
15
|
+
siblingChild = null
|
|
16
|
+
} = slotChildren;
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
ref: ref
|
|
19
|
+
}, "Hi, I am the Parent.", /*#__PURE__*/React.createElement("div", null, child), /*#__PURE__*/React.createElement("div", null, siblingChild));
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
slots: {
|
|
23
|
+
required: false,
|
|
24
|
+
typeMetadata: {
|
|
25
|
+
schema: {
|
|
26
|
+
type: "array"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
eventHandlers: {}
|
|
32
|
+
});
|
|
33
|
+
const Child = createCustomComponent({
|
|
34
|
+
name: "child",
|
|
35
|
+
View: (_ref2, ref) => {
|
|
36
|
+
let {
|
|
37
|
+
slotChildren
|
|
38
|
+
} = _ref2;
|
|
39
|
+
const {
|
|
40
|
+
nestedChildren = null
|
|
41
|
+
} = slotChildren;
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
ref: ref
|
|
44
|
+
}, "Hi, I am the Child.", /*#__PURE__*/React.createElement("div", null, nestedChildren));
|
|
45
|
+
},
|
|
46
|
+
eventHandlers: {},
|
|
47
|
+
properties: {
|
|
48
|
+
slots: {
|
|
49
|
+
required: false,
|
|
50
|
+
typeMetadata: {
|
|
51
|
+
schema: {
|
|
52
|
+
type: "array"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const SiblingChild = createCustomComponent({
|
|
59
|
+
name: "siblingChild",
|
|
60
|
+
View: (props, ref) => {
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
ref: ref
|
|
63
|
+
}, "Hi, I am the sibling Child.");
|
|
64
|
+
},
|
|
65
|
+
eventHandlers: {},
|
|
66
|
+
properties: {}
|
|
67
|
+
});
|
|
68
|
+
const NestedChild = createCustomComponent({
|
|
69
|
+
name: "nestedChild",
|
|
70
|
+
View: (_, ref) => {
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
ref: ref
|
|
73
|
+
}, "Hi, I am the nested Child.");
|
|
74
|
+
},
|
|
75
|
+
eventHandlers: {},
|
|
76
|
+
properties: {}
|
|
77
|
+
});
|
|
78
|
+
const NoSlotName = createCustomComponent({
|
|
79
|
+
name: "noSlotName",
|
|
80
|
+
View: (_, ref) => {
|
|
81
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
ref: ref
|
|
83
|
+
}, "Hi, It should not be rendered.");
|
|
84
|
+
},
|
|
85
|
+
eventHandlers: {},
|
|
86
|
+
properties: {}
|
|
87
|
+
});
|
|
88
|
+
ComponentRegistry.register("Parent", Parent);
|
|
89
|
+
ComponentRegistry.register("Child", Child);
|
|
90
|
+
ComponentRegistry.register("SiblingChild", SiblingChild);
|
|
91
|
+
describe("Slot Integration test suite", () => {
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
jest.clearAllMocks();
|
|
94
|
+
cleanup();
|
|
95
|
+
});
|
|
96
|
+
it("slot Information passed to parent and check children rendering", () => {
|
|
97
|
+
const slots = [{
|
|
98
|
+
name: "child",
|
|
99
|
+
elements: [{
|
|
100
|
+
name: "child",
|
|
101
|
+
type: "Child"
|
|
102
|
+
}]
|
|
103
|
+
}];
|
|
104
|
+
const {
|
|
105
|
+
getByText
|
|
106
|
+
} = render( /*#__PURE__*/React.createElement(Parent, {
|
|
107
|
+
slots: slots
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Child, {
|
|
109
|
+
slotName: "child"
|
|
110
|
+
})));
|
|
111
|
+
const component = getByText("Hi, I am the Child.");
|
|
112
|
+
expect(component).toBeInTheDocument();
|
|
113
|
+
});
|
|
114
|
+
it("slots with nested child and check nested child rendering", () => {
|
|
115
|
+
const slots = [{
|
|
116
|
+
name: "child",
|
|
117
|
+
elements: [{
|
|
118
|
+
name: "child",
|
|
119
|
+
type: "Child",
|
|
120
|
+
slots: [{
|
|
121
|
+
name: "nestedChildren",
|
|
122
|
+
elements: [{
|
|
123
|
+
name: "nestedChild",
|
|
124
|
+
type: "NestedChild"
|
|
125
|
+
}]
|
|
126
|
+
}]
|
|
127
|
+
}]
|
|
128
|
+
}];
|
|
129
|
+
const {
|
|
130
|
+
getByText
|
|
131
|
+
} = render( /*#__PURE__*/React.createElement(Parent, {
|
|
132
|
+
slots: slots
|
|
133
|
+
}, /*#__PURE__*/React.createElement(Child, {
|
|
134
|
+
slotName: "child"
|
|
135
|
+
}, /*#__PURE__*/React.createElement(NestedChild, {
|
|
136
|
+
slotName: "nestedChildren"
|
|
137
|
+
}))));
|
|
138
|
+
const component = getByText("Hi, I am the nested Child.");
|
|
139
|
+
expect(component).toBeInTheDocument();
|
|
140
|
+
});
|
|
141
|
+
it("slots with sibling child and check sibling child rendering", () => {
|
|
142
|
+
const slots = [{
|
|
143
|
+
name: "child",
|
|
144
|
+
elements: [{
|
|
145
|
+
name: "child",
|
|
146
|
+
type: "Child",
|
|
147
|
+
slots: [{
|
|
148
|
+
name: "nestedChildren",
|
|
149
|
+
elements: [{
|
|
150
|
+
name: "nestedChild",
|
|
151
|
+
type: "NestedChild"
|
|
152
|
+
}]
|
|
153
|
+
}]
|
|
154
|
+
}]
|
|
155
|
+
}, {
|
|
156
|
+
name: "siblingChild",
|
|
157
|
+
elements: [{
|
|
158
|
+
name: "siblingChild",
|
|
159
|
+
type: "SiblingChild"
|
|
160
|
+
}]
|
|
161
|
+
}];
|
|
162
|
+
const {
|
|
163
|
+
getByText
|
|
164
|
+
} = render( /*#__PURE__*/React.createElement(Parent, {
|
|
165
|
+
slots: slots
|
|
166
|
+
}, /*#__PURE__*/React.createElement(Child, {
|
|
167
|
+
slotName: "child"
|
|
168
|
+
}, /*#__PURE__*/React.createElement(NestedChild, {
|
|
169
|
+
slotName: "nestedChildren"
|
|
170
|
+
})), /*#__PURE__*/React.createElement(SiblingChild, null)));
|
|
171
|
+
const component = getByText("Hi, I am the sibling Child.");
|
|
172
|
+
expect(component).toBeInTheDocument();
|
|
173
|
+
});
|
|
174
|
+
it("children with no slot support should not be rendered", () => {
|
|
175
|
+
const slots = [{
|
|
176
|
+
name: "child",
|
|
177
|
+
elements: [{
|
|
178
|
+
name: "child",
|
|
179
|
+
type: "Child",
|
|
180
|
+
slots: [{
|
|
181
|
+
name: "nestedChildren",
|
|
182
|
+
elements: [{
|
|
183
|
+
name: "nestedChild",
|
|
184
|
+
type: "NestedChild"
|
|
185
|
+
}]
|
|
186
|
+
}]
|
|
187
|
+
}]
|
|
188
|
+
}, {
|
|
189
|
+
name: "siblingChild",
|
|
190
|
+
elements: [{
|
|
191
|
+
name: "siblingChild",
|
|
192
|
+
type: "SiblingChild"
|
|
193
|
+
}]
|
|
194
|
+
}];
|
|
195
|
+
const {
|
|
196
|
+
queryByText
|
|
197
|
+
} = render( /*#__PURE__*/React.createElement(Parent, {
|
|
198
|
+
slots: slots
|
|
199
|
+
}, /*#__PURE__*/React.createElement(Child, {
|
|
200
|
+
slotName: "child"
|
|
201
|
+
}, /*#__PURE__*/React.createElement(NestedChild, {
|
|
202
|
+
slotName: "nestedChildren"
|
|
203
|
+
})), /*#__PURE__*/React.createElement(SiblingChild, {
|
|
204
|
+
slotName: "siblingChild"
|
|
205
|
+
}), /*#__PURE__*/React.createElement(NoSlotName, {
|
|
206
|
+
slotName: "noslotname"
|
|
207
|
+
})));
|
|
208
|
+
const component = queryByText("Hi, It should not be rendered.");
|
|
209
|
+
expect(component).toBeNull();
|
|
210
|
+
});
|
|
211
|
+
});
|
|
@@ -33,15 +33,15 @@ let getAvailableFields = {
|
|
|
33
33
|
servicePrefix,
|
|
34
34
|
orgName,
|
|
35
35
|
departmentId,
|
|
36
|
-
|
|
36
|
+
module
|
|
37
37
|
} = params;
|
|
38
|
-
const availableFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/views/availableFields?departmentId=${departmentId}&module=${
|
|
38
|
+
const availableFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/views/availableFields?departmentId=${departmentId}&module=${module}`;
|
|
39
39
|
const res = await fetch(availableFieldsUrl, {
|
|
40
40
|
method: 'GET',
|
|
41
41
|
headers
|
|
42
42
|
});
|
|
43
43
|
const availableFields = await getValidJsonResArray(res, 'fields');
|
|
44
|
-
const organizationFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/organizationFields?departmentId=${departmentId}&module=${
|
|
44
|
+
const organizationFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/organizationFields?departmentId=${departmentId}&module=${module}`;
|
|
45
45
|
const ores = await fetch(organizationFieldsUrl, {
|
|
46
46
|
method: 'GET',
|
|
47
47
|
headers
|
|
@@ -57,6 +57,7 @@ let getAvailableFields = {
|
|
|
57
57
|
|
|
58
58
|
return { ...field,
|
|
59
59
|
pickListValues: organizationField.pickListValues,
|
|
60
|
+
returnType: organizationField.returnType,
|
|
60
61
|
subType: organizationField.subType
|
|
61
62
|
};
|
|
62
63
|
})
|
|
@@ -56,7 +56,7 @@ export default class TableTranslator {
|
|
|
56
56
|
isFetching: isClientActionsFetching
|
|
57
57
|
} = fallbackToDefault(zclientAction, {}); // FIX: zclientAction should be available by defaultlt
|
|
58
58
|
|
|
59
|
-
const fieldComponentMapping = componentMapping.fields;
|
|
59
|
+
const fieldComponentMapping = fallbackToDefault(componentMapping.fields, {});
|
|
60
60
|
const rowActionsUiType = componentMapping.rowActionsComponentName;
|
|
61
61
|
const {
|
|
62
62
|
fields: availableFields,
|
|
@@ -2,9 +2,11 @@ import EmptyViewModel from "./EmptyViewModel";
|
|
|
2
2
|
import * as FieldTranslators from "./fields";
|
|
3
3
|
import ClientActionsTranslator from "../../../../client-actions/translators/client-actions-translator";
|
|
4
4
|
|
|
5
|
-
function ColumnTranslator(
|
|
5
|
+
function ColumnTranslator(fieldModel, record, fieldComponentMapping, fieldActions) {
|
|
6
6
|
var _record$cf;
|
|
7
7
|
|
|
8
|
+
const field = { ...fieldModel
|
|
9
|
+
};
|
|
8
10
|
const {
|
|
9
11
|
isCustomField,
|
|
10
12
|
name,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import FieldTypes from "../../../../../../cc/fields/field/Types";
|
|
2
|
+
import FormulaFieldModel from "../../../../../../cc/fields/formula/Model";
|
|
3
|
+
|
|
4
|
+
const FormulaFieldTranslator = (field, value, appendToActionPayload) => {
|
|
5
|
+
const {
|
|
6
|
+
uiType,
|
|
7
|
+
name
|
|
8
|
+
} = field;
|
|
9
|
+
const fieldTypeFactory = {
|
|
10
|
+
STRING: FieldTypes.SingleLineField,
|
|
11
|
+
BOOLEAN: FieldTypes.CheckboxField,
|
|
12
|
+
DECIMAL: FieldTypes.DecimalField,
|
|
13
|
+
CURRENCY: FieldTypes.CurrencyField,
|
|
14
|
+
DATE: FieldTypes.DateField,
|
|
15
|
+
DATETIME: FieldTypes.DateTimeField
|
|
16
|
+
};
|
|
17
|
+
const setFieldType = fieldTypeFactory[field.returnType] || FieldTypes.SingleLineField;
|
|
18
|
+
return FormulaFieldModel({
|
|
19
|
+
uiType: uiType || setFieldType,
|
|
20
|
+
appendToActionPayload,
|
|
21
|
+
name,
|
|
22
|
+
value
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default FormulaFieldTranslator;
|
|
@@ -13,7 +13,8 @@ export { default as Date } from "./DateFieldTranslator";
|
|
|
13
13
|
export { default as DateTime } from "./DateTimeFieldTranslator";
|
|
14
14
|
export { default as Picklist } from "./PickListFieldTranslator";
|
|
15
15
|
export { default as Multiselect } from "./MultiSelectFieldTranslator";
|
|
16
|
-
export { default as LookUp } from "./LookUpFieldTranslator";
|
|
16
|
+
export { default as LookUp } from "./LookUpFieldTranslator";
|
|
17
|
+
export { default as Formula } from "./FormulaFieldTranslator"; // // Field Name is to be similar to the API response
|
|
17
18
|
// class FieldTranslator {
|
|
18
19
|
// static translate(field, value) {
|
|
19
20
|
// const { type } = field;
|
|
@@ -7,13 +7,13 @@ export function calculateFieldWidths(fields, modifiedFieldWidths, preferences) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function decideWidth(width, fieldName, type) {
|
|
10
|
-
var _preferences$fields$f;
|
|
10
|
+
var _preferences$fields, _preferences$fields$f;
|
|
11
11
|
|
|
12
12
|
if (width !== undefined && width !== null) {
|
|
13
13
|
return width;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const initialWidth = (_preferences$fields
|
|
16
|
+
const initialWidth = (_preferences$fields = preferences.fields) === null || _preferences$fields === void 0 ? void 0 : (_preferences$fields$f = _preferences$fields[fieldName]) === null || _preferences$fields$f === void 0 ? void 0 : _preferences$fields$f.initialWidth;
|
|
17
17
|
|
|
18
18
|
if (initialWidth !== undefined && initialWidth !== null) {
|
|
19
19
|
return initialWidth;
|