@lblod/ember-rdfa-editor-lblod-plugins 22.4.0 → 22.4.1-dev.1c9dd1119670ee35f04f8a0d0677e6a4230acd84

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': patch
3
+ ---
4
+
5
+ Add error handling to lmb-plugin
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 22.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#474](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/474) [`714f260`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/714f260e2c9024fe8ea3f031b42b746fd2ac0c26) Thanks [@elpoelma](https://github.com/elpoelma)! - LMB-plugin: query mandatees using `application/x-www-form-urlencoded` approach
8
+
3
9
  ## 22.4.0
4
10
 
5
11
  ### Minor Changes
@@ -37,7 +37,7 @@
37
37
  </tr>
38
38
  </:header>
39
39
  <:body>
40
- {{#unless (or @services.isRunning @error)}}
40
+ {{#unless @services.isRunning}}
41
41
  {{#if @services.value.totalCount}}
42
42
  {{#each @services.value.results as |row|}}
43
43
  <tr>
@@ -36,13 +36,16 @@
36
36
  </mc.sidebar>
37
37
  <mc.content @scroll={{true}}>
38
38
  <div class='worship-modal--list-container'>
39
- <LmbPlugin::List
40
- @error={{this.error}}
41
- @services={{this.servicesResource}}
42
- @sort={{this.sort}}
43
- @setSort={{this.setSort}}
44
- @insert={{@onInsert}}
45
- />
39
+ {{#if this.error}}
40
+ <Common::Search::AlertLoadError @error={{this.error}} />
41
+ {{else}}
42
+ <LmbPlugin::List
43
+ @services={{this.servicesResource}}
44
+ @sort={{this.sort}}
45
+ @setSort={{this.setSort}}
46
+ @insert={{@onInsert}}
47
+ />
48
+ {{/if}}
46
49
  </div>
47
50
  {{#if this.servicesResource.value.totalCount}}
48
51
  {{#let
@@ -42,10 +42,17 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
42
42
  return fetchMandatees({ endpoint: this.args.config.endpoint });
43
43
  });
44
44
 
45
+ // TODO Either make this a trackedFunction or do filtering on the query and correctly pass an
46
+ // AbortController
45
47
  search = restartableTask(async () => {
46
48
  // Can't do what I want, so if the user modifies the filter before resolving the query will run again
47
49
  if (!this.fetchData.lastComplete) {
48
- await this.fetchData.perform();
50
+ try {
51
+ await this.fetchData.perform();
52
+ } catch (err) {
53
+ console.error('Got an error fetching LMB data', err);
54
+ this.error = err;
55
+ }
49
56
  }
50
57
 
51
58
  if (!this.fetchData.lastComplete?.value) return;
@@ -1,24 +1,12 @@
1
1
  import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
2
- import { IBindings } from 'fetch-sparql-endpoint';
3
-
4
- type SparqlResponse = {
5
- results: {
6
- bindings: IBindings[];
7
- };
8
- };
2
+ import { executeQuery } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
9
3
 
10
4
  type FetchMandateesArgs = {
11
5
  endpoint: string;
12
6
  };
13
7
 
14
8
  export async function fetchMandatees({ endpoint }: FetchMandateesArgs) {
15
- const queryResponse = await fetch(endpoint, {
16
- method: 'POST',
17
- headers: {
18
- 'Content-Type': 'application/json',
19
- },
20
- body: JSON.stringify({
21
- query: `
9
+ const query = `
22
10
  PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
23
11
  PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
24
12
  PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
@@ -46,10 +34,11 @@ export async function fetchMandatees({ endpoint }: FetchMandateesArgs) {
46
34
  }
47
35
  filter (!bound(?endDate) || ?endDate > now()).
48
36
  }
49
- `,
50
- }),
37
+ `;
38
+ const response = await executeQuery({
39
+ query,
40
+ endpoint,
51
41
  });
52
- const queryJson: SparqlResponse = await queryResponse.json();
53
- const mandatees = queryJson.results.bindings.map(Mandatee.fromBinding);
42
+ const mandatees = response.results.bindings.map(Mandatee.fromBinding);
54
43
  return mandatees;
55
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "22.4.0",
3
+ "version": "22.4.1-dev.1c9dd1119670ee35f04f8a0d0677e6a4230acd84",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",