Skip to content

Commit 6f0d2bb

Browse files
author
Javier Borrego
committed
Improved data display and added use restrictions
1 parent a999e5c commit 6f0d2bb

3 files changed

Lines changed: 133 additions & 114 deletions

File tree

client/src/app/ui/modules/editor/components/editor-link-dialog/editor-link-dialog.component.html

Lines changed: 88 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
>
1111
<div class="references">
1212
<h1 aria-label="Insert/edit external link" mat-dialog-title translate>Insert/edit external link</h1>
13-
<button #btn class="arrows" matIconButton (click)="toggleArrow('toggleExternalReference')">
14-
@if (toggleExternalReference) {
15-
<mat-icon>keyboard_arrow_up</mat-icon>
16-
} @else {
17-
<mat-icon>keyboard_arrow_down</mat-icon>
18-
}
19-
</button>
13+
@if (allowedToEmbed) {
14+
<button #btn class="arrows" matIconButton>
15+
@if (toggleExternalReference) {
16+
<mat-icon>keyboard_arrow_up</mat-icon>
17+
} @else {
18+
<mat-icon>keyboard_arrow_down</mat-icon>
19+
}
20+
</button>
21+
}
2022
</div>
2123
</div>
22-
@if (toggleExternalReference) {
24+
@if (toggleExternalReference || !allowedToEmbed) {
2325
<div mat-dialog-content [formGroup]="externalLink">
2426
<div class="card-grid">
2527
<mat-form-field>
@@ -46,82 +48,88 @@ <h1 aria-label="Insert/edit external link" mat-dialog-title translate>Insert/edi
4648
</div>
4749
</div>
4850
}
49-
<div
50-
cdkTrapFocus
51-
class="title"
52-
role="button"
53-
tabindex="0"
54-
(click)="toggleArrow('toggleInternalReference')"
55-
(keydown.enter)="toggleArrow('toggleInternalReference')"
56-
(keydown.space)="toggleArrow('toggleInternalReference')"
57-
>
58-
<div class="references">
59-
<h1 aria-label="Link a topic/motion/assignment" mat-dialog-title translate>Link a topic/motion/assignment</h1>
60-
<button class="arrows" matIconButton (click)="toggleArrow('toggleInternalReference')">
61-
@if (toggleInternalReference) {
62-
<mat-icon>keyboard_arrow_up</mat-icon>
63-
} @else {
64-
<mat-icon>keyboard_arrow_down</mat-icon>
65-
}
66-
</button>
67-
</div>
68-
</div>
69-
@if (toggleInternalReference) {
70-
<div mat-dialog-content>
71-
<div class="card-grid" [formGroup]="internalRadioOptions">
72-
<mat-radio-group aria-label="Select an option" class="radio-group" formControlName="options">
73-
<mat-radio-button
74-
aria-label="Topics"
75-
translate
76-
[disabled]="!!externalUrl"
77-
[value]="0"
78-
(click)="changeEditMode()"
79-
>
80-
Topics
81-
</mat-radio-button>
82-
<mat-radio-button
83-
aria-label="Motions"
84-
translate
85-
[disabled]="!!externalUrl"
86-
[value]="1"
87-
(click)="changeEditMode()"
88-
>
89-
Motions
90-
</mat-radio-button>
91-
<mat-radio-button
92-
aria-label="Assignments"
93-
translate
94-
[disabled]="!!externalUrl"
95-
[value]="2"
96-
(click)="changeEditMode()"
97-
>
98-
Assignments
99-
</mat-radio-button>
100-
</mat-radio-group>
101-
<mat-form-field [formGroup]="internalReferenceForm">
102-
<mat-label translate>
103-
{{ searchLists[selectedRepoValue].label }}
104-
</mat-label>
105-
@for (searchRepo of searchRepos; track $index) {
106-
@if (selectedRepoValue === $index) {
107-
<os-repo-search-selector
108-
formControlName="{{ searchLists[$index].label }}FormControl"
109-
[disabled]="!!externalUrl"
110-
[keepOpen]="searchRepo.keepOpen"
111-
[repo]="searchRepo"
112-
[subscriptionConfig]="subscriptionConfig"
113-
[wider]="searchRepo.wider"
114-
></os-repo-search-selector>
115-
}
51+
52+
@if (allowedToEmbed) {
53+
<div
54+
cdkTrapFocus
55+
class="title"
56+
role="button"
57+
tabindex="0"
58+
(click)="toggleArrow('toggleInternalReference')"
59+
(keydown.enter)="toggleArrow('toggleInternalReference')"
60+
(keydown.space)="toggleArrow('toggleInternalReference')"
61+
>
62+
<div class="references">
63+
<h1 aria-label="Link a topic/motion/assignment" mat-dialog-title translate>
64+
Link a topic/motion/assignment
65+
</h1>
66+
<button class="arrows" matIconButton>
67+
@if (toggleInternalReference) {
68+
<mat-icon>keyboard_arrow_up</mat-icon>
69+
} @else {
70+
<mat-icon>keyboard_arrow_down</mat-icon>
11671
}
117-
</mat-form-field>
118-
</div>
119-
<div class="clear-button">
120-
<button aria-label="Reset" color="gray" mat-icon-button translate (click)="initForm()">
121-
<mat-icon>clear</mat-icon>
12272
</button>
12373
</div>
12474
</div>
75+
76+
@if (toggleInternalReference) {
77+
<div mat-dialog-content>
78+
<div class="card-grid" [formGroup]="internalRadioOptions">
79+
<mat-radio-group aria-label="Select an option" class="radio-group" formControlName="options">
80+
<mat-radio-button
81+
aria-label="Topics"
82+
translate
83+
[disabled]="!!externalUrl"
84+
[value]="0"
85+
(click)="changeEditMode()"
86+
>
87+
Topics
88+
</mat-radio-button>
89+
<mat-radio-button
90+
aria-label="Motions"
91+
translate
92+
[disabled]="!!externalUrl"
93+
[value]="1"
94+
(click)="changeEditMode()"
95+
>
96+
Motions
97+
</mat-radio-button>
98+
<mat-radio-button
99+
aria-label="Assignments"
100+
translate
101+
[disabled]="!!externalUrl"
102+
[value]="2"
103+
(click)="changeEditMode()"
104+
>
105+
Assignments
106+
</mat-radio-button>
107+
</mat-radio-group>
108+
<mat-form-field [formGroup]="internalReferenceForm">
109+
<mat-label translate>
110+
{{ searchLists[selectedRepoValue].label }}
111+
</mat-label>
112+
@for (searchRepo of searchRepos; track $index) {
113+
@if (selectedRepoValue === $index) {
114+
<os-repo-search-selector
115+
formControlName="{{ searchLists[$index].label }}FormControl"
116+
[disabled]="!!externalUrl"
117+
[keepOpen]="searchRepo.keepOpen"
118+
[repo]="searchRepo"
119+
[subscriptionConfig]="searchSubscriptionConfig[$index]"
120+
[wider]="searchRepo.wider"
121+
></os-repo-search-selector>
122+
}
123+
}
124+
</mat-form-field>
125+
</div>
126+
<div class="clear-button">
127+
<button aria-label="Reset" color="gray" mat-icon-button translate (click)="initForm()">
128+
<mat-icon>clear</mat-icon>
129+
</button>
130+
</div>
131+
</div>
132+
}
125133
}
126134

127135
<div class="matDialogActions" mat-dialog-actions>

client/src/app/ui/modules/editor/components/editor-link-dialog/editor-link-dialog.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mat-form-field {
3030
outline: none;
3131
box-shadow: none;
3232
& h1 {
33-
background-color: #eee;
33+
text-decoration: underline 2px #ccc;
3434
border-radius: 25px;
3535
}
3636
}

client/src/app/ui/modules/editor/components/editor-link-dialog/editor-link-dialog.component.ts

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
44
import { Router } from '@angular/router';
55
import { TranslateService } from '@ngx-translate/core';
66
import { Observable } from 'rxjs';
7-
import { AgendaItemRepositoryService } from 'src/app/gateways/repositories/agenda';
87
import { AssignmentRepositoryService } from 'src/app/gateways/repositories/assignments/assignment-repository.service';
98
import { MotionRepositoryService } from 'src/app/gateways/repositories/motions';
9+
import { TopicRepositoryService } from 'src/app/gateways/repositories/topics/topic-repository.service';
10+
import { ViewTopic } from 'src/app/site/pages/meetings/pages/agenda';
1011
import { getAgendaListMinimalSubscriptionConfig } from 'src/app/site/pages/meetings/pages/agenda/agenda.subscription';
11-
import { ViewAgendaItem } from 'src/app/site/pages/meetings/pages/agenda/view-models';
12+
import { getAssignmentListMinimalSubscriptionConfig } from 'src/app/site/pages/meetings/pages/assignments/assignments.subscription';
1213
import { ViewAssignment } from 'src/app/site/pages/meetings/pages/assignments/view-models/view-assignment';
14+
import { getMotionListMinimalSubscriptionConfig } from 'src/app/site/pages/meetings/pages/motions/motions.subscription';
1315
import { ViewMotion } from 'src/app/site/pages/meetings/pages/motions/view-models/view-motion';
1416
import { ActiveMeetingIdService } from 'src/app/site/pages/meetings/services/active-meeting-id.service';
1517
import { SubscribeToConfig } from 'src/app/site/services/model-request.service';
@@ -42,13 +44,17 @@ export class EditorLinkDialogComponent implements OnInit {
4244

4345
public internalText = ``;
4446

47+
public allowedToEmbed: boolean;
48+
4549
public toggleInternalReference: boolean;
4650
public toggleExternalReference: boolean;
4751

52+
// subscriptions config
53+
public searchSubscriptionConfig;
4854
private activeMeetingIdService = inject(ActiveMeetingIdService);
49-
public subscriptionConfig: SubscribeToConfig = getAgendaListMinimalSubscriptionConfig(
50-
this.activeMeetingIdService.meetingId
51-
);
55+
public subscriptionTopicConfig: SubscribeToConfig;
56+
public subscriptionMotionConfig: SubscribeToConfig;
57+
public subscriptionAssignmentConfig: SubscribeToConfig;
5258

5359
/**
5460
* Initial value of the input-field.
@@ -69,13 +75,13 @@ export class EditorLinkDialogComponent implements OnInit {
6975
/**
7076
* Init Repos
7177
*/
72-
public agendaItemRepo = inject(AgendaItemRepositoryService);
78+
public agendaItemRepo = inject(TopicRepositoryService);
7379
public motionItemRepo = inject(MotionRepositoryService);
7480
public assignmentItemRepo = inject(AssignmentRepositoryService);
7581
/**
7682
* Define lists
7783
*/
78-
protected agendaItemList: Observable<ViewAgendaItem<any>[]>;
84+
protected agendaItemList: Observable<ViewTopic[]>;
7985
protected motionItemList: Observable<ViewMotion[]>;
8086
protected assignmentItemList: Observable<ViewAssignment[]>;
8187

@@ -143,18 +149,30 @@ export class EditorLinkDialogComponent implements OnInit {
143149
}
144150

145151
public ngOnInit(): void {
146-
this.agendaItemList = this.agendaItemRepo.getSortedViewModelListObservable();
147-
this.motionItemList = this.motionItemRepo.getSortedViewModelListObservable();
148-
this.assignmentItemList = this.assignmentItemRepo.getSortedViewModelListObservable();
149-
150-
this.searchLists = [
151-
{ observable: this.agendaItemList, label: this.translate.instant('Topic') },
152-
{ observable: this.motionItemList, label: this.translate.instant('Motion') },
153-
{ observable: this.assignmentItemList, label: this.translate.instant('Assignment') }
154-
];
155-
this.searchRepos = [this.agendaItemRepo, this.motionItemRepo, this.assignmentItemRepo];
156-
this.initInput();
157-
this.initForm();
152+
if ((this.allowedToEmbed = !this.router.url.includes('motions') ? true : false)) {
153+
this.agendaItemList = this.agendaItemRepo.getViewModelListObservable();
154+
this.motionItemList = this.motionItemRepo.getSortedViewModelListObservable();
155+
this.assignmentItemList = this.assignmentItemRepo.getSortedViewModelListObservable();
156+
this.searchLists = [
157+
{ observable: this.agendaItemList, label: this.translate.instant('Topic') },
158+
{ observable: this.motionItemList, label: this.translate.instant('Motion') },
159+
{ observable: this.assignmentItemList, label: this.translate.instant('Assignment') }
160+
];
161+
this.searchRepos = [this.agendaItemRepo, this.motionItemRepo, this.assignmentItemRepo];
162+
this.searchSubscriptionConfig = [
163+
(this.subscriptionTopicConfig = getAgendaListMinimalSubscriptionConfig(
164+
this.activeMeetingIdService.meetingId
165+
)),
166+
(this.subscriptionMotionConfig = getMotionListMinimalSubscriptionConfig(
167+
this.activeMeetingIdService.meetingId
168+
)),
169+
(this.subscriptionAssignmentConfig = getAssignmentListMinimalSubscriptionConfig(
170+
this.activeMeetingIdService.meetingId
171+
))
172+
];
173+
this.initInput();
174+
this.initForm();
175+
}
158176
}
159177

160178
public removeLink(): void {
@@ -244,20 +262,13 @@ export class EditorLinkDialogComponent implements OnInit {
244262
}
245263

246264
public urlBuilder(item): string {
247-
const parts = item.content_object_id?.split('/');
248-
const isAgendaItem = item.collection === 'agenda_item' && item.content_object_id?.split('/')[0] === 'topic';
249-
const setCollection: string = isAgendaItem
250-
? 'agenda/topic'
251-
: item.collection === 'agenda_item'
252-
? parts?.[0]
253-
: item.collection;
254-
const setId: number = isAgendaItem
255-
? item.content_object.sequential_number
256-
: item.content_object_id
257-
? parts?.[1]
258-
: item.sequential_number;
259-
const builtUrl = `${this.activeMeetingIdService.meetingId}/${setCollection}s/${setId}`;
260-
const url = this.router.url.replace(/^\/.*$/, `/${builtUrl}`);
265+
const isAgendaItem = item.collection === 'topic';
266+
console.log(isAgendaItem, item.collection, item.id, item.sequential_number);
267+
const setCollection: string = isAgendaItem ? 'agenda/topic' : item.collection;
268+
const builtUrl = `${this.activeMeetingIdService.meetingId}/${setCollection}s/`;
269+
const setId: number = item.collection === 'assignment' ? item.id : item.sequential_number;
270+
console.log(builtUrl);
271+
const url = this.router.url.replace(/^\/.*$/, `/${builtUrl}${setId}`);
261272
return url;
262273
}
263274
}

0 commit comments

Comments
 (0)