@entryscape/rdforms 10.3.1 → 10.3.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@entryscape/rdforms",
3
3
  "description": "RDForms (aka RDF Forms) is a JavaScript library that uses templates to describe how to edit, present and validate RDF. The library is intended to be used in web applications to ease the burden of developers to deal natively with RDF.",
4
4
  "keywords": ["RDF", "editor", "metadata", "application profile", "linked data"],
5
- "version": "10.3.1",
5
+ "version": "10.3.2",
6
6
  "main": "dist/rdforms.node.js",
7
7
  "browser": "dist/rdforms.react.js",
8
8
  "module": "main.js",
@@ -357,7 +357,7 @@ const _matchTextItem = (pb, item) => {
357
357
  if (_noDibbs(stmt) && _isPatternMatch(item, stmt)) {
358
358
  const ntMatch = _isNodeTypeMatch(item, stmt);
359
359
  const dtMatch = _isDataTypeMatch(item, stmt);
360
- if ((ntMatch && dtMatch) || _fuzzy) {
360
+ if ((ntMatch && (dtMatch || item.hasStyle('relaxedDatatypeMatch'))) || _fuzzy) {
361
361
  _dibbs(stmt);
362
362
  let matchingCode = ntMatch ? CODES.OK : CODES.WRONG_NODETYPE;
363
363
  if (!dtMatch) {
@@ -45,6 +45,7 @@ export default class Item {
45
45
  'label',
46
46
  'tooltip',
47
47
  'strictmatch',
48
+ 'relaxedDatatypeMatch',
48
49
  'viewAllTranslations',
49
50
  'email',
50
51
  'atLeastOneChild',
@@ -18,7 +18,7 @@ const showNow = (editor, item, bindings, includeLevel) => {
18
18
  const prop = item.getProperty();
19
19
  if (bindings.length > 0) {
20
20
  if (prop) {
21
- return !editor.filterProperty(prop);
21
+ return !editor.filterItem(item);
22
22
  }
23
23
 
24
24
  // Take care of layout grouping by checking recursively.
package/src/view/View.js CHANGED
@@ -3,6 +3,7 @@ import renderingContext from './renderingContext';
3
3
  import GroupBinding from '../model/GroupBinding';
4
4
  import * as engine from '../model/engine';
5
5
  import { bindingReport } from '../model/validate';
6
+ import {namespaces} from "@entryscape/rdfjson";
6
7
 
7
8
  let viewCounter = 0;
8
9
  export default class View {
@@ -286,24 +287,37 @@ export default class View {
286
287
  }
287
288
 
288
289
  filterBinding(binding) {
289
- const fp = this._getFilterPredicates();
290
- const stmt = binding.getStatement();
291
- const item = binding.getItem();
292
- if (fp && stmt) {
293
- return fp[stmt.getPredicate()] === true;
294
- }
295
- if (fp && item.getType() === 'group' && !item.getProperty()) {
296
- // Checks one level below if there is a child that is visible
297
- const childBindings = item.getChildren() || [];
298
- let hasNonFilteredChild = false;
299
- childBindings.forEach((child) => {
300
- if (fp[child.getProperty()] !== true) {
301
- hasNonFilteredChild = true;
302
- }
303
- });
304
- return !hasNonFilteredChild;
305
- }
306
- return false;
290
+ return this.filterItem(binding.getItem());
291
+ }
292
+
293
+ filterItem(itemToCheck) {
294
+ const filterPredicates = this._getFilterPredicates();
295
+
296
+ const filter = (item, fp) => {
297
+ // Exclude based on item id.
298
+ const id = item.getId();
299
+ if (id && fp && Object.keys(fp).includes(id)) {
300
+ return true;
301
+ }
302
+ // Exclude if property matches.
303
+ const prop = item.getProperty();
304
+ if (fp && prop) {
305
+ return fp[prop] === true || fp[namespaces.shortenKnown(prop)] === true;
306
+ }
307
+ if (fp && item.getType() === 'group' && !item.getProperty()) {
308
+ // Checks one level below if there is a child that is visible
309
+ const childBindings = item.getChildren() || [];
310
+ let hasNonFilteredChild = false;
311
+ childBindings.forEach((child) => {
312
+ if (!filter(child, fp)) {
313
+ hasNonFilteredChild = true;
314
+ }
315
+ });
316
+ return !hasNonFilteredChild;
317
+ }
318
+ return false;
319
+ };
320
+ return filter(itemToCheck, filterPredicates);
307
321
  }
308
322
 
309
323
  filterProperty(property) {