@lblod/ember-rdfa-editor-lblod-plugins 32.5.1 → 32.5.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 32.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#593](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/593) [`56039ab`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/56039abb28cb0f78f7fdda7e9a35af603ed427a5) Thanks [@piemonkey](https://github.com/piemonkey)! - Fix inserted text for traffic signals that do not have images
8
+
9
+ - [#592](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/592) [`641a973`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/641a973b1323404962db1c737274762da0a9c3e6) Thanks [@piemonkey](https://github.com/piemonkey)! - Improve sorting of label filters on 'insert traffic measure' modal
10
+
3
11
  ## 32.5.1
4
12
 
5
13
  ### Patch Changes
@@ -19,7 +19,9 @@ import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/p
19
19
  import { pagination } from '@lblod/ember-rdfa-editor-lblod-plugins/helpers/pagination';
20
20
  import { restartableTask, task, timeout } from 'ember-concurrency';
21
21
  import t from 'ember-intl/helpers/t';
22
- import PowerSelect from 'ember-power-select/components/power-select';
22
+ import PowerSelect, {
23
+ Select,
24
+ } from 'ember-power-select/components/power-select';
23
25
  import PowerSelectMultiple from 'ember-power-select/components/power-select-multiple';
24
26
  import { TaskInstance, trackedTask } from 'reactiveweb/ember-concurrency';
25
27
  import { trackedFunction } from 'reactiveweb/function';
@@ -151,6 +153,18 @@ export default class RoadsignsModal extends Component<Signature> {
151
153
  this.args.closeModal();
152
154
  }
153
155
 
156
+ @action
157
+ doFirstCodeSearch(select: Select) {
158
+ if (
159
+ this.searchCodes.isIdle &&
160
+ !select.searchText &&
161
+ // @ts-expect-error not part of the public API... (tested on PS 7 and 8)
162
+ this.searchCodes.lastSuccessful?.args?.[0] !== ''
163
+ ) {
164
+ this.searchCodes.perform('');
165
+ }
166
+ return true;
167
+ }
154
168
  searchCodes = restartableTask(async (term: string) => {
155
169
  const category = this.selectedCategory?.uri;
156
170
  const type = this.selectedType?.uri;
@@ -402,9 +416,11 @@ export default class RoadsignsModal extends Component<Signature> {
402
416
  @verticalPosition='below'
403
417
  @searchEnabled={{true}}
404
418
  @search={{this.searchCodes.perform}}
419
+ @options={{or this.searchCodes.last.value undefined}}
405
420
  @selected={{this.selectedCode}}
406
421
  @allowClear={{true}}
407
422
  @onChange={{this.changeCode}}
423
+ @onOpen={{this.doFirstCodeSearch}}
408
424
  as |option|
409
425
  >
410
426
  {{option.label}}
@@ -99,14 +99,24 @@ export default class RoadSignsTable extends Component<Signature> {
99
99
  as |signalConcept|
100
100
  }}
101
101
  <div class='au-o-grid__item au-u-1-3'>
102
- <img
103
- src={{signalConcept.image}}
104
- alt={{t
105
- 'editor-plugins.roadsign-regulation.table.content.image.alt'
106
- code=signalConcept.code
107
- }}
108
- class='au-c-data-table__image'
109
- />
102
+ {{#if signalConcept.image}}
103
+ <img
104
+ src={{signalConcept.image}}
105
+ alt={{t
106
+ 'editor-plugins.roadsign-regulation.table.content.image.alt'
107
+ code=signalConcept.code
108
+ }}
109
+ class='au-c-data-table__image'
110
+ />
111
+ {{else}}
112
+ <AuPill
113
+ @skin='border'
114
+ @size='small'
115
+ @draft={{true}}
116
+ >
117
+ {{signalConcept.code}}
118
+ </AuPill>
119
+ {{/if}}
110
120
  </div>
111
121
  {{/each}}
112
122
  </div>
@@ -77,6 +77,9 @@ export default async function queryTrafficSignalCodes(
77
77
  const { abortSignal } = options;
78
78
  const filterStatement = buildFilters(options);
79
79
 
80
+ // The sorting here is a little weird. This is to handle labels which are normally of the form
81
+ // 'A1.3b', where the 1.3 should be sorted as a number. There is no enforcement of this format, so
82
+ // we try to handle cases such as 'weird1.2.3LABEL' in a way that is not too broken.
80
83
  const query = /* sparql */ `
81
84
  PREFIX mobiliteit: <https://data.vlaanderen.be/ns/mobiliteit#>
82
85
  PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
@@ -92,8 +95,11 @@ export default async function queryTrafficSignalCodes(
92
95
  skos:prefLabel ?label;
93
96
  ext:valid ${sparqlEscapeBool(true)}.
94
97
  ${filterStatement}
98
+ BIND(REPLACE(?label, "^(\\\\D+).*", "$1", "i") AS ?firstLetters)
99
+ BIND(xsd:decimal(REPLACE(?label, "^\\\\D+(\\\\d*\\\\.?\\\\d*).*", "$1", "i")) AS ?number)
100
+ BIND(REPLACE(?label, "^\\\\D+\\\\d*\\\\.?\\\\d*(.*)", "$1", "i") AS ?secondLetters)
95
101
  }
96
- ORDER BY ASC(?label)
102
+ ORDER BY ASC(UCASE(?firstLetters)) ASC(?number) ASC(LCASE(?secondLetters))
97
103
  `;
98
104
  const queryResult = await executeQuery({ endpoint, query, abortSignal });
99
105
  const bindings = queryResult.results.bindings;
@@ -35,15 +35,17 @@ export async function queryTrafficSignalConcepts(
35
35
  ?type
36
36
  ?code
37
37
  ?zonality
38
- (CONCAT(${sparqlEscapeString(imageBaseUrl ?? '')}, "/files/", ?imageId, "/download") AS ?image)
38
+ ?image
39
39
  WHERE {
40
40
  ?uri
41
41
  a mobiliteit:Verkeerstekenconcept;
42
42
  a ?type;
43
- skos:prefLabel ?code;
44
- mobiliteit:grafischeWeergave ?imageUri.
43
+ skos:prefLabel ?code.
45
44
 
46
- ?imageUri ext:hasFile/mu:uuid ?imageId.
45
+ OPTIONAL {
46
+ ?uri mobiliteit:grafischeWeergave/ext:hasFile/mu:uuid ?imageId.
47
+ BIND(CONCAT(${sparqlEscapeString(imageBaseUrl ?? '')}, "/files/", ?imageId, "/download") AS ?image)
48
+ }
47
49
 
48
50
  OPTIONAL {
49
51
  ?uri ext:zonality ?zonality.
@@ -65,7 +67,13 @@ export async function queryTrafficSignalConcepts(
65
67
  });
66
68
  const bindings = queryResult.results.bindings;
67
69
  const concepts = TrafficSignalConceptSchema.array().parse(
68
- bindings.map(objectify),
70
+ bindings.map((binding) => {
71
+ const objectified = objectify(binding);
72
+ return {
73
+ ...objectified,
74
+ image: objectified.image ?? '',
75
+ };
76
+ }),
69
77
  );
70
78
  const conceptsWithCategories = await Promise.all(
71
79
  concepts.map(async (concept) => {
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
4
4
  import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept';
5
+ import { Select } from 'ember-power-select/components/power-select';
5
6
  import { TaskInstance } from 'reactiveweb/ember-concurrency';
6
7
  import { ZONALITY_OPTIONS } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
7
8
  type Option = {
@@ -43,6 +44,7 @@ export default class RoadsignsModal extends Component<Signature> {
43
44
  changeZonality(value: Zonality): void;
44
45
  handleSearch(event: InputEvent): void;
45
46
  closeModal(): void;
47
+ doFirstCodeSearch(select: Select): boolean;
46
48
  searchCodes: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (term: string) => Promise<{
47
49
  label: string;
48
50
  uri: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "32.5.1",
3
+ "version": "32.5.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",