Skip to content

Commit

Permalink
Add missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianjoel committed Sep 30, 2024
1 parent 1e0413e commit c9fc362
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,14 @@ export const getMotionOriginDetailSubscriptionConfig: SubscriptionConfigGenerato
},
{
idField: `state_id`,
fieldset: [`name`, `css_class`, `meeting_id`]
fieldset: [
`name`,
`css_class`,
`meeting_id`,
`show_state_extension_field`,
`show_recommendation_extension_field`,
`recommendation_label`
]
},
{
idField: `poll_ids`,
Expand All @@ -258,9 +265,23 @@ export const getMotionOriginDetailSubscriptionConfig: SubscriptionConfigGenerato
{ idField: `change_recommendation_ids`, fieldset: FULL_FIELDSET },
{ idField: `category_id`, fieldset: [`name`, `parent_id`, `meeting_id`] },
{ idField: `block_id`, fieldset: [`title`, `meeting_id`] },
{ idField: `meeting_id`, fieldset: [`name`, `motions_line_length`, `motions_default_line_numbering`] }
{ idField: `recommendation_id`, fieldset: [`name`] },
{
idField: `meeting_id`,
fieldset: [
`name`,
`motions_line_length`,
`motions_default_line_numbering`,
`motions_recommendations_by`
]
},
{ idField: `state_extension_reference_ids`, fieldset: [`number`, `title`, `meeting_id`] },
{ idField: `recommendation_extension_reference_ids`, fieldset: [`number`, `title`, `meeting_id`] }
],
fieldset: [
`state_extension`,
`recommendation_extension`,
`additional_submitter`,
`workflow_timestamp`,
`reason`,
`number`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ <h1>
</div>
}

<!-- Recommendation -->
@if (isRecommendationEnabled) {
<div>
<os-motion-extension-field
[canBeEdited]="false"
[chipValue]="recommendationLabel | translate"
extensionLabel="{{ 'Extension' | translate }}"
[hasExtension]="!!motion.recommendation && motion.recommendation.show_recommendation_extension_field"
[inputValue]="motion?.recommendation_extension"
[internal]="motion?.state?.is_internal"
[listValueTransformFns]="[motionTransformFn]"
[searchLists]="searchLists"
[title]="motion.meeting.motions_recommendations_by"
(succeeded)="setRecommendationExtension($event)"
></os-motion-extension-field>
<!-- recommendation referenced motions -->
@if (motion.recommendation_extension_reference_ids?.length) {
@if (referencedMotions$ | async; as referencedMotions) {
<div class="spacer-top-10">
@for (motion of referencedMotions; track motion.id; let last = $last) {
<span>
<a [routerLink]="motion.getDetailStateUrl()">{{ motion.numberOrTitle }}</a>
@if (!last) {
<span class="referencelist">&nbsp;·&nbsp;</span>
}
</span>
}
</div>
}
}
</div>
}

<!-- Category -->
@if (motion.category) {
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen
}

public get isRecommendationEnabled(): boolean {
return (
(this.perms.isAllowed(`change_metadata`) || !!this.motion.recommendation) &&
!!this.recommender &&
!!this.getPossibleRecommendations().length
);
return !!this.motion.recommendation;
}

/**
Expand All @@ -63,11 +59,6 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen
return this.changeRecoMode === ChangeRecoMode.Diff;
}

/**
* Custom recommender as set in the settings
*/
public recommender: string | null = null;

public searchLists: SearchListDefinition[] = [
{
observable: this.repo.getViewModelListObservable(),
Expand Down Expand Up @@ -103,11 +94,6 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen

private _supportersSubject = new BehaviorSubject<ViewUser[]>([]);

/**
* The subscription to the recommender config variable.
*/
private recommenderSubscription: Subscription | null = null;

public constructor(
protected override translate: TranslateService,
public perms: MotionPermissionService,
Expand Down Expand Up @@ -136,10 +122,6 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen
super.ngOnDestroy();
}

protected override onAfterInit(): void {
this.setupRecommender();
}

protected override onAfterSetMotion(previous: ViewMotion, current: ViewMotion): void {
super.onAfterSetMotion(previous, current);
this.updateSupportersSubject();
Expand Down Expand Up @@ -234,11 +216,6 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen
this.repo.followRecommendation(this.motion);
}

public getPossibleRecommendations(): ViewMotionState[] {
const allStates = this.motion.state?.workflow?.states || [];
return allStates.filter(state => state.recommendation_label).sort((a, b) => a.weight - b.weight);
}

public getMeetingName(origin: ViewMotion | ViewMeeting): string {
if (this.isViewMotion(origin)) {
const motion = origin as ViewMotion;
Expand Down Expand Up @@ -270,39 +247,4 @@ export class OriginMotionMetaDataComponent extends BaseMotionDetailChildComponen
private isViewMotion(toTest: ViewMotion | ViewMeeting): boolean {
return toTest.COLLECTION === Motion.COLLECTION;
}

/**
* Observes the repository for changes in the motion recommender
*/
private setupRecommender(): void {
if (this.motion) {
const configKey: keyof Settings = `motions_recommendations_by`;
if (this.recommenderSubscription) {
this.recommenderSubscription.unsubscribe();
}
this.recommenderSubscription = this.meetingSettingsService.get(configKey).subscribe(recommender => {
this.recommender = recommender;
});
}
}

private async checkPresenter(): Promise<(Selectable & { name: string; toString: any })[]> {
const meetingId = this.activeMeetingService.meetingId;
const committees =
this.operator.hasPerms(Permission.motionCanManageMetadata) && !!meetingId
? await this.presenter.call({ meeting_id: meetingId })
: [];
const forwardingCommittees: (Selectable & { name: string; toString: any })[] = [];
for (let n = 0; n < committees.length; n++) {
forwardingCommittees.push({
id: n + 1,
name: committees[n],
getTitle: () => committees[n],
getListTitle: () => ``,
toString: () => committees[n]
});
}

return forwardingCommittees;
}
}

0 comments on commit c9fc362

Please sign in to comment.