@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
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import {
|
|
4
|
+
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
5
|
import { inject as service } from '@ember/service';
|
|
6
6
|
import { capitalize } from '@ember/string';
|
|
7
7
|
import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
|
|
8
8
|
import {
|
|
9
|
-
LEGISLATION_TYPES,
|
|
10
9
|
LEGISLATION_TYPE_CONCEPTS,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
LEGISLATION_TYPES,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legislation-types';
|
|
12
|
+
import {
|
|
13
|
+
Article,
|
|
14
|
+
Decision,
|
|
15
|
+
fetchDecisions,
|
|
16
|
+
} from '../../../plugins/citation-plugin/utils/vlaamse-codex';
|
|
17
|
+
import IntlService from 'ember-intl/services/intl';
|
|
18
|
+
import {
|
|
19
|
+
Option,
|
|
20
|
+
unwrap,
|
|
21
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
13
22
|
|
|
14
|
-
function getISODate(date) {
|
|
23
|
+
function getISODate(date: Option<Date>): string | null {
|
|
15
24
|
if (date) {
|
|
16
25
|
// Flatpickr captures the date in local time. Hence date.toISOString() may return the day before the selected date
|
|
17
26
|
// E.g. selected date 2020-04-15 00:00:00 GMT+0200 will become 2020-04-14 22:00:00 UTC
|
|
@@ -24,27 +33,42 @@ function getISODate(date) {
|
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
interface Args {
|
|
37
|
+
selectedDecision: Decision;
|
|
38
|
+
legislationTypeUri: string;
|
|
39
|
+
text: string;
|
|
40
|
+
insertDecisionCitation: (decision: Decision) => void;
|
|
41
|
+
insertArticleCitation: (decision: Decision, article: Article) => void;
|
|
42
|
+
closeModal: (legislationTypeUri?: string, text?: string) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default class EditorPluginsCitationsSearchModalComponent extends Component<Args> {
|
|
46
|
+
@service declare intl: IntlService;
|
|
31
47
|
// Vlaamse Codex currently doesn't contain captions and content of decisions
|
|
32
48
|
// @tracked isEnabledSearchCaption = false
|
|
33
49
|
// @tracked isEnabledSearchContent = false
|
|
34
|
-
@tracked legislationTypeUri;
|
|
50
|
+
@tracked legislationTypeUri: string;
|
|
35
51
|
@tracked pageNumber = 0;
|
|
36
52
|
@tracked pageSize = 5;
|
|
37
|
-
@tracked totalCount;
|
|
53
|
+
@tracked totalCount = 0;
|
|
38
54
|
@tracked decisions = [];
|
|
39
|
-
@tracked error;
|
|
40
|
-
@tracked selectedDecision;
|
|
41
|
-
@tracked documentDateFrom = null;
|
|
42
|
-
@tracked documentDateTo = null;
|
|
43
|
-
@tracked publicationDateFrom = null;
|
|
44
|
-
@tracked publicationDateTo = null;
|
|
55
|
+
@tracked error: unknown;
|
|
56
|
+
@tracked selectedDecision: Decision | null;
|
|
57
|
+
@tracked documentDateFrom: Date | null = null;
|
|
58
|
+
@tracked documentDateTo: Date | null = null;
|
|
59
|
+
@tracked publicationDateFrom: Date | null = null;
|
|
60
|
+
@tracked publicationDateTo: Date | null = null;
|
|
61
|
+
@tracked inputSearchText: string | null = null;
|
|
45
62
|
minDate = new Date('1930-01-01T12:00:00');
|
|
46
63
|
maxDate = new Date(`${new Date().getFullYear() + 10}-01-01T12:00:00`);
|
|
47
64
|
|
|
65
|
+
constructor(owner: unknown, args: Args) {
|
|
66
|
+
super(owner, args);
|
|
67
|
+
this.selectedDecision = this.args.selectedDecision;
|
|
68
|
+
this.legislationTypeUri =
|
|
69
|
+
this.args.legislationTypeUri || LEGISLATION_TYPES['decreet'];
|
|
70
|
+
}
|
|
71
|
+
|
|
48
72
|
get datePickerLocalization() {
|
|
49
73
|
return {
|
|
50
74
|
buttonLabel: this.intl.t('auDatePicker.buttonLabel'),
|
|
@@ -62,14 +86,6 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
62
86
|
};
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
constructor() {
|
|
66
|
-
super(...arguments);
|
|
67
|
-
this.selectedDecision = this.args.selectedDecision;
|
|
68
|
-
this.legislationTypeUri =
|
|
69
|
-
this.args.legislationTypeUri || LEGISLATION_TYPES['decreet'];
|
|
70
|
-
this.text = this.args.text;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
89
|
get legislationTypes() {
|
|
74
90
|
return Object.keys(LEGISLATION_TYPES).map(capitalize);
|
|
75
91
|
}
|
|
@@ -78,31 +94,44 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
78
94
|
const found = LEGISLATION_TYPE_CONCEPTS.find(
|
|
79
95
|
(c) => c.value === this.legislationTypeUri
|
|
80
96
|
);
|
|
81
|
-
return capitalize(
|
|
97
|
+
return capitalize(
|
|
98
|
+
found ? found.label : unwrap(LEGISLATION_TYPE_CONCEPTS[0]).label
|
|
99
|
+
);
|
|
82
100
|
}
|
|
83
101
|
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
get text() {
|
|
103
|
+
return this.args.text;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get searchText() {
|
|
107
|
+
return this.inputSearchText ?? this.text;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get rangeStart() {
|
|
111
|
+
return this.pageNumber * this.pageSize + 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get rangeEnd() {
|
|
115
|
+
const end = this.rangeStart + this.pageSize - 1;
|
|
116
|
+
return end > this.totalCount ? this.totalCount : end;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get isFirstPage() {
|
|
120
|
+
return this.pageNumber == 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get isLastPage() {
|
|
124
|
+
return this.rangeEnd == this.totalCount;
|
|
125
|
+
}
|
|
94
126
|
|
|
95
|
-
|
|
96
|
-
|
|
127
|
+
resourceSearch = restartableTask(async () => {
|
|
128
|
+
await timeout(500);
|
|
97
129
|
this.error = null;
|
|
98
|
-
yield undefined; //To prevent retriggering because of the use of this.text later.
|
|
99
130
|
const abortController = new AbortController();
|
|
100
|
-
const signal = abortController.signal;
|
|
101
131
|
try {
|
|
102
132
|
// Split search string by grouping on non-whitespace characters
|
|
103
133
|
// This probably needs to be more complex to search on group of words
|
|
104
|
-
const words =
|
|
105
|
-
(this.textAfterTimeout || this.text || '').match(/\S+/g) || [];
|
|
134
|
+
const words = this.searchText.match(/\S+/g) || [];
|
|
106
135
|
const filter = {
|
|
107
136
|
type: this.legislationTypeUri,
|
|
108
137
|
documentDateFrom: getISODate(this.documentDateFrom),
|
|
@@ -110,12 +139,11 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
110
139
|
publicationDateFrom: getISODate(this.publicationDateFrom),
|
|
111
140
|
publicationDateTo: getISODate(this.publicationDateTo),
|
|
112
141
|
};
|
|
113
|
-
const results =
|
|
142
|
+
const results = await fetchDecisions(
|
|
114
143
|
words,
|
|
115
144
|
filter,
|
|
116
145
|
this.pageNumber,
|
|
117
|
-
this.pageSize
|
|
118
|
-
signal
|
|
146
|
+
this.pageSize
|
|
119
147
|
);
|
|
120
148
|
this.totalCount = results.totalCount;
|
|
121
149
|
return results.decisions;
|
|
@@ -128,72 +156,82 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
128
156
|
//Abort all requests now that this task has either successfully finished or has been cancelled
|
|
129
157
|
abortController.abort();
|
|
130
158
|
}
|
|
131
|
-
}
|
|
159
|
+
});
|
|
132
160
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
this.pageNumber
|
|
161
|
+
decisionResource = trackedTask(this, this.resourceSearch, () => [
|
|
162
|
+
this.searchText,
|
|
163
|
+
this.legislationTypeUri,
|
|
164
|
+
this.pageSize,
|
|
165
|
+
this.pageNumber,
|
|
166
|
+
this.documentDateFrom,
|
|
167
|
+
this.documentDateTo,
|
|
168
|
+
this.publicationDateFrom,
|
|
169
|
+
this.publicationDateTo,
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
@action
|
|
173
|
+
setInputSearchText(event: InputEvent) {
|
|
174
|
+
this.inputSearchText = (event.target as HTMLInputElement).value;
|
|
138
175
|
}
|
|
139
176
|
|
|
140
177
|
@action
|
|
141
|
-
selectLegislationType(type) {
|
|
178
|
+
selectLegislationType(type: string) {
|
|
142
179
|
type = type.toLowerCase();
|
|
143
180
|
const found = LEGISLATION_TYPE_CONCEPTS.find(
|
|
144
181
|
(c) => c.label.toLowerCase() === type
|
|
145
182
|
);
|
|
146
183
|
this.legislationTypeUri = found
|
|
147
184
|
? found.value
|
|
148
|
-
: LEGISLATION_TYPE_CONCEPTS[0].value;
|
|
185
|
+
: unwrap(LEGISLATION_TYPE_CONCEPTS[0]).value;
|
|
149
186
|
}
|
|
150
187
|
|
|
151
188
|
@action
|
|
152
|
-
updateDocumentDateFrom(
|
|
189
|
+
updateDocumentDateFrom(_isoDate: unknown, date: Date) {
|
|
153
190
|
this.documentDateFrom = date;
|
|
154
191
|
}
|
|
155
192
|
|
|
156
193
|
@action
|
|
157
|
-
updateDocumentDateTo(
|
|
194
|
+
updateDocumentDateTo(_isoDate: unknown, date: Date) {
|
|
158
195
|
this.documentDateTo = date;
|
|
159
196
|
}
|
|
160
197
|
|
|
161
198
|
@action
|
|
162
|
-
updatePublicationDateFrom(
|
|
199
|
+
updatePublicationDateFrom(_isoDate: unknown, date: Date) {
|
|
163
200
|
this.publicationDateFrom = date;
|
|
164
201
|
}
|
|
165
202
|
|
|
166
203
|
@action
|
|
167
|
-
updatePublicationDateTo(
|
|
204
|
+
updatePublicationDateTo(_isoDate: unknown, date: Date) {
|
|
168
205
|
this.publicationDateTo = date;
|
|
169
206
|
}
|
|
170
207
|
|
|
171
208
|
@action
|
|
172
|
-
insertDecisionCitation(decision) {
|
|
209
|
+
async insertDecisionCitation(decision: Decision) {
|
|
173
210
|
this.args.insertDecisionCitation(decision);
|
|
174
|
-
this.closeModal();
|
|
211
|
+
await this.closeModal();
|
|
175
212
|
}
|
|
176
213
|
|
|
177
214
|
@action
|
|
178
|
-
insertArticleCitation(decision, article) {
|
|
215
|
+
async insertArticleCitation(decision: Decision, article: Article) {
|
|
179
216
|
this.args.insertArticleCitation(decision, article);
|
|
180
|
-
this.closeModal();
|
|
217
|
+
await this.closeModal();
|
|
181
218
|
}
|
|
182
219
|
|
|
183
220
|
@action
|
|
184
|
-
closeModal(legislationTypeUri, text) {
|
|
185
|
-
this.decisionResource.cancel();
|
|
221
|
+
async closeModal(legislationTypeUri?: string, text?: string) {
|
|
222
|
+
await this.decisionResource.cancel();
|
|
223
|
+
this.inputSearchText = null;
|
|
186
224
|
this.args.closeModal(legislationTypeUri, text);
|
|
187
225
|
}
|
|
188
226
|
|
|
189
227
|
@action
|
|
190
|
-
|
|
191
|
-
this.selectedDecision =
|
|
228
|
+
openDecisionDetail(decision: Decision) {
|
|
229
|
+
this.selectedDecision = decision;
|
|
192
230
|
}
|
|
193
231
|
|
|
194
232
|
@action
|
|
195
|
-
|
|
196
|
-
this.selectedDecision =
|
|
233
|
+
closeDecisionDetail() {
|
|
234
|
+
this.selectedDecision = null;
|
|
197
235
|
}
|
|
198
236
|
|
|
199
237
|
// Pagination
|
|
@@ -207,37 +245,26 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
207
245
|
nextPage() {
|
|
208
246
|
++this.pageNumber;
|
|
209
247
|
}
|
|
210
|
-
|
|
211
|
-
get rangeStart() {
|
|
212
|
-
return this.pageNumber * this.pageSize + 1;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
get rangeEnd() {
|
|
216
|
-
const end = this.rangeStart + this.pageSize - 1;
|
|
217
|
-
return end > this.totalCount ? this.totalCount : end;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
get isFirstPage() {
|
|
221
|
-
return this.pageNumber == 0;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
get isLastPage() {
|
|
225
|
-
return this.rangeEnd == this.totalCount;
|
|
226
|
-
}
|
|
227
248
|
}
|
|
228
249
|
|
|
229
|
-
function getLocalizedMonths(
|
|
230
|
-
|
|
250
|
+
function getLocalizedMonths(
|
|
251
|
+
intl: IntlService,
|
|
252
|
+
monthFormat: Intl.DateTimeFormatOptions['month'] = 'long'
|
|
253
|
+
) {
|
|
254
|
+
const someYear = 2021;
|
|
231
255
|
return [...Array(12).keys()].map((monthIndex) => {
|
|
232
|
-
|
|
256
|
+
const date = new Date(someYear, monthIndex);
|
|
233
257
|
return intl.formatDate(date, { month: monthFormat });
|
|
234
258
|
});
|
|
235
259
|
}
|
|
236
260
|
|
|
237
|
-
function getLocalizedDays(
|
|
238
|
-
|
|
261
|
+
function getLocalizedDays(
|
|
262
|
+
intl: IntlService,
|
|
263
|
+
weekdayFormat: Intl.DateTimeFormatOptions['weekday'] = 'long'
|
|
264
|
+
) {
|
|
265
|
+
const someSunday = new Date('2021-01-03');
|
|
239
266
|
return [...Array(7).keys()].map((index) => {
|
|
240
|
-
|
|
267
|
+
const weekday = new Date(someSunday.getTime());
|
|
241
268
|
weekday.setDate(someSunday.getDate() + index);
|
|
242
269
|
return intl.formatDate(weekday, { weekday: weekdayFormat });
|
|
243
270
|
});
|
|
File without changes
|
|
File without changes
|
|
@@ -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 { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
7
|
+
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_VARIABLE_TYPES,
|
|
10
|
+
VariableType,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/insert-variable-plugin/utils/constants';
|
|
12
|
+
import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/insert-variable-plugin/utils/fetch-data';
|
|
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 = DEFAULT_VARIABLE_TYPES[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 '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin/commands';
|
|
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
|