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

Fix committee export and example import file #3476

Merged
merged 9 commits into from
Apr 24, 2024
53 changes: 19 additions & 34 deletions client/src/app/domain/models/comittees/committee.constants.ts
bastianjoel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker';

import { Id } from '../../definitions/key-types';

export const ID = `id`;
export const NAME = `name`;
export const DESCRIPTION = `description`;
export const FORWARD_TO_COMMITTEE_IDS = `forward_to_committee_ids`;
export const ORGANIZATION_TAG_IDS = `organization_tag_ids`;
export const MANAGER_IDS = `manager_ids`;
export const MEETING = `meeting`;
export const MEETING_START_DATE = `meeting_start_date`;
export const MEETING_END_DATE = `meeting_end_date`;
export const MEETING_ADMIN_IDS = `meeting_admin_ids`;
export const MEETING_TEMPLATE_ID = `meeting_template_id`;
const ID = `id`;
const NAME = `name`;
const DESCRIPTION = `description`;
const FORWARD_TO_COMMITTEES = `forward_to_committees`;
const ORGANIZATION_TAGS = `organization_tags`;
const MANAGERS = `managers`;
const MEETING_NAME = `meeting_name`;
const MEETING_START_TIME = `meeting_start_time`;
const MEETING_END_TIME = `meeting_end_time`;
const MEETING_ADMINS = `meeting_admins`;
const MEETING_TEMPLATE = `meeting_template`;

export interface CommitteeCsvPort {
[ID]: Id;
[NAME]: string;
[DESCRIPTION]?: string;
[FORWARD_TO_COMMITTEE_IDS]?: string;
[ORGANIZATION_TAG_IDS]?: string;
[MANAGER_IDS]?: string | number[];
[MEETING]?: string | number;
[MEETING_START_DATE]?: string | number;
[MEETING_END_DATE]?: string | number;
[MEETING_ADMIN_IDS]?: string | number[];
[MEETING_TEMPLATE_ID]?: string | number;
[FORWARD_TO_COMMITTEES]?: string;
[ORGANIZATION_TAGS]?: string;
[MANAGERS]?: string | number[];
[MEETING_NAME]?: string | number;
[MEETING_START_TIME]?: string | number;
[MEETING_END_TIME]?: string | number;
[MEETING_ADMINS]?: string | number[];
[MEETING_TEMPLATE]?: string | number;
}

export const COMMITTEE_PORT_HEADERS_AND_VERBOSE_NAMES: Partial<CommitteeCsvPort> = {
[NAME]: _(`Title`),
[DESCRIPTION]: _(`Description`),
[FORWARD_TO_COMMITTEE_IDS]: _(`Can forward motions to committee`),
[ORGANIZATION_TAG_IDS]: _(`Tags`),
[MANAGER_IDS]: _(`Administrators`),
[MEETING]: _(`Meeting`),
[MEETING_START_DATE]: _(`Start date`),
[MEETING_END_DATE]: _(`End date`),
[MEETING_ADMIN_IDS]: _(`Meeting administrator`),
[MEETING_TEMPLATE_ID]: _(`Meeting template`)
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export const getCommitteeListSubscriptionConfig: SubscriptionConfigGenerator = (
viewModelCtor: ViewOrganization,
ids: [ORGANIZATION_ID],
follow: [
{ idField: `committee_ids`, fieldset: `list`, follow: [{ idField: `user_ids`, fieldset: `accountList` }] }
{
idField: `committee_ids`,
fieldset: `list`,
follow: [{ idField: `user_ids`, fieldset: `accountList` }]
}
]
},
subscriptionName: COMMITTEE_LIST_SUBSCRIPTION
Expand Down Expand Up @@ -42,7 +46,7 @@ export const getCommitteeListMinimalSubscriptionConfig: SubscriptionConfigGenera
}
]
},
subscriptionName: COMMITTEE_LIST_SUBSCRIPTION
subscriptionName: COMMITTEE_LIST_MINIMAL_SUBSCRIPTION
});

export const COMMITTEE_DETAIL_SUBSCRIPTION = `committee_detail`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import { CommitteeCsvPort } from 'src/app/domain/models/comittees/committee.cons
export const COMMITTEE_CSV_EXPORT_EXAMPLE: Partial<CommitteeCsvPort>[] = [
{
name: `Finance committee`,
forward_to_committee_ids: `Confederation congress`,
organization_tag_ids: `Finance`,
meeting: 1
forward_to_committees: `Confederation congress`,
organization_tags: `Finance`,
meeting_name: 1
},
{
name: `Confederation congress`,
description: `Used to manage resolutions`,
forward_to_committee_ids: `General assembly`,
organization_tag_ids: `Independent`,
manager_ids: `Max Mustermann`,
meeting: `General meeting`,
meeting_start_date: `2021-12-17`,
meeting_end_date: `2021-12-19`,
meeting_admin_ids: `Max Mustermann`
forward_to_committees: `General assembly`,
organization_tags: `Independent`,
managers: `Max Mustermann`,
meeting_name: `General meeting`,
meeting_start_time: `2021-12-17`,
meeting_end_time: `2021-12-19`,
meeting_admins: `Max Mustermann`
},
{
name: `General assembly`,
description: `This committee meets once a year. It is the highest decision-making one.`,
forward_to_committee_ids: `General assembly`,
organization_tag_ids: `Independent`,
meeting_template_id: `General main assembly`
forward_to_committees: `General assembly`,
organization_tags: `Independent`,
meeting_template: `General main assembly`
}
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CsvColumnsDefinition } from 'src/app/gateways/export/csv-export.service';
import { CsvExportForBackendService } from 'src/app/gateways/export/csv-export.service/csv-export-for-backend.service';
import { MeetingControllerService } from 'src/app/site/pages/meetings/services/meeting-controller.service';

import { ViewCommittee } from '../../../../view-models/view-committee';
import { CommitteeListServiceModule } from '../committee-list-service.module';
Expand All @@ -11,11 +10,7 @@ import { CommitteeListServiceModule } from '../committee-list-service.module';
providedIn: CommitteeListServiceModule
})
export class CommitteeExportService {
public constructor(
private translate: TranslateService,
private csvExport: CsvExportForBackendService,
private meetingRepo: MeetingControllerService
) {}
public constructor(private translate: TranslateService, private csvExport: CsvExportForBackendService) {}

public export(committees: ViewCommittee[]): void {
const properties: CsvColumnsDefinition<ViewCommittee> = [
Expand All @@ -39,23 +34,7 @@ export class CommitteeExportService {
model
.getManagers()
.map(manager => manager.username)
.join(`,`)
},
{
label: `meeting_name`,
map: model => model.meetings[0]?.name
},
{
label: `meeting_start_time`,
map: model => this.meetingRepo.parseUnixToMeetingTime(model.meetings[0]?.start_time * 1000)
},
{
label: `meeting_end_time`,
map: model => this.meetingRepo.parseUnixToMeetingTime(model.meetings[0]?.end_time * 1000)
},
{
label: `meeting_admins`,
map: _ => ``
.join(`, `)
}
];
const filename = `${this.translate.instant(`Committees`)}.csv`;
Expand Down
Loading