@lblod/ember-rdfa-editor-lblod-plugins 33.2.0 → 33.3.0-dev.770636ca8ec292930c2ff01dfcb8b20c5737251d

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ When inserting an AR design, include the link to the design in the RDFa
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 33.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#611](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/611) [`ad9364d`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/ad9364d3d274d241228887356c057f7e2af84918) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Allow the use of draft besluit types
8
+
3
9
  ## 33.2.0
4
10
 
5
11
  ### Minor Changes
@@ -20,14 +20,17 @@ import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/u
20
20
  import {
21
21
  BesluitTypeInstance,
22
22
  checkBesluitTypeInstance,
23
+ checkForDraftBesluitType,
23
24
  mostSpecificBesluitType,
24
25
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/besluit-type-instances';
25
26
  import BesluitTypeForm from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-type-plugin/besluit-type-form';
26
27
  import { setBesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/set-besluit-type';
28
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
27
29
 
28
30
  type Args = {
29
31
  controller: SayController;
30
32
  options: BesluitTypePluginOptions;
33
+ allowForDraftTypes?: boolean;
31
34
  };
32
35
 
33
36
  export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
@@ -67,7 +70,9 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
67
70
 
68
71
  setType = (type: BesluitTypeInstance) => {
69
72
  this.selectedTypeInstance = type;
70
- this.insertIfValid();
73
+ if (!this.args.allowForDraftTypes) {
74
+ this.insertIfValid();
75
+ }
71
76
  };
72
77
 
73
78
  updateBesluitTypes = () => {
@@ -84,13 +89,16 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
84
89
  );
85
90
  if (typeInstance) {
86
91
  this.selectedTypeInstance = typeInstance;
87
- this.cardExpanded = false;
92
+ const isDraftType = checkForDraftBesluitType(
93
+ this.controller.mainEditorState,
94
+ );
95
+ this.cardExpanded = !this.args.allowForDraftTypes && isDraftType;
88
96
  } else {
89
97
  this.cardExpanded = true;
90
98
  }
91
99
  };
92
100
 
93
- insertIfValid() {
101
+ insertIfValid = () => {
94
102
  this.controller.doCommand((state, dispatch) => {
95
103
  if (!this.selectedTypeInstance || !dispatch) {
96
104
  return false;
@@ -98,6 +106,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
98
106
  const { result, transaction } = setBesluitType(
99
107
  state,
100
108
  this.selectedTypeInstance,
109
+ this.args.allowForDraftTypes,
101
110
  );
102
111
  if (result.every((ok) => ok)) {
103
112
  dispatch(transaction);
@@ -105,7 +114,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
105
114
  }
106
115
  return false;
107
116
  });
108
- }
117
+ };
109
118
 
110
119
  <template>
111
120
  <div
@@ -182,6 +191,11 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
182
191
  @selectedType={{this.selectedTypeInstance}}
183
192
  @setType={{this.setType}}
184
193
  />
194
+ {{#if @allowForDraftTypes}}
195
+ <AuButton {{on 'click' this.insertIfValid}}>
196
+ {{t 'common.insert'}}
197
+ </AuButton>
198
+ {{/if}}
185
199
  {{/if}}
186
200
  </Modal.Body>
187
201
  </AuModal>
@@ -1,7 +1,10 @@
1
1
  import { type EditorState } from '@lblod/ember-rdfa-editor';
2
2
  import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
3
3
  import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
4
- import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
4
+ import {
5
+ EXT,
6
+ RDF,
7
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
5
8
  import { type BesluitType } from './fetchBesluitTypes';
6
9
  import { type NamedNodeTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
7
10
 
@@ -27,6 +30,20 @@ export function extractBesluitTypeUris(editorState: EditorState): string[] {
27
30
  .map((type: NamedNodeTriple) => type?.object.value);
28
31
  }
29
32
 
33
+ export function checkForDraftBesluitType(editorState: EditorState): boolean {
34
+ const besluitRange = getCurrentBesluitRange(editorState);
35
+ if (!besluitRange) {
36
+ return false;
37
+ }
38
+ return getOutgoingTripleList(
39
+ besluitRange.node.attrs,
40
+ EXT('isDraftDecisionType'),
41
+ ).some(
42
+ (draftTypeTriple: NamedNodeTriple) =>
43
+ draftTypeTriple?.object.value === 'true',
44
+ );
45
+ }
46
+
30
47
  /**
31
48
  * Finds a decision type in the document and checks that it represents a valid decision type
32
49
  * according to the list of types passed in.
@@ -10,21 +10,26 @@ import {
10
10
  import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
11
11
  import { getCurrentBesluitURI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/decision-utils';
12
12
  import {
13
+ checkForDraftBesluitType,
13
14
  extractBesluitTypeUris,
14
15
  isValidTypeChoice,
15
16
  mostSpecificBesluitType,
16
17
  type BesluitTypeInstance,
17
18
  } from './besluit-type-instances';
18
- import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
19
+ import {
20
+ EXT,
21
+ RDF,
22
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
19
23
 
20
24
  export function setBesluitType(
21
25
  initialState: EditorState,
22
26
  typeInstance: BesluitTypeInstance,
27
+ isDraftDecisionType?: boolean,
23
28
  ): TransactionCombinatorResult<boolean> {
24
29
  const transaction = initialState.tr;
25
-
26
30
  const resource = getCurrentBesluitURI(initialState);
27
- if (!resource || !isValidTypeChoice(typeInstance)) {
31
+ const isValidType = isValidTypeChoice(typeInstance);
32
+ if (!resource || (!isValidType && !isDraftDecisionType)) {
28
33
  return {
29
34
  result: [false],
30
35
  initialState,
@@ -42,6 +47,17 @@ export function setBesluitType(
42
47
  },
43
48
  });
44
49
  });
50
+ if (checkForDraftBesluitType(initialState)) {
51
+ monads.push(
52
+ removePropertyFromNode({
53
+ resource,
54
+ property: {
55
+ predicate: EXT('isDraftDecisionType').full,
56
+ object: sayDataFactory.literal('true'),
57
+ },
58
+ }),
59
+ );
60
+ }
45
61
  monads.push(
46
62
  addPropertyToNode({
47
63
  resource,
@@ -53,5 +69,16 @@ export function setBesluitType(
53
69
  },
54
70
  }),
55
71
  );
72
+ if (!isValidType && isDraftDecisionType) {
73
+ monads.push(
74
+ addPropertyToNode({
75
+ resource,
76
+ property: {
77
+ predicate: EXT('isDraftDecisionType').full,
78
+ object: sayDataFactory.literal('true'),
79
+ },
80
+ }),
81
+ );
82
+ }
56
83
  return transactionCombinator<boolean>(initialState)(monads);
57
84
  }
@@ -7,10 +7,12 @@ import {
7
7
  } from '@lblod/ember-rdfa-editor';
8
8
  import { v4 as uuid } from 'uuid';
9
9
  import { addPropertyToNode } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
10
+ import { type FullTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
10
11
  import {
11
12
  DCT,
12
13
  EXT,
13
14
  MOBILITEIT,
15
+ ONDERDEEL,
14
16
  PROV,
15
17
  RDF,
16
18
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
@@ -46,6 +48,7 @@ import {
46
48
  } from '../schemas/variable-instance';
47
49
 
48
50
  type InsertMeasureArgs = {
51
+ arDesignUri?: string;
49
52
  zonality: ZonalOrNot;
50
53
  temporal: boolean;
51
54
  variables: Record<
@@ -65,6 +68,7 @@ type InsertMeasureArgs = {
65
68
  );
66
69
 
67
70
  export default function insertMeasure({
71
+ arDesignUri,
68
72
  zonality,
69
73
  temporal,
70
74
  variables,
@@ -79,6 +83,16 @@ export default function insertMeasure({
79
83
  ? args.measureConcept
80
84
  : args.measureDesign.measureConcept;
81
85
  const measureDesign = 'measureDesign' in args && args.measureDesign;
86
+ const externalTriples: FullTriple[] | undefined =
87
+ !arDesignUri || !measureDesign
88
+ ? undefined
89
+ : [
90
+ {
91
+ subject: sayDataFactory.namedNode(arDesignUri),
92
+ predicate: ONDERDEEL('BevatMaatregelOntwerp').full,
93
+ object: sayDataFactory.namedNode(measureDesign.uri),
94
+ },
95
+ ];
82
96
  const { schema } = state;
83
97
  const signNodes = measureConcept.trafficSignalConcepts.map((signConcept) =>
84
98
  constructSignalNode(signConcept, schema, zonality),
@@ -150,6 +164,7 @@ export default function insertMeasure({
150
164
  // mobiliteit:periode, mobiliteit:plaatsbepaling, schema:eventSchedule, mobiliteit:type,
151
165
  // mobiliteit:verwijstNaar, mobiliteit:heeftGevolg
152
166
  ],
167
+ externalTriples,
153
168
  },
154
169
  [measureBody, ...signSection, ...(temporalNode ? [temporalNode] : [])],
155
170
  );
@@ -67,3 +67,7 @@ export const BESTUURSPERIODES = {
67
67
  export type BestuursperiodeLabel = keyof typeof BESTUURSPERIODES;
68
68
  export type BestuursperiodeURI =
69
69
  (typeof BESTUURSPERIODES)[BestuursperiodeLabel];
70
+ export const ONDERDEEL = namespace(
71
+ 'https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#',
72
+ 'onderdeel',
73
+ );
@@ -5,6 +5,7 @@ import { BesluitTypeInstance } from '@lblod/ember-rdfa-editor-lblod-plugins/plug
5
5
  type Args = {
6
6
  controller: SayController;
7
7
  options: BesluitTypePluginOptions;
8
+ allowForDraftTypes?: boolean;
8
9
  };
9
10
  export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
10
11
  selectedTypeInstance?: BesluitTypeInstance;
@@ -17,6 +18,6 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
17
18
  toggleCard: () => void;
18
19
  setType: (type: BesluitTypeInstance) => void;
19
20
  updateBesluitTypes: () => void;
20
- insertIfValid(): void;
21
+ insertIfValid: () => void;
21
22
  }
22
23
  export {};
@@ -6,6 +6,7 @@ export interface BesluitTypeInstance {
6
6
  subSubType?: BesluitType;
7
7
  }
8
8
  export declare function extractBesluitTypeUris(editorState: EditorState): string[];
9
+ export declare function checkForDraftBesluitType(editorState: EditorState): boolean;
9
10
  /**
10
11
  * Finds a decision type in the document and checks that it represents a valid decision type
11
12
  * according to the list of types passed in.
@@ -1,4 +1,4 @@
1
1
  import { type EditorState } from '@lblod/ember-rdfa-editor';
2
2
  import { type TransactionCombinatorResult } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
3
3
  import { type BesluitTypeInstance } from './besluit-type-instances';
4
- export declare function setBesluitType(initialState: EditorState, typeInstance: BesluitTypeInstance): TransactionCombinatorResult<boolean>;
4
+ export declare function setBesluitType(initialState: EditorState, typeInstance: BesluitTypeInstance, isDraftDecisionType?: boolean): TransactionCombinatorResult<boolean>;
@@ -5,6 +5,7 @@ import { ZonalOrNot } from '../constants';
5
5
  import { MobilityMeasureDesign } from '../schemas/mobility-measure-design';
6
6
  import { VariableInstance } from '../schemas/variable-instance';
7
7
  type InsertMeasureArgs = {
8
+ arDesignUri?: string;
8
9
  zonality: ZonalOrNot;
9
10
  temporal: boolean;
10
11
  variables: Record<string, Exclude<Variable, {
@@ -18,5 +19,5 @@ type InsertMeasureArgs = {
18
19
  } | {
19
20
  measureDesign: MobilityMeasureDesign;
20
21
  });
21
- export default function insertMeasure({ zonality, temporal, variables, templateString, articleUriGenerator, decisionUri, ...args }: InsertMeasureArgs): TransactionMonad<boolean>;
22
+ export default function insertMeasure({ arDesignUri, zonality, temporal, variables, templateString, articleUriGenerator, decisionUri, ...args }: InsertMeasureArgs): TransactionMonad<boolean>;
22
23
  export {};
@@ -28,3 +28,4 @@ export declare const BESTUURSPERIODES: {
28
28
  };
29
29
  export type BestuursperiodeLabel = keyof typeof BESTUURSPERIODES;
30
30
  export type BestuursperiodeURI = (typeof BESTUURSPERIODES)[BestuursperiodeLabel];
31
+ export declare const ONDERDEEL: <Suffix extends string = string>(s: Suffix) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource<`https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#${Suffix}`, `onderdeel:${Suffix}`>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "33.2.0",
3
+ "version": "33.3.0-dev.770636ca8ec292930c2ff01dfcb8b20c5737251d",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",