@zohodesk/library-platform 1.0.2-exp.1.3 → 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.
@@ -0,0 +1,3 @@
1
+ import FieldEvents from "../field/Events";
2
+ const Events = FieldEvents;
3
+ export default Events;
@@ -0,0 +1,14 @@
1
+ export default function FormulaFieldModel(_ref) {
2
+ let {
3
+ name,
4
+ value,
5
+ uiType,
6
+ appendToActionPayload
7
+ } = _ref;
8
+ return {
9
+ name,
10
+ appendToActionPayload,
11
+ type: uiType,
12
+ value
13
+ };
14
+ }
@@ -0,0 +1,3 @@
1
+ import FieldProperties from "../field/Properties";
2
+ export default { ...FieldProperties
3
+ };
@@ -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";
@@ -33,15 +33,15 @@ let getAvailableFields = {
33
33
  servicePrefix,
34
34
  orgName,
35
35
  departmentId,
36
- moduleName
36
+ module
37
37
  } = params;
38
- const availableFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/views/availableFields?departmentId=${departmentId}&module=${moduleName}`;
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=${moduleName}`;
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
  })
@@ -4,7 +4,7 @@ let getClientActions = {
4
4
  parameters: `{
5
5
  "from":{{from}},
6
6
  "limit":{{limit}},
7
- "library": "{{library}}",
7
+ "component": "{{component}}",
8
8
  "module": "{{moduleName}}"
9
9
  }`,
10
10
  type: 'GET',
@@ -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(field, record, fieldComponentMapping, fieldActions) {
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"; // // Field Name is to be similar to the API response
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$f = preferences.fields[fieldName]) === null || _preferences$fields$f === void 0 ? void 0 : _preferences$fields$f.initialWidth;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/library-platform",
3
- "version": "1.0.2-exp.1.3",
3
+ "version": "1.0.2-exp.1.4",
4
4
  "description": "",
5
5
  "main": "es/index.js",
6
6
  "files": [