Skip to content

Commit

Permalink
Use instantiateUuids util from standard-template-plugin
Browse files Browse the repository at this point in the history
Enables support for `generateBoundUuid()`
  • Loading branch information
piemonkey committed Oct 3, 2023
1 parent fc625a1 commit be7b65a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-poems-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': minor
---

Add support for regulatory statement templates with repeated entity uris
13 changes: 1 addition & 12 deletions app/components/document-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { action } from '@ember/object';
import { service } from '@ember/service';
import { task } from 'ember-concurrency';
import { DRAFT_STATUS_ID } from 'frontend-gelinkt-notuleren/utils/constants';
import { v4 as uuidv4 } from 'uuid';
import { instantiateUuids } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin';

export default class DocumentCreatorComponent extends Component {
@tracked title = '';
Expand Down Expand Up @@ -117,14 +117,3 @@ export default class DocumentCreatorComponent extends Component {
}
});
}
// we can't afford to import the one from the template plugin
// as the regex is way too loose and also tries to evaluate
// all the variables in the string, which coincidentally use the
// exact same syntax
function instantiateUuids(templateString) {
let generateUuid = uuidv4; // eslint-disable-line no-unused-vars
return templateString.replace(/\$\{generateUuid\(\)\}/g, (match) => {
//input '${content}' and eval('content')
return eval(match.substring(2, match.length - 1));
});
}

0 comments on commit be7b65a

Please sign in to comment.