Merge pull request #4803 from tsiegleauq/sorted-next-motion
Enhance surrounding motion detection
This commit is contained in:
commit
582be687eb
@ -145,4 +145,4 @@ matrix:
|
|||||||
install:
|
install:
|
||||||
- npm install
|
- npm install
|
||||||
script:
|
script:
|
||||||
- npm run ng-high-memory build --prod
|
- npm run ng-high-memory -- build --prod --aot
|
||||||
|
@ -90,7 +90,7 @@ export class MotionBlockListComponent extends ListViewBaseComponent<ViewMotionBl
|
|||||||
translate: TranslateService,
|
translate: TranslateService,
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
private repo: MotionBlockRepositoryService,
|
public repo: MotionBlockRepositoryService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private itemRepo: ItemRepositoryService,
|
private itemRepo: ItemRepositoryService,
|
||||||
private operator: OperatorService,
|
private operator: OperatorService,
|
||||||
|
@ -324,7 +324,7 @@
|
|||||||
|
|
||||||
<!-- Category -->
|
<!-- Category -->
|
||||||
<!-- Disabled during "new motion" since changing has no effect -->
|
<!-- Disabled during "new motion" since changing has no effect -->
|
||||||
<div *ngIf="!editMotion && categoryObserver.value.length > 0">
|
<div *ngIf="!editMotion && categoryObserver.value.length">
|
||||||
<h4 *ngIf="perms.isAllowed('change_metadata', motion) || motion.category" translate>Category</h4>
|
<h4 *ngIf="perms.isAllowed('change_metadata', motion) || motion.category" translate>Category</h4>
|
||||||
<mat-menu #categoryMenu="matMenu">
|
<mat-menu #categoryMenu="matMenu">
|
||||||
<button
|
<button
|
||||||
@ -342,7 +342,7 @@
|
|||||||
class="grey"
|
class="grey"
|
||||||
disableRipple
|
disableRipple
|
||||||
>
|
>
|
||||||
{{ motion.category.prefixedNameWithParents || '–' }}
|
{{ motion.category ? motion.category.prefixedNameWithParents : '–' }}
|
||||||
</mat-basic-chip>
|
</mat-basic-chip>
|
||||||
<mat-basic-chip
|
<mat-basic-chip
|
||||||
*ngIf="!perms.isAllowed('change_metadata', motion) && motion.category"
|
*ngIf="!perms.isAllowed('change_metadata', motion) && motion.category"
|
||||||
|
@ -13,6 +13,7 @@ import { ChangeRecommendationRepositoryService } from 'app/core/repositories/mot
|
|||||||
import { CreateMotion } from 'app/site/motions/models/create-motion';
|
import { CreateMotion } from 'app/site/motions/models/create-motion';
|
||||||
import { ConfigService } from 'app/core/ui-services/config.service';
|
import { ConfigService } from 'app/core/ui-services/config.service';
|
||||||
import { DiffLinesInParagraph, LineRange } from 'app/core/ui-services/diff.service';
|
import { DiffLinesInParagraph, LineRange } from 'app/core/ui-services/diff.service';
|
||||||
|
import { ItemRepositoryService } from 'app/core/repositories/agenda/item-repository.service';
|
||||||
import { LinenumberingService } from 'app/core/ui-services/linenumbering.service';
|
import { LinenumberingService } from 'app/core/ui-services/linenumbering.service';
|
||||||
import { LocalPermissionsService } from 'app/site/motions/services/local-permissions.service';
|
import { LocalPermissionsService } from 'app/site/motions/services/local-permissions.service';
|
||||||
import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
|
import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
|
||||||
@ -23,39 +24,39 @@ import {
|
|||||||
MotionChangeRecommendationComponent
|
MotionChangeRecommendationComponent
|
||||||
} from '../motion-change-recommendation/motion-change-recommendation.component';
|
} from '../motion-change-recommendation/motion-change-recommendation.component';
|
||||||
import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-export.service';
|
import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-export.service';
|
||||||
|
import { MotionBlockRepositoryService } from 'app/core/repositories/motions/motion-block-repository.service';
|
||||||
|
import { MotionFilterListService } from 'app/site/motions/services/motion-filter-list.service';
|
||||||
import { MotionRepositoryService, ParagraphToChoose } from 'app/core/repositories/motions/motion-repository.service';
|
import { MotionRepositoryService, ParagraphToChoose } from 'app/core/repositories/motions/motion-repository.service';
|
||||||
|
import { MotionSortListService } from 'app/site/motions/services/motion-sort-list.service';
|
||||||
import { NotifyService } from 'app/core/core-services/notify.service';
|
import { NotifyService } from 'app/core/core-services/notify.service';
|
||||||
import { OperatorService } from 'app/core/core-services/operator.service';
|
import { OperatorService } from 'app/core/core-services/operator.service';
|
||||||
import { PersonalNoteService } from 'app/core/ui-services/personal-note.service';
|
import { PersonalNoteService } from 'app/core/ui-services/personal-note.service';
|
||||||
import { PromptService } from 'app/core/ui-services/prompt.service';
|
import { PromptService } from 'app/core/ui-services/prompt.service';
|
||||||
import { StatuteParagraphRepositoryService } from 'app/core/repositories/motions/statute-paragraph-repository.service';
|
import { StatuteParagraphRepositoryService } from 'app/core/repositories/motions/statute-paragraph-repository.service';
|
||||||
|
import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service';
|
||||||
import { UserRepositoryService } from 'app/core/repositories/users/user-repository.service';
|
import { UserRepositoryService } from 'app/core/repositories/users/user-repository.service';
|
||||||
import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block';
|
|
||||||
import { ViewWorkflow } from 'app/site/motions/models/view-workflow';
|
|
||||||
import { ViewUser } from 'app/site/users/models/view-user';
|
|
||||||
import { ViewCategory } from 'app/site/motions/models/view-category';
|
|
||||||
import { ViewCreateMotion } from 'app/site/motions/models/view-create-motion';
|
|
||||||
import { ViewportService } from 'app/core/ui-services/viewport.service';
|
|
||||||
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
|
||||||
import { ViewMotionChangeRecommendation } from 'app/site/motions/models/view-motion-change-recommendation';
|
|
||||||
import {
|
|
||||||
ViewMotionNotificationEditMotion,
|
|
||||||
TypeOfNotificationViewMotion
|
|
||||||
} from 'app/site/motions/models/view-motion-notify';
|
|
||||||
import {
|
import {
|
||||||
ViewMotion,
|
ViewMotion,
|
||||||
ChangeRecoMode,
|
ChangeRecoMode,
|
||||||
LineNumberingMode,
|
LineNumberingMode,
|
||||||
verboseChangeRecoMode
|
verboseChangeRecoMode
|
||||||
} from 'app/site/motions/models/view-motion';
|
} from 'app/site/motions/models/view-motion';
|
||||||
|
import {
|
||||||
|
ViewMotionNotificationEditMotion,
|
||||||
|
TypeOfNotificationViewMotion
|
||||||
|
} from 'app/site/motions/models/view-motion-notify';
|
||||||
|
import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block';
|
||||||
|
import { ViewCategory } from 'app/site/motions/models/view-category';
|
||||||
|
import { ViewCreateMotion } from 'app/site/motions/models/view-create-motion';
|
||||||
|
import { ViewportService } from 'app/core/ui-services/viewport.service';
|
||||||
|
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
||||||
|
import { ViewMotionChangeRecommendation } from 'app/site/motions/models/view-motion-change-recommendation';
|
||||||
import { ViewStatuteParagraph } from 'app/site/motions/models/view-statute-paragraph';
|
import { ViewStatuteParagraph } from 'app/site/motions/models/view-statute-paragraph';
|
||||||
import { ViewTag } from 'app/site/tags/models/view-tag';
|
import { ViewTag } from 'app/site/tags/models/view-tag';
|
||||||
import { ViewUnifiedChange } from 'app/shared/models/motions/view-unified-change';
|
import { ViewUnifiedChange } from 'app/shared/models/motions/view-unified-change';
|
||||||
import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service';
|
import { ViewUser } from 'app/site/users/models/view-user';
|
||||||
|
import { ViewWorkflow } from 'app/site/motions/models/view-workflow';
|
||||||
import { WorkflowRepositoryService } from 'app/core/repositories/motions/workflow-repository.service';
|
import { WorkflowRepositoryService } from 'app/core/repositories/motions/workflow-repository.service';
|
||||||
import { MotionBlockRepositoryService } from 'app/core/repositories/motions/motion-block-repository.service';
|
|
||||||
import { MotionSortListService } from 'app/site/motions/services/motion-sort-list.service';
|
|
||||||
import { ItemRepositoryService } from 'app/core/repositories/agenda/item-repository.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component for the motion detail view
|
* Component for the motion detail view
|
||||||
@ -262,6 +263,13 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
*/
|
*/
|
||||||
public motionObserver: BehaviorSubject<ViewMotion[]>;
|
public motionObserver: BehaviorSubject<ViewMotion[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of presorted motions. Filles by sort service
|
||||||
|
* and filter service.
|
||||||
|
* To navigate back and forth
|
||||||
|
*/
|
||||||
|
private sortedMotions: ViewMotion[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the name of supporters are visible
|
* Determine if the name of supporters are visible
|
||||||
*/
|
*/
|
||||||
@ -399,6 +407,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
* @param blockRepo
|
* @param blockRepo
|
||||||
* @param itemRepo
|
* @param itemRepo
|
||||||
* @param motionSortService
|
* @param motionSortService
|
||||||
|
* @param motionFilterListService
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
title: Title,
|
title: Title,
|
||||||
@ -428,8 +437,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
private mediaFilerepo: MediafileRepositoryService,
|
private mediaFilerepo: MediafileRepositoryService,
|
||||||
private workflowRepo: WorkflowRepositoryService,
|
private workflowRepo: WorkflowRepositoryService,
|
||||||
private blockRepo: MotionBlockRepositoryService,
|
private blockRepo: MotionBlockRepositoryService,
|
||||||
|
private itemRepo: ItemRepositoryService,
|
||||||
private motionSortService: MotionSortListService,
|
private motionSortService: MotionSortListService,
|
||||||
private itemRepo: ItemRepositoryService
|
private motionFilterService: MotionFilterListService
|
||||||
) {
|
) {
|
||||||
super(title, translate, matSnackBar);
|
super(title, translate, matSnackBar);
|
||||||
}
|
}
|
||||||
@ -452,7 +462,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
this.createForm();
|
this.createForm();
|
||||||
this.observeRoute();
|
this.observeRoute();
|
||||||
this.getMotionByUrl();
|
this.getMotionByUrl();
|
||||||
this.setSurroundingMotions();
|
|
||||||
|
|
||||||
// load config variables
|
// load config variables
|
||||||
this.configService
|
this.configService
|
||||||
@ -498,12 +507,18 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
this.statuteParagraphs = newViewStatuteParagraphs;
|
this.statuteParagraphs = newViewStatuteParagraphs;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Observe motion changes to trigger surrounding motions
|
// use the filter and the search service to get the current sorting
|
||||||
this.motionObserver.subscribe(motionChanges => {
|
this.motionFilterService.initFilters(this.motionObserver);
|
||||||
if (motionChanges) {
|
this.motionSortService.initSorting(this.motionFilterService.outputObservable);
|
||||||
this.setSurroundingMotions();
|
|
||||||
}
|
this.subscriptions.push(
|
||||||
});
|
this.motionSortService.outputObservable.subscribe(motions => {
|
||||||
|
if (motions) {
|
||||||
|
this.sortedMotions = motions;
|
||||||
|
this.setSurroundingMotions();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -515,6 +530,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
if (this.navigationSubscription) {
|
if (this.navigationSubscription) {
|
||||||
this.navigationSubscription.unsubscribe();
|
this.navigationSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
super.ngOnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1172,19 +1188,17 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
|||||||
* in the {@link MotionSortListService}
|
* in the {@link MotionSortListService}
|
||||||
*/
|
*/
|
||||||
public setSurroundingMotions(): void {
|
public setSurroundingMotions(): void {
|
||||||
const sortedMotions = this.motionSortService.sortSync(this.motionObserver.value);
|
const indexOfCurrent = this.sortedMotions.findIndex(motion => {
|
||||||
const indexOfCurrent = sortedMotions.findIndex(motion => {
|
|
||||||
return motion === this.motion;
|
return motion === this.motion;
|
||||||
});
|
});
|
||||||
if (indexOfCurrent > -1) {
|
if (indexOfCurrent > -1) {
|
||||||
if (indexOfCurrent > 0) {
|
if (indexOfCurrent > 0) {
|
||||||
this.previousMotion = sortedMotions[indexOfCurrent - 1];
|
this.previousMotion = this.sortedMotions[indexOfCurrent - 1];
|
||||||
} else {
|
} else {
|
||||||
this.previousMotion = null;
|
this.previousMotion = null;
|
||||||
}
|
}
|
||||||
|
if (indexOfCurrent < this.sortedMotions.length - 1) {
|
||||||
if (indexOfCurrent < sortedMotions.length - 1) {
|
this.nextMotion = this.sortedMotions[indexOfCurrent + 1];
|
||||||
this.nextMotion = sortedMotions[indexOfCurrent + 1];
|
|
||||||
} else {
|
} else {
|
||||||
this.nextMotion = null;
|
this.nextMotion = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user