Fixing UI incompatibilities
This commit is contained in:
parent
074e374d9a
commit
3f14528f16
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
||||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||||
import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
||||||
import eu.eudat.query.lookup.LookupAware;
|
import eu.eudat.query.lookup.LookupAware;
|
||||||
|
@ -74,6 +75,8 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
||||||
public DescriptionTemplateTypeQuery fromLookup(DescriptionTemplateTypeLookup lookup) {
|
public DescriptionTemplateTypeQuery fromLookup(DescriptionTemplateTypeLookup lookup) {
|
||||||
if (lookup == null)
|
if (lookup == null)
|
||||||
return this;
|
return this;
|
||||||
|
if (lookup.getStatus() == null)
|
||||||
|
statuses(DescriptionTemplateTypeStatus.SAVED.getValue(), DescriptionTemplateTypeStatus.FINALIZED.getValue());
|
||||||
if (lookup.getName() != null)
|
if (lookup.getName() != null)
|
||||||
names(lookup.getName());
|
names(lookup.getName());
|
||||||
if (lookup.getStatus() != null)
|
if (lookup.getStatus() != null)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.UUID;
|
||||||
import static eu.eudat.controllers.v2.BaseController.extractQueryResultWithCount;
|
import static eu.eudat.controllers.v2.BaseController.extractQueryResultWithCount;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(path = "api/v2/descriptionTemplateType", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(path = "api/v2/descriptionTemplateType", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public class DescriptionTemplateTypeV2Controller {
|
public class DescriptionTemplateTypeV2Controller {
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
"pako": "^1.0.11",
|
"pako": "^1.0.11",
|
||||||
"rxjs": "^6.3.2",
|
"rxjs": "^6.3.2",
|
||||||
"tinymce": "^5.9.2",
|
"tinymce": "^5.9.2",
|
||||||
|
"ts-simple-nameof": "^1.3.1",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
"web-animations-js": "^2.3.2",
|
"web-animations-js": "^2.3.2",
|
||||||
"zone.js": "~0.11.4"
|
"zone.js": "~0.11.4"
|
||||||
|
|
|
@ -53,6 +53,7 @@ import { GlossaryService } from './services/glossary/glossary.service';
|
||||||
import { TermsOfServiceService } from './services/terms-of-service/terms-of-service.service';
|
import { TermsOfServiceService } from './services/terms-of-service/terms-of-service.service';
|
||||||
import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service';
|
import { UnlinkAccountEmailConfirmationService } from './services/unlink-account-email-confirmation/unlink-account-email-confirmation.service';
|
||||||
import { DescriptionTemplateTypeService } from './services/description-template-type/description-template-type.service';
|
import { DescriptionTemplateTypeService } from './services/description-template-type/description-template-type.service';
|
||||||
|
import { BaseHttpV2Service } from './services/http/base-http-v2.service';
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
||||||
|
@ -79,6 +80,7 @@ export class CoreServiceModule {
|
||||||
AuthService,
|
AuthService,
|
||||||
CookieService,
|
CookieService,
|
||||||
BaseHttpService,
|
BaseHttpService,
|
||||||
|
BaseHttpV2Service,
|
||||||
AdminAuthGuard,
|
AdminAuthGuard,
|
||||||
SpecialAuthGuard,
|
SpecialAuthGuard,
|
||||||
AuthGuard,
|
AuthGuard,
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { Lookup } from "@common/model/lookup";
|
||||||
|
|
||||||
|
export class DescriptionTemplateTypeLookup extends Lookup {
|
||||||
|
name: string;
|
||||||
|
status: number;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,38 +1,42 @@
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
import { BaseHttpService } from '../http/base-http.service';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { DataTableData } from '@app/core/model/data-table/data-table-data';
|
|
||||||
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
||||||
|
import { QueryResult } from '@common/model/query-result';
|
||||||
|
import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template/description-template-type.lookup';
|
||||||
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DescriptionTemplateTypeService {
|
export class DescriptionTemplateTypeService {
|
||||||
|
|
||||||
private actionUrl: string;
|
private get apiBase(): string { return `${this.configurationService.server}v2/descriptionTemplateType`; }
|
||||||
private headers = new HttpHeaders();
|
private headers = new HttpHeaders();
|
||||||
|
|
||||||
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
|
constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService) {}
|
||||||
this.actionUrl = configurationService.server + 'descriptionTemplateType/';
|
|
||||||
|
getAll(lookup: DescriptionTemplateTypeLookup): Observable<QueryResult<DescriptionTemplateType>> {
|
||||||
|
const url = `${this.apiBase}/all`;
|
||||||
|
return this.http.post<QueryResult<DescriptionTemplateType>>(url, lookup, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
getTypes(): Observable<DataTableData<DescriptionTemplateType>> {
|
getSingle(id: string): Observable<QueryResult<DescriptionTemplateType>> {
|
||||||
return this.http.get<DataTableData<DescriptionTemplateType>>(this.actionUrl + 'get', { headers: this.headers });
|
const url = `${this.apiBase}/${id}`;
|
||||||
|
return this.http.get<QueryResult<DescriptionTemplateType>>(url , { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
getSingle(id: string): Observable<DescriptionTemplateType> {
|
create(payload: DescriptionTemplateType): Observable<QueryResult<DescriptionTemplateType>> {
|
||||||
return this.http.get<DescriptionTemplateType>(this.actionUrl + 'get/' + id, { headers: this.headers });
|
const url = `${this.apiBase}/create`;
|
||||||
|
return this.http.post<QueryResult<DescriptionTemplateType>>(url, payload, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
createType(type: DescriptionTemplateType): Observable<DescriptionTemplateType> {
|
update(payload: DescriptionTemplateType): Observable<QueryResult<DescriptionTemplateType>> {
|
||||||
return this.http.post<DescriptionTemplateType>(this.actionUrl + 'create', type, { headers: this.headers });
|
const url = `${this.apiBase}/update`;
|
||||||
|
return this.http.post<QueryResult<DescriptionTemplateType>>(url, payload, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
updateType(type: DescriptionTemplateType): Observable<DescriptionTemplateType> {
|
delete(id: string): Observable<void> {
|
||||||
return this.http.post<DescriptionTemplateType>(this.actionUrl + 'update', type, { headers: this.headers });
|
const url = `${this.apiBase}/delete/${id}`;
|
||||||
}
|
return this.http.delete<void>(url, { headers: this.headers });
|
||||||
|
|
||||||
deleteType(id: string): Observable<DescriptionTemplateType> {
|
|
||||||
return this.http.delete<DescriptionTemplateType>(this.actionUrl + 'delete/' + id, { headers: this.headers });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BaseHttpV2Service {
|
||||||
|
constructor(
|
||||||
|
protected http: HttpClient
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
get<T>(url: string, options?: Object): Observable<T> {
|
||||||
|
return this.http.get<T>(url, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
post<T>(url: string, body: any, options?: Object): Observable<T> {
|
||||||
|
return this.http.post<T>(url, body, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
put<T>(url: string, body: any, options?: Object): Observable<T> {
|
||||||
|
return this.http.put<T>(url, body, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete<T>(url: string, options?: Object): Observable<T> {
|
||||||
|
return this.http.delete<T>(url, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
patch<T>(url: string, body: any, options?: Object): Observable<T> {
|
||||||
|
return this.http.patch<T>(url, body, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
head<T>(url: string, options?: Object): Observable<T> {
|
||||||
|
return this.http.head<T>(url, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
options<T>(url: string, options?: Object): Observable<T> {
|
||||||
|
return this.http.options<T>(url, options);
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,6 +48,8 @@ import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate
|
||||||
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
|
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
|
||||||
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
||||||
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
|
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
|
||||||
|
import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template/description-template-type.lookup';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
|
const skipDisable: any[] = require('../../../../../assets/resources/skipDisable.json');
|
||||||
|
|
||||||
|
@ -607,9 +609,17 @@ export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
getDescriptionTemplateTypes(): DescriptionTemplateType[] {
|
getDescriptionTemplateTypes(): DescriptionTemplateType[] {
|
||||||
this.descriptionTemplateTypeService.getTypes().pipe(takeUntil(this._destroyed))
|
let lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup();
|
||||||
|
lookup.project = {
|
||||||
|
fields: [
|
||||||
|
nameof<DescriptionTemplateType>(x => x.id),
|
||||||
|
nameof<DescriptionTemplateType>(x => x.name),
|
||||||
|
nameof<DescriptionTemplateType>(x => x.status)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
this.descriptionTemplateTypeService.getAll(lookup).pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(types => {
|
.subscribe(types => {
|
||||||
this.descriptionTemplateTypes = types.data.filter(type => type.status === DescriptionTemplateTypeStatus.Finalized);
|
this.descriptionTemplateTypes = types.items.filter(type => type.status === DescriptionTemplateTypeStatus.Finalized);
|
||||||
});
|
});
|
||||||
return this.descriptionTemplateTypes;
|
return this.descriptionTemplateTypes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ export class DescriptionTypeEditorComponent extends BaseComponent implements OnI
|
||||||
this.descriptionTemplateTypeService.getSingle(this.descriptionTemplateTypeId)
|
this.descriptionTemplateTypeService.getSingle(this.descriptionTemplateTypeId)
|
||||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
type => {
|
type => {
|
||||||
this.descriptionTypeModel = new DescriptionTypeEditorModel().fromModel(type);
|
this.descriptionTypeModel = new DescriptionTypeEditorModel().fromModel(type.items[0]);
|
||||||
if(this.descriptionTypeModel.status === DescriptionTemplateTypeStatus.Finalized){
|
if (this.descriptionTypeModel.status === DescriptionTemplateTypeStatus.Finalized) {
|
||||||
this.formGroup = this.descriptionTypeModel.buildForm(null, true);
|
this.formGroup = this.descriptionTypeModel.buildForm(null, true);
|
||||||
this.viewOnly = true;
|
this.viewOnly = true;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
this.formGroup = this.descriptionTypeModel.buildForm();
|
this.formGroup = this.descriptionTypeModel.buildForm();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -83,16 +83,16 @@ export class DescriptionTypeEditorComponent extends BaseComponent implements OnI
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
if(this.isNew){
|
if (this.isNew) {
|
||||||
this.descriptionTemplateTypeService.createType(this.formGroup.value)
|
this.descriptionTemplateTypeService.create(this.formGroup.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(true),
|
complete => this.onCallbackSuccess(true),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
this.descriptionTemplateTypeService.updateType(this.formGroup.value)
|
this.descriptionTemplateTypeService.update(this.formGroup.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(false),
|
complete => this.onCallbackSuccess(false),
|
||||||
|
@ -102,10 +102,10 @@ export class DescriptionTypeEditorComponent extends BaseComponent implements OnI
|
||||||
}
|
}
|
||||||
|
|
||||||
onCallbackSuccess(creation: boolean): void {
|
onCallbackSuccess(creation: boolean): void {
|
||||||
if(creation){
|
if (creation) {
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION'), SnackBarNotificationLevel.Success);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||||
}
|
}
|
||||||
this.router.navigate(['/description-types']);
|
this.router.navigate(['/description-types']);
|
||||||
|
|
|
@ -28,14 +28,17 @@
|
||||||
<ng-container cdkColumnDef="status">
|
<ng-container cdkColumnDef="status">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header="status">{{'DESCRIPTION-TYPES-LISTING.COLUMNS.STATUS' |
|
<mat-header-cell *matHeaderCellDef mat-sort-header="status">{{'DESCRIPTION-TYPES-LISTING.COLUMNS.STATUS' |
|
||||||
translate}}</mat-header-cell>
|
translate}}</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row"> <div [ngClass]="['status-chip',getStatusClass(row.status)]">{{parseStatus(row.status) | translate}}</div></mat-cell>
|
<mat-cell *matCellDef="let row">
|
||||||
|
<div [ngClass]="['status-chip',getStatusClass(row.status)]">{{parseStatus(row.status) | translate}}</div>
|
||||||
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container cdkColumnDef="delete">
|
<ng-container cdkColumnDef="delete">
|
||||||
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
||||||
<button mat-icon-button (click)="deleteTemplate(row.id)">
|
<button mat-icon-button (click)="deleteTemplate(row.id)">
|
||||||
<mat-icon [matTooltip]="('DESCRIPTION-TYPES-LISTING.ACTIONS.DELETE' | translate)" matTooltipPosition="right" class="dlt-btn">delete</mat-icon>
|
<mat-icon [matTooltip]="('DESCRIPTION-TYPES-LISTING.ACTIONS.DELETE' | translate)"
|
||||||
|
matTooltipPosition="right" class="dlt-btn">delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -44,7 +47,7 @@
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
||||||
|
|
||||||
</mat-table>
|
</mat-table>
|
||||||
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
|
<mat-paginator #paginator [pageSizeOptions]="[10, 25, 100]">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, EventEmitter, OnInit, ViewChild } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
import { MatSort } from '@angular/material/sort';
|
import { MatSort } from '@angular/material/sort';
|
||||||
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type';
|
||||||
|
import { DescriptionTemplateTypeLookup } from '@app/core/query/description-template/description-template-type.lookup';
|
||||||
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
|
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { merge as observableMerge, Observable, of } from 'rxjs';
|
import { Observable, merge, of } from 'rxjs';
|
||||||
import { map, startWith, switchMap, takeUntil } from 'rxjs/operators';
|
import { map, startWith, switchMap, takeUntil } from 'rxjs/operators';
|
||||||
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-description-types',
|
selector: 'app-description-types',
|
||||||
|
@ -22,7 +25,7 @@ import { map, startWith, switchMap, takeUntil } from 'rxjs/operators';
|
||||||
export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator;
|
@ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator;
|
||||||
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
@ViewChild(MatSort, { static: true }) _sort: MatSort;
|
||||||
|
|
||||||
dataSource: DescriptionTypesDataSource | null;
|
dataSource: DescriptionTypesDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'status', 'delete'];
|
displayedColumns: String[] = ['label', 'status', 'delete'];
|
||||||
|
@ -47,24 +50,24 @@ export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.dataSource = new DescriptionTypesDataSource(this.descriptionTemplateTypeService, this._paginator, this.sort/*, this.criteria*/);
|
this.dataSource = new DescriptionTypesDataSource(this.descriptionTemplateTypeService, this._paginator, this._sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowClick(rowId: String) {
|
rowClick(rowId: String) {
|
||||||
this.router.navigate(['description-types/' + rowId]);
|
this.router.navigate(['description-types/' + rowId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseStatus(value: number): string{
|
parseStatus(value: number): string {
|
||||||
const stringVal = value.toString()
|
const stringVal = value.toString()
|
||||||
try{
|
try {
|
||||||
return this.statuses.find(status => status.value === stringVal).viewValue;
|
return this.statuses.find(status => status.value === stringVal).viewValue;
|
||||||
}catch{
|
} catch {
|
||||||
return stringVal;
|
return stringVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTemplate(id: string){
|
deleteTemplate(id: string) {
|
||||||
if(id){
|
if (id) {
|
||||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
restoreFocus: false,
|
restoreFocus: false,
|
||||||
data: {
|
data: {
|
||||||
|
@ -77,7 +80,7 @@ export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.descriptionTemplateTypeService.deleteType(id)
|
this.descriptionTemplateTypeService.delete(id)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => {
|
complete => {
|
||||||
|
@ -105,7 +108,7 @@ export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
getStatusClass(status: number): string {
|
getStatusClass(status: number): string {
|
||||||
|
|
||||||
if(status == 1){
|
if (status == 1) {
|
||||||
return 'status-chip-finalized'
|
return 'status-chip-finalized'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +119,8 @@ export class DescriptionTypesComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
export class DescriptionTypesDataSource extends DataSource<DescriptionTemplateType> {
|
export class DescriptionTypesDataSource extends DataSource<DescriptionTemplateType> {
|
||||||
|
|
||||||
totalCount = 0;
|
data: DescriptionTemplateType[] = [];
|
||||||
|
loadData: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _service: DescriptionTemplateTypeService,
|
private _service: DescriptionTemplateTypeService,
|
||||||
|
@ -124,27 +128,41 @@ export class DescriptionTypesDataSource extends DataSource<DescriptionTemplateTy
|
||||||
private _sort: MatSort
|
private _sort: MatSort
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<DescriptionTemplateType[]> {
|
connect(): Observable<DescriptionTemplateType[]> {
|
||||||
const displayDataChanges = [
|
const dataChanges = [
|
||||||
this._paginator.page
|
this._paginator.page,
|
||||||
//this._sort.matSortChange
|
this._sort.sortChange
|
||||||
];
|
];
|
||||||
|
|
||||||
return observableMerge(...displayDataChanges).pipe(
|
return merge(...dataChanges).pipe(
|
||||||
startWith(null),
|
startWith(<string>null),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return this._service.getTypes();
|
let lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup();
|
||||||
|
lookup.page = {
|
||||||
|
offset: this._paginator.pageIndex * this._paginator.pageSize,
|
||||||
|
size: this._paginator.pageSize
|
||||||
|
},
|
||||||
|
lookup.project = {
|
||||||
|
fields: [
|
||||||
|
nameof<DescriptionTemplateType>(x => x.id),
|
||||||
|
nameof<DescriptionTemplateType>(x => x.name),
|
||||||
|
nameof<DescriptionTemplateType>(x => x.status)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
return this._service.getAll(lookup)
|
||||||
}),
|
}),
|
||||||
map(result => {
|
map(result => {
|
||||||
return result;
|
return result;
|
||||||
}),
|
}),
|
||||||
map(result => {
|
map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
|
||||||
return result.data;
|
this.data = result.items;
|
||||||
|
this._paginator.length = result.count;
|
||||||
|
return result.items;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
export class Lookup {
|
||||||
|
public page: Lookup.Paging;
|
||||||
|
public order: Lookup.Ordering;
|
||||||
|
public metadata: Lookup.Header;
|
||||||
|
public project: Lookup.FieldDirectives;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.project = {
|
||||||
|
fields: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace Lookup {
|
||||||
|
export interface Header {
|
||||||
|
countAll: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FieldDirectives {
|
||||||
|
fields: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Ordering {
|
||||||
|
items: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paging {
|
||||||
|
offset: number;
|
||||||
|
size: number;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface QueryResult<T> {
|
||||||
|
count: number;
|
||||||
|
countOverride?: number;
|
||||||
|
items: T[];
|
||||||
|
}
|
Loading…
Reference in New Issue