@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,119 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
6
|
+
import ImportRdfaSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
|
|
7
|
+
import { RdfaSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
|
|
8
|
+
|
|
9
|
+
type Args = {
|
|
10
|
+
controller: ProseController;
|
|
11
|
+
};
|
|
12
|
+
export default class ImportSnippetPluginCard extends Component<Args> {
|
|
13
|
+
@service declare importRdfaSnippet: ImportRdfaSnippet;
|
|
14
|
+
|
|
15
|
+
get controller() {
|
|
16
|
+
return this.args.controller;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get snippets(): RdfaSnippet[] {
|
|
20
|
+
return this.importRdfaSnippet.snippetsForType('roadsign');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get insertRange() {
|
|
24
|
+
const selection = this.controller.state.selection;
|
|
25
|
+
const besluitRange = [
|
|
26
|
+
...this.controller.datastore
|
|
27
|
+
.limitToRange(this.controller.state, selection.from, selection.to)
|
|
28
|
+
.match(null, 'a', '>http://data.vlaanderen.be/ns/besluit#Besluit')
|
|
29
|
+
.asSubjectNodeMapping()
|
|
30
|
+
.nodes(),
|
|
31
|
+
][0];
|
|
32
|
+
if (besluitRange) {
|
|
33
|
+
const { to } = besluitRange;
|
|
34
|
+
return {
|
|
35
|
+
from: to - 1,
|
|
36
|
+
to: to - 1,
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
return selection;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@action
|
|
44
|
+
insert(snippet: RdfaSnippet, type: string) {
|
|
45
|
+
const insertRange = this.insertRange;
|
|
46
|
+
if (insertRange) {
|
|
47
|
+
const node = this.generateSnippetHtml(snippet, type);
|
|
48
|
+
this.controller.withTransaction((tr) => {
|
|
49
|
+
return tr.replaceRangeWith(insertRange.from, insertRange.to, node);
|
|
50
|
+
});
|
|
51
|
+
this.importRdfaSnippet.removeSnippet(snippet);
|
|
52
|
+
} else {
|
|
53
|
+
console.warn('Could not find a range to insert, so we skipped inserting');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@action
|
|
58
|
+
generateSnippetHtml(snippet: RdfaSnippet, type: string) {
|
|
59
|
+
const domParser = new DOMParser();
|
|
60
|
+
const contentFragment = ProseParser.fromSchema(
|
|
61
|
+
this.controller.schema
|
|
62
|
+
).parse(domParser.parseFromString(snippet.content, 'text/html')).content;
|
|
63
|
+
const { schema } = this.controller;
|
|
64
|
+
if (type === 'attachment') {
|
|
65
|
+
return schema.node(
|
|
66
|
+
'block_rdfa',
|
|
67
|
+
{ property: 'http://lblod.data.gift/vocabularies/editor/isLumpNode' },
|
|
68
|
+
[
|
|
69
|
+
schema.node(
|
|
70
|
+
'block_rdfa',
|
|
71
|
+
{
|
|
72
|
+
resource: snippet.source,
|
|
73
|
+
property: 'http://data.europa.eu/eli/ontology#related_to',
|
|
74
|
+
typeof:
|
|
75
|
+
'http://xmlns.com/foaf/0.1/Document http://lblod.data.gift/vocabularies/editor/SnippetAttachment',
|
|
76
|
+
},
|
|
77
|
+
[
|
|
78
|
+
schema.node('paragraph', {}, [
|
|
79
|
+
schema.text('Bijlage uit externe bron '),
|
|
80
|
+
schema.text(new URL(snippet.source).hostname, [
|
|
81
|
+
schema.mark('link'),
|
|
82
|
+
]),
|
|
83
|
+
]),
|
|
84
|
+
schema.node(
|
|
85
|
+
'block_rdfa',
|
|
86
|
+
{ property: 'http://www.w3.org/ns/prov#value' },
|
|
87
|
+
contentFragment
|
|
88
|
+
),
|
|
89
|
+
]
|
|
90
|
+
),
|
|
91
|
+
]
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
return schema.node(
|
|
95
|
+
'block_rdfa',
|
|
96
|
+
{ property: 'http://lblod.data.gift/vocabularies/editor/isLumpNode' },
|
|
97
|
+
[
|
|
98
|
+
schema.node('paragraph', {}, [
|
|
99
|
+
schema.text('Bijlage uit externe bron'),
|
|
100
|
+
]),
|
|
101
|
+
schema.node(
|
|
102
|
+
'block_rdfa',
|
|
103
|
+
{
|
|
104
|
+
property: 'http://data.europa.eu/eli/ontology#related_to',
|
|
105
|
+
resource: snippet.source,
|
|
106
|
+
},
|
|
107
|
+
[
|
|
108
|
+
schema.node(
|
|
109
|
+
'block_rdfa',
|
|
110
|
+
{ property: 'http://www.w3.org/ns/prov#value' },
|
|
111
|
+
contentFragment
|
|
112
|
+
),
|
|
113
|
+
]
|
|
114
|
+
),
|
|
115
|
+
]
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<div {{did-update this.selectionChanged @controller.state}}>
|
|
1
2
|
{{#if this.showCard}}
|
|
2
3
|
<AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
|
|
3
4
|
<c.header>
|
|
@@ -30,4 +31,4 @@
|
|
|
30
31
|
</c.content>
|
|
31
32
|
</AuCard>
|
|
32
33
|
{{/if}}
|
|
33
|
-
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { task } from 'ember-concurrency';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import {
|
|
7
|
+
defaultVariableTypes,
|
|
8
|
+
VariableType,
|
|
9
|
+
} from '../../utils/variable-plugins/default-variable-types';
|
|
10
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
11
|
+
import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/variable-plugins/fetch-data';
|
|
12
|
+
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
13
|
+
type Args = {
|
|
14
|
+
controller: ProseController;
|
|
15
|
+
widgetArgs: {
|
|
16
|
+
options: {
|
|
17
|
+
publisher: string;
|
|
18
|
+
variableTypes: (VariableType | string)[];
|
|
19
|
+
defaultEndpoint: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default class EditorPluginsInsertCodelistCardComponent extends Component<Args> {
|
|
25
|
+
@tracked variablesArray: VariableType[];
|
|
26
|
+
@tracked selectedVariable?: VariableType;
|
|
27
|
+
@tracked showCard = true;
|
|
28
|
+
@tracked hasSubtype = false;
|
|
29
|
+
@tracked selectedSubtype?: CodeList;
|
|
30
|
+
@tracked subtypes?: CodeList[];
|
|
31
|
+
publisher: string;
|
|
32
|
+
endpoint: string;
|
|
33
|
+
|
|
34
|
+
constructor(parent: unknown, args: Args) {
|
|
35
|
+
super(parent, args);
|
|
36
|
+
const { publisher, variableTypes, defaultEndpoint } =
|
|
37
|
+
this.args.widgetArgs.options || {};
|
|
38
|
+
this.publisher = publisher;
|
|
39
|
+
this.endpoint = defaultEndpoint;
|
|
40
|
+
const variableTypesSelectedByUser = variableTypes ?? [
|
|
41
|
+
'text',
|
|
42
|
+
'number',
|
|
43
|
+
'date',
|
|
44
|
+
'location',
|
|
45
|
+
'codelist',
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const variablesArray: VariableType[] = [];
|
|
49
|
+
for (const type of variableTypesSelectedByUser) {
|
|
50
|
+
if (typeof type === 'string') {
|
|
51
|
+
const variableType = defaultVariableTypes[type];
|
|
52
|
+
if (variableType) {
|
|
53
|
+
variablesArray.push(variableType);
|
|
54
|
+
} else {
|
|
55
|
+
console.warn(
|
|
56
|
+
`Template Variable Plugin: variable type ${type} not found in the default variable types`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
variablesArray.push(type);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.variablesArray = variablesArray;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@action
|
|
67
|
+
insert() {
|
|
68
|
+
if (!this.selectedVariable) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const uri = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
72
|
+
let variableContent;
|
|
73
|
+
if (typeof this.selectedVariable.template === 'function') {
|
|
74
|
+
variableContent = this.selectedVariable.template(
|
|
75
|
+
this.endpoint,
|
|
76
|
+
this.selectedSubtype
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
variableContent = this.selectedVariable.template;
|
|
80
|
+
}
|
|
81
|
+
const htmlToInsert = `<span resource="${uri}" typeof="ext:Mapping">${variableContent}</span>`;
|
|
82
|
+
const { from, to } = this.args.controller.state.selection;
|
|
83
|
+
this.args.controller.doCommand(insertHtml(htmlToInsert, from, to));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@action
|
|
87
|
+
updateSelectedVariable(variable: VariableType) {
|
|
88
|
+
this.selectedVariable = variable;
|
|
89
|
+
if (variable.fetchSubtypes) {
|
|
90
|
+
void this.fetchSubtypes.perform(variable.fetchSubtypes);
|
|
91
|
+
this.hasSubtype = true;
|
|
92
|
+
} else {
|
|
93
|
+
this.hasSubtype = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fetchSubtypes = task(
|
|
98
|
+
async (
|
|
99
|
+
fetchFunction: (
|
|
100
|
+
endpoint: string,
|
|
101
|
+
publisher: string
|
|
102
|
+
) => Promise<CodeList[]>
|
|
103
|
+
) => {
|
|
104
|
+
const subtypes = await fetchFunction(this.endpoint, this.publisher);
|
|
105
|
+
this.subtypes = subtypes;
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
@action
|
|
110
|
+
updateSubtype(subtype: CodeList) {
|
|
111
|
+
this.selectedSubtype = subtype;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@action
|
|
115
|
+
selectionChanged() {
|
|
116
|
+
const currentSelection = this.args.controller.state.selection;
|
|
117
|
+
this.showCard = false;
|
|
118
|
+
const limitedDatastore = this.args.controller.datastore.limitToRange(
|
|
119
|
+
this.args.controller.state,
|
|
120
|
+
currentSelection.from,
|
|
121
|
+
currentSelection.to
|
|
122
|
+
);
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
124
|
+
const quad = limitedDatastore
|
|
125
|
+
.match(null, 'a', 'ext:Mapping')
|
|
126
|
+
.asQuadResultSet()
|
|
127
|
+
.first();
|
|
128
|
+
if (quad) {
|
|
129
|
+
this.showCard = false;
|
|
130
|
+
} else {
|
|
131
|
+
this.showCard = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<div {{did-update this.onSelectionChanged @controller.state}}>
|
|
1
2
|
{{#if this.showCard}}
|
|
2
3
|
<AuCard @shadow={{true}} @size="flush" as |c|>
|
|
3
4
|
<c.header class="au-u-hidden-visually">
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
</c.header>
|
|
6
7
|
<c.content class="au-o-box au-o-box--small">
|
|
7
8
|
<div class="au-o-flow au-o-flow--small">
|
|
8
|
-
<RdfaDatePlugin::
|
|
9
|
+
<RdfaDatePlugin::DateTimePicker
|
|
9
10
|
@onChange={{this.changeDate}}
|
|
10
11
|
@value={{this.dateValue}}
|
|
11
12
|
@onlyDate={{this.onlyDate}}/>
|
|
@@ -20,3 +21,4 @@
|
|
|
20
21
|
</c.content>
|
|
21
22
|
</AuCard>
|
|
22
23
|
{{/if}}
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import modifyDate from '../../commands/modify-date-command';
|
|
5
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
6
|
+
import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
7
|
+
type Args = {
|
|
8
|
+
controller: ProseController;
|
|
9
|
+
};
|
|
10
|
+
export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
11
|
+
@tracked dateValue?: Date;
|
|
12
|
+
@tracked dateRange?: { from: number; to: number };
|
|
13
|
+
@tracked dateInDocument = false;
|
|
14
|
+
@tracked onlyDate = false;
|
|
15
|
+
@tracked showCard = false;
|
|
16
|
+
|
|
17
|
+
get controller() {
|
|
18
|
+
return this.args.controller;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@action
|
|
22
|
+
modifyDate() {
|
|
23
|
+
if (this.dateValue && this.dateRange) {
|
|
24
|
+
this.controller.checkAndDoCommand(
|
|
25
|
+
modifyDate(
|
|
26
|
+
this.dateRange.from,
|
|
27
|
+
this.dateRange.to,
|
|
28
|
+
this.dateValue,
|
|
29
|
+
this.onlyDate
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@action
|
|
36
|
+
changeDate(date: Date) {
|
|
37
|
+
this.dateValue = date;
|
|
38
|
+
if (this.dateInDocument) this.modifyDate();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@action
|
|
42
|
+
onSelectionChanged() {
|
|
43
|
+
const selection = this.controller.state.selection;
|
|
44
|
+
const from = selection.$from;
|
|
45
|
+
const currentNode = from.parent.maybeChild(from.index());
|
|
46
|
+
if (!currentNode) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const datatype = getRdfaAttribute(currentNode, 'datatype').pop();
|
|
50
|
+
if (!datatype) {
|
|
51
|
+
this.showCard = false;
|
|
52
|
+
this.dateRange = undefined;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// const { node: selectionParent, pos: parentPos } = ancestor;
|
|
56
|
+
|
|
57
|
+
if (datatype === 'xsd:dateTime' || datatype === 'xsd:date') {
|
|
58
|
+
this.dateRange = {
|
|
59
|
+
from: from.pos - from.textOffset,
|
|
60
|
+
to: from.pos - from.textOffset + currentNode.nodeSize,
|
|
61
|
+
};
|
|
62
|
+
const dateContent = getRdfaAttribute(currentNode, 'content').pop();
|
|
63
|
+
this.dateValue = dateContent ? new Date(dateContent) : new Date();
|
|
64
|
+
this.dateInDocument = !!dateContent;
|
|
65
|
+
this.onlyDate = datatype === 'xsd:date';
|
|
66
|
+
this.showCard = true;
|
|
67
|
+
} else {
|
|
68
|
+
this.dateRange = undefined;
|
|
69
|
+
this.showCard = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.hbs → date-time-picker.hbs}
RENAMED
|
File without changes
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { inject as service } from '@ember/service';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-ignore
|
|
4
6
|
import { localCopy } from 'tracked-toolbox';
|
|
7
|
+
import Intl from 'ember-intl/services/intl';
|
|
8
|
+
type Args = {
|
|
9
|
+
value: Date;
|
|
10
|
+
onChange: (date: Date) => void;
|
|
11
|
+
};
|
|
5
12
|
|
|
6
|
-
export default class
|
|
7
|
-
@service intl;
|
|
8
|
-
@
|
|
13
|
+
export default class RdfaDatePluginDateTimePicker extends Component<Args> {
|
|
14
|
+
@service declare intl: Intl;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
16
|
+
@localCopy('args.value') declare date: Date;
|
|
9
17
|
|
|
10
18
|
get hours() {
|
|
11
19
|
return this.date.getHours();
|
|
@@ -33,8 +41,8 @@ export default class RdfaDateTimePicker extends Component {
|
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
@action
|
|
36
|
-
onChangeDate(
|
|
37
|
-
|
|
44
|
+
onChangeDate(_isoDate: unknown, date: Date) {
|
|
45
|
+
const wasDateInputCleared = !date;
|
|
38
46
|
if (!wasDateInputCleared) {
|
|
39
47
|
if (!this.date) {
|
|
40
48
|
this.date = new Date();
|
|
@@ -47,7 +55,7 @@ export default class RdfaDateTimePicker extends Component {
|
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
@action
|
|
50
|
-
onChangeTime(timeObject) {
|
|
58
|
+
onChangeTime(timeObject: { hours: number; minutes: number }) {
|
|
51
59
|
if (!this.date) this.date = new Date();
|
|
52
60
|
this.date.setHours(timeObject.hours);
|
|
53
61
|
this.date.setMinutes(timeObject.minutes);
|
|
@@ -55,18 +63,24 @@ export default class RdfaDateTimePicker extends Component {
|
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
function getLocalizedMonths(
|
|
59
|
-
|
|
66
|
+
function getLocalizedMonths(
|
|
67
|
+
intl: Intl,
|
|
68
|
+
monthFormat: 'long' | 'numeric' | '2-digit' | 'short' | 'narrow' = 'long'
|
|
69
|
+
) {
|
|
70
|
+
const someYear = 2021;
|
|
60
71
|
return [...Array(12).keys()].map((monthIndex) => {
|
|
61
|
-
|
|
72
|
+
const date = new Date(someYear, monthIndex);
|
|
62
73
|
return intl.formatDate(date, { month: monthFormat });
|
|
63
74
|
});
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
function getLocalizedDays(
|
|
67
|
-
|
|
77
|
+
function getLocalizedDays(
|
|
78
|
+
intl: Intl,
|
|
79
|
+
weekdayFormat: 'long' | 'short' | 'narrow' = 'long'
|
|
80
|
+
) {
|
|
81
|
+
const someSunday = new Date('2021-01-03');
|
|
68
82
|
return [...Array(7).keys()].map((index) => {
|
|
69
|
-
|
|
83
|
+
const weekday = new Date(someSunday.getTime());
|
|
70
84
|
weekday.setDate(someSunday.getDate() + index);
|
|
71
85
|
return intl.formatDate(weekday, { weekday: weekdayFormat });
|
|
72
86
|
});
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
4
|
+
|
|
5
|
+
type Args = {
|
|
6
|
+
controller: ProseController;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default class RdfaDatePluginInsertComponent extends Component<Args> {
|
|
10
|
+
get controller() {
|
|
11
|
+
return this.args.controller;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get schema() {
|
|
15
|
+
return this.controller.schema;
|
|
16
|
+
}
|
|
17
|
+
@action
|
|
18
|
+
insertDate() {
|
|
19
|
+
this.controller.withTransaction((tr) => {
|
|
20
|
+
const dateNode = this.schema.text('${date}', [
|
|
21
|
+
this.schema.mark('inline_rdfa', {
|
|
22
|
+
datatype: 'xsd:date',
|
|
23
|
+
property: 'ext:content',
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
return tr.replaceSelectionWith(dateNode, false);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@action
|
|
31
|
+
insertDateTime() {
|
|
32
|
+
this.controller.withTransaction((tr) => {
|
|
33
|
+
return tr.replaceSelectionWith(
|
|
34
|
+
this.schema.text('${date and time}', [
|
|
35
|
+
this.schema.mark('inline_rdfa', {
|
|
36
|
+
datatype: 'xsd:dateTime',
|
|
37
|
+
property: 'ext:content',
|
|
38
|
+
}),
|
|
39
|
+
]),
|
|
40
|
+
false
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import {
|
|
5
|
+
NON_ZONAL_URI,
|
|
6
|
+
POTENTIALLY_ZONAL_URI,
|
|
7
|
+
ZONAL_URI,
|
|
8
|
+
} from '../../constants';
|
|
9
|
+
import Measure from '@lblod/ember-rdfa-editor-lblod-plugins/models/measure';
|
|
10
|
+
import { assert } from '@ember/debug';
|
|
11
|
+
|
|
12
|
+
type Args = {
|
|
13
|
+
measure: Measure;
|
|
14
|
+
selectRow: (uri: string) => void;
|
|
15
|
+
insert: (
|
|
16
|
+
measure: Measure,
|
|
17
|
+
zonalityValue?: string,
|
|
18
|
+
temporalValue?: string
|
|
19
|
+
) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default class ExpandedMeasureComponent extends Component<Args> {
|
|
23
|
+
@tracked zonalityValue?: string;
|
|
24
|
+
@tracked temporalValue?: string;
|
|
25
|
+
ZONAL_URI = ZONAL_URI;
|
|
26
|
+
NON_ZONAL_URI = NON_ZONAL_URI;
|
|
27
|
+
get isPotentiallyZonal() {
|
|
28
|
+
return this.args.measure.zonality === POTENTIALLY_ZONAL_URI;
|
|
29
|
+
}
|
|
30
|
+
get insertButtonDisabled() {
|
|
31
|
+
return this.isPotentiallyZonal && !this.zonalityValue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@action
|
|
35
|
+
changeZonality(event: InputEvent) {
|
|
36
|
+
assert(
|
|
37
|
+
'changeZonalityValue must be bound to an input element',
|
|
38
|
+
event.target instanceof HTMLInputElement
|
|
39
|
+
);
|
|
40
|
+
this.zonalityValue = event.target.value;
|
|
41
|
+
}
|
|
42
|
+
@action
|
|
43
|
+
changeTemporality(event: InputEvent) {
|
|
44
|
+
assert(
|
|
45
|
+
'changeTemporality must be bound to an input element',
|
|
46
|
+
event.target instanceof HTMLInputElement
|
|
47
|
+
);
|
|
48
|
+
this.temporalValue = event.target.value;
|
|
49
|
+
}
|
|
50
|
+
@action
|
|
51
|
+
insert() {
|
|
52
|
+
this.args.insert(this.args.measure, this.zonalityValue, this.temporalValue);
|
|
53
|
+
}
|
|
54
|
+
@action
|
|
55
|
+
unselectRow() {
|
|
56
|
+
this.args.selectRow(this.args.measure.uri);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
3
|
+
import { task } from 'ember-concurrency';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
import includeInstructions from '../../utils/roadsign-regulation-plugin/includeInstructions';
|
|
6
|
+
import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/services/roadsign-registry';
|
|
7
|
+
|
|
8
|
+
type Args = {
|
|
9
|
+
template: string;
|
|
10
|
+
measure: string;
|
|
11
|
+
annotated: boolean;
|
|
12
|
+
};
|
|
13
|
+
export default class MeasureTemplateComponent extends Component<Args> {
|
|
14
|
+
@service declare roadsignRegistry: RoadsignRegistryService;
|
|
15
|
+
@tracked template = '';
|
|
16
|
+
|
|
17
|
+
constructor(parent: unknown, args: Args) {
|
|
18
|
+
super(parent, args);
|
|
19
|
+
this.template = this.args.template;
|
|
20
|
+
void this.fetchData.perform();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fetchData = task(async () => {
|
|
24
|
+
const instructions =
|
|
25
|
+
await this.roadsignRegistry.getInstructionsForMeasure.perform(
|
|
26
|
+
this.args.measure
|
|
27
|
+
);
|
|
28
|
+
const template = includeInstructions(
|
|
29
|
+
this.args.template,
|
|
30
|
+
instructions,
|
|
31
|
+
this.args.annotated
|
|
32
|
+
);
|
|
33
|
+
this.template = template;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
@skin="link"
|
|
4
4
|
@icon="add"
|
|
5
5
|
@iconAlignment="left"
|
|
6
|
-
@disabled={{
|
|
6
|
+
@disabled={{not this.showCard}}
|
|
7
7
|
{{on "click" this.toggleModal}}
|
|
8
8
|
>
|
|
9
9
|
Voeg mobiliteitsmaatregel in
|
|
10
10
|
</AuButton>
|
|
11
11
|
</AuList::Item>
|
|
12
|
-
<RoadsignRegulationPlugin::RoadsignsModal @modalOpen={{this.modalOpen}} @closeModal={{this.toggleModal}} @controller={{@controller}}
|
|
12
|
+
<RoadsignRegulationPlugin::RoadsignsModal @modalOpen={{this.modalOpen}} @closeModal={{this.toggleModal}} @controller={{@controller}}/>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Card displaying a hint of the Date plugin
|
|
8
|
+
*
|
|
9
|
+
* @module editor-roadsign-regulation-plugin
|
|
10
|
+
* @class RoadsignRegulationCard
|
|
11
|
+
* @extends Ember.Component
|
|
12
|
+
*/
|
|
13
|
+
const acceptedTypes = [
|
|
14
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/4d8f678a-6fa4-4d5f-a2a1-80974e43bf34',
|
|
15
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/7d95fd2e-3cc9-4a4c-a58e-0fbc408c2f9b',
|
|
16
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/3bba9f10-faff-49a6-acaa-85af7f2199a3',
|
|
17
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/0d1278af-b69e-4152-a418-ec5cfd1c7d0b',
|
|
18
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/e8afe7c5-9640-4db8-8f74-3f023bec3241',
|
|
19
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/256bd04a-b74b-4f2a-8f5d-14dda4765af9',
|
|
20
|
+
'>https://data.vlaanderen.be/id/concept/BesluitType/67378dd0-5413-474b-8996-d992ef81637a',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
type Args = {
|
|
24
|
+
controller: ProseController;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default class RoadsignRegulationCard extends Component<Args> {
|
|
28
|
+
@tracked modalOpen = false;
|
|
29
|
+
|
|
30
|
+
@action
|
|
31
|
+
toggleModal() {
|
|
32
|
+
this.modalOpen = !this.modalOpen;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get controller() {
|
|
36
|
+
return this.args.controller;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get showCard() {
|
|
40
|
+
const selection = this.controller.state.selection;
|
|
41
|
+
const limitedDatastore = this.controller.datastore.limitToRange(
|
|
42
|
+
this.controller.state,
|
|
43
|
+
selection.from,
|
|
44
|
+
selection.to
|
|
45
|
+
);
|
|
46
|
+
const besluit = [
|
|
47
|
+
...limitedDatastore
|
|
48
|
+
.match(undefined, 'a')
|
|
49
|
+
.transformDataset((dataset, termConverter) => {
|
|
50
|
+
return dataset.filter((quad) =>
|
|
51
|
+
acceptedTypes
|
|
52
|
+
.map((type) => termConverter(type).value)
|
|
53
|
+
.includes(quad.object.value)
|
|
54
|
+
);
|
|
55
|
+
})
|
|
56
|
+
.asQuadResultSet(),
|
|
57
|
+
][0];
|
|
58
|
+
return !!besluit;
|
|
59
|
+
}
|
|
60
|
+
}
|