Skip to content

Commit

Permalink
Merge branch 'main' into 2755-angular-16
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianjoel committed Oct 2, 2023
2 parents 0399ff3 + d2a51bf commit 18bb8d1
Show file tree
Hide file tree
Showing 43 changed files with 440 additions and 190 deletions.
6 changes: 6 additions & 0 deletions client/src/app/domain/fieldsets/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ export class UserFieldsets {
]
};
}

export class MeetingUserFieldsets {
public static readonly FullNameSubscription: BaseSimplifiedModelRequest = {
fieldset: [`group_ids`, `meeting_id`, `user_id`, `structure_level`, `number`]
};
}
1 change: 1 addition & 0 deletions client/src/app/domain/models/users/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type UserSortProperty = 'first_name' | 'last_name' | 'number';
* Iterable pre selection of genders
*/
export const GENDERS = [_(`female`), _(`male`), _(`diverse`), _(`non-binary`)];
export const GENDER_FITLERABLE = [`female`, `male`, `diverse`, `non-binary`];

/**
* Representation of a user in contrast to the operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BaseViewModel } from 'src/app/site/base/base-view-model';
import { ExportServiceModule } from '../export-service.module';
import { FileExportService } from '../file-export.service';
import {
CsvColumnsDefinition,
BackendCsvColumnsDefinition,
DEFAULT_COLUMN_SEPARATOR,
DEFAULT_ENCODING,
DEFAULT_LINE_SEPARATOR,
Expand All @@ -30,7 +30,7 @@ export class CsvExportForBackendService {
*/
public export<T extends BaseViewModel>(
models: T[],
columns: CsvColumnsDefinition<T>,
columns: BackendCsvColumnsDefinition<T>,
filename: string,
{
lineSeparator = DEFAULT_LINE_SEPARATOR,
Expand All @@ -54,7 +54,7 @@ export class CsvExportForBackendService {
const header = columns.map(column => {
let label = ``;
if (isPropertyDefinition(column)) {
label = column.label ? column.label : (column.property as string);
label = column.property as string;
} else if (isMapDefinition(column)) {
label = column.label;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Defines a csv column with a property of the model and an optional label. If this is not given, the
* translated and capitalized property name is used.
*/
export interface BackendCsvColumnDefinitionProperty<T> {
property: keyof T;
}

/**
* Defines a csv column with a property of the model and an optional label. If this is not given, the
* translated and capitalized property name is used.
Expand Down Expand Up @@ -44,6 +52,12 @@ export function isMapDefinition<T>(obj: any): obj is CsvColumnDefinitionMap<T> {
*/
export type CsvColumnsDefinition<T> = (CsvColumnDefinitionProperty<T> | CsvColumnDefinitionMap<T>)[];

/**
* The definition of columns in the export. Either use a property for every model or do a custom mapping to
* a string to be put into the csv.
*/
export type BackendCsvColumnsDefinition<T> = (BackendCsvColumnDefinitionProperty<T> | CsvColumnDefinitionMap<T>)[];

export const ISO_8859_15_ENCODING = `iso-8859-15`;
export const DEFAULT_LINE_SEPARATOR = `\r\n`;
export const DEFAULT_COLUMN_SEPARATOR = `,`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export class MeetingUserRepositoryService extends BaseMeetingRelatedRepository<V
`vote_delegated_to_id`,
`vote_delegations_from_ids`,
`vote_weight`,
`structure_level`,
`number`,
`comment`,
`user_id`
`user_id`,
`structure_level`,
`number`
]);

const detailFields: TypedFieldset<MeetingUser> = [`about_me`, `user_id`, `meeting_id`];
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/gateways/repositories/users/user-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export class UserAction {
public static readonly FORGET_PASSWORD_CONFIRM = `user.forget_password_confirm`;
public static readonly ASSIGN_MEETINGS = `user.assign_meetings`;
public static readonly MERGE_TOGETHER = `user.merge_together`;
public static readonly ACCOUNT_JSON_UPLOAD = `account.json_upload`;
public static readonly ACCOUNT_IMPORT = `account.import`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BaseRepository } from 'src/app/gateways/repositories/base-repository';
import { UserAction } from 'src/app/gateways/repositories/users/user-action';
import { ActiveMeetingIdService } from 'src/app/site/pages/meetings/services/active-meeting-id.service';
import { ViewMeetingUser } from 'src/app/site/pages/meetings/view-models/view-meeting-user';
import { BackendImportRawPreview } from 'src/app/ui/modules/import-list/definitions/backend-import-preview';

import { Id } from '../../../domain/definitions/key-types';
import { Displayable } from '../../../domain/interfaces/displayable';
Expand Down Expand Up @@ -497,6 +498,14 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
return this.createAction(UserAction.SET_PRESENT, payload);
}

public accountJsonUpload(payload: { [key: string]: any }): Action<BackendImportRawPreview> {
return this.createAction<BackendImportRawPreview>(UserAction.ACCOUNT_JSON_UPLOAD, payload);
}

public accountImport(payload: { id: number; import: boolean }[]): Action<BackendImportRawPreview | void> {
return this.createAction<BackendImportRawPreview | void>(UserAction.ACCOUNT_IMPORT, payload);
}

private sanitizePayload(payload: any): any {
const temp = { ...payload };
for (const key of Object.keys(temp).filter(field => !this.isFieldAllowedToBeEmpty(field))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,24 @@ export abstract class BaseBackendImportService implements BackendImportService {
isBackendImportRawPreview(result)
) as BackendImportRawPreview[];
this.processRawPreviews(updatedPreviews);
if (this.previewHasRowErrors) {
const statesSet = new Set(updatedPreviews.map(preview => preview.state));
if (statesSet.has(BackendImportState.Error)) {
this._currentImportPhaseSubject.next(BackendImportPhase.ERROR);
} else if (statesSet.has(BackendImportState.Warning)) {
this.processRawPreviews(
updatedPreviews
.filter(preview => preview.state === BackendImportState.Warning)
.map(preview => ({
...preview,
rows: preview.rows.filter(row => row.messages && row.messages.length)
}))
);
this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED_WITH_WARNING);
} else {
this._currentImportPhaseSubject.next(BackendImportPhase.TRY_AGAIN);
this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED);
this._csvLines = [];
return true;
}
} else {
this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED);
this._csvLines = [];
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export abstract class BaseViaBackendImportListComponent extends BaseComponent im
* True if the import is in a state in which an import can be conducted
*/
public get canImport(): boolean {
return this._state === BackendImportPhase.AWAITING_CONFIRM || this.tryAgain;
return this._state === BackendImportPhase.AWAITING_CONFIRM;
}

/**
Expand All @@ -42,8 +42,8 @@ export abstract class BaseViaBackendImportListComponent extends BaseComponent im
/**
* True if, after an attempted import failed, the view is waiting for the user to confirm the import on the new preview.
*/
public get tryAgain(): boolean {
return this._state === BackendImportPhase.TRY_AGAIN;
public get finishedWithWarnings(): boolean {
return this._state === BackendImportPhase.FINISHED_WITH_WARNING;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
import {
MatLegacyDialog as MatDialog,
MatLegacyDialogConfig as MatDialogConfig
} from '@angular/material/legacy-dialog';
import { MatLegacyMenuTrigger as MatMenuTrigger } from '@angular/material/legacy-menu';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -18,6 +21,7 @@ import { ThemeService } from 'src/app/site/services/theme.service';
import { UserControllerService } from 'src/app/site/services/user-controller.service';
import { BaseUiComponent } from 'src/app/ui/base/base-ui-component';
import { ChessDialogComponent } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component';
import { ChessChallengeService } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service';

import { AccountDialogComponent } from '../account-dialog/account-dialog.component';

Expand Down Expand Up @@ -81,9 +85,11 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit {
private theme: ThemeService,
private meetingSettingsService: MeetingSettingsService,
private activeMeetingIdService: ActiveMeetingIdService,
private controller: UserControllerService
private controller: UserControllerService,
chessChallengeService: ChessChallengeService
) {
super();
chessChallengeService.startListening();
}

public ngOnInit(): void {
Expand Down Expand Up @@ -159,7 +165,12 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit {

if (this.clickCounter === 4) {
this.clickCounter = 0;
this.dialog.open(ChessDialogComponent, { ...mediumDialogSettings });
const config: MatDialogConfig = mediumDialogSettings;
const match = this.router.url.match(/.*\/participants\/(\d+)\/?$/);
if (match) {
config.data = { userId: +match[1] };
}
this.dialog.open(ChessDialogComponent, config);
} else {
this.clickTimeout = <any>setTimeout(() => {
this.clickCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { RouterModule } from '@angular/router';
import { DirectivesModule } from 'src/app/ui/directives';
import { CommaSeparatedListingModule } from 'src/app/ui/modules/comma-separated-listing';
import { InputModule } from 'src/app/ui/modules/input';
import { ChessDialogModule } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog';

import { OpenSlidesTranslationModule } from '../translations';
import { UserComponentsModule } from '../user-components';
Expand Down Expand Up @@ -58,6 +59,7 @@ const DECLARATIONS = [GlobalHeadbarComponent];
ScrollingModule,
FormsModule,
ReactiveFormsModule,
ChessDialogModule,
...MODULES
]
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Id } from 'src/app/domain/definitions/key-types';
import { FULL_FIELDSET, MEETING_ROUTING_FIELDS } from 'src/app/domain/fieldsets/misc';
import { UserFieldsets } from 'src/app/domain/fieldsets/user';
import { MeetingUserFieldsets, UserFieldsets } from 'src/app/domain/fieldsets/user';
import { SubscriptionConfigGenerator } from 'src/app/domain/interfaces/subscription-config';
import { ViewMeeting } from 'src/app/site/pages/meetings/view-models/view-meeting';
import { FollowList } from 'src/app/site/services/model-request-builder';
Expand All @@ -21,13 +21,13 @@ export const agendaItemFollow: FollowList<any> = [
follow: [
{
idField: `meeting_user_id`,
fieldset: [],
follow: [
{
idField: `user_id`,
...UserFieldsets.FullNameSubscription
fieldset: [...UserFieldsets.FullNameSubscription.fieldset, `meeting_user_ids`]
}
]
],
...MeetingUserFieldsets.FullNameSubscription
},
{
idField: `point_of_order_category_id`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ <h2>{{ 'Import topics' | translate }}</h2>

<div class="menu-slot">
<button *ngIf="canImport" mat-button (click)="doImport()">
<span class="upper">{{ tryAgain ? 'Try again' : ('Import' | translate) }}</span>
<span class="upper">{{ 'Import' | translate }}</span>
</button>
<div *ngIf="finishedSuccessfully || hasErrors" style="padding-top: 6px">
<mat-icon *ngIf="finishedSuccessfully" matTooltip="{{ 'Import successful' | translate }}">done</mat-icon>
<mat-icon
*ngIf="finishedWithWarnings"
matTooltip="{{ 'Import successful with some warnings' | translate }}"
>
done
</mat-icon>
<mat-icon *ngIf="hasErrors" matTooltip="{{ 'Can not import because of errors' | translate }}">
block
</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Id } from 'src/app/domain/definitions/key-types';
import { UserFieldsets } from 'src/app/domain/fieldsets/user';
import { MeetingUserFieldsets, UserFieldsets } from 'src/app/domain/fieldsets/user';
import { SubscriptionConfigGenerator } from 'src/app/domain/interfaces/subscription-config';
import { ViewMeeting } from 'src/app/site/pages/meetings/view-models/view-meeting';

Expand All @@ -25,13 +25,13 @@ export const getAssignmentSubscriptionConfig: SubscriptionConfigGenerator = (id:
follow: [
{
idField: `meeting_user_id`,
fieldset: [],
follow: [
{
idField: `user_id`,
...UserFieldsets.FullNameSubscription
fieldset: [...UserFieldsets.FullNameSubscription.fieldset, `meeting_user_ids`]
}
]
],
...MeetingUserFieldsets.FullNameSubscription
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Id } from 'src/app/domain/definitions/key-types';
import { FULL_FIELDSET, MEETING_ROUTING_FIELDS } from 'src/app/domain/fieldsets/misc';
import { UserFieldsets } from 'src/app/domain/fieldsets/user';
import { MeetingUserFieldsets, UserFieldsets } from 'src/app/domain/fieldsets/user';
import { SubscriptionConfig, SubscriptionConfigGenerator } from 'src/app/domain/interfaces/subscription-config';
import { ViewMeeting } from 'src/app/site/pages/meetings/view-models/view-meeting';

Expand Down Expand Up @@ -59,13 +59,16 @@ export const getAutopilotContentSubscriptionConfig = (id: Id): SubscriptionConfi
follow: [
{
idField: `meeting_user_id`,
fieldset: [],
follow: [
{
idField: `user_id`,
...UserFieldsets.FullNameSubscription
fieldset: [
...UserFieldsets.FullNameSubscription.fieldset,
`meeting_user_ids`
]
}
]
],
...MeetingUserFieldsets.FullNameSubscription
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
[fullScreen]="false"
>
<!-- Content -->
<div *osScrollingTableCell="'structureLevel'; row as object">
<div *osScrollingTableCell="'structureLevel'; row as object" class="ellipsis-overflow">
<div *osScrollingTableCellLabel>{{ 'Structure level' | translate }}</div>
{{ object.structureLevel | translate }}
</div>
<div *osScrollingTableCell="'durationOfWordRequests'; row as object">
<div *osScrollingTableCell="'durationOfWordRequests'; row as object; config: { width: '100px' }">
<div *osScrollingTableCellLabel>{{ 'Duration of requests to speak' | translate }}</div>
{{ parseDuration(object.speakingTime) }}
</div>
<div *osScrollingTableCell="'numberOfWordRequests'; row as object">
<div *osScrollingTableCell="'numberOfWordRequests'; row as object; config: { width: '50px' }">
<div *osScrollingTableCellLabel>{{ 'Number of requests to speak' | translate }}</div>
{{ object.finishedSpeakers.length }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Identifiable } from 'src/app/domain/interfaces';
import { Selectable } from 'src/app/domain/interfaces/selectable';
import { AgendaItemType } from 'src/app/domain/models/agenda/agenda-item';
import { Action } from 'src/app/gateways/actions';
import { UserRepositoryService } from 'src/app/gateways/repositories/users';
import { SpinnerService } from 'src/app/site/modules/global-spinner';
import { ListOfSpeakersControllerService } from 'src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services';
import { ModelRequestService } from 'src/app/site/services/model-request.service';
Expand All @@ -24,6 +23,7 @@ import {
getParticipantMinimalSubscriptionConfig,
PARTICIPANT_LIST_SUBSCRIPTION_MINIMAL
} from '../../../../participants/participants.subscription';
import { ParticipantControllerService } from '../../../../participants/services/common/participant-controller.service';
import { MotionCategoryControllerService } from '../../../modules/categories/services';
import { MotionBlockControllerService } from '../../../modules/motion-blocks/services';
import { PersonalNoteControllerService } from '../../../modules/personal-notes/services';
Expand All @@ -45,7 +45,7 @@ export class MotionMultiselectService {
private translate: TranslateService,
private promptService: PromptService,
private choiceService: ChoiceService,
private userRepo: UserRepositoryService,
private userRepo: ParticipantControllerService,
private workflowRepo: MotionWorkflowControllerService,
private categoryRepo: MotionCategoryControllerService,
private submitterRepo: MotionSubmitterControllerService,
Expand Down Expand Up @@ -389,8 +389,13 @@ export class MotionMultiselectService {
// `bulkSetStar` does imply that "true" sets favorites while "false" unsets favorites
const isFavorite = selectedChoice.action === options[0];
const message = this.translate.instant(`I have ${motions.length} favorite motions. Please wait ...`);

const filteredMotions = motions
.map(motion => this.repo.getViewModel(motion.id))
.filter(motion => isFavorite || motion.getPersonalNote());
this.spinnerService.show(message, {
hideAfterPromiseResolved: () => this.personalNoteRepo.setPersonalNote({ star: isFavorite }, ...motions)
hideAfterPromiseResolved: () =>
this.personalNoteRepo.setPersonalNote({ star: isFavorite }, ...filteredMotions)
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { ParticipantCommonServiceModule } from '../participants/services/common/participant-common-service.module';
import { MotionMainComponent } from './components/motion-main/motion-main.component';
import { MotionsRoutingModule } from './motions-routing.module';

@NgModule({
declarations: [MotionMainComponent],
imports: [CommonModule, MotionsRoutingModule, RouterModule]
imports: [CommonModule, MotionsRoutingModule, RouterModule, ParticipantCommonServiceModule]
})
export class MotionsModule {}
Loading

0 comments on commit 18bb8d1

Please sign in to comment.