@projectcaluma/ember-form 14.8.3 → 14.9.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.
Files changed (54) hide show
  1. package/addon/components/cf-content.hbs +44 -39
  2. package/addon/components/cf-content.js +50 -14
  3. package/addon/components/cf-field/input/checkbox.hbs +3 -1
  4. package/addon/components/cf-field/input/checkbox.js +15 -0
  5. package/addon/components/cf-field/input/date.hbs +38 -31
  6. package/addon/components/cf-field/input/float.hbs +22 -15
  7. package/addon/components/cf-field/input/integer.hbs +22 -15
  8. package/addon/components/cf-field/input/number-separator.hbs +19 -12
  9. package/addon/components/cf-field/input/number-separator.js +10 -2
  10. package/addon/components/cf-field/input/powerselect.hbs +2 -2
  11. package/addon/components/cf-field/input/powerselect.js +12 -0
  12. package/addon/components/cf-field/input/radio.hbs +3 -1
  13. package/addon/components/cf-field/input/radio.js +15 -0
  14. package/addon/components/cf-field/input/table.hbs +31 -1
  15. package/addon/components/cf-field/input/table.js +10 -0
  16. package/addon/components/cf-field/input/text.hbs +21 -14
  17. package/addon/components/cf-field/input/textarea.hbs +21 -14
  18. package/addon/components/cf-field/input-compare/changes-note.hbs +9 -0
  19. package/addon/components/cf-field/input-compare/text-diff.hbs +6 -0
  20. package/addon/components/cf-field/input-compare/textarea-diff.hbs +6 -0
  21. package/addon/components/cf-field/input-compare.hbs +50 -0
  22. package/addon/components/cf-field/input-compare.js +60 -0
  23. package/addon/components/cf-field/input.hbs +1 -0
  24. package/addon/components/cf-field.hbs +17 -8
  25. package/addon/components/cf-field.js +15 -3
  26. package/addon/components/cf-form-wrapper.hbs +1 -0
  27. package/addon/components/cf-form.hbs +1 -0
  28. package/addon/components/cf-navigation-item.hbs +14 -4
  29. package/addon/components/cf-navigation.hbs +1 -0
  30. package/addon/components/timeline-select.hbs +20 -0
  31. package/addon/gql/queries/document-answers-compare.graphql +157 -0
  32. package/addon/helpers/get-widget.js +17 -31
  33. package/addon/instance-initializers/form-widget-overrides.js +6 -0
  34. package/addon/lib/answer.js +38 -3
  35. package/addon/lib/compare.js +161 -0
  36. package/addon/lib/document.js +10 -2
  37. package/addon/lib/field.js +81 -1
  38. package/addon/lib/fieldset.js +11 -0
  39. package/addon/lib/navigation.js +51 -1
  40. package/addon/lib/parsers.js +57 -5
  41. package/addon/services/caluma-store.js +12 -0
  42. package/app/components/cf-field/input-compare/changes-note.js +1 -0
  43. package/app/components/cf-field/input-compare/text-diff.js +1 -0
  44. package/app/components/cf-field/input-compare/textarea-diff.js +1 -0
  45. package/app/components/cf-field/input-compare.js +1 -0
  46. package/app/components/timeline-select.js +1 -0
  47. package/app/styles/@projectcaluma/ember-form.scss +1 -0
  48. package/app/styles/_cf-content-compare.scss +214 -0
  49. package/app/styles/_cf-navigation.scss +1 -0
  50. package/package.json +5 -5
  51. package/translations/de.yaml +9 -0
  52. package/translations/en.yaml +9 -0
  53. package/translations/fr.yaml +9 -0
  54. package/translations/it.yaml +9 -0
@@ -1,42 +1,47 @@
1
- {{#if this.loading}}
2
- <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
- {{else if this.document}}
4
- {{#let
5
- (hash
6
- document=this.document
7
- navigation=(component
8
- "cf-navigation"
9
- navigation=this.navigation
10
- useAsHeading=(or @useAsHeading false)
11
- headingBaseLevel=(or @headingBaseLevel 1)
12
- )
13
- pagination=(component "cf-pagination" navigation=this.navigation)
14
- form=(component
15
- "cf-form-wrapper"
1
+ <div class="{{if @compare 'cf-content-compare' 'cf-content'}}">
2
+ {{#if this.loading}}
3
+ <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
4
+ {{else if this.document}}
5
+ {{#let
6
+ (hash
16
7
  document=this.document
17
- fieldset=this.fieldset
18
- context=@context
19
- disabled=@disabled
20
- onSave=@onSave
8
+ navigation=(component
9
+ "cf-navigation"
10
+ navigation=this.navigation
11
+ useAsHeading=(or @useAsHeading false)
12
+ headingBaseLevel=(or @headingBaseLevel 1)
13
+ compare=@compare
14
+ )
15
+ pagination=(component "cf-pagination" navigation=this.navigation)
16
+ form=(component
17
+ "cf-form-wrapper"
18
+ document=this.document
19
+ fieldset=this.fieldset
20
+ context=@context
21
+ compare=@compare
22
+ disabled=@disabled
23
+ onSave=@onSave
24
+ )
21
25
  )
22
- )
23
- as |content|
24
- }}
25
- {{#if (has-block)}}
26
- {{yield content}}
27
- {{else if (gt this.document.fieldsets.length 1)}}
28
- <div uk-grid>
29
- <div class="uk-width-1-1 uk-width-1-3@m"><content.navigation /></div>
30
- <div class="uk-width-1-1 uk-width-2-3@m">
31
- <content.form />
32
- <hr />
33
- <content.pagination />
26
+ as |content|
27
+ }}
28
+ {{#if (has-block)}}
29
+ {{yield content}}
30
+ {{else if (gt this.document.fieldsets.length 1)}}
31
+ <div uk-grid>
32
+ <div class="uk-width-1-1 uk-width-1-3@m"><content.navigation /></div>
33
+ <div class="uk-width-1-1 uk-width-2-3@m">
34
+ {{yield to="formHeader"}}
35
+ <content.form />
36
+ <hr />
37
+ <content.pagination />
38
+ </div>
34
39
  </div>
35
- </div>
36
- {{else}}
37
- <content.form />
38
- {{/if}}
39
- {{/let}}
40
- {{else}}
41
- {{yield to="notfound"}}
42
- {{/if}}
40
+ {{else}}
41
+ <content.form />
42
+ {{/if}}
43
+ {{/let}}
44
+ {{else}}
45
+ {{yield to="notfound"}}
46
+ {{/if}}
47
+ </div>
@@ -6,6 +6,7 @@ import { queryManager } from "ember-apollo-client";
6
6
  import { task } from "ember-concurrency";
7
7
  import { trackedTask } from "reactiveweb/ember-concurrency";
8
8
 
9
+ import getDocumentAnswersCompareQuery from "@projectcaluma/ember-form/gql/queries/document-answers-compare.graphql";
9
10
  import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/document-answers.graphql";
10
11
  import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/document-forms.graphql";
11
12
  import { parseDocument } from "@projectcaluma/ember-form/lib/parsers";
@@ -30,6 +31,12 @@ import { parseDocument } from "@projectcaluma/ember-form/lib/parsers";
30
31
  * </div>
31
32
  * </CfContent>
32
33
  * ```
34
+ * To use this component for a comparison between two document revisions, pass @compare
35
+ *
36
+ * <CfContent @documentId="some-id" @compare={{hash
37
+ from=this.fromDate
38
+ to=this.toDate
39
+ * }} />
33
40
  *
34
41
  * If you're rendering multi-page forms, the component also expects a query
35
42
  * param `displayedForm`:
@@ -72,6 +79,13 @@ export default class CfContentComponent extends Component {
72
79
  * @argument {Boolean} disabled
73
80
  */
74
81
 
82
+ /**
83
+ * Can be used to pass "compare" context information from the outside.
84
+ * Pass a hash with `from` and optional `to` date to compare documents.
85
+ *
86
+ * @argument {Object} compare
87
+ */
88
+
75
89
  /**
76
90
  * Whether the form should be displayed as loading, this can be used to
77
91
  * indicate a loading state if the application calling this component is
@@ -131,16 +145,39 @@ export default class CfContentComponent extends Component {
131
145
 
132
146
  if (!this.args.documentId) return;
133
147
 
134
- const [answerDocument] = (
135
- await this.apollo.query(
136
- {
137
- query: getDocumentAnswersQuery,
138
- fetchPolicy: "network-only",
139
- variables: { id: this.args.documentId },
148
+ const owner = getOwner(this);
149
+ const Document = owner.factoryFor("caluma-model:document").class;
150
+ const Navigation = owner.factoryFor("caluma-model:navigation").class;
151
+
152
+ let answerDocument = null;
153
+ let historicalDocument = null;
154
+
155
+ if (!this.args.compare) {
156
+ [answerDocument] = (
157
+ await this.apollo.query(
158
+ {
159
+ query: getDocumentAnswersQuery,
160
+ fetchPolicy: "network-only",
161
+ variables: { id: this.args.documentId },
162
+ },
163
+ "allDocuments.edges",
164
+ )
165
+ ).map(({ node }) => node);
166
+ } else {
167
+ const { from, to } = this.args.compare;
168
+
169
+ const data = await this.apollo.query({
170
+ query: getDocumentAnswersCompareQuery,
171
+ fetchPolicy: "network-only",
172
+ variables: {
173
+ documentId: this.args.documentId,
174
+ from,
175
+ to: to ?? new Date(),
140
176
  },
141
- "allDocuments.edges",
142
- )
143
- ).map(({ node }) => node);
177
+ });
178
+ historicalDocument = data.fromRevision;
179
+ answerDocument = data.toRevision;
180
+ }
144
181
 
145
182
  const [form] = (
146
183
  await this.apollo.query(
@@ -153,16 +190,15 @@ export default class CfContentComponent extends Component {
153
190
  )
154
191
  ).map(({ node }) => node);
155
192
 
156
- const owner = getOwner(this);
157
- const Document = owner.factoryFor("caluma-model:document").class;
158
- const Navigation = owner.factoryFor("caluma-model:navigation").class;
159
-
160
193
  const raw = parseDocument({ ...answerDocument, form });
161
194
 
162
195
  const document = new Document({
163
196
  raw,
164
197
  owner,
165
- dataSourceContext: this.args.context,
198
+ historicalDocument: historicalDocument
199
+ ? parseDocument({ ...historicalDocument, form })
200
+ : null,
201
+ compare: this.args.compare,
166
202
  });
167
203
  const navigation = new Navigation({ document, owner });
168
204
 
@@ -2,7 +2,9 @@
2
2
  {{#if (and (gt i 0) (not @field.raw.question.meta.vertical))}}<br />{{/if}}
3
3
  <label
4
4
  class="{{if @field.isInvalid 'uk-form-danger'}}
5
- {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
5
+ {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}
6
+ {{if (this.isAnswerRemoved option) 'diff-from-version'}}
7
+ {{if (this.isAnswerAdded option) 'diff-to-version'}}"
6
8
  >
7
9
  <input
8
10
  class="uk-checkbox uk-margin-small-right"
@@ -11,6 +11,21 @@ import { localCopy } from "tracked-toolbox";
11
11
  export default class CfFieldInputCheckboxComponent extends Component {
12
12
  @localCopy("args.field.value") selected;
13
13
 
14
+ isAnswerRemoved = (option) => {
15
+ return (
16
+ this.args.field.compare &&
17
+ (this.args.field.answer?.historicalValue ?? []).includes(option.slug) &&
18
+ !(this.args.field.answer?.value ?? []).includes(option.slug)
19
+ );
20
+ };
21
+ isAnswerAdded = (option) => {
22
+ return (
23
+ this.args.field.compare &&
24
+ !(this.args.field.answer?.historicalValue ?? []).includes(option.slug) &&
25
+ (this.args.field.answer?.value ?? []).includes(option.slug)
26
+ );
27
+ };
28
+
14
29
  /**
15
30
  * Update the value of the field with the slugs of the currently checked
16
31
  * boxes.
@@ -1,32 +1,39 @@
1
- <div class="uk-inline uk-width-1-1">
2
- {{#unless @disabled}}
3
- <a
4
- class="uk-form-icon uk-form-icon-flip"
5
- href="#"
6
- {{uk-tooltip (t "caluma.form.delete")}}
7
- {{on "click" this.clearCalendar}}
8
- >
9
- <UkIcon @icon="close" />
10
- </a>
11
- {{/unless}}
12
- <EmberFlatpickr
13
- id={{@field.pk}}
14
- name={{@field.pk}}
15
- class="uk-input {{if @disabled 'uk-disabled'}}"
16
- readonly={{@disabled}}
17
- placeholder={{@field.question.raw.placeholder}}
18
- @disabled={{@disabled}}
19
- @locale={{this.locale}}
20
- @date={{or @field.answer.value null}}
21
- @altFormat={{this.dateFormat}}
22
- @altInput={{true}}
23
- @allowInput={{true}}
24
- @onChange={{this.onChange}}
25
- @onReady={{this.onReady}}
26
- @onClose={{this.onClose}}
27
- @minDate={{@minDate}}
28
- @maxDate={{@maxDate}}
29
- aria-labelledby={{@field.labelId}}
30
- ...attributes
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextDiff
3
+ @currentValue={{format-date @field.answer.value}}
4
+ @historicalValue={{format-date @field.answer.historicalValue}}
31
5
  />
32
- </div>
6
+ {{else}}
7
+ <div class="uk-inline uk-width-1-1">
8
+ {{#unless @disabled}}
9
+ <a
10
+ class="uk-form-icon uk-form-icon-flip"
11
+ href="#"
12
+ {{uk-tooltip (t "caluma.form.delete")}}
13
+ {{on "click" this.clearCalendar}}
14
+ >
15
+ <UkIcon @icon="close" />
16
+ </a>
17
+ {{/unless}}
18
+ <EmberFlatpickr
19
+ id={{@field.pk}}
20
+ name={{@field.pk}}
21
+ class="uk-input {{if @disabled 'uk-disabled'}}"
22
+ readonly={{@disabled}}
23
+ placeholder={{@field.question.raw.placeholder}}
24
+ @disabled={{@disabled}}
25
+ @locale={{this.locale}}
26
+ @date={{or @field.answer.value null}}
27
+ @altFormat={{this.dateFormat}}
28
+ @altInput={{true}}
29
+ @allowInput={{true}}
30
+ @onChange={{this.onChange}}
31
+ @onReady={{this.onReady}}
32
+ @onClose={{this.onClose}}
33
+ @minDate={{@minDate}}
34
+ @maxDate={{@maxDate}}
35
+ aria-labelledby={{@field.labelId}}
36
+ ...attributes
37
+ />
38
+ </div>
39
+ {{/if}}
@@ -1,15 +1,22 @@
1
- <input
2
- type="number"
3
- step={{this.floatStep}}
4
- class="uk-input
5
- {{if @field.isInvalid 'uk-form-danger'}}
6
- {{if this.disabled 'uk-disabled'}}"
7
- readonly={{this.disabled}}
8
- name={{@field.pk}}
9
- id={{@field.pk}}
10
- value={{@field.value}}
11
- min={{@field.question.raw.floatMinValue}}
12
- max={{@field.question.raw.floatMaxValue}}
13
- placeholder={{@field.question.raw.placeholder}}
14
- {{on "input" this.input}}
15
- />
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextDiff
3
+ @currentValue={{@field.answer.value}}
4
+ @historicalValue={{@field.answer.historicalValue}}
5
+ />
6
+ {{else}}
7
+ <input
8
+ type="number"
9
+ step={{this.floatStep}}
10
+ class="uk-input
11
+ {{if @field.isInvalid 'uk-form-danger'}}
12
+ {{if this.disabled 'uk-disabled'}}"
13
+ readonly={{this.disabled}}
14
+ name={{@field.pk}}
15
+ id={{@field.pk}}
16
+ value={{@field.value}}
17
+ min={{@field.question.raw.floatMinValue}}
18
+ max={{@field.question.raw.floatMaxValue}}
19
+ placeholder={{@field.question.raw.placeholder}}
20
+ {{on "input" this.input}}
21
+ />
22
+ {{/if}}
@@ -1,15 +1,22 @@
1
- <input
2
- type="number"
3
- step="1"
4
- class="uk-input
5
- {{if @field.isInvalid 'uk-form-danger'}}
6
- {{if @disabled 'uk-disabled'}}"
7
- name={{@field.pk}}
8
- id={{@field.pk}}
9
- value={{@field.answer.value}}
10
- min={{@field.question.raw.integerMinValue}}
11
- max={{@field.question.raw.integerMaxValue}}
12
- placeholder={{@field.question.raw.placeholder}}
13
- readonly={{@disabled}}
14
- {{on "input" this.input}}
15
- />
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextDiff
3
+ @currentValue={{@field.answer.value}}
4
+ @historicalValue={{@field.answer.historicalValue}}
5
+ />
6
+ {{else}}
7
+ <input
8
+ type="number"
9
+ step="1"
10
+ class="uk-input
11
+ {{if @field.isInvalid 'uk-form-danger'}}
12
+ {{if @disabled 'uk-disabled'}}"
13
+ name={{@field.pk}}
14
+ id={{@field.pk}}
15
+ value={{@field.answer.value}}
16
+ min={{@field.question.raw.integerMinValue}}
17
+ max={{@field.question.raw.integerMaxValue}}
18
+ placeholder={{@field.question.raw.placeholder}}
19
+ readonly={{@disabled}}
20
+ {{on "input" this.input}}
21
+ />
22
+ {{/if}}
@@ -1,12 +1,19 @@
1
- <input
2
- type="text"
3
- class="uk-input
4
- {{if @field.isInvalid 'uk-form-danger'}}
5
- {{if this.disabled 'uk-disabled'}}"
6
- name={{@field.pk}}
7
- id={{@field.pk}}
8
- value={{this.displayValue}}
9
- placeholder={{@field.question.raw.placeholder}}
10
- readonly={{this.disabled}}
11
- {{on "input" this.input}}
12
- />
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextDiff
3
+ @currentValue={{this.displayValue}}
4
+ @historicalValue={{this.historicalDisplayValue}}
5
+ />
6
+ {{else}}
7
+ <input
8
+ type="text"
9
+ class="uk-input
10
+ {{if @field.isInvalid 'uk-form-danger'}}
11
+ {{if this.disabled 'uk-disabled'}}"
12
+ name={{@field.pk}}
13
+ id={{@field.pk}}
14
+ value={{this.displayValue}}
15
+ placeholder={{@field.question.raw.placeholder}}
16
+ readonly={{this.disabled}}
17
+ {{on "input" this.input}}
18
+ />
19
+ {{/if}}
@@ -11,11 +11,19 @@ export default class CfFieldInputNumberSeparatorComponent extends Component {
11
11
  }
12
12
 
13
13
  get displayValue() {
14
- if (isNaN(parseFloat(this.args.field.value))) {
14
+ return this.formatValue(this.args.field.value);
15
+ }
16
+
17
+ get historicalDisplayValue() {
18
+ return this.formatValue(this.args.field.answer?.historicalValue);
19
+ }
20
+
21
+ formatValue(value) {
22
+ if (isNaN(parseFloat(value))) {
15
23
  return "";
16
24
  }
17
25
 
18
- return this.intl.formatNumber(this.args.field.value, {
26
+ return this.intl.formatNumber(value, {
19
27
  maximumFractionDigits: 20,
20
28
  });
21
29
  }
@@ -1,12 +1,12 @@
1
1
  <this.selectComponent
2
2
  @options={{@field.options}}
3
- @selected={{@field.selected}}
3
+ @selected={{this.selected}}
4
4
  @disabled={{@disabled}}
5
5
  @allowClear={{true}}
6
6
  @preventScroll={{true}}
7
7
  @searchEnabled={{this.searchEnabled}}
8
8
  @searchField="label"
9
- @triggerId={{@field.pk}}
9
+ @triggerId={{this.triggerId}}
10
10
  @renderInPlace={{true}}
11
11
  @placeholder={{this.placeholder}}
12
12
  @loadingMessage={{t "caluma.form.power-select.options-loading"}}
@@ -15,6 +15,18 @@ import PowerSelectMultipleComponent from "ember-power-select/components/power-se
15
15
  export default class CfFieldInputPowerselectComponent extends Component {
16
16
  @service intl;
17
17
 
18
+ get selected() {
19
+ return this.args.compare
20
+ ? this.args.field.historicalSelected
21
+ : this.args.field.selected;
22
+ }
23
+
24
+ get triggerId() {
25
+ return this.args.compare
26
+ ? `${this.args.field.pk}-compare`
27
+ : this.args.field.pk;
28
+ }
29
+
18
30
  get multiple() {
19
31
  return this.args.field?.question.isMultipleChoice;
20
32
  }
@@ -2,7 +2,9 @@
2
2
  {{#if (and (gt i 0) (not @field.raw.question.meta.vertical))}}<br />{{/if}}
3
3
  <label
4
4
  class="{{if @field.isInvalid 'uk-form-danger'}}
5
- {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
5
+ {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}
6
+ {{if (this.isAnswerRemoved option) 'diff-from-version'}}
7
+ {{if (this.isAnswerAdded option) 'diff-to-version'}}"
6
8
  >
7
9
  <input
8
10
  class="uk-radio uk-margin-small-right"
@@ -2,6 +2,21 @@ import { action } from "@ember/object";
2
2
  import Component from "@glimmer/component";
3
3
 
4
4
  export default class CfFieldInpuRadio extends Component {
5
+ isAnswerRemoved = (option) => {
6
+ return (
7
+ this.args.compare &&
8
+ this.args.field.answer?.historicalValue === option.slug &&
9
+ this.args.field.answer?.value !== option.slug
10
+ );
11
+ };
12
+ isAnswerAdded = (option) => {
13
+ return (
14
+ this.args.compare &&
15
+ this.args.field.answer?.historicalValue !== option.slug &&
16
+ this.args.field.answer?.value === option.slug
17
+ );
18
+ };
19
+
5
20
  @action
6
21
  reset(event) {
7
22
  event.preventDefault();
@@ -1,6 +1,9 @@
1
1
  <table class="uk-table uk-table-divider uk-margin-remove-vertical">
2
2
  <thead>
3
3
  <tr>
4
+ {{#if @compare}}
5
+ <th></th>
6
+ {{/if}}
4
7
  {{#each this.columns as |column|}}
5
8
  <th>{{column.label}}</th>
6
9
  {{/each}}
@@ -9,7 +12,34 @@
9
12
  </thead>
10
13
  <tbody>
11
14
  {{#each @field.answer.value as |document|}}
12
- <tr>
15
+ <tr
16
+ class="{{if (this.isDocumentAdded document) 'diff-added'}}
17
+ {{if (this.isDocumentDeleted document) 'diff-removed'}}
18
+ {{if (this.isDocumentModified document) 'diff-modified'}}"
19
+ >
20
+ {{#if @compare}}
21
+ <td>
22
+ {{#if (this.isDocumentAdded document)}}
23
+ <UkIcon
24
+ @icon="plus-circle"
25
+ class="uk-text-success"
26
+ {{uk-tooltip (t "caluma.form.compare.diff.added")}}
27
+ />
28
+ {{else if (this.isDocumentDeleted document)}}
29
+ <UkIcon
30
+ @icon="minus-circle"
31
+ class="uk-text-danger"
32
+ {{uk-tooltip (t "caluma.form.compare.diff.removed")}}
33
+ />
34
+ {{else if (this.isDocumentModified document)}}
35
+ <UkIcon
36
+ @icon="pencil"
37
+ class="uk-text-warning"
38
+ {{uk-tooltip (t "caluma.form.compare.diff.modified")}}
39
+ />
40
+ {{/if}}
41
+ </td>
42
+ {{/if}}
13
43
  {{#each this.columns as |column|}}
14
44
  <td>
15
45
  <CfFieldValue
@@ -26,6 +26,16 @@ export default class CfFieldInputTableComponent extends Component {
26
26
  return parseDocument(raw);
27
27
  }
28
28
 
29
+ isDocumentAdded = (document) => {
30
+ return this.args.compare && document?.raw?.historyType === "+";
31
+ };
32
+ isDocumentDeleted = (document) => {
33
+ return this.args.compare && document?.raw?.historyType === "-";
34
+ };
35
+ isDocumentModified = (document) => {
36
+ return this.args.compare && document?.raw?.historyType === "~";
37
+ };
38
+
29
39
  get questions() {
30
40
  return this.args.field.question.raw.rowForm.questions.edges.map(
31
41
  (edge) => edge.node,
@@ -1,14 +1,21 @@
1
- <input
2
- type="text"
3
- class="uk-input
4
- {{if @field.isInvalid 'uk-form-danger'}}
5
- {{if @disabled 'uk-disabled'}}"
6
- name={{@field.pk}}
7
- id={{@field.pk}}
8
- value={{@field.answer.value}}
9
- placeholder={{@field.question.raw.placeholder}}
10
- readonly={{@disabled}}
11
- minlength={{@field.question.raw.textMinLength}}
12
- maxlength={{@field.question.raw.textMaxLength}}
13
- {{on "input" this.input}}
14
- />
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextDiff
3
+ @currentValue={{@field.answer.value}}
4
+ @historicalValue={{@field.answer.historicalValue}}
5
+ />
6
+ {{else}}
7
+ <input
8
+ type="text"
9
+ class="uk-input
10
+ {{if @field.isInvalid 'uk-form-danger'}}
11
+ {{if @disabled 'uk-disabled'}}"
12
+ name={{@field.pk}}
13
+ id={{@field.pk}}
14
+ value={{@field.answer.value}}
15
+ placeholder={{@field.question.raw.placeholder}}
16
+ readonly={{@disabled}}
17
+ minlength={{@field.question.raw.textMinLength}}
18
+ maxlength={{@field.question.raw.textMaxLength}}
19
+ {{on "input" this.input}}
20
+ />
21
+ {{/if}}
@@ -1,14 +1,21 @@
1
- <textarea
2
- class="uk-textarea
3
- {{if @field.isInvalid 'uk-form-danger'}}
4
- {{if @disabled 'uk-disabled'}}"
5
- name={{@field.pk}}
6
- id={{@field.pk}}
7
- placeholder={{@field.question.raw.placeholder}}
8
- minlength={{@field.question.raw.textareaMinLength}}
9
- maxlength={{@field.question.raw.textareaMaxLength}}
10
- readonly={{@disabled}}
11
- value={{@field.answer.value}}
12
- {{on "input" this.input}}
13
- {{autoresize mode="height"}}
14
- >{{@field.answer.value}}</textarea>
1
+ {{#if @compare}}
2
+ <CfField::InputCompare::TextareaDiff
3
+ @currentValue={{@field.answer.value}}
4
+ @historicalValue={{@field.answer.historicalValue}}
5
+ />
6
+ {{else}}
7
+ <textarea
8
+ class="uk-textarea
9
+ {{if @field.isInvalid 'uk-form-danger'}}
10
+ {{if @disabled 'uk-disabled'}}"
11
+ name={{@field.pk}}
12
+ id={{@field.pk}}
13
+ placeholder={{@field.question.raw.placeholder}}
14
+ minlength={{@field.question.raw.textareaMinLength}}
15
+ maxlength={{@field.question.raw.textareaMaxLength}}
16
+ readonly={{@disabled}}
17
+ value={{@field.answer.value}}
18
+ {{on "input" this.input}}
19
+ {{autoresize mode="height"}}
20
+ >{{@field.answer.value}}</textarea>
21
+ {{/if}}
@@ -0,0 +1,9 @@
1
+ <div
2
+ class="cf-compare-note uk-text-muted uk-text-small uk-flex uk-flex-middle uk-padding-small uk-padding-remove-left uk-padding-remove-bottom"
3
+ >
4
+ {{t
5
+ "caluma.form.compare.note"
6
+ username=(user-name (or @historyUserId @field.answer.raw.historyUserId))
7
+ date=(format-date (or @historyDate @field.answer.raw.historyDate))
8
+ }}
9
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="uk-form-controls">
2
+ <div class="uk-input uk-disabled">
3
+ <s class="diff-from-version">{{@historicalValue}}</s>
4
+ <span class="diff-to-version">{{@currentValue}}</span>
5
+ </div>
6
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="uk-form-controls">
2
+ <div class="uk-textarea uk-disabled">
3
+ <div class="diff-from-version"><s>{{@historicalValue}}</s></div>
4
+ <div class="diff-to-version">{{@currentValue}}</div>
5
+ </div>
6
+ </div>