@lblod/ember-rdfa-editor-lblod-plugins 0.4.0 → 1.0.0-alpha.1
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/CHANGELOG.md +36 -0
- package/addon/commands/article-structure-plugin/delete-structure.ts +85 -0
- package/addon/commands/article-structure-plugin/index.ts +4 -0
- package/addon/commands/article-structure-plugin/insert-article-structure.ts +137 -0
- package/addon/commands/article-structure-plugin/move-structure.ts +227 -0
- package/addon/commands/article-structure-plugin/recalculate-structure-numbers.ts +88 -0
- package/addon/commands/besluit-plugin/get-article-nodes-for-besluit.ts +30 -0
- package/addon/commands/besluit-plugin/index.ts +4 -0
- package/addon/commands/besluit-plugin/insert-article.ts +94 -0
- package/addon/commands/besluit-plugin/insert-title.ts +67 -0
- package/addon/commands/besluit-plugin/move-article.ts +69 -0
- package/addon/commands/besluit-plugin/recalculate-article-numbers.ts +44 -0
- package/addon/commands/modify-date-command.ts +48 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +14 -0
- package/addon/components/article-structure-plugin/article-structure-card.ts +83 -0
- package/addon/components/article-structure-plugin/structure-card.hbs +42 -0
- package/addon/components/article-structure-plugin/structure-card.ts +140 -0
- package/addon/components/au-native-input.hbs +30 -0
- package/addon/components/au-native-input.ts +47 -0
- package/addon/components/besluit-plugin/besluit-context-card.hbs +44 -0
- package/addon/components/besluit-plugin/besluit-context-card.ts +144 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +42 -0
- package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +9 -4
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +216 -0
- package/addon/components/citation-plugin/citation-card.hbs +118 -0
- package/addon/components/citation-plugin/citation-card.ts +230 -0
- package/addon/components/citation-plugin/citation-insert.hbs +20 -0
- package/addon/components/citation-plugin/citation-insert.ts +102 -0
- package/addon/components/{citaten-plugin → citation-plugin}/citations/article-list.hbs +2 -2
- package/addon/components/{citaten-plugin → citation-plugin}/citations/article-preview.hbs +0 -0
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-detail.hbs +9 -6
- package/addon/components/{citaten-plugin/citations/decision-detail.js → citation-plugin/citations/decision-detail.ts} +30 -31
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-list.hbs +2 -2
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-preview.hbs +0 -0
- package/addon/components/citation-plugin/citations/search-modal.hbs +254 -0
- package/addon/components/{citaten-plugin/citations/search-modal.js → citation-plugin/citations/search-modal.ts} +116 -89
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.hbs +1 -1
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.hbs +1 -1
- package/addon/components/import-snippet-plugin/card.ts +119 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.hbs +2 -1
- package/addon/components/insert-variable-plugin/insert-variable-card.ts +134 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-card.hbs → card.hbs} +3 -1
- package/addon/components/rdfa-date-plugin/card.ts +72 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.hbs → date-time-picker.hbs} +0 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.js → date-time-picker.ts} +26 -12
- package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-insert.hbs → insert.hbs} +0 -0
- package/addon/components/rdfa-date-plugin/insert.ts +44 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +58 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +35 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +2 -2
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +60 -0
- package/addon/components/roadsign-regulation-plugin/{roadsigns-modal.js → roadsigns-modal.ts} +101 -64
- package/addon/components/roadsign-regulation-plugin/{roadsigns-pagination.js → roadsigns-pagination.ts} +7 -3
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +32 -0
- package/addon/components/standard-template-plugin/{template-card.hbs → card.hbs} +0 -0
- package/addon/components/standard-template-plugin/card.ts +11 -0
- package/addon/components/standard-template-plugin/template-provider.hbs +3 -1
- package/addon/components/standard-template-plugin/template-provider.ts +75 -0
- package/addon/components/table-of-contents-plugin/card.hbs +12 -1
- package/addon/components/table-of-contents-plugin/card.ts +60 -0
- package/addon/components/table-of-contents-plugin/{inline-components → ember-nodes}/outline.hbs +2 -2
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +9 -0
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +95 -0
- package/addon/components/template-variable-plugin/template-variable-card.hbs +2 -1
- package/addon/components/template-variable-plugin/template-variable-card.ts +227 -0
- package/addon/{constants.js → constants.ts} +15 -3
- package/addon/ember-nodes/table-of-contents.ts +53 -0
- package/addon/helpers/{limit-text.js → limit-text.ts} +2 -2
- package/addon/initializers/plugin-initializer.js +0 -75
- package/addon/models/instruction.ts +18 -0
- package/addon/models/measure.ts +38 -0
- package/addon/models/sign.ts +36 -0
- package/addon/models/template.ts +14 -0
- package/addon/plugins/article-structure-plugin.ts +55 -0
- package/addon/plugins/besluit-plugin.ts +27 -0
- package/addon/plugins/besluit-type-plugin.ts +6 -0
- package/addon/plugins/citation-plugin/index.ts +216 -0
- package/addon/plugins/citation-plugin/marks/citation.ts +27 -0
- package/addon/plugins/citation-plugin/utils/cited-text.ts +17 -0
- package/addon/plugins/citation-plugin/utils/process-match.ts +135 -0
- package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +161 -42
- package/addon/plugins/import-snippet-plugin.ts +6 -0
- package/addon/plugins/insert-variable-plugin.ts +11 -0
- package/addon/plugins/rdfa-date-plugin.ts +11 -0
- package/addon/plugins/roadsign-regulation-plugin.ts +6 -0
- package/addon/plugins/standard-template-plugin.ts +6 -0
- package/addon/plugins/table-of-contents-plugin.ts +14 -0
- package/addon/plugins/template-variable-plugin.ts +6 -0
- package/addon/services/{import-rdfa-snippet.js → import-rdfa-snippet.ts} +48 -36
- package/addon/services/roadsign-registry.ts +288 -0
- package/addon/services/{standard-template-plugin.js → standard-template-plugin.ts} +17 -11
- package/addon/utils/article-structure-plugin/constants.ts +260 -0
- package/addon/utils/article-structure-plugin/defaults.ts +3 -0
- package/addon/utils/article-structure-plugin/options-with-defaults.ts +31 -0
- package/addon/utils/article-structure-plugin/validate-datastore.ts +23 -0
- package/addon/utils/besluit-plugin/get-title-for-decision.ts +35 -0
- package/addon/utils/{fetchBesluitTypes.js → fetchBesluitTypes.ts} +36 -16
- package/addon/utils/generate-template-plugin/{default-resources.js → default-resources.ts} +0 -0
- package/addon/utils/{instantiate-uuids.js → instantiate-uuids.ts} +9 -6
- package/addon/utils/{legislation-types.js → legislation-types.ts} +17 -3
- package/addon/utils/{memoize.js → memoize.ts} +4 -2
- package/addon/utils/option.ts +58 -0
- package/addon/utils/roadsign-regulation-plugin/{fetchData.js → fetchData.ts} +19 -2
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.ts +16 -0
- package/addon/utils/romanize.ts +47 -0
- package/addon/utils/variable-plugins/{default-variable-types.js → default-variable-types.ts} +18 -7
- package/addon/utils/variable-plugins/{fetch-data.js → fetch-data.ts} +43 -15
- package/app/components/article-structure-plugin/article-structure-card.js +1 -0
- package/app/components/article-structure-plugin/structure-card.js +1 -0
- package/app/components/{citaten-plugin/citaat-card.js → au-native-input.js} +1 -1
- package/app/components/{citaten-plugin/citations/article-list.js → besluit-plugin/besluit-context-card.js} +1 -1
- package/app/components/besluit-plugin/besluit-plugin-card.js +1 -0
- package/app/components/{citaten-plugin/citations/modal.js → citation-plugin/citation-card.js} +1 -1
- package/app/components/citation-plugin/citation-insert.js +1 -0
- package/app/components/{citaten-plugin/citations/decision-list.js → citation-plugin/citations/article-list.js} +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/citations/article-preview.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/citations/decision-detail.js +1 -1
- package/app/components/citation-plugin/citations/decision-list.js +1 -0
- package/app/components/{citaten-plugin → citation-plugin}/citations/decision-preview.js +1 -1
- package/app/components/citation-plugin/citations/modal.js +1 -0
- package/app/components/{citaten-plugin → citation-plugin}/citations/search-modal.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.js +1 -1
- package/app/components/{citaten-plugin/citaat-insert.js → rdfa-date-plugin/card.js} +1 -1
- package/app/components/rdfa-date-plugin/date-time-picker.js +1 -0
- package/app/components/rdfa-date-plugin/insert.js +1 -0
- package/app/components/standard-template-plugin/card.js +1 -0
- package/app/components/table-of-contents-plugin/ember-nodes/outline.js +1 -0
- package/app/components/table-of-contents-plugin/ember-nodes/table-of-contents.js +1 -0
- package/app/styles/citaten-plugin.scss +1 -1
- package/commands/article-structure-plugin/delete-structure.d.ts +4 -0
- package/commands/article-structure-plugin/index.d.ts +4 -0
- package/commands/article-structure-plugin/insert-article-structure.d.ts +6 -0
- package/commands/article-structure-plugin/move-structure.d.ts +5 -0
- package/commands/article-structure-plugin/recalculate-structure-numbers.d.ts +7 -0
- package/commands/besluit-plugin/get-article-nodes-for-besluit.d.ts +5 -0
- package/commands/besluit-plugin/index.d.ts +4 -0
- package/commands/besluit-plugin/insert-article.d.ts +3 -0
- package/commands/besluit-plugin/insert-title.d.ts +2 -0
- package/commands/besluit-plugin/move-article.d.ts +2 -0
- package/commands/besluit-plugin/recalculate-article-numbers.d.ts +2 -0
- package/commands/modify-date-command.d.ts +2 -0
- package/components/article-structure-plugin/article-structure-card.d.ts +36 -0
- package/components/article-structure-plugin/structure-card.d.ts +23 -0
- package/components/au-native-input.d.ts +20 -0
- package/components/besluit-plugin/besluit-context-card.d.ts +29 -0
- package/components/besluit-plugin/besluit-plugin-card.d.ts +14 -0
- package/components/besluit-type-plugin/besluit-type-select.d.ts +11 -0
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +46 -0
- package/components/citation-plugin/citation-card.d.ts +51 -0
- package/components/citation-plugin/citation-insert.d.ts +24 -0
- package/components/citation-plugin/citations/decision-detail.d.ts +26 -0
- package/components/citation-plugin/citations/search-modal.d.ts +67 -0
- package/components/import-snippet-plugin/card.d.ts +19 -0
- package/components/insert-variable-plugin/insert-variable-card.d.ts +31 -0
- package/components/rdfa-date-plugin/card.d.ts +20 -0
- package/components/rdfa-date-plugin/date-time-picker.d.ts +32 -0
- package/components/rdfa-date-plugin/insert.d.ts +12 -0
- package/components/roadsign-regulation-plugin/expanded-measure.d.ts +20 -0
- package/components/roadsign-regulation-plugin/measure-template.d.ts +14 -0
- package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +12 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +57 -0
- package/components/roadsign-regulation-plugin/roadsigns-pagination.d.ts +19 -0
- package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +9 -0
- package/components/standard-template-plugin/card.d.ts +9 -0
- package/components/standard-template-plugin/template-provider.d.ts +17 -0
- package/components/table-of-contents-plugin/card.d.ts +20 -0
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +22 -0
- package/components/template-variable-plugin/template-variable-card.d.ts +27 -0
- package/constants.d.ts +11 -0
- package/ember-nodes/table-of-contents.d.ts +4 -0
- package/helpers/limit-text.d.ts +8 -0
- package/index.js +5 -0
- package/models/instruction.d.ts +8 -0
- package/models/measure.d.ts +14 -0
- package/models/sign.d.ts +12 -0
- package/models/template.d.ts +13 -0
- package/package.json +27 -8
- package/plugins/article-structure-plugin.d.ts +29 -0
- package/plugins/besluit-plugin.d.ts +9 -0
- package/plugins/besluit-type-plugin.d.ts +2 -0
- package/plugins/citation-plugin/index.d.ts +31 -0
- package/plugins/citation-plugin/marks/citation.d.ts +2 -0
- package/plugins/citation-plugin/utils/cited-text.d.ts +3 -0
- package/plugins/citation-plugin/utils/process-match.d.ts +23 -0
- package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +56 -0
- package/plugins/import-snippet-plugin.d.ts +2 -0
- package/plugins/insert-variable-plugin.d.ts +2 -0
- package/plugins/rdfa-date-plugin.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin.d.ts +2 -0
- package/plugins/standard-template-plugin.d.ts +2 -0
- package/plugins/table-of-contents-plugin.d.ts +3 -0
- package/plugins/template-variable-plugin.d.ts +2 -0
- package/services/import-rdfa-snippet.d.ts +99 -0
- package/services/roadsign-registry.d.ts +42 -0
- package/services/standard-template-plugin.d.ts +21 -0
- package/translations/en-US.yaml +47 -1
- package/translations/nl-BE.yaml +49 -3
- package/tsconfig.json +36 -9
- package/types/config/environment.d.ts +22 -0
- package/types/ember-mu-transform-helpers/transforms/string-set.d.ts +14 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/account.d.ts +10 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid-classificatie-code.d.ts +10 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid.d.ts +12 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/gebruiker-model.d.ts +18 -0
- package/types/lblod/frontend-gelinkt-notuleren/services/current-session.d.ts +30 -0
- package/types/lblod/marawa/dom-helpers.d.ts +4 -0
- package/types/lblod/marawa/ember-object-mock.d.ts +3 -0
- package/types/lblod/marawa/node-walker.d.ts +18 -0
- package/types/lblod/marawa/range-helpers.d.ts +10 -0
- package/types/lblod/marawa/rdfa-attributes.d.ts +25 -0
- package/types/lblod/marawa/rdfa-block.d.ts +22 -0
- package/types/lblod/marawa/rdfa-context-scanner.d.ts +13 -0
- package/types/lblod/marawa/rdfa-helpers.d.ts +22 -0
- package/types/lblod/marawa/rich-node.d.ts +50 -0
- package/types/lblod/marawa/triple.d.ts +16 -0
- package/utils/article-structure-plugin/constants.d.ts +2 -0
- package/utils/article-structure-plugin/defaults.d.ts +4 -0
- package/utils/article-structure-plugin/options-with-defaults.d.ts +2 -0
- package/utils/article-structure-plugin/validate-datastore.d.ts +3 -0
- package/utils/besluit-plugin/get-title-for-decision.d.ts +10 -0
- package/utils/fetchBesluitTypes.d.ts +12 -0
- package/utils/generate-template-plugin/default-resources.d.ts +2 -0
- package/utils/instantiate-uuids.d.ts +1 -0
- package/utils/legislation-types.d.ts +24 -0
- package/utils/memoize.d.ts +1 -0
- package/utils/option.d.ts +14 -0
- package/utils/roadsign-regulation-plugin/fetchData.d.ts +8 -0
- package/utils/roadsign-regulation-plugin/includeInstructions.d.ts +2 -0
- package/utils/romanize.d.ts +2 -0
- package/utils/variable-plugins/default-variable-types.d.ts +7 -0
- package/utils/variable-plugins/fetch-data.d.ts +14 -0
- package/addon/commands/generate-template-command.js +0 -35
- package/addon/commands/insert-and-collapse.js +0 -32
- package/addon/commands/modify-date-command.js +0 -42
- package/addon/components/besluit-type-plugin/toolbar-dropdown.js +0 -188
- package/addon/components/citaten-plugin/citaat-card.hbs +0 -76
- package/addon/components/citaten-plugin/citaat-card.js +0 -286
- package/addon/components/citaten-plugin/citaat-insert.hbs +0 -20
- package/addon/components/citaten-plugin/citaat-insert.js +0 -68
- package/addon/components/citaten-plugin/citations/search-modal.hbs +0 -175
- package/addon/components/import-snippet-plugin/card.js +0 -95
- package/addon/components/insert-variable-plugin/insert-variable-card.js +0 -125
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -64
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -24
- package/addon/components/roadsign-regulation-plugin/expanded-measure.js +0 -38
- package/addon/components/roadsign-regulation-plugin/measure-template.js +0 -30
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -101
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +0 -24
- package/addon/components/standard-template-plugin/template-card.js +0 -7
- package/addon/components/standard-template-plugin/template-provider.js +0 -75
- package/addon/components/table-of-contents-plugin/card.js +0 -53
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +0 -9
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -100
- package/addon/components/template-variable-plugin/template-variable-card.js +0 -230
- package/addon/inline-components/table-of-contents.js +0 -43
- package/addon/models/instruction.js +0 -19
- package/addon/models/measure.js +0 -46
- package/addon/models/sign.js +0 -37
- package/addon/models/template.js +0 -9
- package/addon/plugins/besluit-type-plugin.js +0 -16
- package/addon/plugins/citaten-plugin.js +0 -22
- package/addon/plugins/import-snippet-plugin.js +0 -16
- package/addon/plugins/insert-variable-plugin.js +0 -19
- package/addon/plugins/rdfa-date-plugin.js +0 -26
- package/addon/plugins/roadsign-regulation-plugin.js +0 -24
- package/addon/plugins/standard-template-plugin.js +0 -33
- package/addon/plugins/table-of-contents-plugin.js +0 -27
- package/addon/plugins/template-variable-plugin.js +0 -21
- package/addon/services/roadsign-registry.js +0 -240
- package/addon/utils/processMatch.js +0 -80
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
- package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
- package/app/components/standard-template-plugin/template-card.js +0 -1
- package/app/components/table-of-contents-plugin/inline-components/outline.js +0 -1
- package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
- package/app/initializers/plugin-initializer.js +0 -4
- package/types/dummy/index.d.ts +0 -1
- package/types/ember-data/types/registries/model.d.ts +0 -6
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { capitalize } from '@ember/string';
|
|
6
|
+
import {
|
|
7
|
+
Article,
|
|
8
|
+
cleanCaches,
|
|
9
|
+
Decision,
|
|
10
|
+
fetchDecisions,
|
|
11
|
+
} from '../../plugins/citation-plugin/utils/vlaamse-codex';
|
|
12
|
+
import {
|
|
13
|
+
LEGISLATION_TYPE_CONCEPTS,
|
|
14
|
+
LEGISLATION_TYPES,
|
|
15
|
+
} from '../../utils/legislation-types';
|
|
16
|
+
import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
|
|
17
|
+
import {
|
|
18
|
+
Option,
|
|
19
|
+
unwrap,
|
|
20
|
+
unwrapOr,
|
|
21
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
22
|
+
import {
|
|
23
|
+
CitationDecoration,
|
|
24
|
+
CitationPlugin,
|
|
25
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
26
|
+
import { ProseController, Transaction } from '@lblod/ember-rdfa-editor';
|
|
27
|
+
import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
|
|
28
|
+
|
|
29
|
+
interface Args {
|
|
30
|
+
controller: ProseController;
|
|
31
|
+
widgetArgs: {
|
|
32
|
+
plugin: CitationPlugin;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default class CitationCardComponent extends Component<Args> {
|
|
37
|
+
@tracked pageNumber = 0;
|
|
38
|
+
@tracked pageSize = 5;
|
|
39
|
+
@tracked totalSize = 0;
|
|
40
|
+
@tracked totalCount = 0;
|
|
41
|
+
@tracked decisions = [];
|
|
42
|
+
@tracked error: unknown;
|
|
43
|
+
@tracked showModal = false;
|
|
44
|
+
@tracked decision: Decision | null = null;
|
|
45
|
+
@tracked cardText: string | null = null;
|
|
46
|
+
@tracked cardLegislationType: string | null = null;
|
|
47
|
+
|
|
48
|
+
get controller(): ProseController {
|
|
49
|
+
return this.args.controller;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get showCard() {
|
|
53
|
+
return this.activeDecoration;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get plugin() {
|
|
57
|
+
return this.args.widgetArgs.plugin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get decorations() {
|
|
61
|
+
return this.plugin.getState(this.controller.state)?.highlights;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get activeDecoration(): Option<CitationDecoration> {
|
|
65
|
+
const { from, to } = this.controller.state.selection;
|
|
66
|
+
return this.decorations?.find(from, to)[0];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get documentLegislationType(): Option<string> {
|
|
70
|
+
return this.activeDecoration?.spec.legislationTypeUri;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get documentText(): Option<string> {
|
|
74
|
+
return this.activeDecoration?.spec.searchText;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get searchText(): string {
|
|
78
|
+
return (this.cardText ?? this.documentText) || '';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get legislationTypes() {
|
|
82
|
+
return Object.keys(LEGISLATION_TYPES).map(capitalize);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get selectedLegislationType() {
|
|
86
|
+
const type = this.cardLegislationType || this.documentLegislationType;
|
|
87
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find((c) => c.value === type);
|
|
88
|
+
return found || unwrap(LEGISLATION_TYPE_CONCEPTS[0]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get selectedLegislationTypeLabel(): string {
|
|
92
|
+
return capitalize(this.selectedLegislationType.label);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get selectedLegislationTypeUri(): string {
|
|
96
|
+
return this.selectedLegislationType.value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@action resetToDocumentState(): void {
|
|
100
|
+
this.cardText = null;
|
|
101
|
+
this.cardLegislationType = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@action onCardTextChange(event: InputEvent): void {
|
|
105
|
+
this.cardText = (event.target as HTMLInputElement).value;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
resourceSearch = restartableTask(async () => {
|
|
109
|
+
await timeout(100);
|
|
110
|
+
this.error = null;
|
|
111
|
+
const abortController = new AbortController();
|
|
112
|
+
try {
|
|
113
|
+
// Split search string by grouping on non-whitespace characters
|
|
114
|
+
// This probably needs to be more complex to search on group of words
|
|
115
|
+
const words = this.searchText.match(/\S+/g) || [];
|
|
116
|
+
const filter = {
|
|
117
|
+
type: unwrapOr('', this.selectedLegislationTypeUri),
|
|
118
|
+
};
|
|
119
|
+
const results = await fetchDecisions(
|
|
120
|
+
words,
|
|
121
|
+
filter,
|
|
122
|
+
this.pageNumber,
|
|
123
|
+
this.pageSize
|
|
124
|
+
);
|
|
125
|
+
this.totalCount = results.totalCount;
|
|
126
|
+
return results.decisions;
|
|
127
|
+
} catch (e) {
|
|
128
|
+
console.warn(e); // eslint-ignore-line no-console
|
|
129
|
+
this.totalCount = 0;
|
|
130
|
+
this.error = e;
|
|
131
|
+
return [];
|
|
132
|
+
} finally {
|
|
133
|
+
//Abort all requests now that this task has either successfully finished or has been cancelled
|
|
134
|
+
abortController.abort();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
decisionResource = trackedTask(this, this.resourceSearch, () => [
|
|
139
|
+
this.searchText,
|
|
140
|
+
this.selectedLegislationType,
|
|
141
|
+
this.pageNumber,
|
|
142
|
+
this.pageSize,
|
|
143
|
+
]);
|
|
144
|
+
|
|
145
|
+
@action
|
|
146
|
+
selectLegislationType(type: string) {
|
|
147
|
+
type = type.toLowerCase();
|
|
148
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find(
|
|
149
|
+
(c) => c.label.toLowerCase() === type
|
|
150
|
+
);
|
|
151
|
+
this.cardLegislationType = found
|
|
152
|
+
? found.value
|
|
153
|
+
: unwrap(LEGISLATION_TYPE_CONCEPTS[0]).value;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@action
|
|
157
|
+
openDecisionDetailModal(decision: Decision): void {
|
|
158
|
+
this.decision = decision;
|
|
159
|
+
/** why focus? see {@link EditorPluginsCitationInsertComponent.openModal } */
|
|
160
|
+
this.focus();
|
|
161
|
+
this.showModal = true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@action
|
|
165
|
+
async openSearchModal(): Promise<void> {
|
|
166
|
+
await this.decisionResource.cancel();
|
|
167
|
+
this.decision = null;
|
|
168
|
+
this.focus();
|
|
169
|
+
this.showModal = true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@action
|
|
173
|
+
closeModal(lastSearchType: string, lastSearchTerm: string): void {
|
|
174
|
+
this.showModal = false;
|
|
175
|
+
this.decision = null;
|
|
176
|
+
if (lastSearchType) {
|
|
177
|
+
this.cardLegislationType = lastSearchType;
|
|
178
|
+
}
|
|
179
|
+
if (lastSearchTerm) {
|
|
180
|
+
this.cardText = lastSearchTerm;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@action
|
|
185
|
+
insertDecisionCitation(decision: Decision): void {
|
|
186
|
+
const uri = decision.uri;
|
|
187
|
+
const title = decision.title ?? '';
|
|
188
|
+
const { from, to } = unwrap(this.activeDecoration);
|
|
189
|
+
this.controller.withTransaction((tr: Transaction) =>
|
|
190
|
+
tr
|
|
191
|
+
.replaceRangeWith(
|
|
192
|
+
from,
|
|
193
|
+
to,
|
|
194
|
+
citedText(this.controller.schema, title, uri)
|
|
195
|
+
)
|
|
196
|
+
.scrollIntoView()
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@action
|
|
201
|
+
insertArticleCitation(decision: Decision, article: Article): void {
|
|
202
|
+
const uri = article.uri;
|
|
203
|
+
let title = '';
|
|
204
|
+
if (decision.title) {
|
|
205
|
+
title = `${decision.title}, ${article.number || ''}`;
|
|
206
|
+
}
|
|
207
|
+
const { from, to } = unwrap(this.activeDecoration);
|
|
208
|
+
this.controller.withTransaction((tr: Transaction) =>
|
|
209
|
+
tr
|
|
210
|
+
.replaceRangeWith(
|
|
211
|
+
from,
|
|
212
|
+
to,
|
|
213
|
+
citedText(this.controller.schema, title, uri)
|
|
214
|
+
)
|
|
215
|
+
.scrollIntoView()
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@action
|
|
220
|
+
focus(): void {
|
|
221
|
+
this.controller.focus();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
willDestroy(): void {
|
|
225
|
+
// Not necessary as ember-concurrency does this for us.
|
|
226
|
+
// this.decisionResource.cancel();
|
|
227
|
+
cleanCaches();
|
|
228
|
+
super.willDestroy();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<AuList::Item>
|
|
2
|
+
<AuButton
|
|
3
|
+
@icon='add'
|
|
4
|
+
@iconAlignment='left'
|
|
5
|
+
@skin='link'
|
|
6
|
+
@disabled={{this.disableInsert}}
|
|
7
|
+
{{on 'click' this.openModal}}
|
|
8
|
+
>
|
|
9
|
+
{{t 'citaten-plugin.insert.title'}}
|
|
10
|
+
</AuButton>
|
|
11
|
+
</AuList::Item>
|
|
12
|
+
|
|
13
|
+
<CitationPlugin::Citations::SearchModal
|
|
14
|
+
@open={{this.showModal}}
|
|
15
|
+
@closeModal={{this.closeModal}}
|
|
16
|
+
@insertDecisionCitation={{this.insertDecisionCitation}}
|
|
17
|
+
@insertArticleCitation={{this.insertArticleCitation}}
|
|
18
|
+
@legislationTypeUri={{this.legislationTypeUri}}
|
|
19
|
+
@text={{this.text}}
|
|
20
|
+
/>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { LEGISLATION_TYPES } from '../../utils/legislation-types';
|
|
5
|
+
import {
|
|
6
|
+
Fragment,
|
|
7
|
+
ProseController,
|
|
8
|
+
Slice,
|
|
9
|
+
Transaction,
|
|
10
|
+
} from '@lblod/ember-rdfa-editor';
|
|
11
|
+
import {
|
|
12
|
+
Article,
|
|
13
|
+
Decision,
|
|
14
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
|
|
15
|
+
import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
|
|
16
|
+
import { CitationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
17
|
+
|
|
18
|
+
interface Args {
|
|
19
|
+
controller: ProseController;
|
|
20
|
+
widgetArgs: { plugin: CitationPlugin };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class EditorPluginsCitationInsertComponent extends Component<Args> {
|
|
24
|
+
@tracked showModal = false;
|
|
25
|
+
@tracked legislationTypeUri = LEGISLATION_TYPES.decreet;
|
|
26
|
+
@tracked text = '';
|
|
27
|
+
|
|
28
|
+
get disableInsert() {
|
|
29
|
+
if (!this.activeRanges) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const { from } = this.controller.state.selection;
|
|
33
|
+
return !this.activeRanges.some(
|
|
34
|
+
([start, end]) => from > start && from < end
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get plugin() {
|
|
39
|
+
return this.args.widgetArgs.plugin;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get activeRanges() {
|
|
43
|
+
return this.plugin.getState(this.controller.state)?.activeRanges;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get controller() {
|
|
47
|
+
return this.args.controller;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@action
|
|
51
|
+
openModal() {
|
|
52
|
+
// we focus BEFORE openening the modal, since the modal uses ember-focus-trap
|
|
53
|
+
// that takes control of the focus, and gives it back when disabled
|
|
54
|
+
// so we have to reset the focus to the editor before opening (because
|
|
55
|
+
// we lost it upon clicking the button)
|
|
56
|
+
this.controller.focus();
|
|
57
|
+
this.showModal = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@action
|
|
61
|
+
closeModal() {
|
|
62
|
+
this.showModal = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@action
|
|
66
|
+
insertDecisionCitation(decision: Decision) {
|
|
67
|
+
const type = decision.legislationType?.label || '';
|
|
68
|
+
const uri = decision.uri;
|
|
69
|
+
const title = decision.title ?? '';
|
|
70
|
+
this.controller.withTransaction((tr: Transaction) =>
|
|
71
|
+
tr
|
|
72
|
+
.replaceSelection(
|
|
73
|
+
new Slice(
|
|
74
|
+
Fragment.fromArray([
|
|
75
|
+
this.controller.schema.text(`${type} `),
|
|
76
|
+
citedText(this.controller.schema, title, uri),
|
|
77
|
+
]),
|
|
78
|
+
0,
|
|
79
|
+
0
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
.scrollIntoView()
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@action
|
|
87
|
+
insertArticleCitation(decision: Decision, article: Article) {
|
|
88
|
+
const type = decision.legislationType?.label || '';
|
|
89
|
+
const uri = article.uri;
|
|
90
|
+
let title = '';
|
|
91
|
+
if (decision.title) {
|
|
92
|
+
title = `${decision.title}, ${article.number ?? ''}`;
|
|
93
|
+
}
|
|
94
|
+
const { from, to } = this.args.controller.state.selection;
|
|
95
|
+
this.controller.withTransaction((tr: Transaction) =>
|
|
96
|
+
tr.replaceWith(from, to, [
|
|
97
|
+
this.controller.schema.text(`${type} `),
|
|
98
|
+
citedText(this.controller.schema, title, uri),
|
|
99
|
+
])
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
<AuList @direction="vertical" @divider={{true}}>
|
|
3
3
|
{{#each @articles as |article|}}
|
|
4
4
|
<AuList::Item>
|
|
5
|
-
<
|
|
5
|
+
<CitationPlugin::Citations::ArticlePreview
|
|
6
6
|
@insertArticleCitation={{fn @insertArticleCitation article}}
|
|
7
7
|
@article={{article}} />
|
|
8
8
|
</AuList::Item>
|
|
9
9
|
{{/each}}
|
|
10
10
|
</AuList>
|
|
11
11
|
{{else}}
|
|
12
|
-
<
|
|
12
|
+
<CitationPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize "au-u-margin"}}/>
|
|
13
13
|
{{/if}}
|
|
File without changes
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{{@decision.publicationDate}}
|
|
15
15
|
</AuPill>
|
|
16
16
|
{{/if}}
|
|
17
|
-
<br
|
|
17
|
+
<br/>
|
|
18
18
|
<AuButton
|
|
19
19
|
@skin="primary"
|
|
20
20
|
@icon="plus-text"
|
|
@@ -32,21 +32,24 @@
|
|
|
32
32
|
{{t "citaten-plugin.references.lookup-codex"}}
|
|
33
33
|
</AuLinkExternal>
|
|
34
34
|
{{! Search field }}
|
|
35
|
-
<AuLabel class="au-u-margin-top-small au-margin-bottom-small" for="searchCodex" @inline={{true}}
|
|
36
|
-
|
|
35
|
+
<AuLabel class="au-u-margin-top-small au-margin-bottom-small" for="searchCodex" @inline={{true}}
|
|
36
|
+
@required={{false}} @error={{false}} @warning={{false}}>{{t "citaten-plugin.search.article"}}</AuLabel>
|
|
37
|
+
<AuInput id="searchCodex" placeholder="{{t "citaten-plugin.search.article-placeholder"}}" @type="text"
|
|
38
|
+
@width="default" @icon="search" @iconAlignment="right" @value={{this.articleFilter}} {{on "input"
|
|
39
|
+
(perform this.updateArticleFilter)}}/>
|
|
37
40
|
</div>
|
|
38
41
|
{{! Search results }}
|
|
39
42
|
<div>
|
|
40
43
|
{{#if this.articleResource.isRunning}}
|
|
41
44
|
<div class="au-o-box">
|
|
42
|
-
<AuLoader @padding="large"
|
|
45
|
+
<AuLoader @padding="large"/>
|
|
43
46
|
<span class="au-u-hidden-visually">{{t "citaten-plugin.alert.loading"}}</span>
|
|
44
47
|
</div>
|
|
45
48
|
{{else}}
|
|
46
49
|
{{#if this.error}}
|
|
47
|
-
<
|
|
50
|
+
<CitationPlugin::Helpers::AlertLoadError @fullSize={{true}} @error={{this.error}} class="au-o-box"/>
|
|
48
51
|
{{else}}
|
|
49
|
-
<
|
|
52
|
+
<CitationPlugin::Citations::ArticleList
|
|
50
53
|
@insertArticleCitation={{fn @insertArticleCitation @decision}}
|
|
51
54
|
@articles={{this.articleResource.value}}
|
|
52
55
|
@fullSize={{true}}/>
|
|
@@ -1,49 +1,42 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import { timeout } from 'ember-concurrency';
|
|
2
|
+
import { restartableTask, timeout } from 'ember-concurrency';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
Decision,
|
|
7
|
+
fetchArticles,
|
|
8
|
+
} from '../../../plugins/citation-plugin/utils/vlaamse-codex';
|
|
7
9
|
import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
interface Args {
|
|
12
|
+
decision: Decision;
|
|
13
|
+
close: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class EditorPluginsCitationsDecisionDetailComponent extends Component<Args> {
|
|
17
|
+
@tracked error: unknown;
|
|
11
18
|
@tracked pageNumber = 0;
|
|
12
19
|
@tracked pageSize = 5;
|
|
13
|
-
@tracked totalCount;
|
|
20
|
+
@tracked totalCount = 0;
|
|
14
21
|
@tracked articles = [];
|
|
15
|
-
@tracked articleFilter;
|
|
16
|
-
@tracked articleFilterAfterTimeout;
|
|
22
|
+
@tracked articleFilter = '';
|
|
23
|
+
@tracked articleFilterAfterTimeout = '';
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@task({ restartable: true })
|
|
23
|
-
*updateArticleFilter() {
|
|
24
|
-
yield timeout(500);
|
|
25
|
+
updateArticleFilter = restartableTask(async () => {
|
|
26
|
+
await timeout(500);
|
|
25
27
|
this.pageNumber = 0;
|
|
26
28
|
this.articleFilterAfterTimeout = this.articleFilter;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
articleResource = trackedTask(this, this.resourceSearch, () => [
|
|
30
|
-
this.pageNumber,
|
|
31
|
-
this.pageSize,
|
|
32
|
-
this.articleFilterAfterTimeout,
|
|
33
|
-
]);
|
|
29
|
+
});
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
*resourceSearch() {
|
|
31
|
+
resourceSearch = restartableTask(async () => {
|
|
37
32
|
this.error = null;
|
|
38
33
|
const abortController = new AbortController();
|
|
39
|
-
const signal = abortController.signal;
|
|
40
34
|
try {
|
|
41
|
-
const results =
|
|
35
|
+
const results = await fetchArticles(
|
|
42
36
|
this.args.decision.uri,
|
|
43
37
|
this.pageNumber,
|
|
44
38
|
this.pageSize,
|
|
45
|
-
this.articleFilterAfterTimeout
|
|
46
|
-
signal
|
|
39
|
+
this.articleFilterAfterTimeout
|
|
47
40
|
);
|
|
48
41
|
this.totalCount = results.totalCount;
|
|
49
42
|
return results.articles;
|
|
@@ -55,11 +48,17 @@ export default class EditorPluginsCitationsDecisionDetailComponent extends Compo
|
|
|
55
48
|
} finally {
|
|
56
49
|
abortController.abort();
|
|
57
50
|
}
|
|
58
|
-
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
articleResource = trackedTask(this, this.resourceSearch, () => [
|
|
54
|
+
this.pageNumber,
|
|
55
|
+
this.pageSize,
|
|
56
|
+
this.articleFilterAfterTimeout,
|
|
57
|
+
]);
|
|
59
58
|
|
|
60
59
|
@action
|
|
61
|
-
close() {
|
|
62
|
-
this.articleResource.cancel();
|
|
60
|
+
async close() {
|
|
61
|
+
await this.articleResource.cancel();
|
|
63
62
|
this.args.close();
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<AuList @direction="vertical" @divider={{true}}>
|
|
3
3
|
{{#each @decisions as |decision|}}
|
|
4
4
|
<AuList::Item class="au-u-padding-left-small au-u-padding-right-small">
|
|
5
|
-
<
|
|
5
|
+
<CitationPlugin::Citations::DecisionPreview
|
|
6
6
|
@decision={{decision}}
|
|
7
7
|
@onCitationInsert={{fn @onCitationInsert decision}}
|
|
8
8
|
@onCitationDetails={{fn @onCitationDetails decision}}
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
{{/each}}
|
|
12
12
|
</AuList>
|
|
13
13
|
{{else}}
|
|
14
|
-
<
|
|
14
|
+
<CitationPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize "au-u-margin"}}/>
|
|
15
15
|
{{/if}}
|
|
File without changes
|