Commit 5867a5d6 authored by PECQUOT's avatar PECQUOT

[enh] sampling equipments OK

parent 61f43153
......@@ -17,8 +17,7 @@ npm-debug.log*
.sass-cache/
.tmp/
.versions/
.local/
.local/android
.local/**
coverage/
dist/
node_modules/
......
import {Beans, KeysEnum, Referential} from "sumaris-lib";
import {Beans, KeysEnum, NOT_MINIFY_OPTIONS, Referential, ReferentialAsObjectOptions, ReferentialRef} from "sumaris-lib";
import {BaseReferentialFilter} from "@app/referential/model/referential.model";
......@@ -12,12 +12,18 @@ export class SamplingEquipment extends Referential<SamplingEquipment> {
}
size: number;
unitId: number;
unit: ReferentialRef;
fromObject(source: any) {
super.fromObject(source);
this.size = source.size;
this.unitId = source.unitId;
this.unit = source.unit && ReferentialRef.fromObject(source.unit) || undefined;
}
asObject(opts?: ReferentialAsObjectOptions): any {
const target = super.asObject(opts);
target.unit = this.unit && this.unit.asObject({...opts, ...NOT_MINIFY_OPTIONS, keepEntityName: true} as ReferentialAsObjectOptions) || undefined;
return target;
}
}
......@@ -33,7 +39,7 @@ export class SamplingEquipmentFilter implements BaseReferentialFilter {
searchText?: string;
searchAttribute?: string;
static isEmpty(f: SamplingEquipmentFilter|any): boolean {
static isEmpty(f: SamplingEquipmentFilter | any): boolean {
return Beans.isEmpty<SamplingEquipmentFilter>(f, samplingEquipmentFilterKeys, {
blankStringLikeEmpty: true
});
......
......@@ -4,6 +4,7 @@ export const referentialFragments = {
referential: gql`fragment ReferentialFragment on ReferentialVO {
id
name
label
statusId
entityName
__typename
......@@ -49,7 +50,9 @@ export const referentialFragments = {
description
comments
size
unitId
unit {
...ReferentialFragment
}
updateDate
creationDate
statusId
......
import {Inject, Injectable} from "@angular/core";
import {EnvironmentService, GraphqlService, LoadResult, PlatformService} from "sumaris-lib";
import {EnvironmentService, GraphqlService, PlatformService} from "sumaris-lib";
import {BaseReferentialService} from "@app/referential/services/base-referential.service";
import gql from "graphql-tag";
import {referentialFragments} from "@app/referential/services/referential.fragments";
import {ReferentialQueries} from "@app/referential/services/referential.queries";
import {SamplingEquipment, SamplingEquipmentFilter} from "@app/referential/model/sampling-equipment.model";
import {FetchPolicy} from "@apollo/client/core";
import {SortDirection} from "@angular/material/sort";
import {Observable} from "rxjs";
const queries: ReferentialQueries = {
......@@ -20,6 +17,7 @@ const queries: ReferentialQueries = {
}
}
${referentialFragments.samplingEquipment}
${referentialFragments.referential}
`;
},
......@@ -32,6 +30,7 @@ const queries: ReferentialQueries = {
count:samplingEquipmentsCount(filter: $filter)
}
${referentialFragments.samplingEquipment}
${referentialFragments.referential}
`;
},
......@@ -43,6 +42,7 @@ const queries: ReferentialQueries = {
}
}
${referentialFragments.samplingEquipment}
${referentialFragments.referential}
`;
},
......
......@@ -120,7 +120,7 @@
</ion-item>
<div class="table-container">
<table mat-table #table [dataSource]="dataSource" matSort matSortActive="id" matSortDirection="asc" [resizableTable]="false"
<table mat-table #table [dataSource]="dataSource" matSort matSortActive="id" matSortDirection="asc"
matSortDisableClear [trackBy]="trackByFn"
cdkDropList
cdkDropListOrientation="horizontal"
......@@ -141,7 +141,7 @@
<!-- Id/code column -->
<ng-container matColumnDef="id" sticky>
<th mat-header-cell *matHeaderCellDef [resizableColumn]="false" [resizableColumnDef]="'id'">
<th mat-header-cell *matHeaderCellDef >
<app-loading-spinner [loading]="loadingSubject|async">
<span mat-sort-header><ion-label translate>REFERENTIAL.ID</ion-label></span>
</app-loading-spinner>
......@@ -161,7 +161,7 @@
<!-- Name column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="true" [resizableColumnDef]="'name'" resizable>
<th mat-header-cell *matHeaderCellDef resizable>
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.NAME</ion-label></span>
</th>
<td mat-cell *matCellDef="let row" [class.mat-form-field-disabled]="!row.editing">
......@@ -176,7 +176,7 @@
<!-- Label column -->
<ng-container matColumnDef="label">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="true" [resizableColumnDef]="'label'" resizable>
<th mat-header-cell *matHeaderCellDef resizable>
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.LABEL</ion-label></span>
</th>
<td mat-cell *matCellDef="let row">
......@@ -190,7 +190,7 @@
<!-- Description column -->
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="true" [resizableColumnDef]="'description'" resizable>
<th mat-header-cell *matHeaderCellDef resizable>
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.DESCRIPTION</ion-label></span>
</th>
<td mat-cell *matCellDef="let row">
......@@ -204,7 +204,7 @@
<!-- Size column -->
<ng-container matColumnDef="size">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="true" [resizableColumnDef]="'size'" resizable>
<th mat-header-cell *matHeaderCellDef resizable>
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.SAMPLING_EQUIPMENT.SIZE</ion-label></span>
</th>
<td mat-cell *matCellDef="let row">
......@@ -218,18 +218,22 @@
<!-- Unit column -->
<ng-container matColumnDef="unit">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="true" [resizableColumnDef]="'unit'" resizable>
<th mat-header-cell *matHeaderCellDef resizable>
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.SAMPLING_EQUIPMENT.UNIT</ion-label></span>
</th>
<td mat-cell *matCellDef="let row" [class.mat-form-field-disabled]="!row.editing">
<td mat-cell *matCellDef="let row">
<mat-autocomplete-field floatLabel="never" class="min-width-large"
[formControl]="row.validator.controls.unit"
[placeholder]="'REFERENTIAL.SAMPLING_EQUIPMENT.UNIT'|translate"
[required]="false"
[config]="autocompleteFields.unit">
</mat-autocomplete-field>
</td>
</ng-container>
<!-- Comment column -->
<ng-container matColumnDef="comments">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="false" [resizableColumnDef]="'comment'">
<th mat-header-cell *matHeaderCellDef >
<span cdkDrag><ion-label translate>REFERENTIAL.COMMENTS</ion-label></span>
</th>
<td mat-cell *matCellDef="let row" >
......@@ -243,7 +247,7 @@
<!-- Status column -->
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef [resizableColumn]="false" [resizableColumnDef]="'status'">
<th mat-header-cell *matHeaderCellDef >
<span mat-sort-header cdkDrag><ion-label translate>REFERENTIAL.STATUS</ion-label></span>
</th>
<td mat-cell *matCellDef="let row" [class.mat-form-field-disabled]="!row.editing">
......
......@@ -21,18 +21,10 @@
.mat-column-size {
width: 50px;
//max-width: 150px;
}
.mat-column-unit {
width: 50px;
//max-width: 150px;
width: 150px;
}
//.mat-header-cell.hidden,
//.mat-cell.hidden {
// visibility: hidden;
// display: none;
//}
}
......@@ -58,8 +58,18 @@ export class SamplingEquipmentTable extends ReferentialTable<SamplingEquipment,
super.ngOnInit();
// Unit combo
const unitAttributes = ['name', 'label'];
this.registerAutocompleteField('unit', {
service: this.referentialService,
attributes: unitAttributes,
columnNames: ['REFERENTIAL.NAME', 'REFERENTIAL.UNIT.SYMBOL'],
columnSizes: unitAttributes.map(attr => {
switch (attr) {
case 'name': return 8;
case 'label': return 4;
default: return undefined;
}
}),
filter: {
entityName: 'Unit'
}
......
......@@ -31,7 +31,7 @@ export class SamplingEquipmentValidator
description: [data && data.description || null, Validators.maxLength(255)],
comments: [data && data.comments || null, Validators.maxLength(2000)],
size: [data && data.size || null, SharedValidators.double()],
unitId: [toNumber(data && data.unitId, null)],
unit: [data && data.unit || null, SharedValidators.entity],
statusId: [toNumber(data && data.statusId, null), Validators.required],
creationDate: [data && data.creationDate || null],
updateDate: [data && data.updateDate || null]
......
import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";
import {SharedModule} from "sumaris-lib";
import {ResizableColumnDirective} from "./directive/resizable-column.directive";
import {ResizableTableDirective} from "./directive/resizable-table.directive";
import {environment} from "@environments/environment";
import {CommentModal} from "@app/shared/comment/comment.modal";
import {CommentForm} from "@app/shared/comment/comment.form";
......@@ -21,8 +19,6 @@ import {ResizableModule} from "@app/shared/directive/resizable/resizable.module"
ResizableModule
],
declarations: [
ResizableColumnDirective,
ResizableTableDirective,
CommentModal,
CommentForm,
],
......@@ -33,8 +29,6 @@ import {ResizableModule} from "@app/shared/directive/resizable/resizable.module"
TranslateModule,
ResizableModule,
ResizableColumnDirective,
ResizableTableDirective,
CommentModal,
CommentForm,
]
......
......@@ -491,6 +491,9 @@
"SIZE": "Taille",
"UNIT": "Unité"
},
"UNIT": {
"SYMBOL": "Symbole"
},
"ERROR": {
"SAVE_REFERENTIAL_ERROR": "Erreur de sauvegarde du référentiel.",
"SAVE_REFERENTIALS_ERROR": "Erreur de sauvegarde des référentiels.",
......
......@@ -195,7 +195,7 @@ type SamplingEquipmentVO {
name: String
size: Float
statusId: Int
unitId: Int
unit: ReferentialVO
updateDate: SqlTimestamp
}
......@@ -314,7 +314,7 @@ input SamplingEquipmentVOInput {
name: String
size: Float
statusId: Int
unitId: Int
unit: ReferentialVOInput
updateDate: SqlTimestamp
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment