@startinblox/core 0.18.0 → 0.18.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.
@@ -52,6 +52,8 @@ export const SolidFormSearch = {
52
52
  get defaultSetWidget() {
53
53
  return 'solid-set-default';
54
54
  },
55
+ // Returns the current value of the search from
56
+ // As a search query object
55
57
  get value() {
56
58
  const values = {};
57
59
  this.widgets.forEach(widget => {
@@ -61,6 +63,7 @@ export const SolidFormSearch = {
61
63
  try {
62
64
  value = JSON.parse(value);
63
65
  } catch {}
66
+ // Add another filter value in the values array
64
67
  value = {
65
68
  type: widget.component.type,
66
69
  list: !!widget.component.multiple,
@@ -67,7 +67,7 @@ const orThrow = (throwOn, ret) => {
67
67
  */
68
68
  const matchValue = async (val, query, throwOn) => {
69
69
  const subject = await val;
70
- if (subject == null && query.value === '') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter
70
+ if (subject == null && query.value === '' && query.type !== 'string') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter only if type is not string
71
71
  if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource
72
72
  if (query.list) {
73
73
  // Filter on a container
@@ -136,7 +136,10 @@ function fuzzyCompare(subject, search) {
136
136
  }
137
137
  const compare = {
138
138
  string(subject, query) {
139
- if (query === '') return true;
139
+ // Exact match on empty string between query and subject
140
+ if (query === '' && subject.toString() === '') return false;
141
+ // Else if query is empty and subject is something else, return true
142
+ else if (query === '') return true;
140
143
  if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
141
144
  return fuzzyCompare(subject, query);
142
145
  },
@@ -573,7 +573,10 @@ class CustomGetter {
573
573
  this.parentId = parentId;
574
574
  this.resource = this.expandProperties({
575
575
  ...resource
576
- }, serverContext);
576
+ }, {
577
+ ...serverContext,
578
+ ...clientContext
579
+ });
577
580
  this.resourceId = resourceId;
578
581
  this.serverPagination = serverPagination;
579
582
  this.serverSearch = serverSearch;
@@ -617,8 +620,8 @@ class CustomGetter {
617
620
  if (!this.isFullResource()) {
618
621
  // if resource is not complete, fetch it first
619
622
  await this.getResource(this.resourceId, {
620
- ...this.clientContext,
621
- ...this.serverContext
623
+ ...this.serverContext,
624
+ ...this.clientContext
622
625
  }, this.parentId);
623
626
  }
624
627
  while (true) {
@@ -635,15 +638,15 @@ class CustomGetter {
635
638
  // end of the path
636
639
  if (!value || !value['@id']) return value; // no value or not a resource
637
640
  return await this.getResource(value['@id'], {
638
- ...this.clientContext,
639
- ...this.serverContext
641
+ ...this.serverContext,
642
+ ...this.clientContext
640
643
  }, this.parentId || this.resourceId); // return complete resource
641
644
  }
642
645
 
643
646
  if (!value) return undefined;
644
647
  let resource = await this.getResource(value['@id'], {
645
- ...this.clientContext,
646
- ...this.serverContext
648
+ ...this.serverContext,
649
+ ...this.clientContext
647
650
  }, this.parentId || this.resourceId);
648
651
  store.subscribeResourceTo(this.resourceId, value['@id']);
649
652
  return resource ? await resource[path2.join('.')] : undefined; // return value
@@ -733,8 +736,8 @@ class CustomGetter {
733
736
  if (!permissions) {
734
737
  // if no permission, re-fetch data
735
738
  await this.getResource(this.resourceId, {
736
- ...this.clientContext,
737
- ...this.serverContext
739
+ ...this.serverContext,
740
+ ...this.clientContext
738
741
  }, this.parentId, true);
739
742
  permissions = this.resource[permissionPredicate];
740
743
  }
@@ -749,20 +752,20 @@ class CustomGetter {
749
752
  }
750
753
  getExpandedPredicate(property) {
751
754
  return ContextParser.expandTerm(property, {
752
- ...this.clientContext,
753
- ...this.serverContext
755
+ ...this.serverContext,
756
+ ...this.clientContext
754
757
  }, true);
755
758
  }
756
759
  getCompactedPredicate(property) {
757
760
  return ContextParser.compactIri(property, {
758
- ...this.clientContext,
759
- ...this.serverContext
761
+ ...this.serverContext,
762
+ ...this.clientContext
760
763
  }, true);
761
764
  }
762
765
  getCompactedIri(id) {
763
766
  return ContextParser.compactIri(id, {
764
- ...this.clientContext,
765
- ...this.serverContext
767
+ ...this.serverContext,
768
+ ...this.clientContext
766
769
  });
767
770
  }
768
771
  toString() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",