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

Feature/create new rs versions #386

Merged
merged 13 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions app/controllers/regulatory-statements/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import generateExportFromEditorDocument from 'frontend-gelinkt-notuleren/utils/generate-export-from-editor-document';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';
import { replaceUris } from '../../utils/replace-uris';

export default class RegulatoryAttachmentsShowController extends Controller {
@service currentSession;
Expand All @@ -12,6 +14,33 @@ export default class RegulatoryAttachmentsShowController extends Controller {
generateExportFromEditorDocument(this.model.editorDocument);
}

@task
*createNewVersion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to duplicate quite a bit from https://github.com/lblod/frontend-gelinkt-notuleren/pull/385/files#diff-43a8e9478c35d069347a4336692d075b1fd351b364bb6cb2a579e13be02ba183R36 I'd move the logic to the document service and use that in both

if (!this.currentSession.canWrite) return;
const currentVersion = this.model.editorDocument;
const documentContainer = this.model.documentContainer;
//If it's published
let content = replaceUris(currentVersion.content);

const newDocument = this.store.createRecord('editor-document', {
createdOn: new Date(),
updatedOn: new Date(),
content: content,
title: currentVersion.title,
previousVersion: currentVersion,
documentContainer,
});
yield newDocument.save();
currentVersion.nextVersion = newDocument;
yield currentVersion.save();
documentContainer.currentVersion = newDocument;
yield documentContainer.save();
this.router.transitionTo(
'regulatory-statements.edit',
documentContainer.id
);
}

get readOnly() {
return !this.currentSession.canWrite && this.currentSession.canRead;
}
Expand Down
5 changes: 5 additions & 0 deletions app/templates/regulatory-statements/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
{{t "utils.htmlExport"}}
</AuButton>
</AuDropdown>
{{#if this.currentSession.canWrite}}
<AuButton {{on "click" (perform this.createNewVersion)}} @disabled={{this.createNewVersion.isRunning}}>
{{t "utils.createNewVersion"}}
</AuButton>
{{/if}}
</:actions>
</AppChrome>

Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ utils:
currentVersion: Current Version
history: History
fullHistory: See the full history
createNewVersion: Create new version

validationModal:
title: Name your document
Expand Down
1 change: 1 addition & 0 deletions translations/nl-BE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ utils:
currentVersion: Actuele versie
history: HISTORIEK
fullHistory: Volledige historiek bekijken
createNewVersion: Nieuwe versie maken

validationModal:
title: Geef uw document een naam
Expand Down