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

Motion detail refactoring #4024

Merged
merged 51 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
de36a8e
WIP: Split motion detail component
bastianjoel Aug 14, 2024
1210a20
Add size property to subscription map
bastianjoel Aug 15, 2024
97add9f
Cleanup
bastianjoel Aug 15, 2024
e4895ef
Prevent detail view from emitting wrong ids
bastianjoel Aug 15, 2024
86db014
Linter fixes
bastianjoel Aug 15, 2024
3724a94
Improve motion meta
bastianjoel Aug 15, 2024
b3384ab
Fix karma test
bastianjoel Aug 15, 2024
2b1ac41
Move motion meta data
bastianjoel Aug 15, 2024
2579251
Split motion content
bastianjoel Aug 15, 2024
1795554
Cleanup motion content component
bastianjoel Aug 16, 2024
f867e73
Fix motion content change detection
bastianjoel Aug 16, 2024
3604f7b
Use observable for formatted text
bastianjoel Aug 16, 2024
cfd788b
Cleanup
bastianjoel Aug 16, 2024
4eca6ab
Merge motion form
bastianjoel Aug 16, 2024
6598fe4
Cleanup paragraph based amendments
bastianjoel Aug 19, 2024
2a685d9
Move motion comments and delete motion paragraph based amendments
bastianjoel Aug 19, 2024
19a7e70
Move motion-personal-note
bastianjoel Aug 19, 2024
c73444c
Update change detection
bastianjoel Aug 20, 2024
5594754
Move manage motion users component
bastianjoel Aug 20, 2024
364882b
Move poll button and content
bastianjoel Aug 20, 2024
5eba19b
Move motion extension field
bastianjoel Aug 20, 2024
40748fb
Smoother motion change
bastianjoel Aug 20, 2024
29050ae
Remove motion service collector
bastianjoel Aug 21, 2024
fb63102
Remove unused code from BaseMotionDetailChildComponent
bastianjoel Aug 21, 2024
faf0234
Fix error on motions without polls
bastianjoel Aug 21, 2024
7e3ba3a
Skip autoupdate duplicate view model store updates
bastianjoel Aug 21, 2024
a672423
Move DetailDiffSummary
bastianjoel Aug 22, 2024
ae2998d
Merge branch 'main' into 4023-motion-detail-refactoring
bastianjoel Aug 22, 2024
19ce6a0
WIP: Highlight form cleanup
bastianjoel Aug 23, 2024
0fa7b1d
Cleanup manage title
bastianjoel Aug 26, 2024
4a1c3ce
Fix motion title change indicator
bastianjoel Aug 26, 2024
9186289
Final component moves
bastianjoel Aug 26, 2024
095689c
Move unified changes processing to motion view
bastianjoel Aug 26, 2024
a758683
Fix motion edit category input
bastianjoel Aug 26, 2024
9624723
Fix change reco switching
bastianjoel Aug 26, 2024
3af4801
Merge branch 'main' into 4023-motion-detail-refactoring
bastianjoel Aug 26, 2024
8c7d2ed
Cleanup view service
bastianjoel Aug 26, 2024
f83c078
Motion view load process refactoring
bastianjoel Aug 27, 2024
179f8e9
Improve received data resolve
bastianjoel Aug 27, 2024
c06e14c
Fix amendment diff mode after reload
bastianjoel Aug 27, 2024
1b89ee6
Minor fix
bastianjoel Aug 27, 2024
a55bd39
Fix editor component content update
bastianjoel Aug 28, 2024
47efe22
Change requests
bastianjoel Aug 28, 2024
cef55f3
Merge branch 'main' into 4023-motion-detail-refactoring
bastianjoel Sep 10, 2024
366dc78
Fix forwarding button not displayed
bastianjoel Sep 10, 2024
1c0cffc
Remove debug output
bastianjoel Sep 11, 2024
f710e2a
Hide category/tags/motion block selects if none existing
bastianjoel Sep 11, 2024
3fae0a8
Improve motion form partent initial load
bastianjoel Sep 11, 2024
7f57d07
Merge branch 'main' into 4023-motion-detail-refactoring
bastianjoel Sep 11, 2024
ca1dc6e
Fix create form issues
bastianjoel Sep 11, 2024
164afe4
Merge branch 'main' into 4023-motion-detail-refactoring
bastianjoel Sep 16, 2024
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
4 changes: 4 additions & 0 deletions client/src/app/gateways/repositories/base-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
result = this.relationManager.handleRelation(_model, relation);
}
return result;
},
set: (obj, ...args): any => {
obj.viewModelUpdateTimestamp = Date.now();
return Reflect.set(obj, ...args);
}
});
this._createViewModelPipes.forEach(fn => fn(viewModel));
Expand Down
4 changes: 4 additions & 0 deletions client/src/app/infrastructure/utils/subscription-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class SubscriptionMap {
this._subscriptions = {};
}

public size(): number {
return Object.keys(this._subscriptions).length;
}

private nextRandomId(): string {
const id = Math.floor(Math.random() * (900000 - 1) + 100000);
return id.toString();
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/site/base/base-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface ViewModelConstructor<T extends BaseViewModel> {
* Base class for view models.
*/
export abstract class BaseViewModel<M extends BaseModel = any> implements DetailNavigable {
public viewModelUpdateTimestamp = Date.now();

public get fqid(): Fqid {
return this.getModel().fqid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,26 @@
margin-top: -3px;
transform: scale(0.75);
}

@keyframes train {
0% {
right: 0;
}
99% {
right: 100%;
}
100% {
right: 100%;
display: none;
}
}

.global-headbar.train:after {
content: '🚂 🚃 🚃 🚃';
position: absolute;
overflow: hidden;
animation-name: train;
animation-duration: 15s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
OnInit,
Output
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker';
import { Subscription } from 'rxjs';
import { Collection, Id } from 'src/app/domain/definitions/key-types';
import { ActiveMeetingService } from 'src/app/site/pages/meetings/services/active-meeting.service';
import { ActiveMeetingIdService } from 'src/app/site/pages/meetings/services/active-meeting-id.service';
import { SequentialNumberMappingService } from 'src/app/site/pages/meetings/services/sequential-number-mapping.service';

Expand Down Expand Up @@ -44,29 +45,38 @@ export class DetailViewComponent implements OnInit {
private _shouldShowContent = false;
private _loading = true;
private _id!: Id;
private _sequential_number!: number;

private _subscriptionMap: { [name: string]: Subscription } = {};

public constructor(
private sequentialNumberMappingService: SequentialNumberMappingService,
private activeMeetingService: ActiveMeetingService,
private activeMeetingIdService: ActiveMeetingIdService,
private route: ActivatedRoute,
private router: Router,
private cd: ChangeDetectorRef
) {}

public ngOnInit(): void {
this.activeMeetingIdService.meetingIdObservable.subscribe(() => this.onMeetingChanged());
this.activeMeetingService.meetingIdObservable.subscribe(id => this.onMeetingChanged(id));
}

private onMeetingChanged(): void {
const subscription = this.route.params.subscribe(params => {
this.parseSequentialNumber(params);
private onMeetingChanged(meetingId: Id): void {
this.deleteSubscription(ROUTE_SUBSCRIPTION_NAME);
this.activeMeetingService.ensureActiveMeetingIsAvailable().then(() => {
const subscription = this.route.params.subscribe(params => {
if (this.activeMeetingIdService.parseUrlMeetingId(this.router.url) === meetingId) {
this.parseSequentialNumber(params);
}
});
this.updateSubscription(ROUTE_SUBSCRIPTION_NAME, subscription);
});
this.updateSubscription(ROUTE_SUBSCRIPTION_NAME, subscription);
}

private parseSequentialNumber(params: { id?: string }): void {
const sequentialNumber = +(params.id ?? 0);
this._sequential_number = sequentialNumber;
if (!sequentialNumber && params.id === undefined) {
// it must be another subroute, like creating a new one
this._shouldShowContent = true;
Expand All @@ -76,12 +86,12 @@ export class DetailViewComponent implements OnInit {
const config = {
collection: this.collection,
sequentialNumber,
meetingId: this.activeMeetingIdService.meetingId!
meetingId: this.activeMeetingService.meetingId!
};

this.sequentialNumberMappingService.getIdBySequentialNumber(config).then(id => {
this._loading = false;
if (id !== undefined) {
if (id !== undefined && this._sequential_number === sequentialNumber) {
if (id) {
if (this._id !== id) {
this._id = id;
Expand Down Expand Up @@ -109,4 +119,11 @@ export class DetailViewComponent implements OnInit {
}
this._subscriptionMap[subscriptionName] = subscription;
}

private deleteSubscription(subscriptionName: string): void {
if (this._subscriptionMap[subscriptionName]) {
this._subscriptionMap[subscriptionName].unsubscribe();
this._subscriptionMap[subscriptionName] = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export abstract class BasePollComponent<C extends PollContentObject = any> exten
return this._poll;
}

protected set poll(poll: ViewPoll) {
this._poll = poll;
this.onAfterUpdatePoll(poll);
}

public pollStateActions = {
[PollState.Created]: {
icon: `play_arrow`,
Expand Down Expand Up @@ -110,8 +115,7 @@ export abstract class BasePollComponent<C extends PollContentObject = any> exten
this.subscriptions.push(
this.repo.getViewModelObservable(this._id).subscribe(poll => {
if (poll) {
this._poll = poll;
this.onAfterUpdatePoll(poll);
this.poll = poll;
}
})
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { distinctUntilChanged, map, Observable } from 'rxjs';
import { Id } from 'src/app/domain/definitions/key-types';
import { Identifiable } from 'src/app/domain/interfaces';
import { MotionChangeRecommendation } from 'src/app/domain/models/motions/motion-change-recommendation';
Expand Down Expand Up @@ -47,7 +47,13 @@ export class MotionChangeRecommendationControllerService extends BaseMeetingCont
*/
public getChangeRecosOfMotionObservable(motionId: Id): Observable<ViewMotionChangeRecommendation[]> {
return this.getViewModelListObservable().pipe(
map((recos: ViewMotionChangeRecommendation[]) => recos.filter(reco => reco.motion_id === motionId))
map((recos: ViewMotionChangeRecommendation[]) => recos.filter(reco => reco.motion_id === motionId)),
distinctUntilChanged(
(prev, curr) =>
prev?.length === curr?.length &&
Math.max(...prev.map(e => e.viewModelUpdateTimestamp)) ===
Math.max(...curr.map(e => e.viewModelUpdateTimestamp))
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BasePollComponent } from 'src/app/site/pages/meetings/modules/poll/base
import { OperatorService } from 'src/app/site/services/operator.service';

import { VotingPrivacyWarningDialogService } from '../../../../../../modules/poll/modules/voting-privacy-dialog/services/voting-privacy-warning-dialog.service';
import { ViewPoll } from '../../../../../polls';
import { MotionPollService } from '../../services';
import { MotionPollPdfService } from '../../services/motion-poll-pdf.service/motion-poll-pdf.service';

Expand All @@ -16,6 +17,11 @@ import { MotionPollPdfService } from '../../services/motion-poll-pdf.service/mot
styleUrls: [`./motion-poll.component.scss`]
})
export class MotionPollComponent extends BasePollComponent {
@Input()
public set pollViewModel(poll: ViewPoll) {
this.poll = poll;
}

@Input()
public set pollId(id: Id) {
this.initializePoll(id);
Expand Down
Loading