Daniel 10 месяцев назад
Родитель
Сommit
df390758b6
14 измененных файлов: 86 добавлений и 27 удалений
  1. +2
    -2
      angular/src/app/_components/list/list.component.html
  2. +44
    -18
      angular/src/app/_components/list/list.component.ts
  3. +1
    -0
      angular/src/app/_views/location/location-list/location-list.component.html
  4. +5
    -0
      angular/src/app/_views/location/location-list/location-list.component.ts
  5. +1
    -0
      angular/src/app/_views/shipping-company/shipping-company-list/shipping-company-list.component.html
  6. +5
    -0
      angular/src/app/_views/shipping-company/shipping-company-list/shipping-company-list.component.ts
  7. +1
    -1
      angular/src/app/_views/trip/trip-list/trip-list.component.html
  8. +4
    -0
      angular/src/app/_views/trip/trip-list/trip-list.component.ts
  9. +2
    -1
      angular/src/app/_views/trip/trip-location-list/trip-location-list.component.html
  10. +6
    -1
      angular/src/app/_views/trip/trip-location-list/trip-location-list.component.ts
  11. +1
    -0
      angular/src/app/_views/vessel/vessel-list/vessel-list.component.html
  12. +6
    -1
      angular/src/app/_views/vessel/vessel-list/vessel-list.component.ts
  13. +1
    -0
      angular/src/app/_views/zone/zone-list/zone-list.component.html
  14. +7
    -3
      angular/src/app/_views/zone/zone-list/zone-list.component.ts

+ 2
- 2
angular/src/app/_components/list/list.component.html Просмотреть файл

@@ -90,11 +90,11 @@
</ng-container> </ng-container>


<ng-container *ngSwitchCase="COLUMN_TYPE_BTN_REMOVE"> <ng-container *ngSwitchCase="COLUMN_TYPE_BTN_REMOVE">
<span class="spt-icon-remove" (click)="onRemoveItemFunction(element, column)"></span>
<span class="spt-icon-remove" (click)="onDeleteItem(element)"></span>
</ng-container> </ng-container>


<ng-container *ngSwitchCase="COLUMN_TYPE_BTN_EDIT"> <ng-container *ngSwitchCase="COLUMN_TYPE_BTN_EDIT">
<span class="spt-icon-edit" data-type="user-tool" data-action="edit" (click)="onEditData(element)"></span>
<span class="spt-icon-edit" data-type="user-tool" data-action="edit" (click)="onEditItem(element)"></span>
</ng-container> </ng-container>


<ng-container *ngSwitchCase="COLUMN_TYPE_DATE"> <ng-container *ngSwitchCase="COLUMN_TYPE_DATE">


+ 44
- 18
angular/src/app/_components/list/list.component.ts Просмотреть файл

@@ -8,8 +8,9 @@ import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-funct
import {ListUpdateElementFunctionType} from "@app/_components/list/list-update-element-function-type"; import {ListUpdateElementFunctionType} from "@app/_components/list/list-update-element-function-type";
import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.component"; import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.component";
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import {interval, Subscription} from "rxjs";
import {interval, Observable, Subscription} from "rxjs";
import {AbstractDataFormComponent} from "@app/_components/_abstract/abstract-data-form-component"; import {AbstractDataFormComponent} from "@app/_components/_abstract/abstract-data-form-component";
import {TranslateService} from "@ngx-translate/core";


@Component({ @Component({
selector: 'app-list', selector: 'app-list',
@@ -23,8 +24,8 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() public onSortFunction?: Function; @Input() public onSortFunction?: Function;
@Input() public onNavigateToDetailsFunction!: Function; @Input() public onNavigateToDetailsFunction!: Function;
@Input() public getCustomDetailLinkFunction!: Function; @Input() public getCustomDetailLinkFunction!: Function;
@Input() public onRemoveItemFunction!: Function;
@Input() public onEditFunction!: Function;
@Input() public deleteItemFunction?: (id: string) => Observable<any>;
@Input() public onEditItemFunction!: Function;
@Input() public onDownloadFunction!: Function; @Input() public onDownloadFunction!: Function;
@Input() public onRowSelectedFunction!: Function; @Input() public onRowSelectedFunction!: Function;
@Input() public onUpdateBooleanStateFunction!: ListUpdateElementFunctionType; @Input() public onUpdateBooleanStateFunction!: ListUpdateElementFunctionType;
@@ -83,6 +84,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
constructor( constructor(
protected appHelperService: AppHelperService, protected appHelperService: AppHelperService,
private router: Router, private router: Router,
protected translateService: TranslateService
) { ) {
this.searchable = true; this.searchable = true;
this.showPosition = true; this.showPosition = true;
@@ -105,12 +107,12 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.showPosition) { if (this.showPosition) {
this.listColDefinitions.unshift(ListComponent.getDefaultColPosition()); this.listColDefinitions.unshift(ListComponent.getDefaultColPosition());
} }
if (this.showEditButton) {
this.listColDefinitions.unshift(ListComponent.getDefaultColEditBtn());
}
if (this.showRemoveButton) {
if (this.deleteItemFunction && this.showRemoveButton) {
this.listColDefinitions.unshift(ListComponent.getDefaultRemoveBtn()); this.listColDefinitions.unshift(ListComponent.getDefaultRemoveBtn());
} }
if (this.dataFormComponent && this.showEditButton) {
this.listColDefinitions.unshift(ListComponent.getDefaultColEditBtn());
}
if (this.showDetailButton) { if (this.showDetailButton) {
const url = this.getCustomDetailLinkFunction !== undefined ? '' : this.router.routerState.snapshot.url; const url = this.getCustomDetailLinkFunction !== undefined ? '' : this.router.routerState.snapshot.url;
this.listColDefinitions.unshift(ListComponent.getDefaultColDetailBtnLink(url)); this.listColDefinitions.unshift(ListComponent.getDefaultColDetailBtnLink(url));
@@ -431,17 +433,41 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
); );
} }


public onEditData(element: any) {
// Create a new object instead of modifying the existing one
this.dataFormComponentData = {
...this.dataFormComponentData,
data: element
};
this.appHelperService.openModal(
this.dataFormComponent,
this.dataFormComponentData,
this.getData
);
public onEditItem(element: any) {
if (this.onEditItemFunction) {
this.onEditItemFunction(element);
} else {
// Default edit
// Create a new object instead of modifying the existing one
this.dataFormComponentData = {
...this.dataFormComponentData,
data: element
};
this.appHelperService.openModal(
this.dataFormComponent,
this.dataFormComponentData,
this.getData
);
}
}

public onDeleteItem(element: any) {
const deleteFunction = this.deleteItemFunction;
if (deleteFunction) {
this.translateService.get('basic.delete_confirm_related').subscribe((confirmMessage: string) => {
if (confirm(confirmMessage)) {
deleteFunction(element.dbId).subscribe({
next: () => {
this.getData();
},
error: (error: any) => {
console.error('Delete error:', error);
alert('Error while deleting dataset (there might be related data)');
}
});
}
});
}
} }


public getFilterJsonString(): any { public getFilterJsonString(): any {


+ 1
- 0
angular/src/app/_views/location/location-list/location-list.component.html Просмотреть файл

@@ -2,6 +2,7 @@
<app-list #listComponent <app-list #listComponent
[listId]="'locationList'" [listId]="'locationList'"
[getDataFunction]="getData" [getDataFunction]="getData"
[deleteItemFunction]="deleteItemFunction"
[getCustomDetailLinkFunction]="getCustomDetailLink" [getCustomDetailLinkFunction]="getCustomDetailLink"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="LocationFormComponent" [dataFormComponent]="LocationFormComponent"


+ 5
- 0
angular/src/app/_views/location/location-list/location-list.component.ts Просмотреть файл

@@ -9,6 +9,7 @@ import {ROUTE_LOCATIONS} from "@app/app-routing.module";
import {Sort} from "@angular/material/sort"; import {Sort} from "@angular/material/sort";
import {LocationFormComponent} from "@app/_views/location/location-form/location-form.component"; import {LocationFormComponent} from "@app/_views/location/location-form/location-form.component";
import {SearchSelectComponent} from "@app/_components/search-select/search-select.component"; import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-location-list', selector: 'app-location-list',
@@ -55,4 +56,8 @@ export class LocationListComponent implements OnInit, AfterViewInit {
getCustomDetailLink(element: LocationJsonld) { getCustomDetailLink(element: LocationJsonld) {
return ROUTE_LOCATIONS + '/' + this.appHelperService.extractId(element?.id); return ROUTE_LOCATIONS + '/' + this.appHelperService.extractId(element?.id);
} }

get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.locationService.locationsIdDelete(id);
}
} }

+ 1
- 0
angular/src/app/_views/shipping-company/shipping-company-list/shipping-company-list.component.html Просмотреть файл

@@ -2,6 +2,7 @@
<app-list #listComponent <app-list #listComponent
[listId]="'shippingCompanyList'" [listId]="'shippingCompanyList'"
[getDataFunction]="getData" [getDataFunction]="getData"
[deleteItemFunction]="deleteItemFunction"
[getCustomDetailLinkFunction]="getCustomDetailLink" [getCustomDetailLinkFunction]="getCustomDetailLink"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="ShippingCompanyFormComponent" [dataFormComponent]="ShippingCompanyFormComponent"


+ 5
- 0
angular/src/app/_views/shipping-company/shipping-company-list/shipping-company-list.component.ts Просмотреть файл

@@ -15,6 +15,7 @@ import {ROUTE_LOCATIONS, ROUTE_SHIPPING_COMPANIES} from "@app/app-routing.module
import { import {
ShippingCompanyFormComponent ShippingCompanyFormComponent
} from "@app/_views/shipping-company/shipping-company-form/shipping-company-form.component"; } from "@app/_views/shipping-company/shipping-company-form/shipping-company-form.component";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-shipping-company-list', selector: 'app-shipping-company-list',
@@ -84,6 +85,10 @@ export class ShippingCompanyListComponent {
); );
} }


get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.shippingCompanyService.shippingCompaniesIdDelete(id);
}

getCustomDetailLink(element: LocationJsonld) { getCustomDetailLink(element: LocationJsonld) {
return ROUTE_SHIPPING_COMPANIES + '/' + this.appHelperService.extractId(element?.id); return ROUTE_SHIPPING_COMPANIES + '/' + this.appHelperService.extractId(element?.id);
} }


+ 1
- 1
angular/src/app/_views/trip/trip-list/trip-list.component.html Просмотреть файл

@@ -1,8 +1,8 @@
<div class="spt-container"> <div class="spt-container">
<app-list #listComponent <app-list #listComponent
[listId]="'tripList'" [listId]="'tripList'"
[showEditButton]="true"
[getDataFunction]="getData" [getDataFunction]="getData"
[deleteItemFunction]="deleteItemFunction"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="tripFormComponent" [dataFormComponent]="tripFormComponent"
></app-list> ></app-list>


+ 4
- 0
angular/src/app/_views/trip/trip-list/trip-list.component.ts Просмотреть файл

@@ -6,6 +6,7 @@ import {TripService} from "@app/core/api/v1";
import {AppHelperService} from "@app/_helpers/app-helper.service"; import {AppHelperService} from "@app/_helpers/app-helper.service";
import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.component"; import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.component";
import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-trip-list', selector: 'app-trip-list',
@@ -116,4 +117,7 @@ export class TripListComponent {
); );
} }


get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.tripService.tripsIdDelete(id);
}
} }

+ 2
- 1
angular/src/app/_views/trip/trip-location-list/trip-location-list.component.html Просмотреть файл

@@ -1,10 +1,11 @@
<div class="spt-container"> <div class="spt-container">
<app-list #listComponent <app-list #listComponent
[listId]="'tripLocationList'" [listId]="'tripLocationList'"
[showEditButton]="true"
[showDetailButton]="false"
[getDataFunction]="getData" [getDataFunction]="getData"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="tripLocationFormComponent" [dataFormComponent]="tripLocationFormComponent"
[dataFormComponentData]="dataFormComponentData" [dataFormComponentData]="dataFormComponentData"
[deleteItemFunction]="deleteItemFunction"
></app-list> ></app-list>
</div> </div>

+ 6
- 1
angular/src/app/_views/trip/trip-location-list/trip-location-list.component.ts Просмотреть файл

@@ -7,6 +7,7 @@ import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.compone
import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type";
import {TripLocationFormComponent} from "@app/_views/trip/trip-location-form/trip-location-form.component"; import {TripLocationFormComponent} from "@app/_views/trip/trip-location-form/trip-location-form.component";
import {map, tap} from "rxjs/operators"; import {map, tap} from "rxjs/operators";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-trip-location-list', selector: 'app-trip-location-list',
@@ -23,7 +24,7 @@ export class TripLocationListComponent {
protected dataFormComponentData: any; protected dataFormComponentData: any;


constructor( constructor(
private tripLocationService: TripLocationService,
public tripLocationService: TripLocationService,
protected appHelperService: AppHelperService, protected appHelperService: AppHelperService,
) { ) {
this.listColDefinitions = [ this.listColDefinitions = [
@@ -124,4 +125,8 @@ export class TripLocationListComponent {
}) })
); );
} }

get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.tripLocationService.tripLocationsIdDelete(id);
}
} }

+ 1
- 0
angular/src/app/_views/vessel/vessel-list/vessel-list.component.html Просмотреть файл

@@ -2,6 +2,7 @@
<app-list #listComponent <app-list #listComponent
[listId]="'vesselList'" [listId]="'vesselList'"
[getDataFunction]="getData" [getDataFunction]="getData"
[deleteItemFunction]="deleteItemFunction"
[getCustomDetailLinkFunction]="getCustomDetailLink" [getCustomDetailLinkFunction]="getCustomDetailLink"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="VesselFormComponent" [dataFormComponent]="VesselFormComponent"


+ 6
- 1
angular/src/app/_views/vessel/vessel-list/vessel-list.component.ts Просмотреть файл

@@ -5,9 +5,10 @@ import {VesselService, ZoneJsonld} from "@app/core/api/v1";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {AppHelperService} from "@app/_helpers/app-helper.service"; import {AppHelperService} from "@app/_helpers/app-helper.service";
import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type";
import {ROUTE_VESSELS, ROUTE_ZONES} from "@app/app-routing.module";
import {ROUTE_VESSELS} from "@app/app-routing.module";
import {VesselFormComponent} from "@app/_views/vessel/vessel-form/vessel-form.component"; import {VesselFormComponent} from "@app/_views/vessel/vessel-form/vessel-form.component";
import {SearchSelectComponent} from "@app/_components/search-select/search-select.component"; import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-vessel-list', selector: 'app-vessel-list',
@@ -51,6 +52,10 @@ export class VesselListComponent {
); );
} }


get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.vesselService.vesselsIdDelete(id);
}

getCustomDetailLink(element: ZoneJsonld) { getCustomDetailLink(element: ZoneJsonld) {
return ROUTE_VESSELS + '/' + this.appHelperService.extractId(element?.id); return ROUTE_VESSELS + '/' + this.appHelperService.extractId(element?.id);
} }


+ 1
- 0
angular/src/app/_views/zone/zone-list/zone-list.component.html Просмотреть файл

@@ -2,6 +2,7 @@
<app-list #listComponent <app-list #listComponent
[listId]="'zoneList'" [listId]="'zoneList'"
[getDataFunction]="getData" [getDataFunction]="getData"
[deleteItemFunction]="deleteItemFunction"
[getCustomDetailLinkFunction]="getCustomDetailLink" [getCustomDetailLinkFunction]="getCustomDetailLink"
[listColDefinitions]="listColDefinitions" [listColDefinitions]="listColDefinitions"
[dataFormComponent]="ZoneFormComponent" [dataFormComponent]="ZoneFormComponent"


+ 7
- 3
angular/src/app/_views/zone/zone-list/zone-list.component.ts Просмотреть файл

@@ -1,14 +1,14 @@
import {Component, ViewChild} from '@angular/core'; import {Component, ViewChild} from '@angular/core';
import {ListComponent} from "@app/_components/list/list.component"; import {ListComponent} from "@app/_components/list/list.component";
import {ListColDefinition} from "@app/_components/list/list-col-definition"; import {ListColDefinition} from "@app/_components/list/list-col-definition";
import {LocationJsonld, ZoneJsonld, ZoneService} from "@app/core/api/v1";
import {ZoneJsonld, ZoneService} from "@app/core/api/v1";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {AppHelperService} from "@app/_helpers/app-helper.service"; import {AppHelperService} from "@app/_helpers/app-helper.service";
import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type";
import {Sort} from "@angular/material/sort";
import {ROUTE_LOCATIONS, ROUTE_ZONES} from "@app/app-routing.module";
import {ROUTE_ZONES} from "@app/app-routing.module";
import {SearchSelectComponent} from "@app/_components/search-select/search-select.component"; import {SearchSelectComponent} from "@app/_components/search-select/search-select.component";
import {ZoneFormComponent} from "@app/_views/zone/zone-form/zone-form.component"; import {ZoneFormComponent} from "@app/_views/zone/zone-form/zone-form.component";
import {Observable} from "rxjs";


@Component({ @Component({
selector: 'app-zone-list', selector: 'app-zone-list',
@@ -50,6 +50,10 @@ export class ZoneListComponent {
); );
} }


get deleteItemFunction(): (id: string) => Observable<any> {
return (id: string) => this.zoneService.zonesIdDelete(id);
}

getCustomDetailLink(element: ZoneJsonld) { getCustomDetailLink(element: ZoneJsonld) {
return ROUTE_ZONES + '/' + this.appHelperService.extractId(element?.id); return ROUTE_ZONES + '/' + this.appHelperService.extractId(element?.id);
} }


Загрузка…
Отмена
Сохранить