Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/autofill variable bug #792

Merged
merged 13 commits into from
Jan 13, 2025
5 changes: 5 additions & 0 deletions .changeset/flat-tomatoes-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': patch
---

Wait until everything has loaded to setup plugins, schema and nodeviews
53 changes: 42 additions & 11 deletions app/controllers/agendapoints/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { getActiveEditableNode } from '@lblod/ember-rdfa-editor/plugins/_private

import SnippetInsertRdfaComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-insert-rdfa';
import { fixArticleConnections } from '../../utils/fix-article-connections';
import { modifier } from 'ember-modifier';

export default class AgendapointsEditController extends Controller {
@service store;
@service router;
@service documentService;
@service intl;

@service('editor/agendapoint') agendapointEditor;

Expand All @@ -26,24 +28,21 @@ export default class AgendapointsEditController extends Controller {
@tracked _editorDocument;
@tracked controller;
@service features;
@tracked schema;
@tracked plugins;
@tracked editorSetup = false;

StructureControlCard = StructureControlCardComponent;
InsertArticle = InsertArticleComponent;

SnippetInsert = SnippetInsertRdfaComponent;

config = this.agendapointEditor.config;

nodeViews = this.agendapointEditor.nodeViews;

citationPlugin = this.agendapointEditor.citationPlugin;
get config() {
return this.agendapointEditor.config;
}

constructor(...args) {
super(...args);
const { schema, plugins } =
this.agendapointEditor.getSchemaAndPlugins(false);
this.schema = schema;
this.plugins = plugins;
get nodeViews() {
return this.agendapointEditor.nodeViews;
}

get dirty() {
Expand All @@ -69,6 +68,38 @@ export default class AgendapointsEditController extends Controller {
return null;
}

get isBusy() {
return (
!this.editorSetup ||
this.saveTask.isRunning ||
this.copyAgendapunt.isRunning
);
}

get busyText() {
if (!this.editorSetup) {
return this.intl.t('rdfa-editor-container.loading');
lagartoverde marked this conversation as resolved.
Show resolved Hide resolved
}
if (this.saveTask.isRunning) {
return this.intl.t('rdfa-editor-container.making-copy');
}
if (this.copyAgendapunt.isRunning) {
return this.intl.t('rdfa-editor-container.saving');
}
return '';
}

setSchemaAndPlugins = modifier(() => {
const { schema, plugins } =
this.agendapointEditor.getSchemaAndPlugins(false);
this.schema = schema;
this.plugins = plugins;
this.editorSetup = true;
return () => {
this.editorSetup = false;
};
});

@action
async handleRdfaEditorInit(editor) {
this.controller = editor;
Expand Down
6 changes: 2 additions & 4 deletions app/services/editor/agendapoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ export default class AgendapointEditorService extends Service {
@service intl;
@service currentSession;

citationPlugin = citationPlugin(this.config.citation);

get config() {
const classificatie = this.currentSession.classificatie;
const municipality = this.defaultMunicipality;
const municipality = this.currentSession.group;
return {
date: {
formats: [
Expand Down Expand Up @@ -338,7 +336,7 @@ export default class AgendapointEditorService extends Service {
const plugins = [
...tablePlugins,
tableKeymap,
this.citationPlugin,
citationPlugin(this.config.citation),
createInvisiblesPlugin(
[hardBreak, paragraphInvisible, headingInvisible],
{
Expand Down
11 changes: 3 additions & 8 deletions app/templates/agendapoints/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,15 @@
role='tabpanel'
tabindex='0'
aria-labelledby='tab-1'
{{this.setSchemaAndPlugins}}
>
<RdfaEditorContainer
@rdfaEditorInit={{this.handleRdfaEditorInit}}
@typeOfWrappingDiv='besluit:BehandelingVanAgendapunt'
@showToggleRdfaAnnotations={{true}}
@editorDocument={{this.editorDocument}}
@busy={{or this.saveTask.isRunning this.copyAgendapunt.isRunning}}
@busyText={{if
this.copyAgendapunt.isRunning
(t 'rdfa-editor-container.making-copy')
(t 'rdfa-editor-container.saving')
}}
@busy={{this.isBusy}}
@busyText={{this.busyText}}
@schema={{this.schema}}
@widgets={{this.widgets}}
@nodeViews={{this.nodeViews}}
Expand All @@ -124,7 +121,6 @@
/>
<CitationPlugin::CitationInsert
@controller={{this.controller}}
@plugin={{this.citationPlugin}}
@config={{this.config.citation}}
/>
<VariablePlugin::Date::Insert
Expand Down Expand Up @@ -181,7 +177,6 @@
<DecisionPlugin::DecisionPluginCard @controller={{this.controller}} />
<CitationPlugin::CitationCard
@controller={{this.controller}}
@plugin={{this.citationPlugin}}
@config={{this.config.citation}}
/>
<ImportSnippetPlugin::Card @controller={{this.controller}} />
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ rdfa-editor-container:
default-busy-text: Processing
saving: Saving
making-copy: Making copy
loading: Loading

regulatory-statements-plugin:
type: Regulatory Statement
Expand Down
1 change: 1 addition & 0 deletions translations/nl-BE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ rdfa-editor-container:
default-busy-text: Bezig met verwerken
saving: Bezig met opslaan
making-copy: Kopie aan het maken
loading: Bezig met laden

regulatory-statements-plugin:
type: Reglementaire bijlage
Expand Down