List Table

reddit admissions essay writing service Grabmyessay Review writing a community service essay reddit
reddit college student essay writing service https://www.reddit.com/r/studylevel/comments/w8cx38/domyessay_review/ reddit.com essay writing service recommendation
how to write an essay essay https://freeessaywriter.org/ how to write cover letter for jobs
how to write a essay in english exam https://www.paperhelp.nyc/ how to write job email with reference

Per la creazione di una list table, aprire Visual Studio Code

  • Andare in src/aig-common/modules ed entrare nella sezione in cui si intende lavorare ex. “standard/component”
  • Creare una carella con il nome del componente ex. “city-list-table
  • Creare le tre sezione principali di un componente (HTML,SCSS,TS) ex. “city-list-table.component.ts”“city-list-table.component.html” – “city-list-table.component.ts”

Typescript

Nel Typescript del componente inserire quanto segue ex.

import { Component, OnInit, Input } from '@angular/core';
import { MatDialog, MatSnackBar } from '@angular/material';
import { FuseProgressBarService } from '@fuse/components/progress-bar/progress-bar.service';
import { EventService } from 'aig-common/event-manager/event.service';
import { CityDTO } from 'aig-generic';
import { CityResourceService } from 'aig-standard';
import { AigCityNewUpdateModalComponent } from 'app/main/api-gest-console/modules/aig-standard/components/city-new-update-modal/city-new-update-modal.component';

@Component({
    selector: 'aig-city-list-table',
    templateUrl: './city-list-table.component.html',
    styleUrls: ['./city-list-table.component.scss']
})
export class AigCityListTableComponent implements OnInit {
    constructor(
        private cityResourceService: CityResourceService,
        private eventService: EventService,
        private _fuseProgressBarService: FuseProgressBarService,
        private _snackBar: MatSnackBar,
        private dialog: MatDialog,
    ) { }

    @Input()
    error: any;
    @Input()
    displayedColumns: string[];
    @Input()
    dataSource: any[];

    ngOnInit(): void { }

    async deleteCity(id: number) {
        this._fuseProgressBarService.show();

        try {
            await this.cityResourceService.deleteCityUsingDELETE(id).toPromise();
            this._snackBar.open(`City: '${id}' deleted.`, null, { duration: 2000, });

            this.eventService.reloadCurrentPage();
        } catch (e) {
            this._snackBar.open(`Error during deleting city: '${id}'. (${e.message})`, null, { duration: 5000, });
        }
        this._fuseProgressBarService.hide();
    }

    editCity(cityDTO: CityDTO) {
        this.dialog.open(AigCityNewUpdateModalComponent, { data: { city: cityDTO } });
    }
}

HTML

Nel Html del componente inserire quanto segue ex.

<div *ngIf="error != null" class="p-48" fxLayout="row" fxLayoutAlign="center center" fxFlex>
    <span *ngIf="error.status == 401">No access to this info</span>
</div>
<div *ngIf="error == null && dataSource == null" class="p-48">
    <div fxLayout="row" fxLayoutAlign="center center" fxFlex>
        <mat-spinner></mat-spinner>
    </div>
</div>
<div *ngIf="error == null && dataSource != null">

    <mat-table #table [dataSource]="dataSource">

        <ng-container matColumnDef="id">
            <mat-header-cell *matHeaderCellDef> Id </mat-header-cell>
            <mat-cell *matCellDef="let e"> {{ e.id }} </mat-cell>
        </ng-container>

        <ng-container matColumnDef="code">
            <mat-header-cell *matHeaderCellDef> Code </mat-header-cell>
            <mat-cell *matCellDef="let e"> {{ e.code }} </mat-cell>
        </ng-container>

        <ng-container matColumnDef="name">
            <mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
            <mat-cell *matCellDef="let e"> {{ e.name }} </mat-cell>
        </ng-container>

        <ng-container matColumnDef="wikiCode">
            <mat-header-cell *matHeaderCellDef> Wiki Code </mat-header-cell>
            <mat-cell *matCellDef="let e"> {{ e.wikiCode }} </mat-cell>
        </ng-container>

        <ng-container matColumnDef="buttons">
            <mat-header-cell *matHeaderCellDef></mat-header-cell>
            <mat-cell *matCellDef="let e">
                <button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
                    <mat-icon>more_vert</mat-icon>
                  </button>
                  <mat-menu #menu="matMenu">
                    <button mat-menu-item [routerLink]="'/s6d/city/detail/' + e.id">
                      <mat-icon>details</mat-icon>
                      <span>Details</span>
                    </button>
                    <button mat-menu-item (click)="editCity(e)">
                        <mat-icon>edit</mat-icon>
                        <span>Edit</span>
                      </button>
                    <button mat-menu-item (click)="deleteCity(e.id)">
                      <mat-icon>delete</mat-icon>
                      <span>Delete</span>
                    </button>
                  </mat-menu>
            </mat-cell>
        </ng-container>

        <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
        <mat-row *matRowDef="let dataSource; columns: displayedColumns;"></mat-row>

    </mat-table>

</div>

SCSS

Nel SCSS del componente inserire quanto segue ex.

Per formattare eventuali errori di copia/incolla, usare la combinazione di tasti ALT+MAIUSC+F