@kineticdata/react 5.0.15 → 5.0.18
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/lib/apis/core/authentication.js +11 -3
- package/lib/apis/core/fileResources.js +36 -0
- package/lib/apis/core/filestores.js +40 -0
- package/lib/apis/core/submissions.js +10 -6
- package/lib/apis/http.test.js +8 -3
- package/lib/apis/task/index.js +2 -1
- package/lib/components/agent/filestore/FilestoreForm.js +132 -0
- package/lib/components/agent/filestore/FilestoreTable.js +53 -0
- package/lib/components/common/Scroller.js +6 -6
- package/lib/components/common/code_input/languageHelpers.test.js +1 -1
- package/lib/components/core/core_form/CoreForm.js +10 -10
- package/lib/components/core/field_definition/FieldDefinitionForm.js +130 -0
- package/lib/components/core/field_definition/FieldDefinitionTable.js +86 -0
- package/lib/components/core/file_resource/FileResourceForm.js +180 -0
- package/lib/components/core/file_resource/FileResourceTable.js +71 -0
- package/lib/components/core/i18n/I18n.js +14 -14
- package/lib/components/core/submission/FormSubmissionFilters.js +378 -0
- package/lib/components/core/submission/FormSubmissionTable.js +116 -0
- package/lib/components/core/submission/KappSubmissionTable.js +250 -0
- package/lib/components/core/submission/SubmissionForm.js +124 -0
- package/lib/components/core/submission/helpers.js +95 -0
- package/lib/components/core/submission/helpers.test.js +96 -0
- package/lib/components/form/Form.js +2 -2
- package/lib/components/index.js +4 -4
- package/lib/components/system/SystemBackgroundTasksTable.js +83 -0
- package/lib/components/system/SystemSecurityForm.js +69 -0
- package/lib/components/system/helpers.js +16 -24
- package/lib/components/system/spaces/SystemTenantForm.js +8 -4
- package/lib/components/table/Table.js +23 -3
- package/lib/components/table/Table.redux.js +221 -53
- package/lib/components/table/Table.redux.test.js +73 -2
- package/lib/components/task/builder/Connector.js +2 -2
- package/lib/components/task/builder/NodeForm.js +3 -0
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +113 -0
- package/lib/components/task/builder/TreeBuilder.js +2 -2
- package/lib/components/task/triggers/TriggerTable.js +3 -2
- package/package.json +3 -3
- package/proxyhelper.js +82 -9
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import { get, Map } from 'immutable';
|
|
4
|
+
import { createFileResource, fetchAgentComponents, fetchFileResource, fetchFilestores, fetchSecurityPolicyDefinitions, updateFileResource } from '../../../apis';
|
|
5
|
+
import { generateForm } from '../../form/Form';
|
|
6
|
+
import { handleFormErrors } from '../../form/Form.helpers';
|
|
7
|
+
|
|
8
|
+
var dataSources = function dataSources(_ref) {
|
|
9
|
+
var fileResourceSlug = _ref.fileResourceSlug;
|
|
10
|
+
return {
|
|
11
|
+
fileResource: {
|
|
12
|
+
fn: fetchFileResource,
|
|
13
|
+
params: fileResourceSlug && [{
|
|
14
|
+
fileResourceSlug: fileResourceSlug,
|
|
15
|
+
include: 'details,securityPolicies'
|
|
16
|
+
}],
|
|
17
|
+
transform: function transform(result) {
|
|
18
|
+
return result.fileResource;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
agents: {
|
|
22
|
+
fn: fetchAgentComponents,
|
|
23
|
+
params: [],
|
|
24
|
+
transform: function transform(result) {
|
|
25
|
+
return [{
|
|
26
|
+
label: 'System',
|
|
27
|
+
value: 'system'
|
|
28
|
+
}].concat(_toConsumableArray(get(result, 'agents', []).map(function (agent) {
|
|
29
|
+
return {
|
|
30
|
+
label: agent.name,
|
|
31
|
+
value: agent.slug
|
|
32
|
+
};
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
filestores: {
|
|
37
|
+
fn: function fn(options) {
|
|
38
|
+
return options && options.agentSlug ? fetchFilestores(options) : Promise.resolve([]);
|
|
39
|
+
},
|
|
40
|
+
params: function params(_ref2) {
|
|
41
|
+
var values = _ref2.values;
|
|
42
|
+
return [{
|
|
43
|
+
agentSlug: get(values, 'agentSlug', 'system')
|
|
44
|
+
}];
|
|
45
|
+
},
|
|
46
|
+
transform: function transform(result) {
|
|
47
|
+
return get(result, 'filestores', []).map(function (agent) {
|
|
48
|
+
return {
|
|
49
|
+
label: agent.name,
|
|
50
|
+
value: agent.slug
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
securityPolicyDefinitions: {
|
|
56
|
+
fn: fetchSecurityPolicyDefinitions,
|
|
57
|
+
params: [],
|
|
58
|
+
transform: function transform(result) {
|
|
59
|
+
return result.securityPolicyDefinitions;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var handleSubmit = function handleSubmit(_ref3) {
|
|
66
|
+
var fileResourceSlug = _ref3.fileResourceSlug;
|
|
67
|
+
return function (values) {
|
|
68
|
+
return (fileResourceSlug ? updateFileResource : createFileResource)({
|
|
69
|
+
fileResourceSlug: fileResourceSlug,
|
|
70
|
+
fileResource: values.toJS()
|
|
71
|
+
}).then(handleFormErrors('fileResource', 'There was a problem saving the File Resource.'));
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var securityEndpoints = {
|
|
76
|
+
fileAccess: {
|
|
77
|
+
endpoint: 'File Access',
|
|
78
|
+
label: 'File Access',
|
|
79
|
+
types: ['Space', 'File Resource']
|
|
80
|
+
},
|
|
81
|
+
fileModification: {
|
|
82
|
+
endpoint: 'File Modification',
|
|
83
|
+
label: 'File Modification',
|
|
84
|
+
types: ['Space', 'File Resource']
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var fields = function fields(_ref4) {
|
|
89
|
+
var fileResourceSlug = _ref4.fileResourceSlug;
|
|
90
|
+
return function (_ref5) {
|
|
91
|
+
var fileResource = _ref5.fileResource,
|
|
92
|
+
agents = _ref5.agents,
|
|
93
|
+
securityPolicyDefinitions = _ref5.securityPolicyDefinitions;
|
|
94
|
+
return (!fileResourceSlug || fileResource) && securityPolicyDefinitions && agents && [{
|
|
95
|
+
name: 'slug',
|
|
96
|
+
label: 'Slug',
|
|
97
|
+
type: 'text',
|
|
98
|
+
required: true,
|
|
99
|
+
initialValue: get(fileResource, 'slug', '')
|
|
100
|
+
}, {
|
|
101
|
+
name: 'agentSlug',
|
|
102
|
+
label: 'Agent Slug',
|
|
103
|
+
type: 'select',
|
|
104
|
+
required: true,
|
|
105
|
+
initialValue: get(fileResource, 'agentSlug', 'system'),
|
|
106
|
+
options: function options(_ref6) {
|
|
107
|
+
var agents = _ref6.agents;
|
|
108
|
+
return agents;
|
|
109
|
+
},
|
|
110
|
+
onChange: function onChange(_, _ref7) {
|
|
111
|
+
var setValue = _ref7.setValue;
|
|
112
|
+
return setValue('filestoreSlug', '');
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
name: 'filestoreSlug',
|
|
116
|
+
label: 'Filestore Slug',
|
|
117
|
+
type: 'select',
|
|
118
|
+
required: true,
|
|
119
|
+
initialValue: get(fileResource, 'filestoreSlug', ''),
|
|
120
|
+
options: function options(_ref8) {
|
|
121
|
+
var filestores = _ref8.filestores;
|
|
122
|
+
return filestores;
|
|
123
|
+
}
|
|
124
|
+
}].concat(_toConsumableArray(Object.entries(securityEndpoints).map(function (_ref9) {
|
|
125
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
126
|
+
endpointFieldName = _ref10[0],
|
|
127
|
+
endpoint = _ref10[1];
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
name: endpointFieldName,
|
|
131
|
+
label: endpoint.label,
|
|
132
|
+
type: 'select',
|
|
133
|
+
options: function options(_ref11) {
|
|
134
|
+
var securityPolicyDefinitions = _ref11.securityPolicyDefinitions;
|
|
135
|
+
return securityPolicyDefinitions ? securityPolicyDefinitions.filter(function (definition) {
|
|
136
|
+
return endpoint.types.includes(definition.get('type'));
|
|
137
|
+
}).map(function (definition) {
|
|
138
|
+
return Map({
|
|
139
|
+
value: definition.get('name'),
|
|
140
|
+
label: definition.get('name')
|
|
141
|
+
});
|
|
142
|
+
}) : [];
|
|
143
|
+
},
|
|
144
|
+
initialValue: fileResource ? fileResource.get('securityPolicies').find(function (pol) {
|
|
145
|
+
return pol.get('endpoint') === endpoint.endpoint;
|
|
146
|
+
}, null, Map({})).get('name', '') : '',
|
|
147
|
+
"transient": true
|
|
148
|
+
};
|
|
149
|
+
})), [{
|
|
150
|
+
name: 'securityPolicies',
|
|
151
|
+
label: 'Security Policies',
|
|
152
|
+
type: null,
|
|
153
|
+
visible: false,
|
|
154
|
+
serialize: function serialize(_ref12) {
|
|
155
|
+
var values = _ref12.values;
|
|
156
|
+
return Object.entries(securityEndpoints).map(function (_ref13) {
|
|
157
|
+
var _ref14 = _slicedToArray(_ref13, 2),
|
|
158
|
+
endpointFieldName = _ref14[0],
|
|
159
|
+
policy = _ref14[1];
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
endpoint: policy.endpoint,
|
|
163
|
+
name: values.get(endpointFieldName)
|
|
164
|
+
};
|
|
165
|
+
}).filter(function (endpoint) {
|
|
166
|
+
return endpoint.name !== '';
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
initialValue: get(fileResource, 'securityPolicies')
|
|
170
|
+
}]);
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export var FileResourceForm = generateForm({
|
|
175
|
+
formOptions: ['fileResourceSlug'],
|
|
176
|
+
dataSources: dataSources,
|
|
177
|
+
fields: fields,
|
|
178
|
+
handleSubmit: handleSubmit
|
|
179
|
+
});
|
|
180
|
+
FileResourceForm.displayName = 'FileResourceForm';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { defineKqlQuery } from '../../../helpers';
|
|
3
|
+
import { fetchFileResources } from '../../../apis';
|
|
4
|
+
import { generatePaginationParams, generateSortParams } from '../../../apis/http';
|
|
5
|
+
import { generateTable } from '../../table/Table';
|
|
6
|
+
|
|
7
|
+
var filters = function filters() {
|
|
8
|
+
return function () {
|
|
9
|
+
return [{
|
|
10
|
+
name: 'slug',
|
|
11
|
+
label: 'Slug',
|
|
12
|
+
type: 'text'
|
|
13
|
+
}];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var fileResourceQuery = defineKqlQuery().matches('agentSlug', 'agentSlug').matches('filestoreSlug', 'filestoreSlug').matches('slug', 'slug').end();
|
|
18
|
+
|
|
19
|
+
var dataSource = function dataSource() {
|
|
20
|
+
return {
|
|
21
|
+
fn: fetchFileResources,
|
|
22
|
+
params: function params(paramData) {
|
|
23
|
+
return [_objectSpread(_objectSpread(_objectSpread({}, generateSortParams(paramData)), generatePaginationParams(paramData)), {}, {
|
|
24
|
+
q: fileResourceQuery(paramData.filters.toJS()),
|
|
25
|
+
include: 'details'
|
|
26
|
+
})];
|
|
27
|
+
},
|
|
28
|
+
transform: function transform(result) {
|
|
29
|
+
return {
|
|
30
|
+
data: result.fileResources,
|
|
31
|
+
nextPageToken: result.nextPageToken
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var columns = [{
|
|
38
|
+
value: 'slug',
|
|
39
|
+
title: 'Slug',
|
|
40
|
+
sortable: true
|
|
41
|
+
}, {
|
|
42
|
+
value: 'agentSlug',
|
|
43
|
+
title: 'Agent Slug',
|
|
44
|
+
sortable: true
|
|
45
|
+
}, {
|
|
46
|
+
value: 'filestoreSlug',
|
|
47
|
+
title: 'File Store Slug',
|
|
48
|
+
sortable: true
|
|
49
|
+
}, {
|
|
50
|
+
value: 'createdAt',
|
|
51
|
+
title: 'Created',
|
|
52
|
+
sortable: true
|
|
53
|
+
}, {
|
|
54
|
+
value: 'createdBy',
|
|
55
|
+
title: 'Created By'
|
|
56
|
+
}, {
|
|
57
|
+
value: 'updatedAt',
|
|
58
|
+
title: 'Updated At',
|
|
59
|
+
sortable: true
|
|
60
|
+
}, {
|
|
61
|
+
value: 'updatedBy',
|
|
62
|
+
title: 'Updated By',
|
|
63
|
+
sortable: true
|
|
64
|
+
}];
|
|
65
|
+
export var FileResourceTable = generateTable({
|
|
66
|
+
tableOptions: [],
|
|
67
|
+
columns: columns,
|
|
68
|
+
filters: filters,
|
|
69
|
+
dataSource: dataSource
|
|
70
|
+
});
|
|
71
|
+
FileResourceTable.displayName = 'FileResourceTable';
|
|
@@ -99,24 +99,24 @@ export var I18n = /*#__PURE__*/function (_React$Component) {
|
|
|
99
99
|
}, _this3.props.children);
|
|
100
100
|
} // Otherwise wrap children in a new instance of I18nProvider with the new context
|
|
101
101
|
else if (_this3.state.context) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
context: _this3.state.context,
|
|
105
|
-
locale: locale,
|
|
106
|
-
translations: translations,
|
|
107
|
-
loadTranslations: loadTranslations
|
|
108
|
-
}
|
|
109
|
-
}, /*#__PURE__*/React.createElement(I18nTranslate, {
|
|
102
|
+
return /*#__PURE__*/React.createElement(I18nContext.Provider, {
|
|
103
|
+
value: {
|
|
110
104
|
context: _this3.state.context,
|
|
111
105
|
locale: locale,
|
|
112
106
|
translations: translations,
|
|
113
|
-
loadTranslations: loadTranslations
|
|
114
|
-
"public": _this3.props["public"]
|
|
115
|
-
}, _this3.props.children));
|
|
116
|
-
} // Otherwise return children
|
|
117
|
-
else {
|
|
118
|
-
return _this3.props.children;
|
|
107
|
+
loadTranslations: loadTranslations
|
|
119
108
|
}
|
|
109
|
+
}, /*#__PURE__*/React.createElement(I18nTranslate, {
|
|
110
|
+
context: _this3.state.context,
|
|
111
|
+
locale: locale,
|
|
112
|
+
translations: translations,
|
|
113
|
+
loadTranslations: loadTranslations,
|
|
114
|
+
"public": _this3.props["public"]
|
|
115
|
+
}, _this3.props.children));
|
|
116
|
+
} // Otherwise return children
|
|
117
|
+
else {
|
|
118
|
+
return _this3.props.children;
|
|
119
|
+
}
|
|
120
120
|
}) : null;
|
|
121
121
|
}
|
|
122
122
|
}]);
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import { List, Map, Range } from 'immutable';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { fetchForm, fetchKapp, fetchSpace } from '../../../apis';
|
|
6
|
+
import { defineKqlQuery, MAX_PART_LENGTH, TIMELINES } from '../../../helpers';
|
|
7
|
+
import { availableParts, getUsedFields } from './helpers';
|
|
8
|
+
export var filterDataSources = function filterDataSources(_ref) {
|
|
9
|
+
var formSlug = _ref.formSlug,
|
|
10
|
+
kappSlug = _ref.kappSlug;
|
|
11
|
+
return {
|
|
12
|
+
form: {
|
|
13
|
+
fn: !formSlug && !kappSlug ? fetchSpace : kappSlug && !formSlug ? fetchKapp : fetchForm,
|
|
14
|
+
params: [{
|
|
15
|
+
kappSlug: kappSlug,
|
|
16
|
+
formSlug: formSlug,
|
|
17
|
+
include: 'indexDefinitions,fields,fields.details'
|
|
18
|
+
}],
|
|
19
|
+
transform: function transform(result) {
|
|
20
|
+
return !formSlug && !kappSlug ? result.space : kappSlug && !formSlug ? result.kapp : result.form;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
fields: {
|
|
24
|
+
fn: function fn(form) {
|
|
25
|
+
return form.get('fields').filter(function (f) {
|
|
26
|
+
return f.get('dataType') !== 'file';
|
|
27
|
+
}).map(function (f) {
|
|
28
|
+
return "values[".concat(f.get('name'), "]");
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
params: function params(_ref2) {
|
|
32
|
+
var form = _ref2.form;
|
|
33
|
+
return form && [form];
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
indexDefinitions: {
|
|
37
|
+
fn: function fn(form) {
|
|
38
|
+
return form.get('indexDefinitions');
|
|
39
|
+
},
|
|
40
|
+
params: function params(_ref3) {
|
|
41
|
+
var form = _ref3.form;
|
|
42
|
+
return form && [form];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var getPartIndex = function getPartIndex(name) {
|
|
49
|
+
var match = name.match(/op(\d+)-part/);
|
|
50
|
+
return match && parseInt(match[1]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var getOrderPartIndex = function getOrderPartIndex(name) {
|
|
54
|
+
var match = name.match(/orderby(\d+)-part/);
|
|
55
|
+
return match && parseInt(match[1]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var operatorChangeFn = function operatorChangeFn(i) {
|
|
59
|
+
return function (_ref4, _ref5) {
|
|
60
|
+
var values = _ref4.values;
|
|
61
|
+
var setValue = _ref5.setValue;
|
|
62
|
+
var value = values.get("op".concat(i, "-operator")); // If the operator was set to '' and the first operand is set, clear it.
|
|
63
|
+
|
|
64
|
+
if (!value && values.get("op".concat(i, "-operand1"))) {
|
|
65
|
+
setValue("op".concat(i, "-operand1"), '');
|
|
66
|
+
} // If the operator is not 'bt' and the second operand is set, clear it.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if (value !== 'between' && values.get("op".concat(i, "-operand2"))) {
|
|
70
|
+
setValue("op".concat(i, "-operand2"), '');
|
|
71
|
+
} // If the operator is not 'in and the third operand is set, clear it.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if (value !== 'in' && !values.get("op".concat(i, "-operand3")).isEmpty()) {
|
|
75
|
+
setValue("op".concat(i, "-operand3"), List());
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
var partChangeFn = function partChangeFn(i) {
|
|
81
|
+
return function (_ref6, _ref7) {
|
|
82
|
+
var values = _ref6.values;
|
|
83
|
+
var setValue = _ref7.setValue;
|
|
84
|
+
// If the operator was set to something besides 'eq' or 'in' clear any
|
|
85
|
+
// operators after this. Their change events will then fire and clear the
|
|
86
|
+
// corresponding operands.
|
|
87
|
+
values.filter(function (value, name) {
|
|
88
|
+
return getPartIndex(name) > i;
|
|
89
|
+
}).forEach(function (_value, name) {
|
|
90
|
+
return setValue(name, '', false);
|
|
91
|
+
});
|
|
92
|
+
setValue('range-part', '', false);
|
|
93
|
+
Range(0, MAX_PART_LENGTH).forEach(function (i) {
|
|
94
|
+
return setValue("orderby".concat(i, "-part"), '', false);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var orderChangeFn = function orderChangeFn(i) {
|
|
100
|
+
return function (_ref8, _ref9) {
|
|
101
|
+
var values = _ref8.values;
|
|
102
|
+
var setValue = _ref9.setValue;
|
|
103
|
+
var value = values.get("orderby".concat(i, "-part"));
|
|
104
|
+
|
|
105
|
+
if (!value || TIMELINES.includes(value)) {
|
|
106
|
+
values.filter(function (value, name) {
|
|
107
|
+
return getOrderPartIndex(name) > i;
|
|
108
|
+
}).forEach(function (_value, name) {
|
|
109
|
+
return setValue(name, '', false);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
var enabledFn = function enabledFn(i) {
|
|
116
|
+
return function (_ref10) {
|
|
117
|
+
var values = _ref10.values;
|
|
118
|
+
return Range(0, i, -1).map(function (i) {
|
|
119
|
+
return values.get("op".concat(i, "-part"));
|
|
120
|
+
}).every(function (value) {
|
|
121
|
+
return value;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var rangeVisibleFn = function rangeVisibleFn(operatorType) {
|
|
127
|
+
var timeline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
128
|
+
return function (_ref11) {
|
|
129
|
+
var values = _ref11.values,
|
|
130
|
+
indexDefinitions = _ref11.indexDefinitions;
|
|
131
|
+
var usedFields = getUsedFields(values, -1, 'range');
|
|
132
|
+
var partsAvailable = availableParts(values, indexDefinitions, usedFields, 'range');
|
|
133
|
+
var isOperandValid = operatorType ? !timeline ? operatorType === 'between' ? !TIMELINES.includes(values.get('range-part')) && values.get('range-operator') === 'between' : !TIMELINES.includes(values.get('range-part')) : operatorType === 'between' ? TIMELINES.includes(values.get('range-part')) && values.get('range-operator') === 'between' : TIMELINES.includes(values.get('range-part')) : true;
|
|
134
|
+
return isOperandValid && partsAvailable.size > 0;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
var visibleFn = function visibleFn(currentPart, i, operatorType) {
|
|
139
|
+
return function (_ref12) {
|
|
140
|
+
var values = _ref12.values,
|
|
141
|
+
indexDefinitions = _ref12.indexDefinitions;
|
|
142
|
+
var hasRange = values.get('range-part') !== '';
|
|
143
|
+
var hasOrderBy = Range(0, MAX_PART_LENGTH).map(function (i) {
|
|
144
|
+
return values.get("orderby".concat(i, "-part"));
|
|
145
|
+
}).filter(function (v) {
|
|
146
|
+
return v !== '';
|
|
147
|
+
}).toList().size > 0;
|
|
148
|
+
var usedFields = getUsedFields(values, i, 'eq');
|
|
149
|
+
var partsAvailable = availableParts(values, indexDefinitions, usedFields, 'eq'); // If this equality has this operator type selected.
|
|
150
|
+
|
|
151
|
+
if (operatorType) return values.get("op".concat(i, "-operator")) === operatorType; // If there's a range value set and this equality is not.
|
|
152
|
+
|
|
153
|
+
if ((hasRange || hasOrderBy) && !values.get("op".concat(i, "-part"))) return false; // If it is the first equality or the previous equality has a value set and
|
|
154
|
+
// this equality has available options.
|
|
155
|
+
|
|
156
|
+
return (i === 0 || values.get("op".concat(i - 1, "-part"))) && partsAvailable.size > 0;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
var orderVisibleFn = function orderVisibleFn(partIndex) {
|
|
161
|
+
return function (bindings) {
|
|
162
|
+
var values = bindings.values;
|
|
163
|
+
var prevPart = values.get("orderby".concat(partIndex - 1, "-part"));
|
|
164
|
+
return partIndex === 0 || !values.get('range-part') && prevPart && !TIMELINES.includes(prevPart);
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export var availableOptions = function availableOptions(partType, partIndex) {
|
|
169
|
+
return function (bindings) {
|
|
170
|
+
var values = bindings.values,
|
|
171
|
+
indexDefinitions = bindings.indexDefinitions;
|
|
172
|
+
var usedFields = getUsedFields(values, partIndex, partType);
|
|
173
|
+
var partsAvailable = availableParts(values, indexDefinitions, usedFields, partType).flatten();
|
|
174
|
+
var valueParts = partsAvailable.filter(function (f) {
|
|
175
|
+
return f.startsWith('values[');
|
|
176
|
+
}).sort();
|
|
177
|
+
var staticParts = partsAvailable.filterNot(function (f) {
|
|
178
|
+
return f.startsWith('values[');
|
|
179
|
+
}).sort();
|
|
180
|
+
return valueParts.concat(staticParts).map(function (f) {
|
|
181
|
+
return Map({
|
|
182
|
+
label: f,
|
|
183
|
+
value: f
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var getRValues = function getRValues(operator, values, opBase) {
|
|
190
|
+
var isTimeline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
191
|
+
var v1 = isTimeline ? values.get("".concat(opBase, "-operand3")) : values.get("".concat(opBase, "-operand1"));
|
|
192
|
+
var v2 = isTimeline ? values.get("".concat(opBase, "-operand4")) : values.get("".concat(opBase, "-operand2"));
|
|
193
|
+
return operator === 'between' ? [v1, v2] : operator === 'in' ? [values.get("".concat(opBase, "-operand3"))] : [v1];
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
var getSerializedParts = function getSerializedParts(values) {
|
|
197
|
+
return Range(0, MAX_PART_LENGTH).filter(function (i) {
|
|
198
|
+
return values.get("op".concat(i, "-part"));
|
|
199
|
+
}).map(function (i) {
|
|
200
|
+
// Handle the equality parts.
|
|
201
|
+
var part = values.get("op".concat(i, "-part"));
|
|
202
|
+
var operator = values.get("op".concat(i, "-operator"));
|
|
203
|
+
var rValues = getRValues(operator, values, "op".concat(i));
|
|
204
|
+
return List([part, operator, "op".concat(i)].concat(_toConsumableArray(rValues)));
|
|
205
|
+
}).toList().update(function (ps) {
|
|
206
|
+
var rangePart = values.get('range-part');
|
|
207
|
+
var rangeOp = values.get('range-operator');
|
|
208
|
+
var rangeValues = getRValues(rangeOp, values, 'range', TIMELINES.includes(rangePart));
|
|
209
|
+
return rangePart ? ps.push(List([rangePart, rangeOp, 'range'].concat(_toConsumableArray(rangeValues)))) : ps;
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
var serializeQuery = function serializeQuery(_ref13) {
|
|
214
|
+
var values = _ref13.values;
|
|
215
|
+
var parts = getSerializedParts(values);
|
|
216
|
+
return {
|
|
217
|
+
parts: parts,
|
|
218
|
+
q: parts.reduce(function (query, partEntry) {
|
|
219
|
+
var _partEntry = _slicedToArray(partEntry, 3),
|
|
220
|
+
part = _partEntry[0],
|
|
221
|
+
operator = _partEntry[1],
|
|
222
|
+
opBase = _partEntry[2];
|
|
223
|
+
|
|
224
|
+
var op1 = opBase === 'range' && TIMELINES.includes(part) ? "".concat(opBase, "-operand3") : "".concat(opBase, "-operand1");
|
|
225
|
+
var op2 = opBase === 'range' && TIMELINES.includes(part) ? "".concat(opBase, "-operand4") : "".concat(opBase, "-operand2");
|
|
226
|
+
var op3 = "".concat(opBase, "-operand3");
|
|
227
|
+
return operator === 'between' ? query.between(part, op1, op2, true) : operator === 'in' ? query["in"](part, op3, true) : operator ? query[operator](part, op1, true) : query;
|
|
228
|
+
}, defineKqlQuery()).end()(values.map(function (v, k) {
|
|
229
|
+
return ['range-operand3', 'range-operand4'].includes(k) && v ? moment(v).toISOString() : v;
|
|
230
|
+
}).toJS()),
|
|
231
|
+
orderBy: Range(0, MAX_PART_LENGTH).map(function (i) {
|
|
232
|
+
return values.get("orderby".concat(i, "-part"));
|
|
233
|
+
}).filter(function (v) {
|
|
234
|
+
return v;
|
|
235
|
+
}).toArray().join(',')
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export var filters = function filters() {
|
|
240
|
+
return function (_ref14) {
|
|
241
|
+
var form = _ref14.form,
|
|
242
|
+
indexDefinitions = _ref14.indexDefinitions;
|
|
243
|
+
return form && indexDefinitions && [].concat(_toConsumableArray(Range(0, MAX_PART_LENGTH).flatMap(function (i) {
|
|
244
|
+
return [{
|
|
245
|
+
enabled: enabledFn(i),
|
|
246
|
+
name: "op".concat(i, "-part"),
|
|
247
|
+
type: 'select',
|
|
248
|
+
visible: visibleFn("op".concat(i, "-part"), i),
|
|
249
|
+
onChange: partChangeFn(i),
|
|
250
|
+
options: availableOptions('eq', i),
|
|
251
|
+
"transient": true
|
|
252
|
+
}, {
|
|
253
|
+
enabled: enabledFn(i),
|
|
254
|
+
name: "op".concat(i, "-operator"),
|
|
255
|
+
type: 'select',
|
|
256
|
+
visible: visibleFn("op".concat(i, "-part"), i),
|
|
257
|
+
onChange: operatorChangeFn(i),
|
|
258
|
+
options: [{
|
|
259
|
+
label: '=',
|
|
260
|
+
value: 'equals'
|
|
261
|
+
}, {
|
|
262
|
+
label: 'in',
|
|
263
|
+
value: 'in'
|
|
264
|
+
}],
|
|
265
|
+
initialValue: 'equals',
|
|
266
|
+
"transient": true
|
|
267
|
+
}, {
|
|
268
|
+
enabled: enabledFn(i),
|
|
269
|
+
name: "op".concat(i, "-operand1"),
|
|
270
|
+
"transient": true,
|
|
271
|
+
type: 'text',
|
|
272
|
+
visible: visibleFn("op".concat(i, "-part"), i)
|
|
273
|
+
}, {
|
|
274
|
+
enabled: enabledFn(i),
|
|
275
|
+
name: "op".concat(i, "-operand2"),
|
|
276
|
+
"transient": true,
|
|
277
|
+
type: 'text',
|
|
278
|
+
visible: visibleFn("op".concat(i, "-part"), i, 'between')
|
|
279
|
+
}, {
|
|
280
|
+
enabled: enabledFn(i),
|
|
281
|
+
name: "op".concat(i, "-operand3"),
|
|
282
|
+
"transient": true,
|
|
283
|
+
type: 'text-multi',
|
|
284
|
+
visible: visibleFn("op".concat(i, "-part"), i, 'in')
|
|
285
|
+
}];
|
|
286
|
+
}).toArray()), [{
|
|
287
|
+
name: 'range-part',
|
|
288
|
+
type: 'select',
|
|
289
|
+
visible: rangeVisibleFn(),
|
|
290
|
+
options: availableOptions('range'),
|
|
291
|
+
onChange: function onChange(_ref15, _ref16) {
|
|
292
|
+
var values = _ref15.values;
|
|
293
|
+
var setValue = _ref16.setValue;
|
|
294
|
+
// Recalculate order by.
|
|
295
|
+
var value = values.get('range-part'); // Clear out all of the order by values, range supersedes.
|
|
296
|
+
|
|
297
|
+
setValue('orderby0-part', value);
|
|
298
|
+
Range(1, MAX_PART_LENGTH).forEach(function (i) {
|
|
299
|
+
return setValue("orderby".concat(i, "-part"), '');
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
"transient": true
|
|
303
|
+
}, {
|
|
304
|
+
name: 'range-operator',
|
|
305
|
+
type: 'select',
|
|
306
|
+
visible: rangeVisibleFn(),
|
|
307
|
+
options: [{
|
|
308
|
+
label: '>',
|
|
309
|
+
value: 'greaterThan'
|
|
310
|
+
}, {
|
|
311
|
+
label: '>=',
|
|
312
|
+
value: 'greaterThanOrEquals'
|
|
313
|
+
}, {
|
|
314
|
+
label: '<',
|
|
315
|
+
value: 'lessThan'
|
|
316
|
+
}, {
|
|
317
|
+
label: '<=',
|
|
318
|
+
value: 'lessThanOrEquals'
|
|
319
|
+
}, {
|
|
320
|
+
label: 'between',
|
|
321
|
+
value: 'between'
|
|
322
|
+
}, {
|
|
323
|
+
label: 'startsWith',
|
|
324
|
+
value: 'startsWith'
|
|
325
|
+
}],
|
|
326
|
+
"transient": true
|
|
327
|
+
}, {
|
|
328
|
+
name: 'range-operand1',
|
|
329
|
+
"transient": true,
|
|
330
|
+
type: 'text',
|
|
331
|
+
visible: rangeVisibleFn('eq', false)
|
|
332
|
+
}, {
|
|
333
|
+
name: 'range-operand2',
|
|
334
|
+
"transient": true,
|
|
335
|
+
type: 'text',
|
|
336
|
+
visible: rangeVisibleFn('between', false)
|
|
337
|
+
}, {
|
|
338
|
+
name: 'range-operand3',
|
|
339
|
+
"transient": true,
|
|
340
|
+
type: 'datetime',
|
|
341
|
+
visible: rangeVisibleFn('eq', true)
|
|
342
|
+
}, {
|
|
343
|
+
name: 'range-operand4',
|
|
344
|
+
"transient": true,
|
|
345
|
+
type: 'datetime',
|
|
346
|
+
visible: rangeVisibleFn('between', true)
|
|
347
|
+
}, {
|
|
348
|
+
name: 'orderDirection',
|
|
349
|
+
type: 'select',
|
|
350
|
+
options: [{
|
|
351
|
+
label: 'ASC',
|
|
352
|
+
value: 'ASC'
|
|
353
|
+
}, {
|
|
354
|
+
label: 'DESC',
|
|
355
|
+
value: 'DESC'
|
|
356
|
+
}],
|
|
357
|
+
initialValue: 'DESC',
|
|
358
|
+
required: true
|
|
359
|
+
}], _toConsumableArray(Range(0, MAX_PART_LENGTH).flatMap(function (i) {
|
|
360
|
+
return [{
|
|
361
|
+
name: "orderby".concat(i, "-part"),
|
|
362
|
+
"transient": true,
|
|
363
|
+
type: 'select',
|
|
364
|
+
onChange: orderChangeFn(i),
|
|
365
|
+
enabled: function enabled(_ref17) {
|
|
366
|
+
var values = _ref17.values;
|
|
367
|
+
return !values.get('range-part');
|
|
368
|
+
},
|
|
369
|
+
options: availableOptions('orderBy', i),
|
|
370
|
+
visible: orderVisibleFn(i)
|
|
371
|
+
}];
|
|
372
|
+
}).toArray()), [{
|
|
373
|
+
name: 'query',
|
|
374
|
+
type: null,
|
|
375
|
+
serialize: serializeQuery
|
|
376
|
+
}]);
|
|
377
|
+
};
|
|
378
|
+
};
|