Skip to content

Commit

Permalink
Merge branch 'release/V4.0.0-beta3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwenou committed Jan 8, 2025
2 parents c47b048 + 206197a commit f813ba2
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(maintenanceTeamService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(aircraftMaintenanceCompanyService.optionsService.dictOptionDtos$
| async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(airportService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(userService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(planeTypeService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(engineService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[reorderableColumns]="reorderableColumns"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
? virtualCrudItems
: ((crudItems$ | async) ?? [])
"
[dictOptionDtos]="
(planeService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(siteService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ export class BiaTableFilterComponent<CrudItem>
}

setSimpleFilter(event: any, col: BiaFieldConfig<CrudItem>) {
if (col.type === PropType.ManyToMany) {
const separator = ',';
const separator = ',';
if (
col.type === PropType.ManyToMany &&
event?.value?.toString().indexOf(separator) > -1
) {
if (
event?.value?.trim().length > 0 &&
event?.value?.slice(-1) !== ' ' &&
event?.value?.slice(-1) !== separator
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ export class BiaTableComponent<TDto extends { id: number }>
const table: Table = this as unknown as Table;

const storage = table.getStorage();
let state: TableState = {};
const state: TableState = {};

if (table.paginator) {
state.first = <number>table.first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@
<p-fileUpload
#fileUpload
mode="basic"
[chooseLabel]="'bia.select' | translate"
[chooseLabel]="'bia.browse' | translate"
chooseIcon="pi pi-upload"
[customUpload]="true"
accept="text/csv"
(onSelect)="onFileSelected($event)">
(onSelect)="onFileSelected()">
</p-fileUpload>

<button
[disabled]="this.fileUpload.hasFiles() !== true"
pButton
label="{{ 'primeng.apply' | translate }}"
type="button"
(click)="onApply()"></button>
<ng-container *ngIf="hasDate === true">
<span class="p-float-label">
<p-dropdown
formControlName="dateFormat"
[options]="dateFormats"
(ngModelChange)="onSubmit()"
appendTo="body"
optionLabel="example"
optionValue="format"
placeholder="Select Date Format">
</p-dropdown>
<label>{{ 'bulk.dateFormat' | translate }}</label>
Expand All @@ -27,6 +34,8 @@
[options]="timeFormats"
(ngModelChange)="onSubmit()"
appendTo="body"
optionLabel="example"
optionValue="format"
placeholder="Select Time Format">
</p-dropdown>
<label>{{ 'bulk.timeFormat' | translate }}</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DatePipe } from '@angular/common';
import {
Component,
EventEmitter,
Expand All @@ -22,6 +23,11 @@ import { clone } from 'src/app/shared/bia-shared/utils';
import { CrudConfig } from '../../model/crud-config';
import { BulkParam } from '../../services/crud-item-bulk.service';

interface FormatExample {
format: string;
example: string;
}

@Component({
selector: 'bia-crud-item-bulk-form',
templateUrl: './crud-item-bulk-form.component.html',
Expand All @@ -36,8 +42,8 @@ export class CrudItemBulkFormComponent<TDto extends { id: number }> {
insertChecked = false;
loading = false;
hasDate = false;
dateFormats: string[];
timeFormats: string[];
dateFormats: FormatExample[];
timeFormats: FormatExample[];
form: UntypedFormGroup;

displayedColumns: KeyValuePair[];
Expand Down Expand Up @@ -91,10 +97,13 @@ export class CrudItemBulkFormComponent<TDto extends { id: number }> {
@Input() canAdd = false;
@Output() save = new EventEmitter<any[]>();
@Output() cancel = new EventEmitter<void>();
@Output() fileSelected = new EventEmitter<any>();
@Output() fileSelected = new EventEmitter<File>();
@Output() changeBulkParam = new EventEmitter<BulkParam>();

constructor(public formBuilder: UntypedFormBuilder) {
constructor(
public formBuilder: UntypedFormBuilder,
public datepipe: DatePipe
) {
this.initForm();
}

Expand All @@ -118,12 +127,29 @@ export class CrudItemBulkFormComponent<TDto extends { id: number }> {

initDdlFormatDate() {
if (this.appSettings && this.appSettings.cultures.length > 0) {
this.dateFormats = [
...new Set(this.appSettings.cultures.map(x => x.dateFormat)), // new Set => Distinct()
const dateFormatSets = [
...new Set(this.appSettings.cultures.map(x => x.dateFormat)),
];
this.timeFormats = [

const timeFormatSets = [
...new Set(this.appSettings.cultures.map(x => x.timeFormat)),
];

const exampleDate = new Date(2025, 11, 31, 9, 45);

this.dateFormats = dateFormatSets.map(dateFormatSet => {
return <FormatExample>{
format: dateFormatSet,
example: this.datepipe.transform(exampleDate, dateFormatSet),
};
});

this.timeFormats = timeFormatSets.map(timeFormatSet => {
return <FormatExample>{
format: timeFormatSet,
example: this.datepipe.transform(exampleDate, timeFormatSet),
};
});
}
}

Expand Down Expand Up @@ -170,9 +196,8 @@ export class CrudItemBulkFormComponent<TDto extends { id: number }> {
}
}

onFileSelected(event: any) {
this.loading = true;
this.fileSelected.next(event);
onFileSelected() {
this._bulkData = null;
}

onCancel() {
Expand All @@ -199,6 +224,14 @@ export class CrudItemBulkFormComponent<TDto extends { id: number }> {
}
}

onApply() {
const file: File = this.fileUpload.files[0];
if (file) {
this.loading = true;
this.fileSelected.next(file);
}
}

canUseDelete(): boolean {
return (
this.canDelete === true &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ export class CrudItemBulkService<T extends BaseDto> {
this.form = form;
}

public uploadCsv(files: FileList): Observable<BulkData<T>> {
public uploadCsv(file: File): Observable<BulkData<T>> {
this.initBulkData();
const file = files.item(0);

return from(this.readFileAsText(file)).pipe(
switchMap(csv => this.parseCSV(csv))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export abstract class CrudItemBulkComponent<CrudItem extends BaseDto>
});
}

protected onFileSelected(event: any) {
protected onFileSelected(file: File) {
this.crudItemBulkService
.uploadCsv(event.files)
.uploadCsv(file)
.pipe(take(1)) // auto unsubscribe
.subscribe((bulkData: BulkData<CrudItem>) => (this.bulkData = bulkData));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
: ((crudItems$ | async) ?? [])
"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(crudItemService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[reorderableColumns]="reorderableColumns"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export class CrudItemsIndexComponent<CrudItem extends BaseDto>

useCalcModeChange(e: boolean) {
this.crudConfiguration.useCalcMode = e;
this.useCalcModeConfig();
}

useSignalRChange(e: boolean) {
Expand Down Expand Up @@ -190,20 +189,6 @@ export class CrudItemsIndexComponent<CrudItem extends BaseDto>
}
}

isLoadAllOptionsSubsribe = false;
protected useCalcModeConfig() {
if (this.crudConfiguration.useCalcMode && !this.isLoadAllOptionsSubsribe) {
this.isLoadAllOptionsSubsribe = true;
this.sub.add(
this.biaTranslationService.currentCulture$.subscribe(() => {
this.crudItemService.optionsService.loadAllOptions(
this.crudConfiguration.optionFilter
);
})
);
}
}

protected usePopupConfig(manualChange: boolean) {
if (manualChange) {
this.applyDynamicComponent(this.activatedRoute.routeConfig?.children);
Expand Down Expand Up @@ -239,6 +224,15 @@ export class CrudItemsIndexComponent<CrudItem extends BaseDto>
this.sub = new Subscription();

this.initTableConfiguration();

this.sub.add(
this.biaTranslationService.currentCulture$.subscribe(() => {
this.crudItemService.optionsService.loadAllOptions(
this.crudConfiguration.optionFilter
);
})
);

this.sub.add(
this.authService.authInfo$.subscribe((authInfo: AuthInfo) => {
if (authInfo && authInfo.token !== '') {
Expand Down Expand Up @@ -330,7 +324,6 @@ export class CrudItemsIndexComponent<CrudItem extends BaseDto>
onDisplay() {
this.checkhasAdvancedFilter();
this.useViewConfig(false);
this.useCalcModeConfig();
this.useSignalRConfig(false);
this.usePopupConfig(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<bia-table
*ngIf="!crudConfiguration.useCalcMode"
[elements]="(crudItems$ | async) ?? []"
[dictOptionDtos]="
(memberService.optionsService.dictOptionDtos$ | async) ?? []
"
[totalRecord]="(totalCount$ | async) ?? 0"
[columnToDisplays]="displayedColumns"
[pageSize]="pageSize"
Expand Down
1 change: 1 addition & 0 deletions Angular/src/assets/bia/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"backgroundTaskAdmin": "Administer tasks",
"backgroundTaskReadOnly": "View the tasks",
"backgroundtasks": "Background Tasks",
"browse": "Browse",
"bulk": "Bulk",
"cancel": "Cancel",
"close": "Close",
Expand Down
1 change: 1 addition & 0 deletions Angular/src/assets/bia/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"backgroundTaskAdmin": "Administrar tareas",
"backgroundTaskReadOnly": "Ver tareas",
"backgroundtasks": "Tarea en segundo plano",
"browse": "Buscar",
"bulk": "En Masa",
"cancel": "Cancelar",
"close": "Cerrar",
Expand Down
1 change: 1 addition & 0 deletions Angular/src/assets/bia/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"backgroundTaskAdmin": "Administrer les taches",
"backgroundTaskReadOnly": "Voir les taches",
"backgroundtasks": "Tâches d'arrière-plan",
"browse": "Parcourir",
"bulk": "En Masse",
"cancel": "Annuler",
"close": "Fermer",
Expand Down
2 changes: 1 addition & 1 deletion Angular/src/assets/i18n/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@
"description": "Description to be customised in i18n traductions for each feature"
}
}
}
}
2 changes: 1 addition & 1 deletion Angular/src/assets/i18n/app/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@
"description": "Descripción a personalizar en las traducciones i18n para cada función"
}
}
}
}
2 changes: 1 addition & 1 deletion Angular/src/assets/i18n/app/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@
"description": "Description à customiser dans les traductions i18n pour chaque feature"
}
}
}
}
Loading

0 comments on commit f813ba2

Please sign in to comment.