@kineticdata/react 5.0.17 → 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/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/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/task/builder/Connector.js +2 -2
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +113 -0
- package/lib/components/task/builder/TreeBuilder.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import { generateTable } from '../../table/Table';
|
|
4
|
+
import { searchSubmissions } from '../../../apis';
|
|
5
|
+
import { generatePaginationParams, transformCoreResult } from '../../../apis/http';
|
|
6
|
+
import { filterDataSources, filters } from './FormSubmissionFilters';
|
|
7
|
+
import { Set } from 'immutable';
|
|
8
|
+
|
|
9
|
+
var dataSource = function dataSource(_ref) {
|
|
10
|
+
var kappSlug = _ref.kappSlug,
|
|
11
|
+
formSlug = _ref.formSlug,
|
|
12
|
+
include = _ref.include,
|
|
13
|
+
count = _ref.count;
|
|
14
|
+
return {
|
|
15
|
+
fn: function fn(options) {
|
|
16
|
+
return searchSubmissions(options);
|
|
17
|
+
},
|
|
18
|
+
params: function params(paramData) {
|
|
19
|
+
var q = paramData.filters.getIn(['query', 'q']) || undefined;
|
|
20
|
+
var orderBy = paramData.filters.getIn(['query', 'orderBy']) || 'createdAt';
|
|
21
|
+
return [{
|
|
22
|
+
form: formSlug,
|
|
23
|
+
kapp: kappSlug,
|
|
24
|
+
search: _objectSpread({
|
|
25
|
+
direction: paramData.filters.get('orderDirection', 'DESC'),
|
|
26
|
+
include: Set([].concat(_toConsumableArray(typeof include === 'string' ? include.split(',') : Array.isArray(include) ? include : []), ['details'])).toJS(),
|
|
27
|
+
// need to pass undefined instead of null so the `q` parameter is not
|
|
28
|
+
// added to the query string with empty value
|
|
29
|
+
q: q,
|
|
30
|
+
orderBy: orderBy
|
|
31
|
+
}, generatePaginationParams(paramData)),
|
|
32
|
+
count: count ? true : undefined
|
|
33
|
+
}];
|
|
34
|
+
},
|
|
35
|
+
transform: transformCoreResult('submissions')
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var columns = [{
|
|
40
|
+
value: 'closedAt',
|
|
41
|
+
title: 'Closed At',
|
|
42
|
+
sortable: true
|
|
43
|
+
}, {
|
|
44
|
+
value: 'closedBy',
|
|
45
|
+
title: 'closedBy',
|
|
46
|
+
sortable: false
|
|
47
|
+
}, {
|
|
48
|
+
value: 'coreState',
|
|
49
|
+
title: 'Core State',
|
|
50
|
+
sortable: false
|
|
51
|
+
}, {
|
|
52
|
+
value: 'createdAt',
|
|
53
|
+
title: 'Created',
|
|
54
|
+
sortable: true
|
|
55
|
+
}, {
|
|
56
|
+
value: 'createdBy',
|
|
57
|
+
title: 'Created By',
|
|
58
|
+
sortable: false
|
|
59
|
+
}, {
|
|
60
|
+
value: 'currentPage',
|
|
61
|
+
title: 'Current Page',
|
|
62
|
+
sortable: false
|
|
63
|
+
}, {
|
|
64
|
+
value: 'handle',
|
|
65
|
+
title: 'Handle',
|
|
66
|
+
sortable: false
|
|
67
|
+
}, {
|
|
68
|
+
value: 'id',
|
|
69
|
+
title: 'Id',
|
|
70
|
+
sortable: false
|
|
71
|
+
}, {
|
|
72
|
+
value: 'label',
|
|
73
|
+
title: 'Label',
|
|
74
|
+
sortable: false
|
|
75
|
+
}, {
|
|
76
|
+
value: 'origin',
|
|
77
|
+
title: 'Origin',
|
|
78
|
+
sortable: false
|
|
79
|
+
}, {
|
|
80
|
+
value: 'parent',
|
|
81
|
+
title: 'Parent',
|
|
82
|
+
sortable: false
|
|
83
|
+
}, {
|
|
84
|
+
value: 'sessionToken',
|
|
85
|
+
title: 'Session Token',
|
|
86
|
+
sortable: false
|
|
87
|
+
}, {
|
|
88
|
+
value: 'submittedAt',
|
|
89
|
+
title: 'Submitted At',
|
|
90
|
+
sortable: true
|
|
91
|
+
}, {
|
|
92
|
+
value: 'submittedBy',
|
|
93
|
+
title: 'Submitted By',
|
|
94
|
+
sortable: false
|
|
95
|
+
}, {
|
|
96
|
+
value: 'type',
|
|
97
|
+
title: 'Type',
|
|
98
|
+
sortable: false
|
|
99
|
+
}, {
|
|
100
|
+
value: 'updatedAt',
|
|
101
|
+
title: 'Updated',
|
|
102
|
+
sortable: false
|
|
103
|
+
}, {
|
|
104
|
+
value: 'updatedBy',
|
|
105
|
+
title: 'Updated By',
|
|
106
|
+
sortable: false
|
|
107
|
+
}];
|
|
108
|
+
export var FormSubmissionTable = generateTable({
|
|
109
|
+
tableOptions: ['kappSlug', 'formSlug', 'include', 'count'],
|
|
110
|
+
columns: columns,
|
|
111
|
+
dataSource: dataSource,
|
|
112
|
+
filters: filters,
|
|
113
|
+
filterDataSources: filterDataSources
|
|
114
|
+
});
|
|
115
|
+
FormSubmissionTable.displayName = 'FormSubmissionTable';
|
|
116
|
+
export default FormSubmissionTable;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { getIn, List, Map, Set } from 'immutable';
|
|
3
|
+
import { generateTable } from '../../table/Table';
|
|
4
|
+
import { fetchForm, fetchKapp, searchSubmissions, SubmissionSearch, VALID_KAPP_CORE_STATES } from '../../../apis';
|
|
5
|
+
|
|
6
|
+
var applyMeta = function applyMeta(query, op, rvalue) {
|
|
7
|
+
return rvalue ? query[op](rvalue) : query;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
var applyOp = function applyOp(query, op, lvalue, rvalue) {
|
|
11
|
+
return rvalue ? query[op](lvalue, rvalue) : query;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
var submissionSearch = function submissionSearch(_ref, include) {
|
|
15
|
+
var filters = _ref.filters,
|
|
16
|
+
pageSize = _ref.pageSize,
|
|
17
|
+
sortColumn = _ref.sortColumn,
|
|
18
|
+
sortDirection = _ref.sortDirection;
|
|
19
|
+
var query = new SubmissionSearch().includes(Set([].concat(_toConsumableArray(typeof include === 'string' ? include.split(',') : Array.isArray(include) ? include : []), ['details', 'form'])).toJS()).sortBy(sortColumn || 'createdAt').sortDirection(sortDirection.toLocaleUpperCase()).limit(pageSize);
|
|
20
|
+
applyMeta(query, 'coreState', filters.get('coreState'));
|
|
21
|
+
applyMeta(query, 'startDate', filters.get('startDate') && new Date("".concat(filters.get('startDate'), "T00:00:00")));
|
|
22
|
+
applyMeta(query, 'endDate', filters.get('endDate') && new Date("".concat(filters.get('endDate'), "T00:00:00")));
|
|
23
|
+
applyOp(query, 'eq', 'handle', filters.get('handle'));
|
|
24
|
+
applyOp(query, 'eq', 'submittedBy', filters.getIn(['submittedBy', 'username']));
|
|
25
|
+
filters.get('values', Map()).forEach(function (value, field) {
|
|
26
|
+
return applyOp(query, 'eq', "values[".concat(field, "]"), value);
|
|
27
|
+
});
|
|
28
|
+
return query.build();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var dataSource = function dataSource(_ref2) {
|
|
32
|
+
var formSlug = _ref2.formSlug,
|
|
33
|
+
kappSlug = _ref2.kappSlug,
|
|
34
|
+
include = _ref2.include;
|
|
35
|
+
return {
|
|
36
|
+
fn: searchSubmissions,
|
|
37
|
+
params: function params(paramData) {
|
|
38
|
+
return [{
|
|
39
|
+
kapp: kappSlug,
|
|
40
|
+
form: paramData.filters.getIn(['form', 'slug'], formSlug),
|
|
41
|
+
pageToken: paramData.nextPageToken,
|
|
42
|
+
search: submissionSearch(paramData, include)
|
|
43
|
+
}];
|
|
44
|
+
},
|
|
45
|
+
transform: function transform(result) {
|
|
46
|
+
return {
|
|
47
|
+
data: result.submissions,
|
|
48
|
+
nextPageToken: result.nextPageToken
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var onValidateFilters = function onValidateFilters(filters) {
|
|
55
|
+
return filters.getIn(['values', 'value'], List()).reduce(function (valid, value) {
|
|
56
|
+
return valid && value.get('field') !== '' ? value.get('value') !== '' : valid;
|
|
57
|
+
}, true);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var filterDataSources = function filterDataSources(_ref3) {
|
|
61
|
+
var kappSlug = _ref3.kappSlug,
|
|
62
|
+
formSlug = _ref3.formSlug;
|
|
63
|
+
return {
|
|
64
|
+
kapp: {
|
|
65
|
+
fn: fetchKapp,
|
|
66
|
+
params: [{
|
|
67
|
+
kappSlug: kappSlug,
|
|
68
|
+
include: 'fields'
|
|
69
|
+
}],
|
|
70
|
+
transform: function transform(result) {
|
|
71
|
+
return result.kapp;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
form: {
|
|
75
|
+
fn: function fn(formSlug) {
|
|
76
|
+
return formSlug ? fetchForm({
|
|
77
|
+
kappSlug: kappSlug,
|
|
78
|
+
formSlug: formSlug,
|
|
79
|
+
include: 'fields'
|
|
80
|
+
}) : null;
|
|
81
|
+
},
|
|
82
|
+
params: function params(_ref4) {
|
|
83
|
+
var values = _ref4.values;
|
|
84
|
+
return [getIn(values, ['form', 'slug'], formSlug)];
|
|
85
|
+
},
|
|
86
|
+
transform: function transform(result) {
|
|
87
|
+
return result && result.form;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
fieldOptions: {
|
|
91
|
+
fn: function fn(form, kapp) {
|
|
92
|
+
return form ? form.get('fields').toArray() : kapp.get('fields').toArray();
|
|
93
|
+
},
|
|
94
|
+
params: function params(_ref5) {
|
|
95
|
+
var form = _ref5.form,
|
|
96
|
+
kapp = _ref5.kapp;
|
|
97
|
+
return kapp && [form, kapp];
|
|
98
|
+
},
|
|
99
|
+
transform: function transform(result) {
|
|
100
|
+
return result.map(function (field) {
|
|
101
|
+
return {
|
|
102
|
+
label: field.get('name'),
|
|
103
|
+
value: field.get('name')
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
coreStateOptions: {
|
|
109
|
+
fn: function fn() {
|
|
110
|
+
return VALID_KAPP_CORE_STATES;
|
|
111
|
+
},
|
|
112
|
+
params: [],
|
|
113
|
+
transform: function transform(coreStates) {
|
|
114
|
+
return coreStates.map(function (coreState) {
|
|
115
|
+
return {
|
|
116
|
+
label: coreState,
|
|
117
|
+
value: coreState
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var filters = function filters(_ref6) {
|
|
126
|
+
var kappSlug = _ref6.kappSlug,
|
|
127
|
+
formSlug = _ref6.formSlug;
|
|
128
|
+
return function (_ref7) {
|
|
129
|
+
var coreStateOptions = _ref7.coreStateOptions;
|
|
130
|
+
return coreStateOptions && [{
|
|
131
|
+
label: 'Start Date',
|
|
132
|
+
name: 'startDate',
|
|
133
|
+
type: 'date'
|
|
134
|
+
}, {
|
|
135
|
+
label: 'End Date',
|
|
136
|
+
name: 'endDate',
|
|
137
|
+
type: 'date'
|
|
138
|
+
}, {
|
|
139
|
+
label: 'Handle',
|
|
140
|
+
name: 'handle',
|
|
141
|
+
pattern: /[A-F0-9]{6}/,
|
|
142
|
+
patternMessage: 'Handles only contain characters A-F and 0-9, and are exactly 6 characters long',
|
|
143
|
+
type: 'text'
|
|
144
|
+
}, !formSlug && {
|
|
145
|
+
label: 'Form',
|
|
146
|
+
name: 'form',
|
|
147
|
+
type: 'form',
|
|
148
|
+
search: {
|
|
149
|
+
kappSlug: kappSlug
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
label: 'Submitted By',
|
|
153
|
+
name: 'submittedBy',
|
|
154
|
+
type: 'user'
|
|
155
|
+
}, {
|
|
156
|
+
label: 'State',
|
|
157
|
+
name: 'coreState',
|
|
158
|
+
type: 'select',
|
|
159
|
+
options: coreStateOptions
|
|
160
|
+
}, {
|
|
161
|
+
label: 'Values',
|
|
162
|
+
name: 'values',
|
|
163
|
+
type: 'map',
|
|
164
|
+
options: function options(_ref8) {
|
|
165
|
+
var fieldOptions = _ref8.fieldOptions;
|
|
166
|
+
return fieldOptions;
|
|
167
|
+
}
|
|
168
|
+
}];
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
var columns = [{
|
|
173
|
+
value: 'closedAt',
|
|
174
|
+
title: 'Closed At',
|
|
175
|
+
sortable: true
|
|
176
|
+
}, {
|
|
177
|
+
value: 'closedBy',
|
|
178
|
+
title: 'closedBy',
|
|
179
|
+
sortable: false
|
|
180
|
+
}, {
|
|
181
|
+
value: 'coreState',
|
|
182
|
+
title: 'Core State',
|
|
183
|
+
sortable: false
|
|
184
|
+
}, {
|
|
185
|
+
value: 'createdAt',
|
|
186
|
+
title: 'Created',
|
|
187
|
+
sortable: true
|
|
188
|
+
}, {
|
|
189
|
+
value: 'createdBy',
|
|
190
|
+
title: 'Created By',
|
|
191
|
+
sortable: false
|
|
192
|
+
}, {
|
|
193
|
+
value: 'currentPage',
|
|
194
|
+
title: 'Current Page',
|
|
195
|
+
sortable: false
|
|
196
|
+
}, {
|
|
197
|
+
value: 'handle',
|
|
198
|
+
title: 'Handle',
|
|
199
|
+
sortable: false
|
|
200
|
+
}, {
|
|
201
|
+
value: 'id',
|
|
202
|
+
title: 'Id',
|
|
203
|
+
sortable: false
|
|
204
|
+
}, {
|
|
205
|
+
value: 'label',
|
|
206
|
+
title: 'Label',
|
|
207
|
+
sortable: false
|
|
208
|
+
}, {
|
|
209
|
+
value: 'origin',
|
|
210
|
+
title: 'Origin',
|
|
211
|
+
sortable: false
|
|
212
|
+
}, {
|
|
213
|
+
value: 'parent',
|
|
214
|
+
title: 'Parent',
|
|
215
|
+
sortable: false
|
|
216
|
+
}, {
|
|
217
|
+
value: 'sessionToken',
|
|
218
|
+
title: 'Session Token',
|
|
219
|
+
sortable: false
|
|
220
|
+
}, {
|
|
221
|
+
value: 'submittedAt',
|
|
222
|
+
title: 'Submitted At',
|
|
223
|
+
sortable: true
|
|
224
|
+
}, {
|
|
225
|
+
value: 'submittedBy',
|
|
226
|
+
title: 'Submitted By',
|
|
227
|
+
sortable: false
|
|
228
|
+
}, {
|
|
229
|
+
value: 'type',
|
|
230
|
+
title: 'Type',
|
|
231
|
+
sortable: false
|
|
232
|
+
}, {
|
|
233
|
+
value: 'updatedAt',
|
|
234
|
+
title: 'Updated',
|
|
235
|
+
sortable: true
|
|
236
|
+
}, {
|
|
237
|
+
value: 'updatedBy',
|
|
238
|
+
title: 'Updated By',
|
|
239
|
+
sortable: false
|
|
240
|
+
}];
|
|
241
|
+
export var KappSubmissionTable = generateTable({
|
|
242
|
+
tableOptions: ['kappSlug', 'formSlug', 'datastore', 'include'],
|
|
243
|
+
columns: columns,
|
|
244
|
+
dataSource: dataSource,
|
|
245
|
+
filterDataSources: filterDataSources,
|
|
246
|
+
filters: filters,
|
|
247
|
+
onValidateFilters: onValidateFilters
|
|
248
|
+
});
|
|
249
|
+
KappSubmissionTable.displayName = 'KappSubmissionTable';
|
|
250
|
+
export default KappSubmissionTable;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { List, getIn } from 'immutable';
|
|
2
|
+
import { fetchSubmission, updateSubmission } from '../../../apis';
|
|
3
|
+
import { generateForm } from '../../form/Form';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
|
|
6
|
+
var dataSources = function dataSources(_ref) {
|
|
7
|
+
var submissionId = _ref.submissionId;
|
|
8
|
+
return {
|
|
9
|
+
submission: {
|
|
10
|
+
fn: fetchSubmission,
|
|
11
|
+
params: [{
|
|
12
|
+
id: submissionId,
|
|
13
|
+
include: 'details,values,form,form.fields,form.fields.details,form.pages'
|
|
14
|
+
}],
|
|
15
|
+
transform: function transform(result) {
|
|
16
|
+
return result.submission;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var handleSubmit = function handleSubmit(_ref2) {
|
|
23
|
+
var id = _ref2.submissionId;
|
|
24
|
+
return function (values) {
|
|
25
|
+
return updateSubmission({
|
|
26
|
+
id: id,
|
|
27
|
+
values: values.toJS()
|
|
28
|
+
}).then(function (_ref3) {
|
|
29
|
+
var submission = _ref3.submission,
|
|
30
|
+
error = _ref3.error;
|
|
31
|
+
|
|
32
|
+
if (error) {
|
|
33
|
+
throw error.statusCode === 400 && error.message || 'There was an error saving the submission';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return submission;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var traverseElement = function traverseElement(traverse, iteratee, acc) {
|
|
42
|
+
var element = traverse.get(0);
|
|
43
|
+
var elements = traverse.shift();
|
|
44
|
+
var childElements = element.get('elements', List());
|
|
45
|
+
var result = iteratee(element, acc); // If the current element has child elements make a recursive call.
|
|
46
|
+
|
|
47
|
+
if (childElements.size > 0) {
|
|
48
|
+
result = traverseElement(childElements, iteratee, result);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (elements.size > 0) {
|
|
52
|
+
return traverseElement(elements, iteratee, result);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var convertRenderType = function convertRenderType(element) {
|
|
59
|
+
if (element.get('renderType') === 'dropdown') {
|
|
60
|
+
return element.get('choicesResourceName') ? 'text' : 'select';
|
|
61
|
+
} else if (element.get('renderType') === 'checkbox') {
|
|
62
|
+
return 'text-multi';
|
|
63
|
+
} else if (element.get('renderType') === 'attachment') {
|
|
64
|
+
return 'text';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return element.get('renderType');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var getInitialValue = function getInitialValue(submission, element, type) {
|
|
71
|
+
var name = element.get('name');
|
|
72
|
+
var isAttachment = element.get('renderType') === 'attachment';
|
|
73
|
+
var value = getIn(submission, ['values', name], element.get('renderType') === 'checkbox' ? List() : '') || '';
|
|
74
|
+
return isAttachment ? JSON.stringify(List.isList(value) ? value.toJS() : value) : type === 'datetime' ? moment(value).format('yyyy-MM-DDThh:mm') : type === 'date' ? moment(value).format('yyyy-MM-DD') : value;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var serializer = function serializer(element, type) {
|
|
78
|
+
return function (_ref4) {
|
|
79
|
+
var values = _ref4.values;
|
|
80
|
+
var name = element.get('name');
|
|
81
|
+
return type === 'datetime' ? moment(values.get(name)).format() : values.get(name);
|
|
82
|
+
};
|
|
83
|
+
}; // If the element uses bridged options then the `choices` value represents the
|
|
84
|
+
// label/value mapping from and not actual choices.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
var getChoices = function getChoices(element) {
|
|
88
|
+
return !!element.get('choicesResourceName') ? List() : element.get('choices');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var fields = function fields() {
|
|
92
|
+
return function (_ref5) {
|
|
93
|
+
var submission = _ref5.submission;
|
|
94
|
+
|
|
95
|
+
if (submission) {
|
|
96
|
+
var pages = submission.getIn(['form', 'pages'], List());
|
|
97
|
+
var values = traverseElement(pages, function (element, values) {
|
|
98
|
+
var name = element.get('name');
|
|
99
|
+
var type = convertRenderType(element);
|
|
100
|
+
var initialValue = getInitialValue(submission, element, type);
|
|
101
|
+
var isAttachment = element.get('renderType') === 'attachment';
|
|
102
|
+
return element.get('type') === 'field' ? values.push({
|
|
103
|
+
name: name,
|
|
104
|
+
label: name,
|
|
105
|
+
type: type,
|
|
106
|
+
options: getChoices(element, initialValue),
|
|
107
|
+
initialValue: initialValue,
|
|
108
|
+
enabled: !isAttachment,
|
|
109
|
+
"transient": isAttachment,
|
|
110
|
+
serialize: serializer(element, type)
|
|
111
|
+
}) : values;
|
|
112
|
+
}, List());
|
|
113
|
+
return values.toJS();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export var SubmissionForm = generateForm({
|
|
119
|
+
formOptions: ['submissionId'],
|
|
120
|
+
dataSources: dataSources,
|
|
121
|
+
fields: fields,
|
|
122
|
+
handleSubmit: handleSubmit
|
|
123
|
+
});
|
|
124
|
+
SubmissionForm.displayName = 'SubmissionForm';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { fromJS, List, Range } from 'immutable';
|
|
2
|
+
import { TIMELINES, MAX_PART_LENGTH } from '../../../helpers';
|
|
3
|
+
export var getUsedFields = function getUsedFields(values, partIndex) {
|
|
4
|
+
var partType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'eq';
|
|
5
|
+
var equalities = List();
|
|
6
|
+
|
|
7
|
+
if (partType === 'eq' && partIndex === 0) {
|
|
8
|
+
equalities = List();
|
|
9
|
+
} else if (partType === 'eq' && partIndex === 1) {
|
|
10
|
+
equalities = List([values.get('op0-part')]);
|
|
11
|
+
} else if (partType === 'eq') {
|
|
12
|
+
equalities = Range(0, partIndex).map(function (i) {
|
|
13
|
+
return values.get("op".concat(i, "-part"));
|
|
14
|
+
}).toList().filter(function (f) {
|
|
15
|
+
return f !== '';
|
|
16
|
+
});
|
|
17
|
+
} else if (partType === 'range') {
|
|
18
|
+
var orders = Range(0, MAX_PART_LENGTH).map(function (i) {
|
|
19
|
+
return values.get("orderby".concat(i, "-part"));
|
|
20
|
+
}).toList().filter(function (f) {
|
|
21
|
+
return f !== '' && f !== values.get('range-part');
|
|
22
|
+
});
|
|
23
|
+
equalities = Range(0, MAX_PART_LENGTH).map(function (i) {
|
|
24
|
+
return values.get("op".concat(i, "-part"));
|
|
25
|
+
}).toList().concat(orders).filter(function (f) {
|
|
26
|
+
return f !== '';
|
|
27
|
+
});
|
|
28
|
+
} else if (partType === 'orderBy') {
|
|
29
|
+
var _orders;
|
|
30
|
+
|
|
31
|
+
if (partIndex === 0) {
|
|
32
|
+
_orders = List();
|
|
33
|
+
} else if (partIndex === 1) {
|
|
34
|
+
_orders = List([values.get('orderby0-part')]);
|
|
35
|
+
} else {
|
|
36
|
+
_orders = Range(0, partIndex).map(function (i) {
|
|
37
|
+
return values.get("orderby".concat(i, "-part"));
|
|
38
|
+
}).toList().filter(function (f) {
|
|
39
|
+
return f !== '';
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
equalities = Range(0, MAX_PART_LENGTH).map(function (i) {
|
|
44
|
+
return values.get("op".concat(i, "-part"));
|
|
45
|
+
}).toList().concat(_orders).filter(function (f) {
|
|
46
|
+
return f !== '';
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return equalities;
|
|
51
|
+
};
|
|
52
|
+
export var availableParts = function availableParts(values, indexes, equalityFields) {
|
|
53
|
+
var partType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'eq';
|
|
54
|
+
var remainingParts = indexes.map(function (index) {
|
|
55
|
+
return getRemainingParts(index.get('parts', List()), equalityFields);
|
|
56
|
+
});
|
|
57
|
+
var containsTimeline = equalityFields.some(function (index) {
|
|
58
|
+
return TIMELINES.includes(index);
|
|
59
|
+
});
|
|
60
|
+
var anyAtLast = remainingParts.some(function (index) {
|
|
61
|
+
return index && index.size === 0;
|
|
62
|
+
});
|
|
63
|
+
var rangePart = values.get('range-part');
|
|
64
|
+
var timelinesAvailable = anyAtLast && !containsTimeline ? TIMELINES : containsTimeline ? getRemainingParts(List([equalityFields.last()]), fromJS(TIMELINES)) : List();
|
|
65
|
+
|
|
66
|
+
if (partType === 'range') {
|
|
67
|
+
var rangeRemaining = remainingParts.filter(function (index) {
|
|
68
|
+
return index && index.size === 1;
|
|
69
|
+
});
|
|
70
|
+
return rangeRemaining.concat(rangePart && rangeRemaining.size === 0 && values.get('orderby0-part') && values.get('orderby0-part') !== rangePart ? List([]) : timelinesAvailable || List([]));
|
|
71
|
+
} else if (partType === 'orderBy') {
|
|
72
|
+
return (rangePart ? List([rangePart]) : remainingParts.filter(function (index) {
|
|
73
|
+
return index && index.size > 0;
|
|
74
|
+
}).map(function (index) {
|
|
75
|
+
return index.first();
|
|
76
|
+
})).concat(TIMELINES.includes(rangePart) ? List([rangePart]) : anyAtLast ? fromJS(TIMELINES) : equalityFields.size === 0 ? fromJS(TIMELINES) : List()).toSet().toList();
|
|
77
|
+
} else {
|
|
78
|
+
return remainingParts.filterNot(function (index) {
|
|
79
|
+
return !index || index.size === 0;
|
|
80
|
+
}).map(function (index) {
|
|
81
|
+
return index.first();
|
|
82
|
+
}).toSet().toList().filterNot(function (p) {
|
|
83
|
+
return TIMELINES.includes(p);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export var getRemainingParts = function getRemainingParts(src, dst) {
|
|
88
|
+
if (src.size === 0 && dst.size === 0) return List(); // If we're matching so far, and the are no more to compare it's a match.
|
|
89
|
+
|
|
90
|
+
if (src.size > 0 && dst.size === 0) return src; // If we're out of elements but there's more to match, it's not a match.
|
|
91
|
+
|
|
92
|
+
if (src.size === 0 && dst.size > 0) return List();
|
|
93
|
+
if (src.first() === dst.first()) return getRemainingParts(src.shift(), dst.shift());
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { List, Map, fromJS } from 'immutable';
|
|
2
|
+
import { availableParts, getRemainingParts } from './helpers';
|
|
3
|
+
var INDEX_A_B = fromJS({
|
|
4
|
+
name: 'values[A],values[B]',
|
|
5
|
+
parts: ['values[A]', 'values[B]']
|
|
6
|
+
});
|
|
7
|
+
var INDEX_A_C = fromJS({
|
|
8
|
+
name: 'values[A],values[C]',
|
|
9
|
+
parts: ['values[A]', 'values[C]']
|
|
10
|
+
});
|
|
11
|
+
var INDEX_A_B_C = fromJS({
|
|
12
|
+
name: 'values[A],values[B],values[C]',
|
|
13
|
+
parts: ['values[A]', 'values[B]', 'values[C]']
|
|
14
|
+
});
|
|
15
|
+
describe('submission filter helpers', function () {
|
|
16
|
+
var indexes;
|
|
17
|
+
var values;
|
|
18
|
+
beforeEach(function () {
|
|
19
|
+
values = Map({});
|
|
20
|
+
indexes = List([]);
|
|
21
|
+
});
|
|
22
|
+
describe('#getRemainingParts', function () {
|
|
23
|
+
test('empty sets match', function () {
|
|
24
|
+
var result = getRemainingParts(List(), List());
|
|
25
|
+
expect(result).toBeImmutableList();
|
|
26
|
+
expect(result.size).toBe(0);
|
|
27
|
+
});
|
|
28
|
+
test('when left is the same as right', function () {
|
|
29
|
+
var result = getRemainingParts(List([1]), List([1]));
|
|
30
|
+
expect(result).toBeImmutableList();
|
|
31
|
+
expect(result.size).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
test('when left is larger than right', function () {
|
|
34
|
+
var result = getRemainingParts(List([1, 2]), List([1]));
|
|
35
|
+
expect(result).toBeImmutableList();
|
|
36
|
+
expect(result.size).toBe(1);
|
|
37
|
+
expect(result.first()).toBe(2);
|
|
38
|
+
});
|
|
39
|
+
test('when left is larger than right with multiple values', function () {
|
|
40
|
+
var result = getRemainingParts(List([1, 2, 3, 4]), List([1]));
|
|
41
|
+
expect(result).toBeImmutableList();
|
|
42
|
+
expect(result.size).toBe(3);
|
|
43
|
+
expect(result.first()).toBe(2);
|
|
44
|
+
});
|
|
45
|
+
test('when left does not start with right', function () {
|
|
46
|
+
var result = getRemainingParts(List([2, 1]), List([1]));
|
|
47
|
+
expect(result).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
test('when left does fully not start with right', function () {
|
|
50
|
+
var result = getRemainingParts(List([1, 1, 1]), List([1, 2]));
|
|
51
|
+
expect(result).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
test('when left contains but does not start with right', function () {
|
|
54
|
+
var result = getRemainingParts(List([1, 1, 2]), List([1, 2]));
|
|
55
|
+
expect(result).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('#avaialbleParts', function () {
|
|
59
|
+
test('when there are no indexes', function () {
|
|
60
|
+
var result = availableParts(values, indexes, List(['values[A]', 'values[B]']));
|
|
61
|
+
expect(result).toBeImmutableList();
|
|
62
|
+
expect(result.size).toBe(0);
|
|
63
|
+
});
|
|
64
|
+
test('when there are no indexes with parts remaining', function () {
|
|
65
|
+
var result = availableParts(values, indexes.push(INDEX_A_B), List(['values[A]', 'values[B]']));
|
|
66
|
+
expect(result).toBeImmutableList();
|
|
67
|
+
expect(result.size).toBe(0);
|
|
68
|
+
});
|
|
69
|
+
test('when there are fewer parts', function () {
|
|
70
|
+
// We're expecting parts from `values[A],values[B]`
|
|
71
|
+
var result = availableParts(values, indexes.push(INDEX_A_B), List(['values[A]']));
|
|
72
|
+
expect(result).toBeImmutableList();
|
|
73
|
+
expect(result.size).toBe(1);
|
|
74
|
+
expect(result.first()).toBe('values[B]');
|
|
75
|
+
});
|
|
76
|
+
test('when there are fewer parts in multiple indexes', function () {
|
|
77
|
+
var result = availableParts(values, indexes.push(INDEX_A_B).push(INDEX_A_C), List(['values[A]']));
|
|
78
|
+
expect(result).toBeImmutableList();
|
|
79
|
+
expect(result.size).toBe(2);
|
|
80
|
+
expect(result.first()).toBe('values[B]');
|
|
81
|
+
expect(result.last()).toBe('values[C]');
|
|
82
|
+
});
|
|
83
|
+
test('when there are more parts in the index', function () {
|
|
84
|
+
var result = availableParts(values, indexes.push(INDEX_A_B_C), List(['values[A]']));
|
|
85
|
+
expect(result).toBeImmutableList();
|
|
86
|
+
expect(result.size).toBe(1);
|
|
87
|
+
expect(result.first()).toBe('values[B]');
|
|
88
|
+
});
|
|
89
|
+
test('when multiple indexes start the same', function () {
|
|
90
|
+
var result = availableParts(values, indexes.push(INDEX_A_B).push(INDEX_A_B_C), List(['values[A]']));
|
|
91
|
+
expect(result).toBeImmutableList();
|
|
92
|
+
expect(result.size).toBe(1);
|
|
93
|
+
expect(result.first()).toBe('values[B]');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -918,8 +918,8 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
918
918
|
} // else if the autoFocus prop has been changed we will also focus the new
|
|
919
919
|
// resulting focus element
|
|
920
920
|
else if (this.props.autoFocus !== prevProps.autoFocus && this.focusRef.current) {
|
|
921
|
-
|
|
922
|
-
|
|
921
|
+
this.focusRef.current.focus();
|
|
922
|
+
}
|
|
923
923
|
}
|
|
924
924
|
}, {
|
|
925
925
|
key: "render",
|