@projectcaluma/ember-form 14.11.1 → 14.13.0
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/addon/components/cf-content.js +12 -12
- package/addon/components/cf-field/input/powerselect.hbs +1 -0
- package/addon/components/cf-field/input/powerselect.js +1 -5
- package/addon/components/cf-field/input/table.hbs +6 -6
- package/addon/components/cf-field/input-compare.hbs +1 -1
- package/addon/components/cf-field.hbs +1 -1
- package/addon/gql/queries/document-answers-compare.graphql +2 -0
- package/addon/gql/queries/document-answers.graphql +24 -12
- package/addon/lib/document.js +13 -9
- package/addon/lib/field.js +5 -1
- package/package.json +5 -5
- package/addon/gql/fragments/case-form-and-workflow.graphql +0 -28
|
@@ -160,18 +160,17 @@ export default class CfContentComponent extends Component {
|
|
|
160
160
|
|
|
161
161
|
let answerDocument = null;
|
|
162
162
|
let historicalDocument = null;
|
|
163
|
+
let jexlContext = null;
|
|
163
164
|
|
|
164
165
|
if (!this.args.compare) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)
|
|
174
|
-
).map(({ node }) => node);
|
|
166
|
+
const data = await this.apollo.query({
|
|
167
|
+
query: getDocumentAnswersQuery,
|
|
168
|
+
fetchPolicy: "network-only",
|
|
169
|
+
variables: { id: this.args.documentId },
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
answerDocument = data.allDocuments.edges[0].node;
|
|
173
|
+
jexlContext = data.jexlContext;
|
|
175
174
|
} else {
|
|
176
175
|
const { from, to } = this.args.compare;
|
|
177
176
|
|
|
@@ -186,6 +185,7 @@ export default class CfContentComponent extends Component {
|
|
|
186
185
|
});
|
|
187
186
|
historicalDocument = data.fromRevision;
|
|
188
187
|
answerDocument = data.toRevision;
|
|
188
|
+
jexlContext = data.jexlContext;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const [form] = (
|
|
@@ -199,14 +199,14 @@ export default class CfContentComponent extends Component {
|
|
|
199
199
|
)
|
|
200
200
|
).map(({ node }) => node);
|
|
201
201
|
|
|
202
|
-
const raw = parseDocument({ ...answerDocument, form });
|
|
202
|
+
const raw = parseDocument({ ...answerDocument, form, jexlContext });
|
|
203
203
|
|
|
204
204
|
const document = new Document({
|
|
205
205
|
raw,
|
|
206
206
|
owner,
|
|
207
207
|
dataSourceContext: this.args.context,
|
|
208
208
|
historicalDocument: historicalDocument
|
|
209
|
-
? parseDocument({ ...historicalDocument, form })
|
|
209
|
+
? parseDocument({ ...historicalDocument, form, jexlContext })
|
|
210
210
|
: null,
|
|
211
211
|
compare: this.args.compare,
|
|
212
212
|
});
|
|
@@ -3,7 +3,6 @@ import { inject as service } from "@ember/service";
|
|
|
3
3
|
import { ensureSafeComponent } from "@embroider/util";
|
|
4
4
|
import Component from "@glimmer/component";
|
|
5
5
|
import PowerSelectComponent from "ember-power-select/components/power-select";
|
|
6
|
-
import PowerSelectMultipleComponent from "ember-power-select/components/power-select-multiple";
|
|
7
6
|
|
|
8
7
|
import getConfig from "@projectcaluma/ember-core/utils/get-config";
|
|
9
8
|
|
|
@@ -33,10 +32,7 @@ export default class CfFieldInputPowerselectComponent extends Component {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
get selectComponent() {
|
|
36
|
-
return ensureSafeComponent(
|
|
37
|
-
this.multiple ? PowerSelectMultipleComponent : PowerSelectComponent,
|
|
38
|
-
this,
|
|
39
|
-
);
|
|
35
|
+
return ensureSafeComponent(PowerSelectComponent, this);
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
get searchEnabled() {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
</UkButton>
|
|
80
80
|
<UkButton
|
|
81
81
|
@color="link"
|
|
82
|
-
@onClick={{fn
|
|
82
|
+
@onClick={{fn this.delete.perform document}}
|
|
83
83
|
title={{t "caluma.form.delete"}}
|
|
84
84
|
class="uk-flex-inline uk-margin-small-left table-controls"
|
|
85
85
|
data-test-delete-row
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
<td colspan={{add this.columns.length 1}} class="uk-text-center">
|
|
100
100
|
<UkButton
|
|
101
101
|
@color="link"
|
|
102
|
-
@onClick={{
|
|
102
|
+
@onClick={{this.add.perform}}
|
|
103
103
|
title={{t "caluma.form.addRow"}}
|
|
104
104
|
data-test-add-row
|
|
105
105
|
>
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
{{#if this.documentToEdit}}
|
|
116
116
|
<UkModal
|
|
117
117
|
@visible={{this.showAddModal}}
|
|
118
|
-
@onHide={{
|
|
118
|
+
@onHide={{this.close.perform}}
|
|
119
119
|
@bgClose={{false}}
|
|
120
120
|
as |modal|
|
|
121
121
|
>
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
<UkButton
|
|
135
135
|
@label={{t "caluma.form.close"}}
|
|
136
136
|
@color="primary"
|
|
137
|
-
@onClick={{
|
|
137
|
+
@onClick={{this.close.perform}}
|
|
138
138
|
@disabled={{this.close.isRunning}}
|
|
139
139
|
@loading={{this.close.isRunning}}
|
|
140
140
|
data-test-close
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
{{else}}
|
|
143
143
|
<UkButton
|
|
144
144
|
@label={{t "caluma.form.cancel"}}
|
|
145
|
-
@onClick={{
|
|
145
|
+
@onClick={{this.close.perform}}
|
|
146
146
|
@disabled={{this.close.isRunning}}
|
|
147
147
|
@loading={{this.close.isRunning}}
|
|
148
148
|
data-test-cancel
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
@type="submit"
|
|
159
159
|
@disabled={{or this.save.isRunning (not isValid)}}
|
|
160
160
|
@loading={{this.save.isRunning}}
|
|
161
|
-
@onClick={{fn
|
|
161
|
+
@onClick={{fn this.save.perform validate}}
|
|
162
162
|
data-test-save
|
|
163
163
|
/>
|
|
164
164
|
</DocumentValidity>
|
|
@@ -108,6 +108,8 @@ query (
|
|
|
108
108
|
$to: DateTime!
|
|
109
109
|
$context: JSONString
|
|
110
110
|
) {
|
|
111
|
+
jexlContext: documentGlobalJexlContext(id: $documentId)
|
|
112
|
+
|
|
111
113
|
fromRevision: documentAsOf(id: $documentId, asOf: $from) {
|
|
112
114
|
...RevisionDocument
|
|
113
115
|
answers: historicalAnswers(asOf: $from, excludeDeleted: true) {
|
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
#import * from '../fragments/field.graphql'
|
|
2
|
-
#import * from '../fragments/case-form-and-workflow.graphql'
|
|
3
2
|
|
|
4
3
|
query DocumentAnswers($id: ID!) {
|
|
4
|
+
# Global JEXL context (case & work item) for JEXL evaluations. This will be
|
|
5
|
+
# enriched with the document depending data in `lib/document.js` and
|
|
6
|
+
# `lib/field.js` before being passed into the JEXL evaluation
|
|
7
|
+
jexlContext: documentGlobalJexlContext(id: $id)
|
|
8
|
+
|
|
5
9
|
allDocuments(filter: [{ id: $id }]) {
|
|
6
10
|
edges {
|
|
7
11
|
node {
|
|
8
12
|
id
|
|
13
|
+
|
|
14
|
+
# Basic form information
|
|
9
15
|
form {
|
|
10
16
|
id
|
|
11
17
|
slug
|
|
12
18
|
}
|
|
19
|
+
|
|
20
|
+
# All answers of the document, up to three levels deep (top form -> sub
|
|
21
|
+
# form -> table form)
|
|
22
|
+
answers {
|
|
23
|
+
edges {
|
|
24
|
+
node {
|
|
25
|
+
...FieldAnswer
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Work item and case work items to determine the actionable work item
|
|
31
|
+
# for action buttons. This is either the direct work item below or a
|
|
32
|
+
# case work item of the type complete workflow form.
|
|
33
|
+
# See `workItemUuid` in `lib/document.js`
|
|
13
34
|
workItem {
|
|
14
35
|
id
|
|
15
|
-
case {
|
|
16
|
-
...CaseFormAndWorkflow
|
|
17
|
-
}
|
|
18
36
|
}
|
|
19
37
|
case {
|
|
20
|
-
...CaseFormAndWorkflow
|
|
21
38
|
workItems {
|
|
22
39
|
edges {
|
|
23
40
|
node {
|
|
24
41
|
id
|
|
42
|
+
# `__typename` is what identifies the complete workflow form
|
|
43
|
+
# work item, the `task` selection is only there to request it
|
|
25
44
|
task {
|
|
26
45
|
id
|
|
27
46
|
}
|
|
@@ -29,13 +48,6 @@ query DocumentAnswers($id: ID!) {
|
|
|
29
48
|
}
|
|
30
49
|
}
|
|
31
50
|
}
|
|
32
|
-
answers {
|
|
33
|
-
edges {
|
|
34
|
-
node {
|
|
35
|
-
...FieldAnswer
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
}
|
package/addon/lib/document.js
CHANGED
|
@@ -232,26 +232,30 @@ export default class Document extends Base {
|
|
|
232
232
|
* @property {Object} jexlContext
|
|
233
233
|
*/
|
|
234
234
|
get jexlContext() {
|
|
235
|
-
const
|
|
235
|
+
const globalContext = this.raw.jexlContext ?? {
|
|
236
|
+
info: {
|
|
237
|
+
// Expressions rely on these being `null` rather than absent when the
|
|
238
|
+
// document is not attached to a case or work item.
|
|
239
|
+
case: null,
|
|
240
|
+
workItem: null,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
|
|
236
244
|
return (
|
|
237
245
|
this.parentDocument?.jexlContext ?? {
|
|
246
|
+
...globalContext,
|
|
238
247
|
// JEXL interprets null in an expression as variable instead of a
|
|
239
248
|
// primitive. This resolves that issue.
|
|
240
249
|
null: null,
|
|
250
|
+
// The information about the root form needs to be constructed on the
|
|
251
|
+
// first document as it doesn't depend on the field.
|
|
241
252
|
form: this.rootForm.slug,
|
|
242
253
|
info: {
|
|
254
|
+
...globalContext.info,
|
|
243
255
|
root: {
|
|
244
256
|
form: this.rootForm.slug,
|
|
245
257
|
formMeta: this.rootForm.raw.meta,
|
|
246
258
|
},
|
|
247
|
-
case: {
|
|
248
|
-
form: _case?.document?.form.slug,
|
|
249
|
-
workflow: _case?.workflow.slug,
|
|
250
|
-
root: {
|
|
251
|
-
form: _case?.family.document?.form.slug,
|
|
252
|
-
workflow: _case?.family.workflow.slug,
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
259
|
},
|
|
256
260
|
}
|
|
257
261
|
);
|
package/addon/lib/field.js
CHANGED
|
@@ -554,13 +554,17 @@ export default class Field extends Base {
|
|
|
554
554
|
* - `info.formMeta`: The meta of the form this question is attached to.
|
|
555
555
|
* - `info.parent.form`: The parent form if applicable.
|
|
556
556
|
* - `info.parent.formMeta`: The parent form meta if applicable.
|
|
557
|
-
* - `info.parent.question`: The parent
|
|
557
|
+
* - `info.parent.question`: The parent question (table or form question)
|
|
558
558
|
* - `info.root.form`: The new property for the root form.
|
|
559
559
|
* - `info.root.formMeta`: The new property for the root form meta.
|
|
560
560
|
* - `info.case.form`: The cases' form (works for task forms and case forms).
|
|
561
561
|
* - `info.case.workflow`: The cases' workflow (works for task forms and case forms).
|
|
562
|
+
* - `info.case.meta`: The cases' meta (works for task forms and case forms).
|
|
562
563
|
* - `info.case.root.form`: The _root_ cases' form (works for task forms and case forms).
|
|
563
564
|
* - `info.case.root.workflow`: The _root_ cases' workflow (works for task forms and case forms).
|
|
565
|
+
* - `info.case.root.meta`: The _root_ cases' meta (works for task forms and case forms).
|
|
566
|
+
* - `info.workItem.task`: The task slug of the work item
|
|
567
|
+
* - `info.workItem.meta`: The meta of the work item
|
|
564
568
|
*
|
|
565
569
|
* @property {Object} jexlContext
|
|
566
570
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.13.0",
|
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"luxon": "^3.5.0",
|
|
40
40
|
"reactiveweb": "^1.3.0",
|
|
41
41
|
"tracked-toolbox": "^2.0.0",
|
|
42
|
-
"@projectcaluma/ember-core": "^14.
|
|
42
|
+
"@projectcaluma/ember-core": "^14.13.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@ember/optional-features": "2.3.0",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"uikit": "3.25.6",
|
|
75
75
|
"uuid": "13.0.0",
|
|
76
76
|
"webpack": "5.104.1",
|
|
77
|
-
"@projectcaluma/ember-testing": "14.
|
|
78
|
-
"@projectcaluma/ember-workflow": "14.
|
|
77
|
+
"@projectcaluma/ember-testing": "14.13.0",
|
|
78
|
+
"@projectcaluma/ember-workflow": "14.13.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"ember-source": ">= 4.0.0",
|
|
82
|
-
"@projectcaluma/ember-workflow": "^14.
|
|
82
|
+
"@projectcaluma/ember-workflow": "^14.13.0"
|
|
83
83
|
},
|
|
84
84
|
"dependenciesMeta": {
|
|
85
85
|
"@projectcaluma/ember-core": {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
fragment CaseFormAndWorkflow on Case {
|
|
2
|
-
id
|
|
3
|
-
workflow {
|
|
4
|
-
id
|
|
5
|
-
slug
|
|
6
|
-
}
|
|
7
|
-
document {
|
|
8
|
-
id
|
|
9
|
-
form {
|
|
10
|
-
id
|
|
11
|
-
slug
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
family {
|
|
15
|
-
id
|
|
16
|
-
workflow {
|
|
17
|
-
id
|
|
18
|
-
slug
|
|
19
|
-
}
|
|
20
|
-
document {
|
|
21
|
-
id
|
|
22
|
-
form {
|
|
23
|
-
id
|
|
24
|
-
slug
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|