@lblod/ember-rdfa-editor-lblod-plugins 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-it.json +14 -0
- package/.woodpecker/.release.yml +15 -0
- package/.woodpecker/.test.yml +23 -0
- package/CHANGELOG.md +84 -0
- package/README.md +311 -14
- package/RELEASE.md +60 -0
- package/addon/commands/generate-template-command.js +35 -0
- package/addon/commands/insert-and-collapse.js +32 -0
- package/addon/commands/modify-date-command.js +42 -0
- package/addon/components/besluit-type-plugin/besluit-type-select.hbs +28 -0
- package/addon/components/besluit-type-plugin/besluit-type-select.js +21 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +83 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.js +188 -0
- package/addon/components/citaten-plugin/citaat-card.hbs +76 -0
- package/addon/components/citaten-plugin/citaat-card.js +286 -0
- package/addon/components/citaten-plugin/citaat-insert.hbs +20 -0
- package/addon/components/citaten-plugin/citaat-insert.js +68 -0
- package/addon/components/citaten-plugin/citations/article-list.hbs +13 -0
- package/addon/components/citaten-plugin/citations/article-preview.hbs +16 -0
- package/addon/components/citaten-plugin/citations/decision-detail.hbs +110 -0
- package/addon/components/citaten-plugin/citations/decision-detail.js +94 -0
- package/addon/components/citaten-plugin/citations/decision-list.hbs +15 -0
- package/addon/components/citaten-plugin/citations/decision-preview.hbs +53 -0
- package/addon/components/citaten-plugin/citations/search-modal.hbs +175 -0
- package/addon/components/citaten-plugin/citations/search-modal.js +244 -0
- package/addon/components/citaten-plugin/helpers/alert-load-error.hbs +21 -0
- package/addon/components/citaten-plugin/helpers/alert-no-items.hbs +10 -0
- package/addon/components/import-snippet-plugin/card.hbs +17 -0
- package/addon/components/import-snippet-plugin/card.js +95 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.hbs +33 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.js +125 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.hbs +22 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +64 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.hbs +18 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +24 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-time-picker.hbs +21 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-time-picker.js +73 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +44 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.js +38 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.hbs +5 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.js +30 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +12 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +101 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +92 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.js +268 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +25 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.js +55 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +73 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +24 -0
- package/addon/components/standard-template-plugin/template-card.hbs +16 -0
- package/addon/components/standard-template-plugin/template-card.js +7 -0
- package/addon/components/standard-template-plugin/template-provider.hbs +6 -0
- package/addon/components/standard-template-plugin/template-provider.js +75 -0
- package/addon/components/table-of-contents-plugin/card.hbs +5 -0
- package/addon/components/table-of-contents-plugin/card.js +53 -0
- package/addon/components/table-of-contents-plugin/inline-components/outline.hbs +21 -0
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +9 -0
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +100 -0
- package/addon/components/template-variable-plugin/template-variable-card.hbs +34 -0
- package/addon/components/template-variable-plugin/template-variable-card.js +230 -0
- package/addon/constants.js +24 -0
- package/{dist → addon}/helpers/limit-text.js +1 -4
- package/addon/initializers/plugin-initializer.js +75 -0
- package/addon/inline-components/table-of-contents.js +43 -0
- package/addon/marks/citaten-mark.js +32 -0
- package/addon/models/instruction.js +19 -0
- package/addon/models/measure.js +46 -0
- package/{dist → addon}/models/sign.js +12 -13
- package/addon/models/template.js +9 -0
- package/addon/plugins/besluit-type-plugin.js +16 -0
- package/addon/plugins/citaten-plugin.js +22 -0
- package/addon/plugins/generate-template-plugin.js +16 -0
- package/addon/plugins/import-snippet-plugin.js +16 -0
- package/addon/plugins/insert-variable-plugin.js +19 -0
- package/addon/plugins/rdfa-date-plugin.js +26 -0
- package/addon/plugins/roadsign-regulation-plugin.js +24 -0
- package/addon/plugins/standard-template-plugin.js +33 -0
- package/addon/plugins/table-of-contents-plugin.js +27 -0
- package/addon/plugins/template-variable-plugin.js +21 -0
- package/addon/serializers/application.js +8 -0
- package/{dist → addon}/services/import-rdfa-snippet.js +28 -18
- package/{dist → addon}/services/roadsign-registry.js +67 -121
- package/addon/services/standard-template-plugin.js +45 -0
- package/addon/utils/fetchBesluitTypes.js +90 -0
- package/addon/utils/generate-template-plugin/default-resources.js +9 -0
- package/addon/utils/instantiate-uuids.js +34 -0
- package/addon/utils/legislation-types.js +32 -0
- package/addon/utils/memoize.js +8 -0
- package/addon/utils/processMatch.js +80 -0
- package/addon/utils/roadsign-regulation-plugin/fetchData.js +78 -0
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +10 -0
- package/addon/utils/variable-plugins/default-variable-types.js +56 -0
- package/{dist/fetch-data-284bf106.js → addon/utils/variable-plugins/fetch-data.js} +36 -18
- package/{dist/vlaamse-codex-187fe526.js → addon/utils/vlaamse-codex.js} +159 -63
- package/app/components/besluit-type-plugin/besluit-type-select.js +1 -0
- package/app/components/besluit-type-plugin/toolbar-dropdown.js +1 -0
- package/app/components/citaten-plugin/citaat-card.js +1 -0
- package/app/components/citaten-plugin/citaat-insert.js +1 -0
- package/app/components/citaten-plugin/citations/article-list.js +1 -0
- package/app/components/citaten-plugin/citations/article-preview.js +1 -0
- package/app/components/citaten-plugin/citations/decision-detail.js +1 -0
- package/app/components/citaten-plugin/citations/decision-list.js +1 -0
- package/app/components/citaten-plugin/citations/decision-preview.js +1 -0
- package/app/components/citaten-plugin/citations/modal.js +1 -0
- package/app/components/citaten-plugin/citations/search-modal.js +1 -0
- package/app/components/citaten-plugin/helpers/alert-load-error.js +1 -0
- package/app/components/citaten-plugin/helpers/alert-no-items.js +1 -0
- package/app/components/import-snippet-plugin/card.js +1 -0
- package/app/components/insert-variable-plugin/insert-variable-card.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +1 -0
- package/app/components/roadsign-regulation-plugin/expanded-measure.js +1 -0
- package/app/components/roadsign-regulation-plugin/measure-template.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsign-regulation-card.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-modal.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-pagination.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-table.js +1 -0
- package/app/components/standard-template-plugin/template-card.js +1 -0
- package/app/components/standard-template-plugin/template-provider.js +1 -0
- package/app/components/table-of-contents-plugin/card.js +1 -0
- package/app/components/table-of-contents-plugin/inline-components/outline.js +1 -0
- package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +1 -0
- package/app/components/template-variable-plugin/template-variable-card.js +1 -0
- package/app/helpers/limit-text.js +4 -0
- package/app/initializers/plugin-initializer.js +4 -0
- package/app/models/instruction.js +1 -0
- package/app/models/measure.js +1 -0
- package/app/models/sign.js +1 -0
- package/app/models/template.js +1 -0
- package/app/serializers/application.js +1 -0
- package/app/services/import-rdfa-snippet.js +1 -0
- package/app/services/rdfa-editor-roadsign-regulation-plugin.js +1 -0
- package/app/services/roadsign-registry.js +1 -0
- package/app/services/standard-template-plugin.js +1 -0
- package/{dist → app}/styles/citaten-plugin.scss +0 -0
- package/config/environment.js +0 -1
- package/index.js +8 -0
- package/package.json +112 -107
- package/tsconfig.json +42 -0
- package/types/dummy/index.d.ts +1 -0
- package/types/ember-data/types/registries/model.d.ts +6 -0
- package/types/global.d.ts +7 -0
- package/addon-main.js +0 -4
- package/dist/_app_/components/besluit-type-plugin/besluit-type-select.js +0 -1
- package/dist/_app_/components/besluit-type-plugin/toolbar-dropdown.js +0 -1
- package/dist/_app_/components/citaten-plugin/citaat-card.js +0 -1
- package/dist/_app_/components/citaten-plugin/citaat-insert.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/article-list.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/article-preview.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-detail.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-list.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-preview.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/search-modal.js +0 -1
- package/dist/_app_/components/citaten-plugin/helpers/alert-load-error.js +0 -1
- package/dist/_app_/components/citaten-plugin/helpers/alert-no-items.js +0 -1
- package/dist/_app_/components/import-snippet-plugin/card.js +0 -1
- package/dist/_app_/components/insert-variable-plugin/insert-variable-card.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/expanded-measure.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/measure-template.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-modal.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-pagination.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-table.js +0 -1
- package/dist/_app_/components/standard-template-plugin/template-card.js +0 -1
- package/dist/_app_/components/standard-template-plugin/template-provider.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/card.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/inline-components/outline.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
- package/dist/_app_/components/template-variable-plugin/template-variable-card.js +0 -1
- package/dist/_app_/helpers/limit-text.js +0 -1
- package/dist/_app_/initializers/plugin-initializer.js +0 -1
- package/dist/_app_/models/instruction.js +0 -1
- package/dist/_app_/models/measure.js +0 -1
- package/dist/_app_/models/sign.js +0 -1
- package/dist/_app_/models/template.js +0 -1
- package/dist/_app_/serializers/application.js +0 -1
- package/dist/_app_/services/import-rdfa-snippet.js +0 -1
- package/dist/_app_/services/roadsign-registry.js +0 -1
- package/dist/_app_/services/standard-template-plugin.js +0 -1
- package/dist/_rollupPluginBabelHelpers-537ad14b.js +0 -48
- package/dist/_rollupPluginBabelHelpers-537ad14b.js.map +0 -1
- package/dist/components/besluit-type-plugin/besluit-type-select.js +0 -30
- package/dist/components/besluit-type-plugin/besluit-type-select.js.map +0 -1
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js +0 -292
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js.map +0 -1
- package/dist/components/citaten-plugin/citaat-card.js +0 -367
- package/dist/components/citaten-plugin/citaat-card.js.map +0 -1
- package/dist/components/citaten-plugin/citaat-insert.js +0 -84
- package/dist/components/citaten-plugin/citaat-insert.js.map +0 -1
- package/dist/components/citaten-plugin/citations/article-list.js +0 -10
- package/dist/components/citaten-plugin/citations/article-list.js.map +0 -1
- package/dist/components/citaten-plugin/citations/article-preview.js +0 -10
- package/dist/components/citaten-plugin/citations/article-preview.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-detail.js +0 -123
- package/dist/components/citaten-plugin/citations/decision-detail.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-list.js +0 -10
- package/dist/components/citaten-plugin/citations/decision-list.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-preview.js +0 -10
- package/dist/components/citaten-plugin/citations/decision-preview.js.map +0 -1
- package/dist/components/citaten-plugin/citations/search-modal.js +0 -282
- package/dist/components/citaten-plugin/citations/search-modal.js.map +0 -1
- package/dist/components/citaten-plugin/helpers/alert-load-error.js +0 -10
- package/dist/components/citaten-plugin/helpers/alert-load-error.js.map +0 -1
- package/dist/components/citaten-plugin/helpers/alert-no-items.js +0 -10
- package/dist/components/citaten-plugin/helpers/alert-no-items.js.map +0 -1
- package/dist/components/import-snippet-plugin/card.js +0 -99
- package/dist/components/import-snippet-plugin/card.js.map +0 -1
- package/dist/components/insert-variable-plugin/insert-variable-card.js +0 -190
- package/dist/components/insert-variable-plugin/insert-variable-card.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -85
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -23
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -91
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/expanded-measure.js +0 -52
- package/dist/components/roadsign-regulation-plugin/expanded-measure.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/measure-template.js +0 -42
- package/dist/components/roadsign-regulation-plugin/measure-template.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -82
- package/dist/components/roadsign-regulation-plugin/roadsign-regulation-card.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-modal.js +0 -251
- package/dist/components/roadsign-regulation-plugin/roadsigns-modal.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-pagination.js +0 -71
- package/dist/components/roadsign-regulation-plugin/roadsigns-pagination.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-table.js +0 -36
- package/dist/components/roadsign-regulation-plugin/roadsigns-table.js.map +0 -1
- package/dist/components/standard-template-plugin/template-card.js +0 -15
- package/dist/components/standard-template-plugin/template-card.js.map +0 -1
- package/dist/components/standard-template-plugin/template-provider.js +0 -109
- package/dist/components/standard-template-plugin/template-provider.js.map +0 -1
- package/dist/components/table-of-contents-plugin/card.js +0 -52
- package/dist/components/table-of-contents-plugin/card.js.map +0 -1
- package/dist/components/table-of-contents-plugin/inline-components/outline.js +0 -10
- package/dist/components/table-of-contents-plugin/inline-components/outline.js.map +0 -1
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -92
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js.map +0 -1
- package/dist/components/template-variable-plugin/template-variable-card.js +0 -178
- package/dist/components/template-variable-plugin/template-variable-card.js.map +0 -1
- package/dist/constants-c77fd478.js +0 -16
- package/dist/constants-c77fd478.js.map +0 -1
- package/dist/fetch-data-284bf106.js.map +0 -1
- package/dist/helpers/limit-text.js.map +0 -1
- package/dist/includeInstructions-a32c24e6.js +0 -10
- package/dist/includeInstructions-a32c24e6.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/initializers/plugin-initializer.js +0 -401
- package/dist/initializers/plugin-initializer.js.map +0 -1
- package/dist/legislation-types-4d487cb9.js +0 -26
- package/dist/legislation-types-4d487cb9.js.map +0 -1
- package/dist/models/instruction.js +0 -18
- package/dist/models/instruction.js.map +0 -1
- package/dist/models/measure.js +0 -41
- package/dist/models/measure.js.map +0 -1
- package/dist/models/sign.js.map +0 -1
- package/dist/models/template.js +0 -48
- package/dist/models/template.js.map +0 -1
- package/dist/serializers/application.js +0 -10
- package/dist/serializers/application.js.map +0 -1
- package/dist/services/import-rdfa-snippet.js.map +0 -1
- package/dist/services/roadsign-registry.js.map +0 -1
- package/dist/services/standard-template-plugin.js +0 -53
- package/dist/services/standard-template-plugin.js.map +0 -1
- package/dist/styles/test.css +0 -0
- package/dist/vlaamse-codex-187fe526.js.map +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { task, timeout } from 'ember-concurrency';
|
|
5
|
+
import { inject as service } from '@ember/service';
|
|
6
|
+
import { capitalize } from '@ember/string';
|
|
7
|
+
import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
|
|
8
|
+
import {
|
|
9
|
+
LEGISLATION_TYPES,
|
|
10
|
+
LEGISLATION_TYPE_CONCEPTS,
|
|
11
|
+
} from '../../../utils/legislation-types';
|
|
12
|
+
import { fetchDecisions } from '../../../utils/vlaamse-codex';
|
|
13
|
+
|
|
14
|
+
function getISODate(date) {
|
|
15
|
+
if (date) {
|
|
16
|
+
// Flatpickr captures the date in local time. Hence date.toISOString() may return the day before the selected date
|
|
17
|
+
// E.g. selected date 2020-04-15 00:00:00 GMT+0200 will become 2020-04-14 22:00:00 UTC
|
|
18
|
+
// We will pretend the selected date is UTC because that's what's meant as date for filtering
|
|
19
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
20
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
21
|
+
return `${date.getFullYear()}-${month}-${day}`;
|
|
22
|
+
} else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default class EditorPluginsCitationsSearchModalComponent extends Component {
|
|
28
|
+
@service intl;
|
|
29
|
+
@tracked text;
|
|
30
|
+
@tracked textAfterTimeout;
|
|
31
|
+
// Vlaamse Codex currently doesn't contain captions and content of decisions
|
|
32
|
+
// @tracked isEnabledSearchCaption = false
|
|
33
|
+
// @tracked isEnabledSearchContent = false
|
|
34
|
+
@tracked legislationTypeUri;
|
|
35
|
+
@tracked pageNumber = 0;
|
|
36
|
+
@tracked pageSize = 5;
|
|
37
|
+
@tracked totalCount;
|
|
38
|
+
@tracked decisions = [];
|
|
39
|
+
@tracked error;
|
|
40
|
+
@tracked selectedDecision;
|
|
41
|
+
@tracked documentDateFrom = null;
|
|
42
|
+
@tracked documentDateTo = null;
|
|
43
|
+
@tracked publicationDateFrom = null;
|
|
44
|
+
@tracked publicationDateTo = null;
|
|
45
|
+
minDate = new Date('1930-01-01T12:00:00');
|
|
46
|
+
maxDate = new Date(`${new Date().getFullYear() + 10}-01-01T12:00:00`);
|
|
47
|
+
|
|
48
|
+
get datePickerLocalization() {
|
|
49
|
+
return {
|
|
50
|
+
buttonLabel: this.intl.t('auDatePicker.buttonLabel'),
|
|
51
|
+
selectedDateMessage: this.intl.t('auDatePicker.selectedDateMessage'),
|
|
52
|
+
prevMonthLabel: this.intl.t('auDatePicker.prevMonthLabel'),
|
|
53
|
+
nextMonthLabel: this.intl.t('auDatePicker.nextMonthLabel'),
|
|
54
|
+
monthSelectLabel: this.intl.t('auDatePicker.monthSelectLabel'),
|
|
55
|
+
yearSelectLabel: this.intl.t('auDatePicker.yearSelectLabel'),
|
|
56
|
+
closeLabel: this.intl.t('auDatePicker.closeLabel'),
|
|
57
|
+
keyboardInstruction: this.intl.t('auDatePicker.keyboardInstruction'),
|
|
58
|
+
calendarHeading: this.intl.t('auDatePicker.calendarHeading'),
|
|
59
|
+
dayNames: getLocalizedDays(this.intl),
|
|
60
|
+
monthNames: getLocalizedMonths(this.intl),
|
|
61
|
+
monthNamesShort: getLocalizedMonths(this.intl, 'short'),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
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
|
+
get legislationTypes() {
|
|
74
|
+
return Object.keys(LEGISLATION_TYPES).map(capitalize);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get legislationSelected() {
|
|
78
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find(
|
|
79
|
+
(c) => c.value === this.legislationTypeUri
|
|
80
|
+
);
|
|
81
|
+
return capitalize(found ? found.label : LEGISLATION_TYPE_CONCEPTS[0].label);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
decisionResource = trackedTask(this, this.resourceSearch, () => [
|
|
85
|
+
this.textAfterTimeout,
|
|
86
|
+
this.legislationTypeUri,
|
|
87
|
+
this.pageSize,
|
|
88
|
+
this.pageNumber,
|
|
89
|
+
this.documentDateFrom,
|
|
90
|
+
this.documentDateTo,
|
|
91
|
+
this.publicationDateFrom,
|
|
92
|
+
this.publicationDateTo,
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
@task({ restartable: true })
|
|
96
|
+
*resourceSearch() {
|
|
97
|
+
this.error = null;
|
|
98
|
+
yield undefined; //To prevent retriggering because of the use of this.text later.
|
|
99
|
+
const abortController = new AbortController();
|
|
100
|
+
const signal = abortController.signal;
|
|
101
|
+
try {
|
|
102
|
+
// Split search string by grouping on non-whitespace characters
|
|
103
|
+
// This probably needs to be more complex to search on group of words
|
|
104
|
+
const words =
|
|
105
|
+
(this.textAfterTimeout || this.text || '').match(/\S+/g) || [];
|
|
106
|
+
const filter = {
|
|
107
|
+
type: this.legislationTypeUri,
|
|
108
|
+
documentDateFrom: getISODate(this.documentDateFrom),
|
|
109
|
+
documentDateTo: getISODate(this.documentDateTo),
|
|
110
|
+
publicationDateFrom: getISODate(this.publicationDateFrom),
|
|
111
|
+
publicationDateTo: getISODate(this.publicationDateTo),
|
|
112
|
+
};
|
|
113
|
+
const results = yield fetchDecisions(
|
|
114
|
+
words,
|
|
115
|
+
filter,
|
|
116
|
+
this.pageNumber,
|
|
117
|
+
this.pageSize,
|
|
118
|
+
signal
|
|
119
|
+
);
|
|
120
|
+
this.totalCount = results.totalCount;
|
|
121
|
+
return results.decisions;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.warn(e); // eslint-ignore-line no-console
|
|
124
|
+
this.totalCount = 0;
|
|
125
|
+
this.error = e;
|
|
126
|
+
return [];
|
|
127
|
+
} finally {
|
|
128
|
+
//Abort all requests now that this task has either successfully finished or has been cancelled
|
|
129
|
+
abortController.abort();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@task({ restartable: true })
|
|
134
|
+
*updateSearch() {
|
|
135
|
+
yield timeout(500);
|
|
136
|
+
this.textAfterTimeout = this.text;
|
|
137
|
+
this.pageNumber = 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@action
|
|
141
|
+
selectLegislationType(type) {
|
|
142
|
+
type = type.toLowerCase();
|
|
143
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find(
|
|
144
|
+
(c) => c.label.toLowerCase() === type
|
|
145
|
+
);
|
|
146
|
+
this.legislationTypeUri = found
|
|
147
|
+
? found.value
|
|
148
|
+
: LEGISLATION_TYPE_CONCEPTS[0].value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@action
|
|
152
|
+
updateDocumentDateFrom(isoDate, date) {
|
|
153
|
+
this.documentDateFrom = date;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@action
|
|
157
|
+
updateDocumentDateTo(isoDate, date) {
|
|
158
|
+
this.documentDateTo = date;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@action
|
|
162
|
+
updatePublicationDateFrom(isoDate, date) {
|
|
163
|
+
this.publicationDateFrom = date;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@action
|
|
167
|
+
updatePublicationDateTo(isoDate, date) {
|
|
168
|
+
this.publicationDateTo = date;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@action
|
|
172
|
+
insertDecisionCitation(decision) {
|
|
173
|
+
this.args.insertDecisionCitation(decision);
|
|
174
|
+
this.closeModal();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@action
|
|
178
|
+
insertArticleCitation(decision, article) {
|
|
179
|
+
this.args.insertArticleCitation(decision, article);
|
|
180
|
+
this.closeModal();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@action
|
|
184
|
+
closeModal(legislationTypeUri, text) {
|
|
185
|
+
this.decisionResource.cancel();
|
|
186
|
+
this.args.closeModal(legislationTypeUri, text);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@action
|
|
190
|
+
closeDecisionDetail() {
|
|
191
|
+
this.selectedDecision = null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@action
|
|
195
|
+
openDecisionDetail(decision) {
|
|
196
|
+
this.selectedDecision = decision;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Pagination
|
|
200
|
+
|
|
201
|
+
@action
|
|
202
|
+
previousPage() {
|
|
203
|
+
--this.pageNumber;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@action
|
|
207
|
+
nextPage() {
|
|
208
|
+
++this.pageNumber;
|
|
209
|
+
}
|
|
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
|
+
}
|
|
228
|
+
|
|
229
|
+
function getLocalizedMonths(intl, monthFormat = 'long') {
|
|
230
|
+
let someYear = 2021;
|
|
231
|
+
return [...Array(12).keys()].map((monthIndex) => {
|
|
232
|
+
let date = new Date(someYear, monthIndex);
|
|
233
|
+
return intl.formatDate(date, { month: monthFormat });
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function getLocalizedDays(intl, weekdayFormat = 'long') {
|
|
238
|
+
let someSunday = new Date('2021-01-03');
|
|
239
|
+
return [...Array(7).keys()].map((index) => {
|
|
240
|
+
let weekday = new Date(someSunday.getTime());
|
|
241
|
+
weekday.setDate(someSunday.getDate() + index);
|
|
242
|
+
return intl.formatDate(weekday, { weekday: weekdayFormat });
|
|
243
|
+
});
|
|
244
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<AuAlert
|
|
2
|
+
@alertTitle="{{t "citaten-plugin.citaten-plugin.alert.error-title"}}"
|
|
3
|
+
@alertSkin="error"
|
|
4
|
+
@alertIcon="alert-triangle"
|
|
5
|
+
@alertSize="{{if @fullSize "default" "small"}}"
|
|
6
|
+
@closable={{false}}
|
|
7
|
+
...attributes>
|
|
8
|
+
<p>{{t "citaten-plugin.alert.error-intro"}}</p>
|
|
9
|
+
<code class="au-u-error citaten--error-code">{{@error}}</code>
|
|
10
|
+
<p>
|
|
11
|
+
{{t "citaten-plugin.alert.error-outro"}}
|
|
12
|
+
<AuLinkExternal
|
|
13
|
+
href="mailto:Gelinkt-Notuleren@vlaanderen.be"
|
|
14
|
+
@icon="mail"
|
|
15
|
+
@iconAlignment="left">
|
|
16
|
+
{{!-- template-lint-disable no-bare-strings --}}
|
|
17
|
+
Gelinkt-Notuleren@vlaanderen.be
|
|
18
|
+
</AuLinkExternal>.
|
|
19
|
+
</p>
|
|
20
|
+
</AuAlert>
|
|
21
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<AuAlert
|
|
2
|
+
@alertTitle="{{t "citaten-plugin.citaten-plugin.alert.no-results"}}"
|
|
3
|
+
@alertSkin="warning"
|
|
4
|
+
@alertIcon="cross"
|
|
5
|
+
@alertSize="{{if @fullSize "default" "small"}}"
|
|
6
|
+
@closable={{false}}
|
|
7
|
+
class="{{unless @fullSize "au-u-margin-small"}}"
|
|
8
|
+
...attributes>
|
|
9
|
+
</AuAlert>
|
|
10
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{#each this.snippets as |snippet|}}
|
|
2
|
+
<AuCard @flex={{true}} @divided={{true}} @expandable={{true}} @shadow={{true}} @isOpenInitially={{true}} @size="small" as |c|>
|
|
3
|
+
<c.header>
|
|
4
|
+
<AuHeading @level="3" @skin="6">
|
|
5
|
+
Document importeren
|
|
6
|
+
</AuHeading>
|
|
7
|
+
</c.header>
|
|
8
|
+
<c.content>
|
|
9
|
+
<p class="u-spacer--tiny">Er is een <a href="{{snippet.source}}" target="_blank" rel="noopener noreferrer">document</a> beschikbaar</p>
|
|
10
|
+
<p><strong>Wenst u dit document in te voegen?</strong></p>
|
|
11
|
+
{{#if this.besluitNode}}
|
|
12
|
+
<AuButton {{on "click" (fn this.insert snippet 'attachment')}} >Bijlage invoegen</AuButton>
|
|
13
|
+
{{/if}}
|
|
14
|
+
<AuButton {{on "click" (fn this.insert snippet)}} >Document invoegen</AuButton>
|
|
15
|
+
</c.content>
|
|
16
|
+
</AuCard>
|
|
17
|
+
{{/each}}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
|
|
6
|
+
export default class ImportSnippetPluginCard extends Component {
|
|
7
|
+
@service importRdfaSnippet;
|
|
8
|
+
@tracked snippets = [];
|
|
9
|
+
@tracked besluitNode;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.args.controller.onEvent(
|
|
14
|
+
'selectionChanged',
|
|
15
|
+
this.selectionChangedHandler
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@action
|
|
20
|
+
selectionChangedHandler() {
|
|
21
|
+
const { controller } = this.args;
|
|
22
|
+
const selectedRange = controller.selection.lastRange;
|
|
23
|
+
if (!selectedRange) {
|
|
24
|
+
console.info(
|
|
25
|
+
'Selection did not have a range, skipping handling of the selectionChanged event'
|
|
26
|
+
);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.snippets = this.importRdfaSnippet.snippetsForType('roadsign');
|
|
30
|
+
const limitedDatastore = controller.datastore.limitToRange(
|
|
31
|
+
selectedRange,
|
|
32
|
+
'rangeIsInside'
|
|
33
|
+
);
|
|
34
|
+
const besluit = limitedDatastore
|
|
35
|
+
.match(null, 'a', '>http://data.vlaanderen.be/ns/besluit#Besluit')
|
|
36
|
+
.asSubjectNodes()
|
|
37
|
+
.next().value;
|
|
38
|
+
if (besluit) {
|
|
39
|
+
this.besluitNode = [...besluit.nodes][0];
|
|
40
|
+
} else {
|
|
41
|
+
this.besluitNode = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@action
|
|
46
|
+
insert(snippet, type) {
|
|
47
|
+
const html = this.generateSnippetHtml(snippet, type);
|
|
48
|
+
let rangeToInsert;
|
|
49
|
+
if (this.besluitNode) {
|
|
50
|
+
rangeToInsert = this.args.controller.rangeFactory.fromInNode(
|
|
51
|
+
this.besluitNode,
|
|
52
|
+
this.besluitNode.getMaxOffset(),
|
|
53
|
+
this.besluitNode.getMaxOffset()
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
rangeToInsert = this.args.controller.selection.lastRange;
|
|
57
|
+
}
|
|
58
|
+
if (rangeToInsert) {
|
|
59
|
+
this.args.controller.executeCommand('insert-html', html, rangeToInsert);
|
|
60
|
+
this.importRdfaSnippet.removeSnippet(snippet);
|
|
61
|
+
} else {
|
|
62
|
+
console.warn('Could not find a range to insert, so we skipped inserting');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
generateSnippetHtml(snippet, type) {
|
|
67
|
+
if (type === 'attachment') {
|
|
68
|
+
return `
|
|
69
|
+
<div property="http://lblod.data.gift/vocabularies/editor/isLumpNode">
|
|
70
|
+
<div
|
|
71
|
+
resource="${snippet.source}"
|
|
72
|
+
property="http://data.europa.eu/eli/ontology#related_to"
|
|
73
|
+
typeof="http://xmlns.com/foaf/0.1/Document http://lblod.data.gift/vocabularies/editor/SnippetAttachment"
|
|
74
|
+
>
|
|
75
|
+
Bijlage uit externe bron <a href="${snippet.source}">${
|
|
76
|
+
new URL(snippet.source).hostname
|
|
77
|
+
}</a>
|
|
78
|
+
<div property="http://www.w3.org/ns/prov#value">${
|
|
79
|
+
snippet.content
|
|
80
|
+
}</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
`;
|
|
84
|
+
} else {
|
|
85
|
+
return `
|
|
86
|
+
<div property="http://lblod.data.gift/vocabularies/editor/isLumpNode">
|
|
87
|
+
Bijlage uit externe bron
|
|
88
|
+
<div property="http://data.europa.eu/eli/ontology#related_to" resource="${snippet.source}">
|
|
89
|
+
<div property="http://www.w3.org/ns/prov#value">${snippet.content}</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{{#if this.showCard}}
|
|
2
|
+
<AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
|
|
3
|
+
<c.header>
|
|
4
|
+
<AuHeading @level="3" @skin="6">
|
|
5
|
+
{{t "insert-variable-plugin.variable"}}
|
|
6
|
+
</AuHeading>
|
|
7
|
+
</c.header>
|
|
8
|
+
<c.content>
|
|
9
|
+
<PowerSelect
|
|
10
|
+
@allowClear={{false}}
|
|
11
|
+
@searchEnabled={{false}}
|
|
12
|
+
@options={{this.variablesArray}}
|
|
13
|
+
@selected={{this.selectedVariable}}
|
|
14
|
+
@onChange={{this.updateSelectedVariable}} as |variable|
|
|
15
|
+
>
|
|
16
|
+
{{variable.label}}
|
|
17
|
+
</PowerSelect>
|
|
18
|
+
{{#if this.hasSubtype}}
|
|
19
|
+
<PowerSelect
|
|
20
|
+
@allowClear={{false}}
|
|
21
|
+
@searchEnabled={{false}}
|
|
22
|
+
@options={{this.subtypes}}
|
|
23
|
+
@selected={{this.selectedSubtype}}
|
|
24
|
+
@onChange={{this.updateSubtype}} as |subtype|
|
|
25
|
+
>
|
|
26
|
+
{{subtype.label}}
|
|
27
|
+
</PowerSelect>
|
|
28
|
+
{{/if}}
|
|
29
|
+
<AuButton {{on 'click' this.insert}} @disabled={{or (not this.selectedVariable) (and this.hasSubtype (not this.selectedSubtype))}}>{{t "insert-variable-plugin.button"}}</AuButton>
|
|
30
|
+
</c.content>
|
|
31
|
+
</AuCard>
|
|
32
|
+
{{/if}}
|
|
33
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
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 { INVISIBLE_SPACE } from '@lblod/ember-rdfa-editor/model/util/constants';
|
|
7
|
+
import { defaultVariableTypes } from '../../utils/variable-plugins/default-variable-types';
|
|
8
|
+
|
|
9
|
+
export default class EditorPluginsInsertCodelistCardComponent extends Component {
|
|
10
|
+
@tracked variablesArray;
|
|
11
|
+
@tracked selectedVariable;
|
|
12
|
+
@tracked showCard = true;
|
|
13
|
+
@tracked hasSubtype = false;
|
|
14
|
+
@tracked selectedSubtype;
|
|
15
|
+
@tracked subtypes;
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
const { publisher, variableTypes, defaultEndpoint } =
|
|
20
|
+
this.args.widgetArgs.options || {};
|
|
21
|
+
this.publisher = publisher;
|
|
22
|
+
this.endpoint = defaultEndpoint;
|
|
23
|
+
let variableTypesSelectedByUser = variableTypes ?? [
|
|
24
|
+
'text',
|
|
25
|
+
'number',
|
|
26
|
+
'date',
|
|
27
|
+
'location',
|
|
28
|
+
'codelist',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const variablesArray = [];
|
|
32
|
+
for (let type of variableTypesSelectedByUser) {
|
|
33
|
+
if (typeof type === 'string') {
|
|
34
|
+
const defaultVariable = defaultVariableTypes[type];
|
|
35
|
+
if (defaultVariable) {
|
|
36
|
+
variablesArray.push(defaultVariable);
|
|
37
|
+
} else {
|
|
38
|
+
console.warn(
|
|
39
|
+
`Template Variable Plugin: variable type ${type} not found in the default variable types`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
variablesArray.push(type);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.variablesArray = variablesArray;
|
|
47
|
+
this.args.controller.onEvent('selectionChanged', this.selectionChanged);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@action
|
|
51
|
+
insert() {
|
|
52
|
+
const uri = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
53
|
+
let variableContent;
|
|
54
|
+
if (typeof this.selectedVariable.template === 'function') {
|
|
55
|
+
variableContent = this.selectedVariable.template(
|
|
56
|
+
this.endpoint,
|
|
57
|
+
this.selectedSubtype
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
variableContent = this.selectedVariable.template;
|
|
61
|
+
}
|
|
62
|
+
const htmlToInsert = `
|
|
63
|
+
<span resource="${uri}" typeof="ext:Mapping">
|
|
64
|
+
${variableContent}
|
|
65
|
+
</span>
|
|
66
|
+
`;
|
|
67
|
+
this.args.controller.executeCommand(
|
|
68
|
+
'insert-html',
|
|
69
|
+
htmlToInsert,
|
|
70
|
+
this.args.controller.selection.lastRange
|
|
71
|
+
);
|
|
72
|
+
this.args.controller.executeCommand(
|
|
73
|
+
'insert-text',
|
|
74
|
+
INVISIBLE_SPACE,
|
|
75
|
+
this.args.controller.selection.lastRange
|
|
76
|
+
);
|
|
77
|
+
this.selectedVariableType = undefined;
|
|
78
|
+
this.selectedCodelist = undefined;
|
|
79
|
+
this.isCodelist = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@action
|
|
83
|
+
updateSelectedVariable(variable) {
|
|
84
|
+
this.selectedVariable = variable;
|
|
85
|
+
if (variable.fetchSubtypes) {
|
|
86
|
+
this.fetchSubtypes.perform(variable.fetchSubtypes);
|
|
87
|
+
this.hasSubtype = true;
|
|
88
|
+
} else {
|
|
89
|
+
this.hasSubtype = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@task
|
|
94
|
+
*fetchSubtypes(fetchFunction) {
|
|
95
|
+
const subtypes = yield fetchFunction(this.endpoint, this.publisher);
|
|
96
|
+
this.subtypes = subtypes;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@action
|
|
100
|
+
updateSubtype(subtype) {
|
|
101
|
+
this.selectedSubtype = subtype;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@action
|
|
105
|
+
selectionChanged() {
|
|
106
|
+
const currentSelection = this.args.controller.selection.lastRange;
|
|
107
|
+
if (!currentSelection) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.showCard = false;
|
|
111
|
+
const limitedDatastore = this.args.controller.datastore.limitToRange(
|
|
112
|
+
currentSelection,
|
|
113
|
+
'rangeIsInside'
|
|
114
|
+
);
|
|
115
|
+
const mapping = limitedDatastore
|
|
116
|
+
.match(null, 'a', 'ext:Mapping')
|
|
117
|
+
.asQuads()
|
|
118
|
+
.next().value;
|
|
119
|
+
if (mapping) {
|
|
120
|
+
this.showCard = false;
|
|
121
|
+
} else {
|
|
122
|
+
this.showCard = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{{#if this.showCard}}
|
|
2
|
+
<AuCard @shadow={{true}} @size="flush" as |c|>
|
|
3
|
+
<c.header class="au-u-hidden-visually">
|
|
4
|
+
<AuHeading @level="3" @skin="6">{{t "date-plugin.card.title"}}</AuHeading>
|
|
5
|
+
</c.header>
|
|
6
|
+
<c.content class="au-o-box au-o-box--small">
|
|
7
|
+
<div class="au-o-flow au-o-flow--small">
|
|
8
|
+
<RdfaDatePlugin::RdfaDateTimePicker
|
|
9
|
+
@onChange={{this.changeDate}}
|
|
10
|
+
@value={{this.dateValue}}
|
|
11
|
+
@onlyDate={{this.onlyDate}}/>
|
|
12
|
+
{{#unless this.dateInDocument}}
|
|
13
|
+
<AuFormRow class="au-u-margin-top">
|
|
14
|
+
<AuButton {{on 'click' this.modifyDate}}>
|
|
15
|
+
{{if this.onlyDate (t "date-plugin.card.insert-date") (t "date-plugin.card.insert-datetime")}}
|
|
16
|
+
</AuButton>
|
|
17
|
+
</AuFormRow>
|
|
18
|
+
{{/unless}}
|
|
19
|
+
</div>
|
|
20
|
+
</c.content>
|
|
21
|
+
</AuCard>
|
|
22
|
+
{{/if}}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
|
|
5
|
+
export default class RdfaDatePluginCardComponent extends Component {
|
|
6
|
+
@tracked showCard = false;
|
|
7
|
+
@tracked dateValue;
|
|
8
|
+
@tracked dateElement;
|
|
9
|
+
@tracked dateInDocument;
|
|
10
|
+
@tracked onlyDate;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.args.controller.onEvent(
|
|
15
|
+
'selectionChanged',
|
|
16
|
+
this.selectionChangedHandler
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@action
|
|
21
|
+
modifyDate() {
|
|
22
|
+
this.args.controller.executeCommand(
|
|
23
|
+
'modify-date',
|
|
24
|
+
this.args.controller,
|
|
25
|
+
this.dateElement,
|
|
26
|
+
this.dateValue,
|
|
27
|
+
this.onlyDate
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@action
|
|
32
|
+
changeDate(date) {
|
|
33
|
+
this.dateValue = date;
|
|
34
|
+
if (this.dateInDocument) this.modifyDate();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@action
|
|
38
|
+
selectionChangedHandler() {
|
|
39
|
+
const selectedRange = this.args.controller.selection.lastRange;
|
|
40
|
+
if (!selectedRange) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const selectionParent = selectedRange.start.parent;
|
|
44
|
+
const datatype = selectionParent.attributeMap.get('datatype');
|
|
45
|
+
if (datatype === 'xsd:dateTime') {
|
|
46
|
+
this.showCard = true;
|
|
47
|
+
this.dateElement = selectionParent;
|
|
48
|
+
const dateContent = selectionParent.attributeMap.get('content');
|
|
49
|
+
this.dateValue = dateContent ? new Date(dateContent) : new Date();
|
|
50
|
+
this.dateInDocument = !!dateContent;
|
|
51
|
+
this.onlyDate = false;
|
|
52
|
+
} else if (datatype === 'xsd:date') {
|
|
53
|
+
this.showCard = true;
|
|
54
|
+
this.dateElement = selectionParent;
|
|
55
|
+
const dateContent = selectionParent.attributeMap.get('content');
|
|
56
|
+
this.dateValue = dateContent ? new Date(dateContent) : new Date();
|
|
57
|
+
this.dateInDocument = !!dateContent;
|
|
58
|
+
this.onlyDate = true;
|
|
59
|
+
} else {
|
|
60
|
+
this.showCard = false;
|
|
61
|
+
this.dateElement = undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<AuList::Item>
|
|
2
|
+
<AuButton
|
|
3
|
+
@icon="add"
|
|
4
|
+
@iconAlignment="left"
|
|
5
|
+
@skin="link"
|
|
6
|
+
{{on 'click' this.insertDate}}>
|
|
7
|
+
{{t "date-plugin.insert.date"}}
|
|
8
|
+
</AuButton>
|
|
9
|
+
</AuList::Item>
|
|
10
|
+
<AuList::Item>
|
|
11
|
+
<AuButton
|
|
12
|
+
@icon="add"
|
|
13
|
+
@iconAlignment="left"
|
|
14
|
+
@skin="link"
|
|
15
|
+
{{on 'click' this.insertDateTime}}>
|
|
16
|
+
{{t "date-plugin.insert.datetime"}}
|
|
17
|
+
</AuButton>
|
|
18
|
+
</AuList::Item>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
|
|
4
|
+
export default class RdfaDatePluginInsertComponent extends Component {
|
|
5
|
+
@action
|
|
6
|
+
insertDate() {
|
|
7
|
+
const selection = this.args.controller.selection.lastRange;
|
|
8
|
+
this.args.controller.executeCommand(
|
|
9
|
+
'insert-html',
|
|
10
|
+
'<span datatype="xsd:date" property="ext:content">${date}</span>',
|
|
11
|
+
selection
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@action
|
|
16
|
+
insertDateTime() {
|
|
17
|
+
const selection = this.args.controller.selection.lastRange;
|
|
18
|
+
this.args.controller.executeCommand(
|
|
19
|
+
'insert-html',
|
|
20
|
+
'<span datatype="xsd:dateTime" property="ext:content">${date and time}</span>',
|
|
21
|
+
selection
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|