Skip to content
Commits on Source (4)
......@@ -2,6 +2,8 @@
All notable changes to [ngpr_prodige_contribution](https://gitlab.adullact.net/prodige/ngpr_prodige_contribution) project will be documented in this file.
## [5.0.8](https://gitlab.adullact.net/prodige/ngpr_prodige_contribution/compare/5.0.7...5.0.8) - 2023-03-21
## [5.0.7](https://gitlab.adullact.net/prodige/ngpr_prodige_contribution/compare/5.0.6...5.0.7) - 2023-03-20
## [5.0.6](https://gitlab.adullact.net/prodige/ngpr_prodige_contribution/compare/5.0.5...5.0.6) - 2023-03-15
......
5.0.7
\ No newline at end of file
5.0.8
\ No newline at end of file
......@@ -41,7 +41,7 @@ docker-compose up
In an other terminal, connect as www-data to the dev container
```bash
# Connect to container as node
docker exec --user node -w /home/node/app -it ngpr_prodige_contribution_dev_node bash
docker exec --user node -w /home/node/app -it ngpr_prodige_contribution_web bash
```
In container
......
......@@ -14,8 +14,8 @@ export const contributionExtentValidator = z.object({
export const contributionFieldValidaor = z.object({
name: z.string(),
type: z.string(),
alias: z.string(),
description: z.string(),
alias: z.string().optional(),
description: z.string().optional(),
selected: z.boolean().optional(),
});
......@@ -38,11 +38,11 @@ function transformDate( val: string, ctx: RefinementCtx ): string{
export const contributionValidator = z.object({
id: z.number(),
userId: z.number(),
map: z.string(),
layerName: z.string(),
map: z.string().optional(),
layerName: z.string().optional(),
metadataUuid: z.string().nullable().optional(),
sourceSRS: z.union([ z.string(), z.number() ]).nullable(),
extent: contributionExtentValidator,
extent: contributionExtentValidator.optional(),
sourceEncoding: z.string().nullable().optional(),
fields: contributionFieldValidaor.array().nullable(),
table: z.string().optional(),
......@@ -61,6 +61,7 @@ export const contributionValidator = z.object({
openData: z.boolean().optional(),
contact: contactValidator.array().optional(),
type: z.string().optional(),
isTabular: z.boolean().optional(),
status: z.string().transform(( val, ctx ) =>{
const strSplited = val.split( `/` );
if ( strSplited.length !== 4 ){
......@@ -109,3 +110,20 @@ export const CONTRIBUTION_KEY_PATCH = [
`type`,
`layerId`,
];
export const CONTRIBUTION_KEY_PATCH_TABULAIRE = [
`status`,
`fields`,
`table`,
`title`,
`abstract`,
`lineage`,
`localisationKeyword`,
`themeKeyword`,
`contact`,
`geonetworkStatus`,
`openData`,
`subdomains`,
`createdAt`,
`updatedAt`,
`type`,
];
......@@ -4,7 +4,7 @@ import { map, Observable, ReplaySubject } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { EnvService } from './env/env.service';
import * as moment from 'moment';
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
@Injectable({
providedIn: `root`,
......@@ -38,6 +38,10 @@ export class ContributionService {
map(( contribution ) => {
this.contribution.fields = this.contribution.fields.map<ContributionField>(( field ) => {
field.selected = true;
field.alias = field.alias ? field.alias : ``;
field.description = field.description ? field.description : ``;
return field;
});
......@@ -56,6 +60,8 @@ export class ContributionService {
this.contribution.localisationKeyword = null;
}
this.contribution.isTabular = this.contribution.type === `/api/lex_layer_types/3`;
this.initFormControl();
return contribution;
......@@ -95,46 +101,57 @@ export class ContributionService {
Validators.pattern( /\d+/ ),
];
const dataOverviewForm: {[key:string]: AbstractControl, extent?: FormGroup} = {
'sourceEncoding': new FormControl( this.contribution.sourceEncoding, Validators.required ),
'fields': new FormArray(
this.contribution.fields.map(( field ) => (
new FormGroup({
'name': new FormControl( field.name ),
'alias': new FormControl( field.alias ),
'description': new FormControl( field.description ),
'type': new FormControl( field.type ),
'selected': new FormControl( field.selected ),
})
)),
) };
if ( !this.contribution.isTabular ){
dataOverviewForm.extent = new FormGroup({
'xmin': new FormControl( this.contribution.extent.xmin, extentControl ),
'ymin': new FormControl( this.contribution.extent.ymin, extentControl ),
'xmax': new FormControl( this.contribution.extent.xmax, extentControl ),
'ymax': new FormControl( this.contribution.extent.ymax, extentControl ),
});
}
const generalInformationForm: {[key:string]: AbstractControl, equivalentScale?: FormControl} = {
'table': new FormControl( this.contribution.table, [
Validators.required,
Validators.pattern( /^[a-zA-Z0-9_]+$/ ),
]),
'title': new FormControl( this.contribution.title, [Validators.required]),
'abstract': new FormControl( this.contribution.abstract, [Validators.required]),
'lineage': new FormControl( this.contribution.lineage ),
'themeKeyword': new FormControl( this.contribution.themeKeyword ),
'localisationKeyword': new FormControl( this.contribution.localisationKeyword ),
'updatedAt': new FormControl( this.contribution.updatedAt, [Validators.required]),
'createdAt': new FormControl( this.contribution.createdAt, [Validators.required]),
'updateDate': new FormControl( this.contribution.updateDate, [Validators.required]),
'createDate': new FormControl( this.contribution.createDate, [Validators.required]),
'geonetworkStatus': new FormControl( this.contribution.geonetworkStatus ),
'contact': new FormArray( this.getContactForm()),
};
if ( !this.contribution.isTabular ){
generalInformationForm.equivalentScale = new FormControl( this.contribution.equivalentScale, [Validators.required]);
}
this.contributionForm = new FormGroup({
DataOverview: new FormGroup({
'extent': new FormGroup({
'xmin': new FormControl( this.contribution.extent.xmin, extentControl ),
'ymin': new FormControl( this.contribution.extent.ymin, extentControl ),
'xmax': new FormControl( this.contribution.extent.xmax, extentControl ),
'ymax': new FormControl( this.contribution.extent.ymax, extentControl ),
}),
'sourceEncoding': new FormControl( this.contribution.sourceEncoding, Validators.required ),
'fields': new FormArray(
this.contribution.fields.map(( field ) => (
new FormGroup({
'name': new FormControl( field.name ),
'alias': new FormControl( field.alias, [Validators.required]),
'description': new FormControl( field.description ),
'type': new FormControl( field.type ),
'selected': new FormControl( field.selected ),
})
)),
),
}),
GeneralInformation: new FormGroup({
'table': new FormControl( this.contribution.table, [
Validators.required,
Validators.pattern( /^[a-zA-Z0-9_]+$/ ),
]),
'title': new FormControl( this.contribution.title, [Validators.required]),
'abstract': new FormControl( this.contribution.abstract, [Validators.required]),
'lineage': new FormControl( this.contribution.lineage ),
'themeKeyword': new FormControl( this.contribution.themeKeyword ),
'localisationKeyword': new FormControl( this.contribution.localisationKeyword ),
'updatedAt': new FormControl( this.contribution.updatedAt, [Validators.required]),
'createdAt': new FormControl( this.contribution.createdAt, [Validators.required]),
'updateDate': new FormControl( this.contribution.updateDate, [Validators.required]),
'createDate': new FormControl( this.contribution.createDate, [Validators.required]),
'equivalentScale': new FormControl( this.contribution.equivalentScale, [Validators.required]),
'geonetworkStatus': new FormControl( this.contribution.geonetworkStatus ),
'contact': new FormArray( this.getContactForm()),
}),
DiffusionModality: new FormGroup({
DataOverview: new FormGroup( dataOverviewForm ),
GeneralInformation: new FormGroup( generalInformationForm ),
DiffusionModality: new FormGroup({
'openData': new FormControl( this.contribution.openData ),
'subdomains': new FormControl( this.contribution.subdomains ),
}),
......
......@@ -7,7 +7,7 @@
Veuillez vérifier que le système de référence spatiale ainsi que les données récupérées sont valides.
</p>
</div>
<form class="row g-3" >
<form class="row g-3" *ngIf="!this.contribution.isTabular" >
<div class="mb-3 col-lg-12">
<label class="form-label" i18n="@@overwiewExtentSrid">Étendue (emprise géographique)</label>
<ng-container *ngIf="!canDisplayMap" >
......
......@@ -7,7 +7,7 @@ import { StepperService } from '../stepper.service';
import { StepType } from '../../../core/models/step-type';
import { MapIdService, MapService, VisualiseurCoreService } from '@alkante/visualiseur-core';
import { BaseComponent } from '../../../core/components/base/base.component';
import { delay, finalize, switchMap, takeUntil } from 'rxjs';
import { delay, finalize, of, switchMap, takeUntil } from 'rxjs';
import { ContributionService } from '../../../core/services/contribution.service';
import { Contribution, ContributionExtent, ContributionField } from '../../../core/models/contribution';
import { PRODIGE_TYPE } from '../../../core/models/prodige-type';
......@@ -77,24 +77,33 @@ export class DataOverviewComponent extends BaseComponent implements OnInit, OnDe
this.contribution = contribution;
this.contributionForm = <FormGroup> this.contributionService.getContributionForm().controls[`DataOverview`];
this.extentForm = <FormGroup> this.contributionForm.get( `extent` );
this.fieldForm = <FormArray> this.contributionForm.get( `fields` );
this.updateFields();
return this.contextService.getContext$( this.contribution.map ).pipe(
finalize(() =>{
setTimeout(() => {
if ( !this.canDisplayMap ){
this.loggerService.errorOnToast$( $localize`:@@contextNotLoad:Erreur pendant le chargement du context` );
}
}, 250 );
}),
);
if ( !this.contribution.isTabular ){
this.extentForm = <FormGroup> this.contributionForm.get( `extent` );
return this.contextService.getContext$( this.contribution.map ).pipe(
finalize(() =>{
setTimeout(() => {
if ( !this.canDisplayMap ){
this.loggerService.errorOnToast$( $localize`:@@contextNotLoad:Erreur pendant le chargement du context` );
}
}, 250 );
}),
);
} else {
return of( null );
}
}),
).subscribe({
next: ( context ) => {
this.coreService.setContext( context );
this.canDisplayMap = true;
if ( context ){
this.coreService.setContext( context );
this.canDisplayMap = true;
}
},
error: ( err ) => console.error( err ),
});
......
......@@ -108,7 +108,7 @@
<alk-form-error [control]="contributionForm" field="updateDate"></alk-form-error>
</div>
</form>
<form class="row g-3" [formGroup]="contributionForm">
<form class="row g-3" [formGroup]="contributionForm" *ngIf="!this.contribution.isTabular">
<div class="mb-3 col-lg-4">
<label class="form-label" i18n="@@informationOptimalDataScale">Echelle optimale d'emploi de la donnée<span class="required">*</span> </label>
<select class="form-control" name="contribution-scale" aria-label="Default select example" formControlName="equivalentScale">
......
......@@ -61,13 +61,14 @@
</p>
</dd>
<dt class="col-sm-4" i18n="@@MapScaleData" >
Échelle d'emploi de la donnée :
</dt>
<dd class="col-sm-8">
<p>{{this.contribControl['equivalentScale'].value | scaleToLabel}}</p>
</dd>
<ng-container *ngIf="!contribution.isTabular">
<dt class="col-sm-4" i18n="@@MapScaleData" >
Échelle d'emploi de la donnée :
</dt>
<dd class="col-sm-8">
<p>{{this.contribControl['equivalentScale'].value | scaleToLabel}}</p>
</dd>
</ng-container>
<dt class="col-sm-4" i18n="@@updateFrequency" >
Fréquence de mise à jour :
</dt>
......@@ -113,7 +114,8 @@
<ngb-accordion>
<ngb-panel (shown)="onMapShow()" title="Étendue (emprise géographique)" i18n-title="@@ExtentGeographicExtent">
<ngb-panel (shown)="onMapShow()" title="Étendue (emprise géographique)"
i18n-title="@@ExtentGeographicExtent" *ngIf="!contribution.isTabular">
<ng-template ngbPanelContent>
<ng-container *ngIf="!canDisplayMap" >
<div class="visualiseur-loading">
......
import { Injectable } from '@angular/core';
import {
Contribution,
CONTRIBUTION_KEY_PATCH,
CONTRIBUTION_KEY_PATCH, CONTRIBUTION_KEY_PATCH_TABULAIRE,
contributionValidator,
} from '../../../core/models/contribution';
import { HttpClient } from '@angular/common/http';
......@@ -32,7 +32,13 @@ export class SynthesisAndValidationService {
console.log( contribution );
CONTRIBUTION_KEY_PATCH.forEach(( key ) => ( sendData[key] = contribution[key as keyof Contribution]));
if ( contribution.isTabular ){
CONTRIBUTION_KEY_PATCH_TABULAIRE.forEach(( key ) => ( sendData[key] = contribution[key as keyof Contribution]));
}
else {
CONTRIBUTION_KEY_PATCH.forEach(( key ) => ( sendData[key] = contribution[key as keyof Contribution]));
}
if ( sendData[`fields`]){
sendData[`fields`] = ( <Contribution>sendData )[`fields`]
......