Merge pull request #5004 from GabrielInTheWorld/buildForVerdi
Adds amount of waiting speakers for xlsx-export
This commit is contained in:
commit
30502a95c6
@ -49,6 +49,9 @@
|
|||||||
<mat-button-toggle *ngFor="let metaInfo of metaInfoExportOrder" [value]="metaInfo">
|
<mat-button-toggle *ngFor="let metaInfo of metaInfoExportOrder" [value]="metaInfo">
|
||||||
<span>{{ getLabelForMetadata(metaInfo) | translate }}</span>
|
<span>{{ getLabelForMetadata(metaInfo) | translate }}</span>
|
||||||
</mat-button-toggle>
|
</mat-button-toggle>
|
||||||
|
<mat-button-toggle *osPerms="'agenda.can_see_list_of_speakers'" value="speakers" #speakersButton>
|
||||||
|
<span translate>Speakers</span>
|
||||||
|
</mat-button-toggle>
|
||||||
<mat-button-toggle value="polls" #votingResultButton>
|
<mat-button-toggle value="polls" #votingResultButton>
|
||||||
<span translate>Voting result</span>
|
<span translate>Voting result</span>
|
||||||
</mat-button-toggle>
|
</mat-button-toggle>
|
||||||
|
@ -83,6 +83,12 @@ export class MotionExportDialogComponent implements OnInit {
|
|||||||
@ViewChild('votingResultButton', { static: true })
|
@ViewChild('votingResultButton', { static: true })
|
||||||
public votingResultButton: MatButtonToggle;
|
public votingResultButton: MatButtonToggle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To deactivate the speakers button.
|
||||||
|
*/
|
||||||
|
@ViewChild('speakersButton', { static: false })
|
||||||
|
public speakersButton: MatButtonToggle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Sets the default values for the lineNumberingMode and changeRecoMode and creates the form.
|
* Sets the default values for the lineNumberingMode and changeRecoMode and creates the form.
|
||||||
@ -134,8 +140,10 @@ export class MotionExportDialogComponent implements OnInit {
|
|||||||
// XLSX cannot have "content"
|
// XLSX cannot have "content"
|
||||||
if (format === ExportFileFormat.XLSX) {
|
if (format === ExportFileFormat.XLSX) {
|
||||||
this.disableControl('content');
|
this.disableControl('content');
|
||||||
|
this.changeStateOfButton(this.speakersButton, false);
|
||||||
} else {
|
} else {
|
||||||
this.enableControl('content');
|
this.enableControl('content');
|
||||||
|
this.changeStateOfButton(this.speakersButton, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format === ExportFileFormat.CSV || format === ExportFileFormat.XLSX) {
|
if (format === ExportFileFormat.CSV || format === ExportFileFormat.XLSX) {
|
||||||
@ -144,12 +152,10 @@ export class MotionExportDialogComponent implements OnInit {
|
|||||||
this.disableControl('pdfOptions');
|
this.disableControl('pdfOptions');
|
||||||
|
|
||||||
// remove the selection of "votingResult"
|
// remove the selection of "votingResult"
|
||||||
let metaInfoVal: string[] = this.exportForm.get('metaInfo').value;
|
if (format === ExportFileFormat.CSV) {
|
||||||
if (metaInfoVal) {
|
this.disableMetaInfoControl('polls', 'speakers');
|
||||||
metaInfoVal = metaInfoVal.filter(info => {
|
} else {
|
||||||
return info !== 'polls';
|
this.disableMetaInfoControl('polls');
|
||||||
});
|
|
||||||
this.exportForm.get('metaInfo').setValue(metaInfoVal);
|
|
||||||
}
|
}
|
||||||
this.votingResultButton.disabled = true;
|
this.votingResultButton.disabled = true;
|
||||||
}
|
}
|
||||||
@ -162,6 +168,20 @@ export class MotionExportDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to change the state of the property `disabled` of a given button.
|
||||||
|
*
|
||||||
|
* Ensures, that the button exists.
|
||||||
|
*
|
||||||
|
* @param button The button whose state will change.
|
||||||
|
* @param nextState The next state the button will assume.
|
||||||
|
*/
|
||||||
|
private changeStateOfButton(button: MatButtonToggle, nextState: boolean): void {
|
||||||
|
if (!!button) {
|
||||||
|
button.disabled = nextState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to easier enable a control
|
* Helper function to easier enable a control
|
||||||
* @param name
|
* @param name
|
||||||
@ -196,6 +216,19 @@ export class MotionExportDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to deactivate at least one field of the meta-info.
|
||||||
|
*
|
||||||
|
* @param fields All fields to deactivate.
|
||||||
|
*/
|
||||||
|
private disableMetaInfoControl(...fields: string[]): void {
|
||||||
|
let metaInfoVal: string[] = this.exportForm.get('metaInfo').value;
|
||||||
|
if (metaInfoVal) {
|
||||||
|
metaInfoVal = metaInfoVal.filter(info => !fields.includes(info));
|
||||||
|
this.exportForm.get('metaInfo').setValue(metaInfoVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the form with default values
|
* Creates the form with default values
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +43,9 @@ export class MotionExportService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
public evaluateExportRequest(exportInfo: MotionExportInfo, data: ViewMotion[]): void {
|
public evaluateExportRequest(exportInfo: MotionExportInfo, data: ViewMotion[]): void {
|
||||||
|
if (!exportInfo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!!exportInfo.format) {
|
if (!!exportInfo.format) {
|
||||||
if (exportInfo.format === ExportFileFormat.PDF) {
|
if (exportInfo.format === ExportFileFormat.PDF) {
|
||||||
try {
|
try {
|
||||||
|
@ -31,6 +31,7 @@ export type InfoToExport =
|
|||||||
| 'origin'
|
| 'origin'
|
||||||
| 'tags'
|
| 'tags'
|
||||||
| 'polls'
|
| 'polls'
|
||||||
|
| 'speakers'
|
||||||
| 'id'
|
| 'id'
|
||||||
| 'allcomments';
|
| 'allcomments';
|
||||||
|
|
||||||
|
@ -81,7 +81,9 @@ export class MotionXlsxExportService {
|
|||||||
*/
|
*/
|
||||||
public exportMotionList(motions: ViewMotion[], infoToExport: InfoToExport[], comments: number[]): void {
|
public exportMotionList(motions: ViewMotion[], infoToExport: InfoToExport[], comments: number[]): void {
|
||||||
const workbook = new Workbook();
|
const workbook = new Workbook();
|
||||||
const properties = sortMotionPropertyList(['identifier', 'title'].concat(infoToExport));
|
const properties = infoToExport.includes('speakers')
|
||||||
|
? sortMotionPropertyList(['identifier', 'title'].concat(infoToExport)).concat('speakers')
|
||||||
|
: sortMotionPropertyList(['identifier', 'title'].concat(infoToExport));
|
||||||
|
|
||||||
const worksheet = workbook.addWorksheet(this.translate.instant('Motions'), {
|
const worksheet = workbook.addWorksheet(this.translate.instant('Motions'), {
|
||||||
pageSetup: {
|
pageSetup: {
|
||||||
@ -105,10 +107,17 @@ export class MotionXlsxExportService {
|
|||||||
const columns = [];
|
const columns = [];
|
||||||
columns.push(
|
columns.push(
|
||||||
...properties.map(property => {
|
...properties.map(property => {
|
||||||
const propertyHeader =
|
let propertyHeader = '';
|
||||||
property === 'motion_block'
|
switch (property) {
|
||||||
? 'Motion block'
|
case 'motion_block':
|
||||||
: property.charAt(0).toLocaleUpperCase() + property.slice(1);
|
propertyHeader = 'Motion block';
|
||||||
|
break;
|
||||||
|
case 'speakers':
|
||||||
|
propertyHeader = 'List of next speakers';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
propertyHeader = property.charAt(0).toUpperCase() + property.slice(1);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
header: this.translate.instant(propertyHeader)
|
header: this.translate.instant(propertyHeader)
|
||||||
};
|
};
|
||||||
@ -138,7 +147,14 @@ export class MotionXlsxExportService {
|
|||||||
data.push(
|
data.push(
|
||||||
...properties.map(property => {
|
...properties.map(property => {
|
||||||
const motionProp = motion[property];
|
const motionProp = motion[property];
|
||||||
if (motionProp) {
|
if (property === 'speakers') {
|
||||||
|
return motion.listOfSpeakers && motion.listOfSpeakers.waitingSpeakerAmount > 0
|
||||||
|
? motion.listOfSpeakers.waitingSpeakerAmount
|
||||||
|
: '';
|
||||||
|
}
|
||||||
|
if (!motionProp) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case 'state':
|
case 'state':
|
||||||
return this.motionRepo.getExtendedStateLabel(motion);
|
return this.motionRepo.getExtendedStateLabel(motion);
|
||||||
@ -147,9 +163,6 @@ export class MotionXlsxExportService {
|
|||||||
default:
|
default:
|
||||||
return this.translate.instant(motionProp.toString());
|
return this.translate.instant(motionProp.toString());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (comments) {
|
if (comments) {
|
||||||
|
Loading…
Reference in New Issue
Block a user