Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions client/src/app/domain/models/meetings/meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export class Settings {
public motions_export_follow_recommendation!: boolean;
public motions_hide_metadata_background: boolean;
public motions_create_enable_additional_submitter_text: boolean;
public motions_enable_restricted_editor_for_manager: boolean;
public motions_enable_restricted_editor_for_non_manager: boolean;

public motion_poll_ballot_paper_selection!: BallotPaperSelection;
public motion_poll_ballot_paper_number!: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MotionEditorComponent } from './motion-editor.component';

xdescribe(`MotionEditor`, () => {
let component: MotionEditorComponent;
let fixture: ComponentFixture<MotionEditorComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MotionEditorComponent]
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(MotionEditorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it(`should create`, () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { AfterViewInit, Component, forwardRef, inject } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import OfficePaste from '@intevation/tiptap-extension-office-paste';
import { Extension } from '@tiptap/core';
import { Bold } from '@tiptap/extension-bold';
import { Document } from '@tiptap/extension-document';
import { HardBreak } from '@tiptap/extension-hard-break';
import { Heading } from '@tiptap/extension-heading';
import { Paragraph } from '@tiptap/extension-paragraph';
import { Text } from '@tiptap/extension-text';
import { UndoRedo } from '@tiptap/extensions';
import { Permission } from 'src/app/domain/definitions/permission';
import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service';
import { OperatorService } from 'src/app/site/services/operator.service';

import { EditorComponent } from '../../../../../../../ui/modules/editor/components/editor/editor.component';
import {
OsSplit,
OsSplitBulletList,
OsSplitListItem,
OsSplitOrderedList
} from '../../../../../../../ui/modules/editor/components/editor/extensions/os-split';
import { TextStyle } from '../../../../../../../ui/modules/editor/components/editor/extensions/text-style';

@Component({
selector: `os-motion-editor`,

templateUrl: `../../../../../../../ui/modules/editor/components/editor/editor.component.html`,
styleUrls: [`../../../../../../../ui/modules/editor/components/editor/editor.component.scss`],
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MotionEditorComponent), multi: true }],
standalone: false
})
export class MotionEditorComponent extends EditorComponent implements AfterViewInit {
private nonManagerSetting = false;
private managerSetting = false;

private canManage = false;

protected operator: OperatorService = inject(OperatorService);

public constructor(private meetingSettingsService: MeetingSettingsService) {
super();

this.nonManagerSetting = this.meetingSettingsService.instant(
`motions_enable_restricted_editor_for_non_manager`
);
this.managerSetting = this.meetingSettingsService.instant(`motions_enable_restricted_editor_for_manager`);

this.canManage = this.operator.hasPerms(Permission.motionCanManage);
}

public override getExtensions(): Extension[] {
if ((this.canManage && this.managerSetting) || (!this.canManage && this.nonManagerSetting)) {
return [
OfficePaste,
// Nodes
Document,
HardBreak,
Heading,
OsSplitBulletList,
OsSplitOrderedList,
OsSplitListItem,
Paragraph,
Text,

// Marks
Bold,
TextStyle,

// Extensions
UndoRedo,
OsSplit,
this.ngExtension()
];
}
return super.getExtensions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h4>
</h4>
}
<div>
<os-editor formControlName="text"></os-editor>
<os-motion-editor formControlName="text"></os-motion-editor>
</div>

<mat-checkbox formControlName="public">{{ 'Public' | translate }}</mat-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h4>
</span>
}
</h4>
<os-editor [formControlName]="'text_' + paragraph.paragraphNo"></os-editor>
<os-motion-editor [formControlName]="'text_' + paragraph.paragraphNo"></os-motion-editor>
</section>
}

Expand All @@ -131,7 +131,7 @@ <h4>
}
</h3>

<os-editor formControlName="reason" [required]="reasonRequired"></os-editor>
<os-motion-editor formControlName="reason" [required]="reasonRequired"></os-motion-editor>
@if (
reasonRequired &&
contentForm.get('reason')?.invalid &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ <h3>
<span>{{ preamble }}</span>
</h3>
}
<os-editor
<os-motion-editor
formControlName="text"
[required]="!isParagraphBasedAmendment"
></os-editor>
></os-motion-editor>
@if (
contentForm.get('text')?.invalid &&
(contentForm.get('text')?.dirty || contentForm.get('text')?.touched)
Expand Down Expand Up @@ -154,7 +154,10 @@ <h3>
}
</h3>
<!-- The HTML Editor -->
<os-editor formControlName="reason" [required]="reasonRequired"></os-editor>
<os-motion-editor
formControlName="reason"
[required]="reasonRequired"
></os-motion-editor>
@if (
reasonRequired &&
contentForm.get('reason')?.invalid &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>
</span>
}
</h3>
<os-editor [formControlName]="paragraph.paragraphNo"></os-editor>
<os-motion-editor [formControlName]="paragraph.paragraphNo"></os-motion-editor>
@if (isControlInvalid(paragraph.paragraphNo)) {
<div class="red-warning-text">
{{ 'This field is required.' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
} @else {
<form [formGroup]="formGroup">
<!-- The HTML Editor -->
<os-editor formControlName="text" [id]="sectionId"></os-editor>
<os-motion-editor formControlName="text" [id]="sectionId"></os-motion-editor>
</form>
}
@if (saveHint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@if (isEditMode) {
<form [formGroup]="contentForm">
<os-editor formControlName="modified_final_version" required [hidden]="!isEditMode"></os-editor>
<os-motion-editor formControlName="modified_final_version" required [hidden]="!isEditMode"></os-motion-editor>
@if (
contentForm.get('modified_final_version')?.invalid &&
(contentForm.get('modified_final_version')?.dirty || contentForm.get('modified_final_version')?.touched)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
} @else {
<form [formGroup]="formGroup">
<!-- The HTML Editor -->
<os-editor formControlName="text"></os-editor>
<os-motion-editor formControlName="text"></os-motion-editor>
</form>
}
@if (saveHint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,16 @@ export const meetingSettings: SettingsGroup[] = fillInSettingsDefaults([
label: _(`Show the sequential number for a motion`),
helpText: _(`In motion list, motion detail and PDF.`),
type: `boolean`
},
{
key: `motions_enable_restricted_editor_for_non_manager`,
label: _(`Limit the editor for all users without motion manage permissions`),
type: `boolean`
},
{
key: `motions_enable_restricted_editor_for_manager`,
label: _(`Limit the editor for all users with motion manage permissions`),
type: `boolean`
}
]
},
Expand Down
Loading
Loading