Skip to content

Commit

Permalink
Merge pull request #700 from lblod/GN-4961
Browse files Browse the repository at this point in the history
Don't make unnecessary history changes when updating RS inside agendapoints
  • Loading branch information
lagartoverde authored Aug 21, 2024
2 parents 98fd55f + 0def693 commit 377255e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wild-dogs-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': patch
---

Don't make unnecesary history changes when updating regulatory statements inside agendapoints
6 changes: 5 additions & 1 deletion app/components/editor-plugins/regulatory-statements/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ export default class ReadOnlyContentSectionComponent extends Component {
include: 'current-version',
})
).firstObject;

this.currentVersion =
await this.regulatoryStatementContainer.currentVersion;
if (this.node.attrs.title !== this.currentVersion.title) {
this.args.updateAttribute('title', this.currentVersion.title);
}
if (this.content !== this.currentVersion.htmlSafeContent) {
if (
this.node.attrs.content.toString() !==
this.currentVersion.htmlSafeContent.toString()
) {
this.args.updateAttribute('content', this.currentVersion.htmlSafeContent);
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/editor-plugins/regulatory-statements-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createEmberNodeView,
} from '@lblod/ember-rdfa-editor/utils/ember-node';
import ReadOnlyContentSectionComponent from 'frontend-gelinkt-notuleren/components/editor-plugins/regulatory-statements/view';
import { htmlSafe } from '@ember/template';

/**
* @typedef {import('@lblod/ember-rdfa-editor/utils/ember-node').EmberNodeConfig} EmberNodeConfig
Expand All @@ -21,6 +22,7 @@ const emberNodeConfig = {
resource: {},
title: { default: '' },
content: { default: '' },
oldContent: { default: '' },
},
toDOM: (node) => {
const parser = new DOMParser();
Expand All @@ -33,6 +35,8 @@ const emberNodeConfig = {
property: 'eli:related_to',
rev: 'dct:isPartOf',
typeof: 'besluitpublicatie:Documentonderdeel',
'data-rs-content': node.attrs['content'],
'data-rs-title': node.attrs['title'],
},
['h5', {}, `Reglementaire bijlage: ${node.attrs['title']}`],
['div', {}, ...html.body.childNodes],
Expand All @@ -42,9 +46,13 @@ const emberNodeConfig = {
{
tag: 'div',
getAttrs(element) {
const oldContent = element.dataset.rsContent;
const title = element.dataset.rsTitle;
if (element.dataset['emberNode'] === 'regulatory-statement-view') {
return {
resource: element.getAttribute('resource'),
title,
content: htmlSafe(oldContent),
};
} else if (
element.dataset.inlineComponent ===
Expand All @@ -55,6 +63,8 @@ const emberNodeConfig = {
const propsParsed = JSON.parse(element.dataset.props);
return {
resource: propsParsed['uri'],
title,
content: htmlSafe(oldContent),
};
}
return false;
Expand Down

0 comments on commit 377255e

Please sign in to comment.