@lblod/ember-rdfa-editor-lblod-plugins 7.0.0 → 7.1.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/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.1.0] - 2023-05-18
11
+
12
+ ### Added
13
+ - validate motivering and article section
14
+
10
15
  ## [7.0.0] - 2023-05-17
11
16
  ### Added
12
17
  - add docker build for easy demo environments
@@ -14,9 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
19
  - BREAKING: Endpoint config for `CitationPlugin`
15
20
  ### Fixed
16
21
  - Remove structure doesn't always work - disable the "Remove <structure>" button correctly
22
+ - Fix initialization of default date properties
17
23
 
18
24
  ### Fixed
19
- - Fix initialization of default date properties
25
+
20
26
  ## [6.1.0] - 2023-05-11
21
27
 
22
28
  ### Added
@@ -438,7 +444,8 @@ add onclick handler to pencil icon in variable plugin
438
444
 
439
445
  # Changelog
440
446
 
441
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...HEAD
447
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...HEAD
448
+ [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
442
449
  [7.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.1.0...v7.0.0
443
450
  [6.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.0.0...v6.1.0
444
451
  [6.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.1...v6.0.0
package/README.md CHANGED
@@ -21,6 +21,7 @@ This addon contains the following editor plugins:
21
21
 
22
22
  * besluit-type-plugin
23
23
  * citaten-plugin
24
+ * decision-plugin
24
25
  * import-snippet-plugin
25
26
  * insert-variable-plugin
26
27
  * rdfa-date-plugin
@@ -76,6 +77,28 @@ You can need to specify the endpoint from which the plugin will fetch the types
76
77
  }
77
78
  ```
78
79
 
80
+ ## decision-plugin
81
+
82
+ This plugin provides some warnings to the user if the validation for a besluit fails, it need to be used with the validation plugin as it exports some validation rules for it.
83
+ In order to use it you will need to add its card to the sidebar like
84
+ ```hbs
85
+ <DecisionPlugin::DecisionPluginCard
86
+ @controller={{this.controller}}
87
+ />
88
+ ```
89
+
90
+ and then import the rule and add it to the config of your validation plugin like
91
+ ```js
92
+ import { atLeastOneArticleContainer } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/validation-rules';
93
+ ...
94
+ @tracked validationPlugin = validation((schema: Schema) => ({
95
+ shapes: [
96
+ atLeastOneArticleContainer(schema),
97
+ ]
98
+ })
99
+ ```
100
+ With these changes you will see a warning if the decision is missing a title, a motivation block or an article block.
101
+
79
102
  ## citaten-plugin
80
103
 
81
104
  Plugin which allows a user to insert references to a legal resource or legal expression into the document.
@@ -1,8 +1,24 @@
1
1
  {{#if this.canInsertTitle}}
2
- <AuAlert class="title-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-title-warning"}}>
3
- <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertTitle}} {{on 'click'
4
- this.insertTitle}}>
5
- {{t "besluit-plugin.insert.decision-title"}}
6
- </AuButton>
7
- </AuAlert>
2
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-title-warning"}}>
3
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertTitle}} {{on 'click'
4
+ this.insertTitle}}>
5
+ {{t "besluit-plugin.insert.decision-title"}}
6
+ </AuButton>
7
+ </AuAlert>
8
+ {{/if}}
9
+ {{#if this.canInsertMotivation}}
10
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-motivation-warning"}}>
11
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertMotivation}} {{on 'click'
12
+ this.insertMotivation}}>
13
+ {{t "besluit-plugin.insert.motivation"}}
14
+ </AuButton>
15
+ </AuAlert>
16
+ {{/if}}
17
+ {{#if this.missingArticleBlock}}
18
+ <AuAlert class="validation-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-article-block-warning"}}>
19
+ <AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.missingArticleBlock}} {{on 'click'
20
+ this.insertArticleBlock}}>
21
+ {{t "besluit-plugin.insert.article-block"}}
22
+ </AuButton>
23
+ </AuAlert>
8
24
  {{/if}}
@@ -1,9 +1,13 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { action } from '@ember/object';
3
- import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
3
+ import {
4
+ insertMotivation,
5
+ insertArticleContainer,
6
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands';
4
7
  import { SayController } from '@lblod/ember-rdfa-editor';
5
8
  import { inject as service } from '@ember/service';
6
9
  import IntlService from 'ember-intl/services/intl';
10
+ import { VALIDATION_KEY } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
7
11
 
8
12
  type Args = {
9
13
  controller: SayController;
@@ -24,26 +28,41 @@ export default class DecisionPluginCard extends Component<Args> {
24
28
  }
25
29
 
26
30
  @action
27
- insertTitle() {
28
- this.controller.doCommand(
29
- insertTitle({
30
- placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
31
- }),
32
- {
33
- view: this.controller.mainEditorView,
34
- }
35
- );
31
+ insertMotivation() {
32
+ this.controller.doCommand(insertMotivation({ intl: this.intl }), {
33
+ view: this.controller.mainEditorView,
34
+ });
35
+ this.focus();
36
+ }
37
+
38
+ get canInsertMotivation() {
39
+ return this.controller.checkCommand(insertMotivation({ intl: this.intl }), {
40
+ view: this.controller.mainEditorView,
41
+ });
42
+ }
43
+
44
+ @action
45
+ insertArticleBlock() {
46
+ this.controller.doCommand(insertArticleContainer({ intl: this.intl }), {
47
+ view: this.controller.mainEditorView,
48
+ });
36
49
  this.focus();
37
50
  }
38
51
 
39
- get canInsertTitle() {
40
- return this.controller.checkCommand(
41
- insertTitle({
42
- placeholderText: this.intl.t('besluit-plugin.insert.decision-title'),
43
- }),
44
- {
45
- view: this.controller.mainEditorView,
52
+ get missingArticleBlock() {
53
+ const state = VALIDATION_KEY.getState(this.controller.activeEditorState);
54
+ if (state) {
55
+ let missingArticleBlock = false;
56
+ const results = state.report.results;
57
+ if (!results) return false;
58
+ for (const result of results) {
59
+ if (result.sourceShape.name === 'at-least-one-article-container') {
60
+ missingArticleBlock = true;
61
+ }
46
62
  }
47
- );
63
+ return missingArticleBlock;
64
+ } else {
65
+ return false;
66
+ }
48
67
  }
49
68
  }
@@ -8,16 +8,17 @@ import { v4 as uuid } from 'uuid';
8
8
  import { isNone } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
9
9
  import { transactionCompliesWithShapes } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation/utils/transaction-complies-with-shapes';
10
10
  import { findInsertionPosInAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/find-insertion-pos-in-ancestor-of-type';
11
+ import IntlService from 'ember-intl/services/intl';
11
12
 
12
13
  interface InsertMotivationArgs {
13
- placeholderText?: string;
14
+ intl: IntlService;
14
15
  validateShapes?: Set<string>;
15
16
  }
16
17
 
17
18
  export default function insertMotivation({
19
+ intl,
18
20
  validateShapes,
19
- placeholderText = 'Insert motivation',
20
- }: InsertMotivationArgs = {}): Command {
21
+ }: InsertMotivationArgs): Command {
21
22
  return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
22
23
  const { selection, schema } = state;
23
24
  const nodeToInsert = schema.node('motivering', { __rdfaId: uuid() }, [
@@ -25,9 +26,63 @@ export default function insertMotivation({
25
26
  'paragraph',
26
27
  null,
27
28
  schema.node('placeholder', {
28
- placeholderText,
29
+ placeholderText: intl.t('besluit-plugin.placeholder.government-body'),
29
30
  })
30
31
  ),
32
+ schema.node(
33
+ 'heading',
34
+ {
35
+ level: 5,
36
+ },
37
+ [schema.text(intl.t('besluit-plugin.text.authority'))]
38
+ ),
39
+ schema.node('bullet_list', null, [
40
+ schema.node('list_item', null, [
41
+ schema.node('paragraph', null, [
42
+ schema.node('placeholder', {
43
+ placeholderText: intl.t(
44
+ 'besluit-plugin.placeholder.legal-jurisdiction'
45
+ ),
46
+ }),
47
+ ]),
48
+ ]),
49
+ ]),
50
+ schema.node(
51
+ 'heading',
52
+ {
53
+ level: 5,
54
+ },
55
+ [schema.text(intl.t('besluit-plugin.text.legal-context'))]
56
+ ),
57
+ schema.node('bullet_list', null, [
58
+ schema.node('list_item', null, [
59
+ schema.node('paragraph', null, [
60
+ schema.node('placeholder', {
61
+ placeholderText: intl.t(
62
+ 'besluit-plugin.placeholder.insert-legal-context'
63
+ ),
64
+ }),
65
+ ]),
66
+ ]),
67
+ ]),
68
+ schema.node(
69
+ 'heading',
70
+ {
71
+ level: 5,
72
+ },
73
+ [schema.text(intl.t('besluit-plugin.text.factual-context'))]
74
+ ),
75
+ schema.node('bullet_list', null, [
76
+ schema.node('list_item', null, [
77
+ schema.node('paragraph', null, [
78
+ schema.node('placeholder', {
79
+ placeholderText: intl.t(
80
+ 'besluit-plugin.placeholder.insert-factual-context'
81
+ ),
82
+ }),
83
+ ]),
84
+ ]),
85
+ ]),
31
86
  ]);
32
87
  // how the offset between the insertion point and the point where the cursor should end up
33
88
  const cursorOffset = 2;
@@ -47,8 +102,6 @@ export default function insertMotivation({
47
102
  return false;
48
103
  }
49
104
  if (dispatch) {
50
- console.log('inserts in ', insertionPos);
51
- console.log('selection on ', insertionPos + cursorOffset);
52
105
  const selectionPos = tr.doc.resolve(insertionPos + cursorOffset);
53
106
  // const targetPos = tr.doc.resolve(insertionPos + cursorOffset + 1);
54
107
  // TODO figure out why I cant just set a nodeSelection here
@@ -0,0 +1,11 @@
1
+ import { Schema } from '@lblod/ember-rdfa-editor';
2
+
3
+ export const atLeastOneArticleContainer = (schema: Schema) => ({
4
+ name: 'at-least-one-article-container',
5
+ focusNodeType: schema.nodes.besluit,
6
+ path: ['article_container'],
7
+ message: 'Document must contain at least one article container.',
8
+ constraints: {
9
+ minCount: 1,
10
+ },
11
+ });
@@ -141,13 +141,7 @@ export function validation(
141
141
  const schemaChanged = oldState.schema !== newState.schema;
142
142
  if (schemaChanged) {
143
143
  const spec = compileSpec(configurator, newState.schema);
144
- const newValidation = doValidation(
145
- tr,
146
- oldPluginState,
147
- oldState,
148
- newState,
149
- spec
150
- );
144
+ const newValidation = doValidation(newState, spec);
151
145
  tr.setMeta('validated', newValidation);
152
146
  tr.setMeta('firstPass', false);
153
147
  return { spec, report: newValidation };
@@ -166,13 +160,7 @@ export function validation(
166
160
  tr.setMeta('firstPass', false);
167
161
  return cachedValidation;
168
162
  }
169
- const newValidation = doValidation(
170
- tr,
171
- oldPluginState,
172
- oldState,
173
- newState,
174
- spec
175
- );
163
+ const newValidation = doValidation(newState, spec);
176
164
  tr.setMeta('validated', newValidation);
177
165
  tr.setMeta('firstPass', false);
178
166
  return { spec, report: newValidation };
@@ -230,9 +218,6 @@ interface ValidationContext {
230
218
  * @param spec
231
219
  */
232
220
  function doValidation(
233
- tr: Transaction,
234
- oldPluginState: ValidationState,
235
- oldState: EditorState,
236
221
  newState: EditorState,
237
222
  spec: ValidationSpec
238
223
  ): ValidationReport {
@@ -1,4 +1,4 @@
1
- .title-alert .au-c-button {
1
+ .validation-alert .au-c-button {
2
2
  padding: 0;
3
3
  }
4
4
 
@@ -11,7 +11,9 @@ export default class DecisionPluginCard extends Component<Args> {
11
11
  intl: IntlService;
12
12
  get controller(): SayController;
13
13
  focus(): void;
14
- insertTitle(): void;
15
- get canInsertTitle(): boolean;
14
+ insertMotivation(): void;
15
+ get canInsertMotivation(): boolean;
16
+ insertArticleBlock(): void;
17
+ get missingArticleBlock(): boolean;
16
18
  }
17
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -1,7 +1,8 @@
1
1
  import { Command } from '@lblod/ember-rdfa-editor';
2
+ import IntlService from 'ember-intl/services/intl';
2
3
  interface InsertMotivationArgs {
3
- placeholderText?: string;
4
+ intl: IntlService;
4
5
  validateShapes?: Set<string>;
5
6
  }
6
- export default function insertMotivation({ validateShapes, placeholderText, }?: InsertMotivationArgs): Command;
7
+ export default function insertMotivation({ intl, validateShapes, }: InsertMotivationArgs): Command;
7
8
  export {};
@@ -0,0 +1,10 @@
1
+ import { Schema } from '@lblod/ember-rdfa-editor';
2
+ export declare const atLeastOneArticleContainer: (schema: Schema) => {
3
+ name: string;
4
+ focusNodeType: import("prosemirror-model").NodeType;
5
+ path: string[];
6
+ message: string;
7
+ constraints: {
8
+ minCount: number;
9
+ };
10
+ };
@@ -114,11 +114,24 @@ besluit-type-plugin:
114
114
  error-rest-body: '. For more specific details about this problem, inspect the browser console.'
115
115
 
116
116
  besluit-plugin:
117
- missing-title-warning: This decision is missing a title
117
+ missing-title-warning: This decision is missing a title.
118
+ missing-motivation-warning: This decision is missing a motivation block, a decision without this block will be harder to parse by our system.
119
+ missing-article-block-warning: This decision is missing an article block, a decision without this block will be harder to parse by our system.
118
120
  insert:
119
121
  decision-title: Insert decision title
122
+ motivation: Insert motivation
123
+ article-block: Insert article block
120
124
  placeholder:
121
125
  decision-title: Insert decision title
126
+ government-body: specify governing body
127
+ legal-jurisdiction: Legal basis providing that body has jurisdiction.
128
+ insert-legal-context: Insert juridische context
129
+ insert-factual-context: Factual context and reasoning
130
+ insert-article: Insert article
131
+ text:
132
+ authority: Authority
133
+ legal-context: Legal context
134
+ factual-context: Factual context and reasoning
122
135
 
123
136
  date-plugin:
124
137
  help:
@@ -117,11 +117,24 @@ besluit-type-plugin:
117
117
 
118
118
 
119
119
  besluit-plugin:
120
- missing-title-warning: Dit besluit heeft geen titel
120
+ missing-title-warning: Dit besluit heeft geen titel.
121
+ missing-motivation-warning: Dit besluit mist een motivatieblok, een besluit zonder dit blok zal moeilijker te ontleden zijn door ons systeem.
122
+ missing-article-block-warning: Deze besluit mist een artikelblok, een besluit zonder dit blok zal moeilijker te ontleden zijn door ons systeem.
121
123
  insert:
122
124
  decision-title: Voeg besluittitel in
125
+ motivation: Voeg motivatie in
126
+ article-block: Voeg artikelblok in
123
127
  placeholder:
124
128
  decision-title: Geef titel besluit op
129
+ government-body: geef bestuursorgaan op
130
+ legal-jurisdiction: Rechtsgrond die bepaalt dat dit orgaan bevoegd is.
131
+ insert-legal-context: Voeg juridische context in
132
+ insert-factual-context: Feitelijke context en argumentatie
133
+ insert-article: Artikel invoegen
134
+ text:
135
+ authority: Bevoegdheid
136
+ legal-context: Juridische context
137
+ factual-context: Feitelijke context en argumentatie
125
138
 
126
139
 
127
140
  date-plugin: