Skip to content

Commit 18d3a4e

Browse files
authored
Limit options and add setting to editor (#5432)
1 parent f50a911 commit 18d3a4e

File tree

14 files changed

+535
-344
lines changed

14 files changed

+535
-344
lines changed

client/src/app/domain/models/meetings/meeting.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export class Settings {
141141
public motions_export_follow_recommendation!: boolean;
142142
public motions_hide_metadata_background: boolean;
143143
public motions_create_enable_additional_submitter_text: boolean;
144+
public motions_enable_restricted_editor_for_manager: boolean;
145+
public motions_enable_restricted_editor_for_non_manager: boolean;
144146

145147
public motion_poll_ballot_paper_selection!: BallotPaperSelection;
146148
public motion_poll_ballot_paper_number!: number;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MotionEditorComponent } from './motion-editor.component';
4+
5+
xdescribe(`MotionEditor`, () => {
6+
let component: MotionEditorComponent;
7+
let fixture: ComponentFixture<MotionEditorComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [MotionEditorComponent]
12+
}).compileComponents();
13+
});
14+
15+
beforeEach(() => {
16+
fixture = TestBed.createComponent(MotionEditorComponent);
17+
component = fixture.componentInstance;
18+
fixture.detectChanges();
19+
});
20+
21+
it(`should create`, () => {
22+
expect(component).toBeTruthy();
23+
});
24+
});
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { AfterViewInit, Component, forwardRef, inject } from '@angular/core';
2+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
3+
import OfficePaste from '@intevation/tiptap-extension-office-paste';
4+
import { Extension } from '@tiptap/core';
5+
import { Bold } from '@tiptap/extension-bold';
6+
import { Document } from '@tiptap/extension-document';
7+
import { HardBreak } from '@tiptap/extension-hard-break';
8+
import { Heading } from '@tiptap/extension-heading';
9+
import { Paragraph } from '@tiptap/extension-paragraph';
10+
import { Text } from '@tiptap/extension-text';
11+
import { UndoRedo } from '@tiptap/extensions';
12+
import { Permission } from 'src/app/domain/definitions/permission';
13+
import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service';
14+
import { OperatorService } from 'src/app/site/services/operator.service';
15+
16+
import { EditorComponent } from '../../../../../../../ui/modules/editor/components/editor/editor.component';
17+
import {
18+
OsSplit,
19+
OsSplitBulletList,
20+
OsSplitListItem,
21+
OsSplitOrderedList
22+
} from '../../../../../../../ui/modules/editor/components/editor/extensions/os-split';
23+
import { TextStyle } from '../../../../../../../ui/modules/editor/components/editor/extensions/text-style';
24+
25+
@Component({
26+
selector: `os-motion-editor`,
27+
28+
templateUrl: `../../../../../../../ui/modules/editor/components/editor/editor.component.html`,
29+
styleUrls: [`../../../../../../../ui/modules/editor/components/editor/editor.component.scss`],
30+
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MotionEditorComponent), multi: true }],
31+
standalone: false
32+
})
33+
export class MotionEditorComponent extends EditorComponent implements AfterViewInit {
34+
private nonManagerSetting = false;
35+
private managerSetting = false;
36+
37+
private canManage = false;
38+
39+
protected operator: OperatorService = inject(OperatorService);
40+
41+
public constructor(private meetingSettingsService: MeetingSettingsService) {
42+
super();
43+
44+
this.nonManagerSetting = this.meetingSettingsService.instant(
45+
`motions_enable_restricted_editor_for_non_manager`
46+
);
47+
this.managerSetting = this.meetingSettingsService.instant(`motions_enable_restricted_editor_for_manager`);
48+
49+
this.canManage = this.operator.hasPerms(Permission.motionCanManage);
50+
}
51+
52+
public override getExtensions(): Extension[] {
53+
if ((this.canManage && this.managerSetting) || (!this.canManage && this.nonManagerSetting)) {
54+
return [
55+
OfficePaste,
56+
// Nodes
57+
Document,
58+
HardBreak,
59+
Heading,
60+
OsSplitBulletList,
61+
OsSplitOrderedList,
62+
OsSplitListItem,
63+
Paragraph,
64+
Text,
65+
66+
// Marks
67+
Bold,
68+
TextStyle,
69+
70+
// Extensions
71+
UndoRedo,
72+
OsSplit,
73+
this.ngExtension()
74+
];
75+
}
76+
return super.getExtensions();
77+
}
78+
}

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/modules/motion-change-recommendation-dialog/components/motion-content-change-recommendation-dialog/motion-content-change-recommendation-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h4>
2525
</h4>
2626
}
2727
<div>
28-
<os-editor formControlName="text"></os-editor>
28+
<os-motion-editor formControlName="text"></os-motion-editor>
2929
</div>
3030

3131
<mat-checkbox formControlName="public">{{ 'Public' | translate }}</mat-checkbox>

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-form/components/amendment-create-wizard/amendment-create-wizard.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h4>
110110
</span>
111111
}
112112
</h4>
113-
<os-editor [formControlName]="'text_' + paragraph.paragraphNo"></os-editor>
113+
<os-motion-editor [formControlName]="'text_' + paragraph.paragraphNo"></os-motion-editor>
114114
</section>
115115
}
116116

@@ -131,7 +131,7 @@ <h4>
131131
}
132132
</h3>
133133

134-
<os-editor formControlName="reason" [required]="reasonRequired"></os-editor>
134+
<os-motion-editor formControlName="reason" [required]="reasonRequired"></os-motion-editor>
135135
@if (
136136
reasonRequired &&
137137
contentForm.get('reason')?.invalid &&

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-form/components/motion-form/motion-form.component.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ <h3>
116116
<span>{{ preamble }}</span>
117117
</h3>
118118
}
119-
<os-editor
119+
<os-motion-editor
120120
formControlName="text"
121121
[required]="!isParagraphBasedAmendment"
122-
></os-editor>
122+
></os-motion-editor>
123123
@if (
124124
contentForm.get('text')?.invalid &&
125125
(contentForm.get('text')?.dirty || contentForm.get('text')?.touched)
@@ -154,7 +154,10 @@ <h3>
154154
}
155155
</h3>
156156
<!-- The HTML Editor -->
157-
<os-editor formControlName="reason" [required]="reasonRequired"></os-editor>
157+
<os-motion-editor
158+
formControlName="reason"
159+
[required]="reasonRequired"
160+
></os-motion-editor>
158161
@if (
159162
reasonRequired &&
160163
contentForm.get('reason')?.invalid &&

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-form/components/paragraph-based-amendment-editor/paragraph-based-amendment-editor.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h3>
1111
</span>
1212
}
1313
</h3>
14-
<os-editor [formControlName]="paragraph.paragraphNo"></os-editor>
14+
<os-motion-editor [formControlName]="paragraph.paragraphNo"></os-motion-editor>
1515
@if (isControlInvalid(paragraph.paragraphNo)) {
1616
<div class="red-warning-text">
1717
{{ 'This field is required.' | translate }}

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-comment/motion-comment.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
} @else {
2020
<form [formGroup]="formGroup">
2121
<!-- The HTML Editor -->
22-
<os-editor formControlName="text" [id]="sectionId"></os-editor>
22+
<os-motion-editor formControlName="text" [id]="sectionId"></os-motion-editor>
2323
</form>
2424
}
2525
@if (saveHint) {

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-final-version/motion-final-version.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@if (isEditMode) {
22
<form [formGroup]="contentForm">
3-
<os-editor formControlName="modified_final_version" required [hidden]="!isEditMode"></os-editor>
3+
<os-motion-editor formControlName="modified_final_version" required [hidden]="!isEditMode"></os-motion-editor>
44
@if (
55
contentForm.get('modified_final_version')?.invalid &&
66
(contentForm.get('modified_final_version')?.dirty || contentForm.get('modified_final_version')?.touched)

client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-personal-note/motion-personal-note.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
} @else {
4343
<form [formGroup]="formGroup">
4444
<!-- The HTML Editor -->
45-
<os-editor formControlName="text"></os-editor>
45+
<os-motion-editor formControlName="text"></os-motion-editor>
4646
</form>
4747
}
4848
@if (saveHint) {

0 commit comments

Comments
 (0)