@@ -4,12 +4,14 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
44import { Router } from '@angular/router' ;
55import { TranslateService } from '@ngx-translate/core' ;
66import { Observable } from 'rxjs' ;
7- import { AgendaItemRepositoryService } from 'src/app/gateways/repositories/agenda' ;
87import { AssignmentRepositoryService } from 'src/app/gateways/repositories/assignments/assignment-repository.service' ;
98import { 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' ;
1011import { 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 ' ;
1213import { 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' ;
1315import { ViewMotion } from 'src/app/site/pages/meetings/pages/motions/view-models/view-motion' ;
1416import { ActiveMeetingIdService } from 'src/app/site/pages/meetings/services/active-meeting-id.service' ;
1517import { 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