@lblod/ember-rdfa-editor-lblod-plugins 0.4.1 → 1.0.0-alpha.2
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 +46 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +10 -0
- package/addon/components/article-structure-plugin/article-structure-card.ts +33 -0
- package/addon/components/article-structure-plugin/structure-card.hbs +46 -0
- package/addon/components/article-structure-plugin/structure-card.ts +124 -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 +138 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +40 -0
- package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +8 -4
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +218 -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} +117 -90
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.hbs +0 -0
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.hbs +0 -0
- 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 +45 -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} +103 -66
- 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/helpers/{limit-text.js → limit-text.ts} +2 -2
- 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/commands/index.ts +6 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +80 -0
- package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +130 -0
- package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +26 -0
- package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +21 -0
- package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +40 -0
- package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +66 -0
- package/addon/plugins/article-structure-plugin/constants.ts +11 -0
- package/addon/plugins/article-structure-plugin/index.ts +70 -0
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +94 -0
- package/addon/plugins/article-structure-plugin/structures/article.ts +129 -0
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +83 -0
- package/addon/plugins/article-structure-plugin/structures/index.ts +33 -0
- package/addon/plugins/article-structure-plugin/structures/section.ts +82 -0
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +65 -0
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +83 -0
- package/addon/plugins/article-structure-plugin/structures/title.ts +83 -0
- package/addon/plugins/article-structure-plugin/utils/namespace.ts +25 -0
- package/addon/plugins/article-structure-plugin/utils/structure.ts +162 -0
- package/addon/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.ts +30 -0
- package/addon/plugins/besluit-plugin/commands/index.ts +4 -0
- package/addon/plugins/besluit-plugin/commands/insert-article.ts +70 -0
- package/addon/plugins/besluit-plugin/commands/insert-title.ts +67 -0
- package/addon/plugins/besluit-plugin/commands/move-article.ts +69 -0
- package/addon/plugins/besluit-plugin/commands/recalculate-article-numbers.ts +44 -0
- package/addon/plugins/besluit-plugin/index.ts +11 -0
- package/addon/plugins/besluit-plugin/utils/get-title-for-decision.ts +35 -0
- package/addon/plugins/besluit-type-plugin/index.ts +6 -0
- package/addon/{utils/fetchBesluitTypes.js → plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts} +35 -16
- 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/{utils/legislation-types.js → plugins/citation-plugin/utils/legislation-types.ts} +17 -3
- package/addon/plugins/citation-plugin/utils/process-match.ts +132 -0
- package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +160 -41
- package/addon/plugins/import-snippet-plugin.ts +6 -0
- package/addon/plugins/insert-variable-plugin/index.ts +11 -0
- package/addon/{utils/variable-plugins/default-variable-types.js → plugins/insert-variable-plugin/utils/constants.ts} +18 -7
- package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +41 -0
- package/addon/plugins/rdfa-date-plugin/commands/index.ts +1 -0
- package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +48 -0
- package/addon/plugins/rdfa-date-plugin/index.ts +11 -0
- package/addon/plugins/roadsign-regulation-plugin/index.ts +6 -0
- package/addon/plugins/roadsign-regulation-plugin/utils/constants.ts +8 -0
- package/addon/{utils/roadsign-regulation-plugin/fetchData.js → plugins/roadsign-regulation-plugin/utils/fetchData.ts} +20 -3
- package/addon/plugins/roadsign-regulation-plugin/utils/includeInstructions.ts +16 -0
- package/addon/plugins/standard-template-plugin/index.ts +6 -0
- package/addon/plugins/standard-template-plugin/utils/instantiate-uuids.ts +48 -0
- package/addon/plugins/table-of-contents-plugin/index.ts +14 -0
- package/addon/plugins/table-of-contents-plugin/nodes/index.ts +1 -0
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +53 -0
- package/addon/plugins/table-of-contents-plugin/utils/constants.ts +17 -0
- package/addon/plugins/template-variable-plugin/index.ts +6 -0
- package/addon/plugins/template-variable-plugin/utils/constants.ts +2 -0
- package/addon/plugins/template-variable-plugin/utils/fetch-data.ts +62 -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/memoize.ts +8 -0
- package/addon/utils/option.ts +58 -0
- package/addon/utils/sparql-helpers.ts +27 -0
- 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/components/article-structure-plugin/article-structure-card.d.ts +17 -0
- package/components/article-structure-plugin/structure-card.d.ts +32 -0
- package/components/au-native-input.d.ts +20 -0
- package/components/besluit-plugin/besluit-context-card.d.ts +24 -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/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 +29 -8
- package/plugins/article-structure-plugin/commands/index.d.ts +6 -0
- package/plugins/article-structure-plugin/commands/insert-structure.d.ts +5 -0
- package/plugins/article-structure-plugin/commands/move-selected-structure.d.ts +10 -0
- package/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +3 -0
- package/plugins/article-structure-plugin/commands/remove-structure.d.ts +7 -0
- package/plugins/article-structure-plugin/commands/unwrap-structure.d.ts +8 -0
- package/plugins/article-structure-plugin/commands/wrap-structure-content.d.ts +8 -0
- package/plugins/article-structure-plugin/constants.d.ts +5 -0
- package/plugins/article-structure-plugin/index.d.ts +41 -0
- package/plugins/article-structure-plugin/structures/article-paragraph.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/article.d.ts +6 -0
- package/plugins/article-structure-plugin/structures/chapter.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/index.d.ts +17 -0
- package/plugins/article-structure-plugin/structures/section.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/structure-header.d.ts +2 -0
- package/plugins/article-structure-plugin/structures/subsection.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/title.d.ts +4 -0
- package/plugins/article-structure-plugin/utils/namespace.d.ts +6 -0
- package/plugins/article-structure-plugin/utils/structure.d.ts +20 -0
- package/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.d.ts +5 -0
- package/plugins/besluit-plugin/commands/index.d.ts +4 -0
- package/plugins/besluit-plugin/commands/insert-article.d.ts +3 -0
- package/plugins/besluit-plugin/commands/insert-title.d.ts +2 -0
- package/plugins/besluit-plugin/commands/move-article.d.ts +2 -0
- package/plugins/besluit-plugin/commands/recalculate-article-numbers.d.ts +2 -0
- package/plugins/besluit-plugin/index.d.ts +3 -0
- package/plugins/besluit-plugin/utils/get-title-for-decision.d.ts +10 -0
- package/plugins/besluit-type-plugin/index.d.ts +2 -0
- package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +12 -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/legislation-types.d.ts +24 -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/index.d.ts +2 -0
- package/plugins/insert-variable-plugin/utils/constants.d.ts +7 -0
- package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +5 -0
- package/plugins/rdfa-date-plugin/commands/index.d.ts +1 -0
- package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +2 -0
- package/plugins/rdfa-date-plugin/index.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin/index.d.ts +2 -0
- package/plugins/roadsign-regulation-plugin/utils/constants.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin/utils/fetchData.d.ts +8 -0
- package/plugins/roadsign-regulation-plugin/utils/includeInstructions.d.ts +2 -0
- package/plugins/standard-template-plugin/index.d.ts +2 -0
- package/plugins/standard-template-plugin/utils/instantiate-uuids.d.ts +15 -0
- package/plugins/table-of-contents-plugin/index.d.ts +3 -0
- package/plugins/table-of-contents-plugin/nodes/index.d.ts +1 -0
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -0
- package/plugins/table-of-contents-plugin/utils/constants.d.ts +7 -0
- package/plugins/template-variable-plugin/index.d.ts +2 -0
- package/plugins/template-variable-plugin/utils/constants.d.ts +1 -0
- package/plugins/template-variable-plugin/utils/fetch-data.d.ts +9 -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 +64 -1
- package/translations/nl-BE.yaml +66 -3
- package/tsconfig.json +34 -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/memoize.d.ts +1 -0
- package/utils/option.d.ts +14 -0
- package/utils/sparql-helpers.d.ts +7 -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 -71
- 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/constants.js +0 -24
- package/addon/initializers/plugin-initializer.js +0 -75
- package/addon/inline-components/table-of-contents.js +0 -43
- package/addon/marks/citaten-mark.js +0 -32
- 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/generate-template-plugin.js +0 -16
- 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/generate-template-plugin/default-resources.js +0 -9
- package/addon/utils/instantiate-uuids.js +0 -34
- package/addon/utils/memoize.js +0 -8
- package/addon/utils/processMatch.js +0 -80
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
- package/addon/utils/variable-plugins/fetch-data.js +0 -98
- 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,132 @@
|
|
|
1
|
+
import { isBlank } from '@ember/utils';
|
|
2
|
+
import { LEGISLATION_TYPES, LegislationKey } from './legislation-types';
|
|
3
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
4
|
+
|
|
5
|
+
const STOP_WORDS = ['het', 'de', 'van', 'tot', 'dat'];
|
|
6
|
+
const DATE_REGEX = new RegExp('(\\d{1,2})\\s(\\w+)\\s(\\d{2,4})', 'g');
|
|
7
|
+
const INVISIBLE_SPACE = '\u200B';
|
|
8
|
+
const SPACES_REGEX = new RegExp('[\\s${UNBREAKABLE_SPACE}]+');
|
|
9
|
+
export type RegexpMatchArrayWithIndices = RegExpMatchArray & {
|
|
10
|
+
indices: Array<[number, number]> & {
|
|
11
|
+
groups: { [key: string]: [number, number] };
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface ProcessedMatch {
|
|
16
|
+
text: string;
|
|
17
|
+
legislationTypeUri: string;
|
|
18
|
+
typeMatch: {
|
|
19
|
+
text: string;
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
} | null;
|
|
23
|
+
searchTextMatch: {
|
|
24
|
+
text: string;
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function processMatch(
|
|
31
|
+
match: RegexpMatchArrayWithIndices
|
|
32
|
+
): ProcessedMatch | null {
|
|
33
|
+
const matchgroups = match.groups;
|
|
34
|
+
if (!matchgroups) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const type = matchgroups['type'];
|
|
38
|
+
const searchTerms = matchgroups['searchTerms'];
|
|
39
|
+
if (!type || !searchTerms) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
let cleanedSearchTerms = cleanupText(searchTerms)
|
|
43
|
+
.split(SPACES_REGEX)
|
|
44
|
+
.filter(
|
|
45
|
+
(word) => !isBlank(word) && word.length > 3 && !STOP_WORDS.includes(word)
|
|
46
|
+
)
|
|
47
|
+
.join(' ');
|
|
48
|
+
if (type) {
|
|
49
|
+
let typeLabel: LegislationKey;
|
|
50
|
+
if (/\w+decreet/i.test(type)) {
|
|
51
|
+
typeLabel = 'decreet';
|
|
52
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
53
|
+
} else if (/decreet/i.test(type)) {
|
|
54
|
+
typeLabel = 'decreet';
|
|
55
|
+
} else if (/\w+wetboek/i.test(type)) {
|
|
56
|
+
typeLabel = 'wetboek';
|
|
57
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
58
|
+
} else if (/wetboek/i.test(type)) {
|
|
59
|
+
typeLabel = 'wetboek';
|
|
60
|
+
} else if (/geco[oö]rdineerde[^\S\n]wetten/i.test(type)) {
|
|
61
|
+
typeLabel = 'gecoördineerde wetten';
|
|
62
|
+
} else if (/grondwetswijziging/i.test(type)) {
|
|
63
|
+
typeLabel = 'grondwetswijziging';
|
|
64
|
+
} else if (/grondwet/i.test(type)) {
|
|
65
|
+
typeLabel = 'grondwet';
|
|
66
|
+
} else if (/\w+wet/i.test(type)) {
|
|
67
|
+
typeLabel = 'wet';
|
|
68
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
69
|
+
} else if (/wet/i.test(type)) {
|
|
70
|
+
typeLabel = 'wet';
|
|
71
|
+
} else {
|
|
72
|
+
typeLabel = 'decreet';
|
|
73
|
+
}
|
|
74
|
+
const typeUri = LEGISLATION_TYPES[typeLabel];
|
|
75
|
+
return {
|
|
76
|
+
text: cleanedSearchTerms,
|
|
77
|
+
legislationTypeUri: typeUri,
|
|
78
|
+
typeMatch: {
|
|
79
|
+
text: type,
|
|
80
|
+
start: unwrap(match.indices.groups['type'])[0],
|
|
81
|
+
end: unwrap(match.indices.groups['type'])[1],
|
|
82
|
+
},
|
|
83
|
+
searchTextMatch: {
|
|
84
|
+
text: searchTerms,
|
|
85
|
+
start: unwrap(match.indices.groups['searchTerms'])[0],
|
|
86
|
+
end: unwrap(match.indices.groups['searchTerms'])[1],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
return {
|
|
91
|
+
text: cleanedSearchTerms,
|
|
92
|
+
legislationTypeUri: LEGISLATION_TYPES['decreet'],
|
|
93
|
+
typeMatch: null,
|
|
94
|
+
searchTextMatch: {
|
|
95
|
+
text: searchTerms,
|
|
96
|
+
start: unwrap(match.indices.groups['searchTerms'])[0],
|
|
97
|
+
end: unwrap(match.indices.groups['searchTerms'])[1],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function cleanupText(text?: string): string {
|
|
104
|
+
if (!text) return '';
|
|
105
|
+
const { textWithoutDates } = extractDates(text);
|
|
106
|
+
const textWithoutOddChars = textWithoutDates.replace(
|
|
107
|
+
new RegExp(`[,.:"()&${INVISIBLE_SPACE}]`, 'g'),
|
|
108
|
+
''
|
|
109
|
+
);
|
|
110
|
+
const articleIndex = textWithoutOddChars.indexOf('artikel');
|
|
111
|
+
return articleIndex >= 0
|
|
112
|
+
? textWithoutOddChars.slice(0, articleIndex)
|
|
113
|
+
: textWithoutOddChars;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function extractDates(text: string): {
|
|
117
|
+
dates: RegExpMatchArray[];
|
|
118
|
+
textWithoutDates: string;
|
|
119
|
+
} {
|
|
120
|
+
let date;
|
|
121
|
+
const matches: RegExpMatchArray[] = [];
|
|
122
|
+
while ((date = DATE_REGEX.exec(text)) !== null) {
|
|
123
|
+
matches.push(date);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let textWithoutDates = text;
|
|
127
|
+
for (const match of matches) {
|
|
128
|
+
textWithoutDates = textWithoutDates.replace(match[0], '');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { dates: matches, textWithoutDates };
|
|
132
|
+
}
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import { LEGISLATION_TYPE_CONCEPTS } from './legislation-types';
|
|
2
|
-
const SPARQL_ENDPOINT = '/codex/sparql/';
|
|
3
2
|
import { warn } from '@ember/debug';
|
|
4
3
|
import { htmlSafe } from '@ember/template';
|
|
4
|
+
import {
|
|
5
|
+
Option,
|
|
6
|
+
optionMapOr,
|
|
7
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
8
|
+
import Ember from 'ember';
|
|
9
|
+
import SafeString = Ember.Handlebars.SafeString;
|
|
10
|
+
|
|
11
|
+
const SPARQL_ENDPOINT = '/codex/sparql/';
|
|
5
12
|
|
|
6
13
|
//const SPARQL_ENDPOINT = 'https://codex.opendata.api.vlaanderen.be:8888/sparql';
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
interface DecisionArgs {
|
|
16
|
+
uri: string;
|
|
17
|
+
legislationTypeUri: Option<string>;
|
|
18
|
+
title: string | null;
|
|
19
|
+
publicationDate: string | null;
|
|
20
|
+
documentDate: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class Decision {
|
|
24
|
+
uri: string;
|
|
25
|
+
legislationType: { label: string; value: string } | undefined;
|
|
26
|
+
title: string | null;
|
|
27
|
+
publicationDate: string | null;
|
|
28
|
+
documentDate: string | null;
|
|
29
|
+
|
|
9
30
|
constructor({
|
|
10
31
|
uri,
|
|
11
32
|
legislationTypeUri,
|
|
12
33
|
title,
|
|
13
34
|
publicationDate,
|
|
14
35
|
documentDate,
|
|
15
|
-
}) {
|
|
36
|
+
}: DecisionArgs) {
|
|
16
37
|
this.uri = uri;
|
|
17
38
|
this.legislationType = LEGISLATION_TYPE_CONCEPTS.find(
|
|
18
|
-
(t) => t.value
|
|
39
|
+
(t) => t.value === legislationTypeUri
|
|
19
40
|
);
|
|
20
41
|
this.title = title;
|
|
21
42
|
this.publicationDate = publicationDate;
|
|
@@ -23,15 +44,35 @@ class Decision {
|
|
|
23
44
|
}
|
|
24
45
|
|
|
25
46
|
get fullTitle() {
|
|
26
|
-
return `${this.legislationType
|
|
47
|
+
return `${this.legislationType?.label ?? ''} ${this.title ?? ''}`;
|
|
27
48
|
}
|
|
28
49
|
}
|
|
29
50
|
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
interface ArticleArgs {
|
|
52
|
+
uri: string;
|
|
53
|
+
number?: number;
|
|
54
|
+
content: string | null;
|
|
55
|
+
dateInForce: string | null;
|
|
56
|
+
dateNoLongerInForce: string | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class Article {
|
|
60
|
+
uri: string;
|
|
61
|
+
number?: number;
|
|
62
|
+
content: SafeString | null;
|
|
63
|
+
dateInForce: string | null;
|
|
64
|
+
dateNoLongerInForce: string | null;
|
|
65
|
+
|
|
66
|
+
constructor({
|
|
67
|
+
uri,
|
|
68
|
+
number,
|
|
69
|
+
content,
|
|
70
|
+
dateInForce,
|
|
71
|
+
dateNoLongerInForce,
|
|
72
|
+
}: ArticleArgs) {
|
|
32
73
|
this.uri = uri;
|
|
33
74
|
this.number = number;
|
|
34
|
-
this.content = htmlSafe
|
|
75
|
+
this.content = optionMapOr(null, htmlSafe, content);
|
|
35
76
|
this.dateInForce = dateInForce;
|
|
36
77
|
this.dateNoLongerInForce = dateNoLongerInForce;
|
|
37
78
|
}
|
|
@@ -41,12 +82,12 @@ class Article {
|
|
|
41
82
|
* flemish codex encodes certain characters as a html character, which breaks our search
|
|
42
83
|
* this is an ugly work around
|
|
43
84
|
*/
|
|
44
|
-
function replaceDiacriticsInWord(word) {
|
|
85
|
+
function replaceDiacriticsInWord(word: string): string {
|
|
45
86
|
const characters =
|
|
46
87
|
'Ë À Ì Â Í Ã Î Ä Ï Ç Ò È Ó É Ô Ê Õ Ö ê Ù ë Ú î Û ï Ü ô Ý õ â û ã ÿ ç'.split(
|
|
47
88
|
' '
|
|
48
89
|
);
|
|
49
|
-
for (
|
|
90
|
+
for (const char of characters) {
|
|
50
91
|
word = word.replace(new RegExp(`${char}`, 'g'), `&#${char.charCodeAt(0)};`);
|
|
51
92
|
}
|
|
52
93
|
return word;
|
|
@@ -55,11 +96,19 @@ function replaceDiacriticsInWord(word) {
|
|
|
55
96
|
//Attempt to memoise on the fetching by stringifying the arguments. This could spare a few fetches.
|
|
56
97
|
//If memoising fails, at least a normal fetch is performed.
|
|
57
98
|
|
|
58
|
-
const fetchDecisionsMemory = new Map();
|
|
99
|
+
const fetchDecisionsMemory = new Map<string, DecisionCollection>();
|
|
100
|
+
|
|
101
|
+
export interface QueryFilter {
|
|
102
|
+
type: string;
|
|
103
|
+
documentDateFrom?: Option<string>;
|
|
104
|
+
documentDateTo?: Option<string>;
|
|
105
|
+
publicationDateFrom?: Option<string>;
|
|
106
|
+
publicationDateTo?: Option<string>;
|
|
107
|
+
}
|
|
59
108
|
|
|
60
109
|
async function fetchDecisions(
|
|
61
|
-
words,
|
|
62
|
-
filter,
|
|
110
|
+
words: string[],
|
|
111
|
+
filter: QueryFilter,
|
|
63
112
|
pageNumber = 0,
|
|
64
113
|
pageSize = 5
|
|
65
114
|
/*abortSignal*/
|
|
@@ -83,19 +132,29 @@ async function fetchDecisions(
|
|
|
83
132
|
if (results) {
|
|
84
133
|
return results;
|
|
85
134
|
} else {
|
|
86
|
-
const newResults = await
|
|
135
|
+
const newResults = await fetchDecisionsMemo(
|
|
136
|
+
words,
|
|
137
|
+
filter,
|
|
138
|
+
pageNumber,
|
|
139
|
+
pageSize
|
|
140
|
+
);
|
|
87
141
|
fetchDecisionsMemory.set(stringArguments, newResults);
|
|
88
142
|
return newResults;
|
|
89
143
|
}
|
|
90
144
|
}
|
|
91
145
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
146
|
+
interface DecisionCollection {
|
|
147
|
+
totalCount: number;
|
|
148
|
+
decisions: Decision[];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function fetchDecisionsMemo(
|
|
152
|
+
words: string[],
|
|
153
|
+
filter: QueryFilter,
|
|
95
154
|
pageNumber = 0,
|
|
96
155
|
pageSize = 5,
|
|
97
|
-
abortSignal
|
|
98
|
-
) {
|
|
156
|
+
abortSignal?: AbortSignal
|
|
157
|
+
): Promise<DecisionCollection> {
|
|
99
158
|
// TBD/NOTE: in the context of a <http://data.europa.eu/eli/ontology#LegalResource>
|
|
100
159
|
// the eli:cites can have either a <http://xmlns.com/foaf/0.1/Document> or <http://data.europa.eu/eli/ontology#LegalResource>
|
|
101
160
|
// as range (see AP https://data.vlaanderen.be/doc/applicatieprofiel/besluit-publicatie/#Rechtsgrond),
|
|
@@ -165,7 +224,7 @@ async function fetchDecisionsMemd(
|
|
|
165
224
|
);
|
|
166
225
|
|
|
167
226
|
if (totalCount > 0) {
|
|
168
|
-
const response = await executeQuery(
|
|
227
|
+
const response = await executeQuery<DecisionBinding>(
|
|
169
228
|
`PREFIX eli: <http://data.europa.eu/eli/ontology#>
|
|
170
229
|
|
|
171
230
|
SELECT DISTINCT ?expressionUri as ?uri ?title ?publicationDate ?documentDate
|
|
@@ -219,15 +278,26 @@ async function fetchDecisionsMemd(
|
|
|
219
278
|
}
|
|
220
279
|
}
|
|
221
280
|
|
|
222
|
-
|
|
281
|
+
interface Binding<A> {
|
|
282
|
+
value: A;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface DecisionBinding {
|
|
286
|
+
uri: Binding<string>;
|
|
287
|
+
title: Binding<string>;
|
|
288
|
+
publicationDate: Binding<string>;
|
|
289
|
+
documentDate: Binding<string>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const fetchArticlesMemory = new Map<string, ArticleCollection>();
|
|
223
293
|
|
|
224
294
|
async function fetchArticles(
|
|
225
|
-
legalExpression,
|
|
226
|
-
pageNumber,
|
|
227
|
-
pageSize,
|
|
228
|
-
articleFilter
|
|
295
|
+
legalExpression: string,
|
|
296
|
+
pageNumber: number,
|
|
297
|
+
pageSize: number,
|
|
298
|
+
articleFilter: string
|
|
229
299
|
/*abortSignal*/
|
|
230
|
-
) {
|
|
300
|
+
): Promise<ArticleCollection> {
|
|
231
301
|
//Simpler here, only one way arguments are set up
|
|
232
302
|
const stringArguments = JSON.stringify({
|
|
233
303
|
legalExpression,
|
|
@@ -239,19 +309,56 @@ async function fetchArticles(
|
|
|
239
309
|
if (results) {
|
|
240
310
|
return results;
|
|
241
311
|
} else {
|
|
242
|
-
const newResults = await
|
|
312
|
+
const newResults = await fetchArticlesMemo(
|
|
313
|
+
legalExpression,
|
|
314
|
+
pageNumber,
|
|
315
|
+
pageSize,
|
|
316
|
+
articleFilter
|
|
317
|
+
);
|
|
243
318
|
fetchArticlesMemory.set(stringArguments, newResults);
|
|
244
319
|
return newResults;
|
|
245
320
|
}
|
|
246
321
|
}
|
|
247
322
|
|
|
248
|
-
|
|
249
|
-
|
|
323
|
+
interface ArticleBinding {
|
|
324
|
+
count: {
|
|
325
|
+
value: string;
|
|
326
|
+
};
|
|
327
|
+
content?: {
|
|
328
|
+
value: string;
|
|
329
|
+
};
|
|
330
|
+
dateInForce?: {
|
|
331
|
+
value: string;
|
|
332
|
+
};
|
|
333
|
+
dateNoLongerInForce?: {
|
|
334
|
+
value: string;
|
|
335
|
+
};
|
|
336
|
+
article: {
|
|
337
|
+
value: string;
|
|
338
|
+
};
|
|
339
|
+
number?: {
|
|
340
|
+
value: number;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface QueryResponse<B> {
|
|
345
|
+
results: {
|
|
346
|
+
bindings: B[];
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface ArticleCollection {
|
|
351
|
+
totalCount: number;
|
|
352
|
+
articles: Article[];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async function fetchArticlesMemo(
|
|
356
|
+
legalExpression: string,
|
|
250
357
|
pageNumber = 0,
|
|
251
358
|
pageSize = 10,
|
|
252
|
-
articleFilter,
|
|
253
|
-
abortSignal
|
|
254
|
-
) {
|
|
359
|
+
articleFilter: string,
|
|
360
|
+
abortSignal?: AbortSignal
|
|
361
|
+
): Promise<ArticleCollection> {
|
|
255
362
|
const numberFilter = articleFilter
|
|
256
363
|
? `FILTER( !BOUND(?number) || CONTAINS(?number, "${articleFilter}"))`
|
|
257
364
|
: '';
|
|
@@ -280,7 +387,7 @@ async function fetchArticlesMemd(
|
|
|
280
387
|
if (totalCount > 0) {
|
|
281
388
|
// ?number has format like "Artikel 12." We parse the number from the string for ordering
|
|
282
389
|
// Second degree ordering on ?numberStr to make sure "Artikel 3/1." comes after "Artikel 3."
|
|
283
|
-
const response = await executeQuery(
|
|
390
|
+
const response = await executeQuery<ArticleBinding>(
|
|
284
391
|
`PREFIX eli: <http://data.europa.eu/eli/ontology#>
|
|
285
392
|
PREFIX prov: <http://www.w3.org/ns/prov#>
|
|
286
393
|
PREFIX dct: <http://purl.org/dc/terms/>
|
|
@@ -343,7 +450,7 @@ function cleanCaches() {
|
|
|
343
450
|
fetchArticlesMemory.clear();
|
|
344
451
|
}
|
|
345
452
|
|
|
346
|
-
function escapeValue(value) {
|
|
453
|
+
function escapeValue(value?: string) {
|
|
347
454
|
if (value) {
|
|
348
455
|
const shadowDomElement = document.createElement('textarea');
|
|
349
456
|
shadowDomElement.innerHTML = value;
|
|
@@ -353,14 +460,20 @@ function escapeValue(value) {
|
|
|
353
460
|
}
|
|
354
461
|
}
|
|
355
462
|
|
|
356
|
-
function dateValue(value) {
|
|
463
|
+
function dateValue(value?: string): string | null {
|
|
357
464
|
if (value) {
|
|
358
465
|
try {
|
|
359
466
|
return new Intl.DateTimeFormat('nl-BE').format(
|
|
360
467
|
new Date(Date.parse(value))
|
|
361
468
|
);
|
|
362
469
|
} catch (e) {
|
|
363
|
-
|
|
470
|
+
let message: string;
|
|
471
|
+
if (e instanceof Error) {
|
|
472
|
+
message = e.message;
|
|
473
|
+
} else {
|
|
474
|
+
message = e as string;
|
|
475
|
+
}
|
|
476
|
+
warn(`Error parsing date ${value}: ${message}`, {
|
|
364
477
|
id: 'date-parsing-error',
|
|
365
478
|
});
|
|
366
479
|
return null;
|
|
@@ -370,12 +483,18 @@ function dateValue(value) {
|
|
|
370
483
|
}
|
|
371
484
|
}
|
|
372
485
|
|
|
373
|
-
async function executeCountQuery(query, abortSignal) {
|
|
374
|
-
const response = await executeQuery(
|
|
375
|
-
|
|
486
|
+
async function executeCountQuery(query: string, abortSignal?: AbortSignal) {
|
|
487
|
+
const response = await executeQuery<{ count: { value: string } }>(
|
|
488
|
+
query,
|
|
489
|
+
abortSignal
|
|
490
|
+
);
|
|
491
|
+
return optionMapOr(0, parseInt, response.results.bindings[0]?.count.value);
|
|
376
492
|
}
|
|
377
493
|
|
|
378
|
-
async function executeQuery(
|
|
494
|
+
async function executeQuery<A>(
|
|
495
|
+
query: string,
|
|
496
|
+
abortSignal?: AbortSignal
|
|
497
|
+
): Promise<QueryResponse<A>> {
|
|
379
498
|
const encodedQuery = encodeURIComponent(query.trim());
|
|
380
499
|
const endpoint = `${SPARQL_ENDPOINT}`;
|
|
381
500
|
const response = await fetch(endpoint, {
|
|
@@ -389,7 +508,7 @@ async function executeQuery(query, abortSignal) {
|
|
|
389
508
|
});
|
|
390
509
|
|
|
391
510
|
if (response.ok) {
|
|
392
|
-
return response.json()
|
|
511
|
+
return response.json() as Promise<QueryResponse<A>>;
|
|
393
512
|
} else {
|
|
394
513
|
throw new Error(
|
|
395
514
|
`Request to Vlaamse Codex was unsuccessful: [${response.status}] ${response.statusText}`
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
|
|
3
|
+
export function insertVariableWidget(options?: unknown): WidgetSpec {
|
|
4
|
+
return {
|
|
5
|
+
componentName: 'insert-variable-plugin/insert-variable-card',
|
|
6
|
+
desiredLocation: 'sidebar',
|
|
7
|
+
widgetArgs: {
|
|
8
|
+
options,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { fetchCodeListsByPublisher } from './fetch-data';
|
|
1
|
+
import { CodeList, fetchCodeListsByPublisher } from './fetch-data';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type VariableType = {
|
|
4
|
+
label: string;
|
|
5
|
+
fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
|
|
6
|
+
template:
|
|
7
|
+
| string
|
|
8
|
+
| ((endpoint: string, selectedCodelist?: CodeList) => string);
|
|
9
|
+
};
|
|
10
|
+
export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
4
11
|
text: {
|
|
5
12
|
label: 'text',
|
|
6
13
|
template: `
|
|
@@ -30,7 +37,7 @@ export const defaultVariableTypes = {
|
|
|
30
37
|
},
|
|
31
38
|
location: {
|
|
32
39
|
label: 'location',
|
|
33
|
-
template: (endpoint) => `
|
|
40
|
+
template: (endpoint: string) => `
|
|
34
41
|
<span property="dct:type" content="location"></span>
|
|
35
42
|
<span property="dct:source" resource="${endpoint}"></span>
|
|
36
43
|
<span property="ext:content">
|
|
@@ -40,16 +47,20 @@ export const defaultVariableTypes = {
|
|
|
40
47
|
},
|
|
41
48
|
codelist: {
|
|
42
49
|
label: 'codelist',
|
|
43
|
-
fetchSubtypes: async (endpoint, publisher) => {
|
|
50
|
+
fetchSubtypes: async (endpoint: string, publisher: string) => {
|
|
44
51
|
const codelists = fetchCodeListsByPublisher(endpoint, publisher);
|
|
45
52
|
return codelists;
|
|
46
53
|
},
|
|
47
|
-
template: (endpoint, selectedCodelist) => `
|
|
48
|
-
<span property="ext:codelist" resource="${
|
|
54
|
+
template: (endpoint: string, selectedCodelist?: CodeList) => `
|
|
55
|
+
<span property="ext:codelist" resource="${
|
|
56
|
+
selectedCodelist?.uri ?? ''
|
|
57
|
+
}"></span>
|
|
49
58
|
<span property="dct:type" content="codelist"></span>
|
|
50
59
|
<span property="dct:source" resource="${endpoint}"></span>
|
|
51
60
|
<span property="ext:content">
|
|
52
|
-
<span class="mark-highlight-manual">\${${
|
|
61
|
+
<span class="mark-highlight-manual">\${${
|
|
62
|
+
selectedCodelist?.label ?? ''
|
|
63
|
+
}}</span>
|
|
53
64
|
</span>
|
|
54
65
|
`,
|
|
55
66
|
},
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { executeQuery } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
|
|
2
|
+
export type CodeList = {
|
|
3
|
+
uri?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function generateCodeListsByPublisherQuery(publisher: string): string {
|
|
8
|
+
const codeListOptionsQuery = `
|
|
9
|
+
PREFIX lblodMobilitiet: <http://data.lblod.info/vocabularies/mobiliteit/>
|
|
10
|
+
PREFIX dct: <http://purl.org/dc/terms/>
|
|
11
|
+
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
12
|
+
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
|
13
|
+
SELECT DISTINCT * WHERE {
|
|
14
|
+
?uri a lblodMobilitiet:Codelist;
|
|
15
|
+
skos:prefLabel ?label.
|
|
16
|
+
${
|
|
17
|
+
publisher
|
|
18
|
+
? `
|
|
19
|
+
?uri dct:publisher <${publisher}>.
|
|
20
|
+
`
|
|
21
|
+
: ''
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
return codeListOptionsQuery;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function fetchCodeListsByPublisher(
|
|
29
|
+
endpoint: string,
|
|
30
|
+
publisher: string
|
|
31
|
+
): Promise<CodeList[]> {
|
|
32
|
+
const codelistsOptionsQueryResult = await executeQuery(
|
|
33
|
+
endpoint,
|
|
34
|
+
generateCodeListsByPublisherQuery(publisher)
|
|
35
|
+
);
|
|
36
|
+
const bindings = codelistsOptionsQueryResult.results.bindings;
|
|
37
|
+
return bindings.map((binding) => ({
|
|
38
|
+
uri: binding['uri']?.value,
|
|
39
|
+
label: binding['label']?.value,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as modifyDate } from './modify-date';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Command, Mark } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
3
|
+
|
|
4
|
+
function formatDate(date: Date, onlyDate: boolean) {
|
|
5
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
6
|
+
year: 'numeric',
|
|
7
|
+
month: '2-digit',
|
|
8
|
+
day: '2-digit',
|
|
9
|
+
...(!onlyDate && {
|
|
10
|
+
hour: '2-digit',
|
|
11
|
+
minute: '2-digit',
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
return date.toLocaleString('nl-BE', options);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function modifyDate(
|
|
18
|
+
from: number,
|
|
19
|
+
to: number,
|
|
20
|
+
dateValue: Date,
|
|
21
|
+
onlyDate: boolean
|
|
22
|
+
): Command {
|
|
23
|
+
return function (state, dispatch) {
|
|
24
|
+
if (dispatch) {
|
|
25
|
+
const transaction = state.tr;
|
|
26
|
+
const node = unwrap(transaction.doc.nodeAt(from));
|
|
27
|
+
const currentRdfaMark = node.marks
|
|
28
|
+
.filter((mark) => mark.type.name === 'inline_rdfa')
|
|
29
|
+
.at(-1);
|
|
30
|
+
if (currentRdfaMark) {
|
|
31
|
+
transaction.removeMark(from, to, currentRdfaMark);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const newMark: Mark = currentRdfaMark
|
|
35
|
+
? state.schema.mark('inline_rdfa', {
|
|
36
|
+
...currentRdfaMark.attrs,
|
|
37
|
+
content: dateValue.toISOString(),
|
|
38
|
+
})
|
|
39
|
+
: state.schema.mark('inline_rdfa', {
|
|
40
|
+
content: dateValue.toISOString(),
|
|
41
|
+
});
|
|
42
|
+
transaction.addMark(from, to, newMark);
|
|
43
|
+
transaction.insertText(formatDate(dateValue, onlyDate), from, to);
|
|
44
|
+
dispatch(transaction);
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
|
|
3
|
+
export const rdfaDateCardWidget: WidgetSpec = {
|
|
4
|
+
componentName: 'rdfa-date-plugin/card',
|
|
5
|
+
desiredLocation: 'sidebar',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const rdfaDateInsertWidget: WidgetSpec = {
|
|
9
|
+
componentName: 'rdfa-date-plugin/insert',
|
|
10
|
+
desiredLocation: 'insertSidebar',
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const POTENTIALLY_ZONAL_URI =
|
|
2
|
+
'http://lblod.data.gift/concepts/8f9367b2-c717-4be7-8833-4c75bbb4ae1f';
|
|
3
|
+
|
|
4
|
+
export const ZONAL_URI =
|
|
5
|
+
'http://lblod.data.gift/concepts/c81c6b96-736a-48cf-b003-6f5cc3dbc55d';
|
|
6
|
+
|
|
7
|
+
export const NON_ZONAL_URI =
|
|
8
|
+
'http://lblod.data.gift/concepts/b651931b-923c-477c-8da9-fc7dd841fdcc';
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { POTENTIALLY_ZONAL_URI } from '
|
|
1
|
+
import { POTENTIALLY_ZONAL_URI } from './constants';
|
|
2
2
|
|
|
3
|
-
function buildFilters({
|
|
3
|
+
function buildFilters({
|
|
4
|
+
zonality,
|
|
5
|
+
type,
|
|
6
|
+
codes,
|
|
7
|
+
category,
|
|
8
|
+
}: {
|
|
9
|
+
zonality?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
codes?: string[];
|
|
12
|
+
category?: string;
|
|
13
|
+
}) {
|
|
4
14
|
const filters = [];
|
|
5
15
|
if (zonality) {
|
|
6
16
|
filters.push(
|
|
@@ -33,7 +43,14 @@ export function generateMeasuresQuery({
|
|
|
33
43
|
codes,
|
|
34
44
|
category,
|
|
35
45
|
pageStart = 0,
|
|
36
|
-
count,
|
|
46
|
+
count = false,
|
|
47
|
+
}: {
|
|
48
|
+
zonality?: string;
|
|
49
|
+
type?: string;
|
|
50
|
+
codes?: string[];
|
|
51
|
+
category?: string;
|
|
52
|
+
pageStart?: number;
|
|
53
|
+
count?: boolean;
|
|
37
54
|
}) {
|
|
38
55
|
const filters = buildFilters({ zonality, type, codes, category });
|
|
39
56
|
let pagination = '';
|