From f9eff97ddbe0c51fe8e06d98db74e15ab197f747 Mon Sep 17 00:00:00 2001 From: MrJimmyChevallier Date: Tue, 18 Jul 2023 00:12:15 +0200 Subject: [PATCH 1/7] update bug simulator titlePopup et simu blanc affichage --- .../editable-situation.component.html | 11 +++---- .../editable-situation.component.scss | 33 +++++++++++++++---- .../app/routes/simulator/simulator.page.ts | 16 ++++++--- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/front/src/app/components/editable-situation/editable-situation.component.html b/front/src/app/components/editable-situation/editable-situation.component.html index 1d5ea3e15..166bb6eb8 100644 --- a/front/src/app/components/editable-situation/editable-situation.component.html +++ b/front/src/app/components/editable-situation/editable-situation.component.html @@ -27,7 +27,7 @@

Temps moyen / dossier

-
+

@@ -74,12 +74,11 @@ -
-
- Valider -
+
+ -
+
Editer
diff --git a/front/src/app/components/editable-situation/editable-situation.component.scss b/front/src/app/components/editable-situation/editable-situation.component.scss index 1449d6eee..1b5ea63aa 100644 --- a/front/src/app/components/editable-situation/editable-situation.component.scss +++ b/front/src/app/components/editable-situation/editable-situation.component.scss @@ -4,19 +4,28 @@ top: auto !important; height: 60px !important; } + .actual-situation { top: auto !important; } - .validate-button { - width: 60px; - margin-left: 10px; + .validate-label { background-color: #000091; - height: 22px; + border-radius: 6px; + padding: 3px; + margin: auto; + right: 0px; + position: relative; + color: white; + } + + .validate-button { border-radius: 6px; color: white; text-align: center; cursor: pointer; + flex: 0.855 !important; + height: 104px !important; } .edit-button { @@ -59,6 +68,7 @@ } } + .item:first-child { margin-left: 200px; } @@ -73,6 +83,10 @@ align-items: center; justify-content: center; + &.end-item { + flex: 0.855; + } + &.blue-bg { background-color: #f5f5fe; @@ -97,6 +111,9 @@ } } } + + + .actual-situation { background-color: #fef6e3; position: relative; @@ -306,13 +323,16 @@ } } } + .disabled { pointer-events: none; } + .disabled-field { pointer-events: none; - background-color: rgba(185, 184, 182, 0.2901960784)!important; + background-color: rgba(185, 184, 182, 0.2901960784) !important; } + .line-item { flex: 1; display: flex; @@ -321,6 +341,7 @@ color: #161616; position: relative; height: 100%; + &.orange-bg { background-color: #feecc2; @@ -460,4 +481,4 @@ } } } -} +} \ No newline at end of file diff --git a/front/src/app/routes/simulator/simulator.page.ts b/front/src/app/routes/simulator/simulator.page.ts index 1867a73ae..ee1559088 100644 --- a/front/src/app/routes/simulator/simulator.page.ts +++ b/front/src/app/routes/simulator/simulator.page.ts @@ -35,7 +35,7 @@ const etpMag = 'etpMag' /** * Variable ETP magistrat popup title */ -const etpMagTitle = 'des ETPT magistrat' +const etpMagTitle = 'des ETPT siège' /** * Variable ETP magistrat unité */ @@ -327,6 +327,7 @@ displayWhiteElements:boolean = false this.displayWhiteElements = b if (b===false){ this.toDisplaySimulation=false + this.initParamsToAjust() } }) ) @@ -620,6 +621,7 @@ displayWhiteElements:boolean = false ? this.decisionTreeMag : this.decisionTreeFon + const find = treeToUse.find((item: any) => item.label === buttonToFind) if (this.paramsToAjust.param1.input === 0) { @@ -956,11 +958,18 @@ displayWhiteElements:boolean = false */ initParams(buttons: any) { this.disabled = 'disabled-date' - this.toDisplaySimulation = false + this.initParamsToAjust() + buttons.forEach((x: any) => { x.value = 'Ajuster' x.classList.remove('disable') }) + this.simulatorService.isValidatedWhiteSimu.next(false) + } + + initParamsToAjust() { + this.toDisplaySimulation = false + this.paramsToAjust = { param1: { label: '', @@ -978,7 +987,6 @@ displayWhiteElements:boolean = false }, } this.simulateButton = 'disabled' - this.toDisplay = [] this.toCalculate = [] this.pickersParamsToLock = [] @@ -986,9 +994,7 @@ displayWhiteElements:boolean = false param1: { label: '', value: '' }, param2: { label: '', value: '' }, } - this.simulatorService.isValidatedWhiteSimu.next(false) } - /** * Retourne le titre complet d'un champs à éditer * @param label label correspondant à un input field (ex: etpMag) From f249bd08d4bd75e875eeb2ec94b222af0b735ec1 Mon Sep 17 00:00:00 2001 From: MrJimmyChevallier Date: Tue, 18 Jul 2023 16:41:01 +0200 Subject: [PATCH 2/7] update white simulator affichage --- .../editable-situation/editable-situation.component.html | 2 +- .../editable-situation/editable-situation.component.scss | 1 + front/src/app/routes/simulator/simulator.page.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/front/src/app/components/editable-situation/editable-situation.component.html b/front/src/app/components/editable-situation/editable-situation.component.html index 166bb6eb8..e99a9c1c5 100644 --- a/front/src/app/components/editable-situation/editable-situation.component.html +++ b/front/src/app/components/editable-situation/editable-situation.component.html @@ -121,7 +121,7 @@
-
+
diff --git a/front/src/app/components/editable-situation/editable-situation.component.scss b/front/src/app/components/editable-situation/editable-situation.component.scss index 1b5ea63aa..5481470a8 100644 --- a/front/src/app/components/editable-situation/editable-situation.component.scss +++ b/front/src/app/components/editable-situation/editable-situation.component.scss @@ -26,6 +26,7 @@ cursor: pointer; flex: 0.855 !important; height: 104px !important; + font-size: 14px; } .edit-button { diff --git a/front/src/app/routes/simulator/simulator.page.html b/front/src/app/routes/simulator/simulator.page.html index 93fbf24ba..593a7c722 100644 --- a/front/src/app/routes/simulator/simulator.page.html +++ b/front/src/app/routes/simulator/simulator.page.html @@ -590,7 +590,7 @@
-
+
From c5b02c8d5c3d6be3a40d5119c3f8c01c4b632290 Mon Sep 17 00:00:00 2001 From: MrJimmyChevallier Date: Tue, 18 Jul 2023 16:49:35 +0200 Subject: [PATCH 3/7] update calculateur --- front/src/app/routes/calculator/calculator.page.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/app/routes/calculator/calculator.page.html b/front/src/app/routes/calculator/calculator.page.html index 324ab022a..e7556e020 100644 --- a/front/src/app/routes/calculator/calculator.page.html +++ b/front/src/app/routes/calculator/calculator.page.html @@ -3,11 +3,11 @@
+ (valueChange)="updateReferentielSelected('dateStart', $event)" class="date-start bg-white" [max]="dateStop" + [dateClass]="dateClass"> + class="date-stop bg-white" [dateClass]="dateClass">
-

DTES

+

DTES en mois

Temps moyen / dossier

diff --git a/front/src/app/components/editable-situation/editable-situation.component.ts b/front/src/app/components/editable-situation/editable-situation.component.ts index 64c50863e..53c8e5020 100644 --- a/front/src/app/components/editable-situation/editable-situation.component.ts +++ b/front/src/app/components/editable-situation/editable-situation.component.ts @@ -165,7 +165,7 @@ export class EditableSituationComponent implements OnChanges { const dtes = fixDecimal(startLastStock / startTotalOut) this.formWhiteSim.controls['realDTESInMonths'].setValue( - String(dtes) + ' mois' + String(dtes) //+ ' mois' ) const prefix1 = this.category==='MAGISTRAT'?'nbDaysByMagistrat':'nbDaysByFonctionnaire' @@ -220,7 +220,7 @@ export class EditableSituationComponent implements OnChanges { } this.endSituationDisplay.realCoverage = fixDecimal(coverage) + '%' this.endSituationDisplay.realDTESInMonths = - fixDecimal(endStock / startTotalOut) + ' mois' + fixDecimal(endStock / startTotalOut) +''//+ ' mois' this.endSituationDisplay.magRealTimePerCase = decimalToStringDate(tmd) this.simulatorService.situationProjected.next({ From 8c6841887b159bf9e8374115eb1090bd6b5dc3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Montigny?= Date: Wed, 19 Jul 2023 16:33:06 +0200 Subject: [PATCH 5/7] fix fonction by categorie --- api/src/constants/referentiel.js | 2 ++ api/src/models/TableHumanresources.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/src/constants/referentiel.js b/api/src/constants/referentiel.js index b7cdf2db0..7683650a4 100644 --- a/api/src/constants/referentiel.js +++ b/api/src/constants/referentiel.js @@ -130,6 +130,8 @@ export function etpLabel (value) { return 'Mi-temps' case 0: return 'Ne travaille pas' + case ETP_NEED_TO_BE_UPDATED: + return null } return `${fixDecimal(value * 100)}%` diff --git a/api/src/models/TableHumanresources.js b/api/src/models/TableHumanresources.js index 27b75b002..bf98226a5 100644 --- a/api/src/models/TableHumanresources.js +++ b/api/src/models/TableHumanresources.js @@ -1,4 +1,5 @@ import { posad } from '../constants/hr' +import { ETP_NEED_TO_BE_UPDATED } from '../constants/referentiel' import { snakeToCamelObject } from '../utils/utils' import config from 'config' @@ -200,7 +201,6 @@ export default (sequelizeInstance, Model) => { console.log('findCategory', findCategory) if (findCategory) { - console.log('oui ?', filterNoEtpt.includes(list[i].fonction), privilegedInGreff.includes(list[i].grade)) if (filterNoEtpt.includes(list[i].fonction) || privilegedInGreff.includes(list[i].grade)) { situation.category_id = findEAM.id @@ -261,6 +261,7 @@ export default (sequelizeInstance, Model) => { let findFonction = await Model.models.HRFonctions.findOne({ where: { code, + category_id: situation.category_id, }, logging: false, }) @@ -290,6 +291,12 @@ export default (sequelizeInstance, Model) => { } } + // control ETP to complete + const gradeToETPComplete = ['MTT', 'MHFJ', 'MHFNJ'] + if (gradeToETPComplete.indexOf(list[i].grade) !== -1) { + situation.etp = ETP_NEED_TO_BE_UPDATED + } + let updatedAt = new Date() const dateUpdatedSplited = (list[i].date_modif || '').split('/') if (dateUpdatedSplited.length === 3) { @@ -314,6 +321,8 @@ export default (sequelizeInstance, Model) => { situation.date_start = new Date(dateSplited[2], +dateSplited[1] - 1, dateSplited[0]) } + //console.log(options, situation) + // create person findHRToDB = await Model.create(options) From 19d332e13d04a6f3f82c3ba291817224f53ce953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Montigny?= Date: Wed, 19 Jul 2023 16:48:07 +0200 Subject: [PATCH 6/7] alert when the ETP need to be updated --- front/src/app/constants/colors.ts | 12 ++ .../big-etp-preview.component.html | 4 +- .../big-etp-preview.component.scss | 4 + .../big-etp-preview.component.ts | 110 ++++++++++-------- .../cover-profil-details.component.html | 2 +- .../cover-profil-details.component.ts | 2 +- .../panel-history-ventilation.component.html | 4 +- .../panel-history-ventilation.component.scss | 8 ++ .../panel-history-ventilation.component.ts | 9 +- .../person-preview.component.html | 2 +- .../app/routes/workforce/workforce.page.ts | 2 +- front/src/app/utils/referentiel.ts | 6 +- 12 files changed, 105 insertions(+), 60 deletions(-) create mode 100644 front/src/app/constants/colors.ts diff --git a/front/src/app/constants/colors.ts b/front/src/app/constants/colors.ts new file mode 100644 index 000000000..ba97c0e77 --- /dev/null +++ b/front/src/app/constants/colors.ts @@ -0,0 +1,12 @@ +/** + * RED COLOR + */ +export const RED_COLOR = 'rgb(255, 86, 85)' + +export const GET_COLOR = (color: string, opacity: number = 1) => { + if (color.startsWith('rgb(')) { + return color.replace('rgb(', 'rgba(').replace(')', `, ${opacity})`) + } + + return color +} diff --git a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.html b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.html index 9b1996221..6f7981004 100644 --- a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.html +++ b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.html @@ -1,5 +1,5 @@
- ETPT -

{{ etp }}

+ ETPT +

{{ warningETP ? '?' : etp }}

\ No newline at end of file diff --git a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.scss b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.scss index bf96df495..5781720dc 100644 --- a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.scss +++ b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.scss @@ -19,6 +19,10 @@ p { font-size: 26px; + + &.alert { + color: fColor(cred); + } } } diff --git a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.ts b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.ts index 62d833d57..2245e9a79 100644 --- a/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.ts +++ b/front/src/app/routes/human-resource/big-etp-preview/big-etp-preview.component.ts @@ -5,6 +5,8 @@ import { ViewChild, OnChanges, } from '@angular/core' +import { GET_COLOR, RED_COLOR } from 'src/app/constants/colors' +import { ETP_NEED_TO_BE_UPDATED } from 'src/app/constants/referentiel' import { degreesToRadians } from 'src/app/utils/geometry' import { fixDecimal } from 'src/app/utils/numbers' @@ -33,18 +35,26 @@ export class BigEtpPreviewComponent implements OnChanges { * Hauteur du composant */ @Input() height: number = 84 + /** + * Valeur de l'ETP réélement + */ + @Input() realETP: number = 0 /** * Dom HTML du canvas pour dessiner */ @ViewChild('canvas') domCanvas: ElementRef | null = null /** - * Marge d'espacement exterieur pour dessiner + * Marge d'espacement exterieur pour dessiner */ margin: number = 8 /** * Largeur de la bordure du dessin */ borderWidth: number = 12 + /** + * ETP need to be updated + */ + warningETP: boolean = false /** * Constructeur @@ -55,6 +65,8 @@ export class BigEtpPreviewComponent implements OnChanges { * Détection du changement de variable pour rédessiner */ ngOnChanges() { + this.warningETP = this.realETP === ETP_NEED_TO_BE_UPDATED + const fixDec = fixDecimal(this.etp) this.etp = fixDec < 0 ? 0 : fixDec this.onDraw() @@ -98,7 +110,7 @@ export class BigEtpPreviewComponent implements OnChanges { ctx.beginPath() ctx.lineCap = 'round' ctx.lineWidth = this.borderWidth - ctx.strokeStyle = '#e3e3fd' + ctx.strokeStyle = this.warningETP ? GET_COLOR(RED_COLOR, 0.2) : '#e3e3fd' ctx.arc( this.width / 2 + this.margin, this.height / 2 + this.margin, @@ -107,62 +119,60 @@ export class BigEtpPreviewComponent implements OnChanges { this.getRadiusPosition(100) ) ctx.stroke() - ctx.beginPath() - ctx.strokeStyle = '#e4794a' - ctx.arc( - this.width / 2 + this.margin, - this.height / 2 + this.margin, - this.width / 2, - this.getRadiusPosition(0), - this.getRadiusPosition((this.etp + this.indisponibility) * 100) - ) - ctx.stroke() - ctx.beginPath() - ctx.strokeStyle = '#1dd884' - ctx.arc( - this.width / 2 + this.margin, - this.height / 2 + this.margin, - this.width / 2, - this.getRadiusPosition(0), - this.getRadiusPosition(this.etp * 100) - ) - ctx.stroke() - ctx.beginPath() - ctx.fillStyle = '#ffffff' - ctx.arc( - this.margin, - this.height / 2 + this.margin, - this.borderWidth / 4, - 0, - 2 * Math.PI - ) + if (!this.warningETP) { + ctx.beginPath() + ctx.strokeStyle = '#e4794a' + ctx.arc( + this.width / 2 + this.margin, + this.height / 2 + this.margin, + this.width / 2, + this.getRadiusPosition(0), + this.getRadiusPosition((this.etp + this.indisponibility) * 100) + ) + ctx.stroke() - ctx.beginPath() - ctx.lineWidth = 2 - ctx.moveTo(this.width + this.margin - 7, this.height / 2 + this.margin) - ctx.lineTo(this.width + this.margin + 7, this.height / 2 + this.margin) - ctx.strokeStyle = '#49835e' - ctx.lineCap = 'round' - ctx.stroke() + ctx.beginPath() + ctx.strokeStyle = '#1dd884' + ctx.arc( + this.width / 2 + this.margin, + this.height / 2 + this.margin, + this.width / 2, + this.getRadiusPosition(0), + this.getRadiusPosition(this.etp * 100) + ) + ctx.stroke() - ctx.beginPath() - ctx.fillStyle = 'white' - ctx.arc( - 8, - 50, - 3, - 0, - degreesToRadians(360) - ) + ctx.beginPath() + ctx.fillStyle = '#ffffff' + ctx.arc( + this.margin, + this.height / 2 + this.margin, + this.borderWidth / 4, + 0, + 2 * Math.PI + ) + + ctx.beginPath() + ctx.lineWidth = 2 + ctx.moveTo(this.width + this.margin - 7, this.height / 2 + this.margin) + ctx.lineTo(this.width + this.margin + 7, this.height / 2 + this.margin) + ctx.strokeStyle = '#49835e' + ctx.lineCap = 'round' + ctx.stroke() - ctx.fill() + ctx.beginPath() + ctx.fillStyle = 'white' + ctx.arc(8, 50, 3, 0, degreesToRadians(360)) + + ctx.fill() + } } /** * Conversion des degrées en Radius - * @param degree - * @returns + * @param degree + * @returns */ getRadiusPosition(degree: number) { return degreesToRadians(180 + degree * (180 / 100)) diff --git a/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.html b/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.html index 314131630..3c77daa0f 100644 --- a/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.html +++ b/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.html @@ -13,7 +13,7 @@
- +
diff --git a/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.ts b/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.ts index 2cb0278be..82e2cf1fa 100644 --- a/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.ts +++ b/front/src/app/routes/human-resource/cover-profil-details/cover-profil-details.component.ts @@ -85,7 +85,7 @@ export class CoverProfilDetailsComponent /** * Temps de travail en text */ - timeWorked: string = '' + timeWorked: string | null = '' /** * ETP des indispo */ diff --git a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.html b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.html index 1ca660cb1..fe6228d98 100644 --- a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.html +++ b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.html @@ -11,9 +11,9 @@

{{ fonction.code }}

{{ timeWorked }}

-
+

ETPTravaillé :

- +
diff --git a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.scss b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.scss index f58d551c4..3f2be2e0f 100644 --- a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.scss +++ b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.scss @@ -43,6 +43,14 @@ display: flex; align-items: center; + &.alert { + background-color: rgba(fColor(cred), 0.2); + + p { + color: fColor(cred); + } + } + p { font-size: 12px; color: fColor(cgreen); diff --git a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.ts b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.ts index 4d4a9ee0f..c2c41827f 100644 --- a/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.ts +++ b/front/src/app/routes/human-resource/panel-history-ventilation/panel-history-ventilation.component.ts @@ -6,6 +6,7 @@ import { Output, } from '@angular/core' import { sumBy } from 'lodash' +import { ETP_NEED_TO_BE_UPDATED } from 'src/app/constants/referentiel' import { HRFonctionInterface } from 'src/app/interfaces/hr-fonction' import { RHActivityInterface } from 'src/app/interfaces/rh-activity' import { MainClass } from 'src/app/libs/main-class' @@ -88,7 +89,11 @@ export class PanelHistoryVentilationComponent /** * Temps de travail en text */ - timeWorked: string = '' + timeWorked: string | null = '' + /** + * ETP need to be updated + */ + warningETP: boolean = false /** * Constructeur @@ -101,6 +106,8 @@ export class PanelHistoryVentilationComponent * Lors d'un changement on recalcul l'interface */ ngOnChanges() { + this.warningETP = this.etp === ETP_NEED_TO_BE_UPDATED + this.indisponibility = fixDecimal( sumBy(this.indisponibilities, 'percent') / 100 ) diff --git a/front/src/app/routes/workforce/person-preview/person-preview.component.html b/front/src/app/routes/workforce/person-preview/person-preview.component.html index 03a0f86c1..28d121c66 100644 --- a/front/src/app/routes/workforce/person-preview/person-preview.component.html +++ b/front/src/app/routes/workforce/person-preview/person-preview.component.html @@ -24,7 +24,7 @@

{{ hr.fonction && hr.fonction.code }}

-

{{ hr.etpLabel }}

+

{{ hr.etpLabel }}

diff --git a/front/src/app/routes/workforce/workforce.page.ts b/front/src/app/routes/workforce/workforce.page.ts index 82c95e688..3e5328a35 100644 --- a/front/src/app/routes/workforce/workforce.page.ts +++ b/front/src/app/routes/workforce/workforce.page.ts @@ -62,7 +62,7 @@ export interface HumanResourceSelectedInterface extends HumanResourceInterface { /** * Temps de travail en string */ - etpLabel: string + etpLabel: string | null /** * Total des indispo */ diff --git a/front/src/app/utils/referentiel.ts b/front/src/app/utils/referentiel.ts index f84c2d213..f2bdfa5c5 100644 --- a/front/src/app/utils/referentiel.ts +++ b/front/src/app/utils/referentiel.ts @@ -1,3 +1,5 @@ +import { ETP_NEED_TO_BE_UPDATED } from "../constants/referentiel" + /** * Conversion d'un nom de référentiel en version simplifiée * @param name @@ -74,7 +76,7 @@ export function referentielMappingColor( * @param value * @returns */ -export function etpLabel(value: number): string { +export function etpLabel(value: number): string | null { switch (value) { case 1: return 'Temps plein' @@ -84,6 +86,8 @@ export function etpLabel(value: number): string { return 'Mi-temps' case 0: return 'Ne travaille pas' + case ETP_NEED_TO_BE_UPDATED: + return null } return `${Math.floor(value * 100)}%` From 530c824ad8055adf6777510da1e3082832bfde6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Montigny?= Date: Wed, 19 Jul 2023 17:33:43 +0200 Subject: [PATCH 7/7] add back url to contact page --- front/src/app/app.component.ts | 15 ++++++++-- .../components/wrapper/wrapper.component.html | 2 +- .../src/app/routes/contact/contact.page.html | 2 +- front/src/app/routes/contact/contact.page.ts | 30 ++++++++++++++----- front/src/app/services/app/app.service.ts | 8 +++++ 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts index 8601d49f2..c82c1d67f 100644 --- a/front/src/app/app.component.ts +++ b/front/src/app/app.component.ts @@ -1,5 +1,5 @@ import { AfterViewInit, Component } from '@angular/core' -import { Router } from '@angular/router' +import { NavigationEnd, Router } from '@angular/router' import { environment } from 'src/environments/environment' import { USER_ACCESS_AVERAGE_TIME } from './constants/user-access' import { AlertInterface } from './interfaces/alert' @@ -8,6 +8,7 @@ import { ContentieuxOptionsService } from './services/contentieux-options/conten import { UserService } from './services/user/user.service' import { iIOS } from './utils/system' import { copy } from './utils' +import { filter } from 'rxjs' /** * Variable d'environement en global @@ -50,6 +51,15 @@ export class AppComponent implements AfterViewInit { } this.onControlSSL() + + router.events + .pipe(filter((event) => event instanceof NavigationEnd)) + // @ts-ignore + .subscribe((event: NavigationEnd) => { + this.appService.previousUrl = this.appService.currentUrl + this.appService.currentUrl = event.url + }) + router.events.subscribe(() => { const user = this.userService.user.getValue() if (user && this.dbReady === false) { @@ -106,7 +116,7 @@ export class AppComponent implements AfterViewInit { onCloseAlert(clickToOk = false) { const alertObject = this.appService.alert.getValue() this.appService.alert.next(null) - if(clickToOk && alertObject && alertObject.callback) { + if (clickToOk && alertObject && alertObject.callback) { alertObject.callback() } } @@ -135,7 +145,6 @@ export class AppComponent implements AfterViewInit { observer.observe(elementToObserve, { subtree: true, childList: true }); */ - /* document.addEventListener( 'DOMNodeInserted', () => { diff --git a/front/src/app/components/wrapper/wrapper.component.html b/front/src/app/components/wrapper/wrapper.component.html index 10e03bd8c..33479a725 100644 --- a/front/src/app/components/wrapper/wrapper.component.html +++ b/front/src/app/components/wrapper/wrapper.component.html @@ -68,7 +68,7 @@
{{ hrBackup && hrBackup.label }}
diff --git a/front/src/app/routes/contact/contact.page.html b/front/src/app/routes/contact/contact.page.html index 0b5f52bfe..fbeb54ffe 100644 --- a/front/src/app/routes/contact/contact.page.html +++ b/front/src/app/routes/contact/contact.page.html @@ -3,7 +3,7 @@ ministère de la justice a-just - +

Contact

diff --git a/front/src/app/routes/contact/contact.page.ts b/front/src/app/routes/contact/contact.page.ts index b594d585d..559bb715e 100644 --- a/front/src/app/routes/contact/contact.page.ts +++ b/front/src/app/routes/contact/contact.page.ts @@ -1,5 +1,7 @@ import { AfterViewInit, Component } from '@angular/core' import { Title } from '@angular/platform-browser' +import { ActivatedRoute } from '@angular/router' +import { AppService } from 'src/app/services/app/app.service' declare const hbspt: any @@ -12,20 +14,34 @@ declare const hbspt: any styleUrls: ['./contact.page.scss'], }) export class ContactPage implements AfterViewInit { + /** + * Get Link to back + */ + routerLinkToGoBack: string[] = ['/'] + /** * Constructeur - * @param title + * @param title */ - constructor(private title: Title) { + constructor( + private title: Title, + private route: ActivatedRoute, + private appService: AppService + ) { this.title.setTitle('Contact | A-Just') } ngAfterViewInit() { hbspt.forms.create({ - region: "eu1", - portalId: "26493393", - formId: "0f776962-cddf-4ccb-b2a8-100936289ebb", - target: "#hubspotForm" - }); + region: 'eu1', + portalId: '26493393', + formId: '0f776962-cddf-4ccb-b2a8-100936289ebb', + target: '#hubspotForm', + }) + + const { backUrl } = this.route.snapshot.queryParams + if (backUrl && backUrl === 'true' && this.appService.previousUrl) { + this.routerLinkToGoBack = [this.appService.previousUrl] + } } } diff --git a/front/src/app/services/app/app.service.ts b/front/src/app/services/app/app.service.ts index 9fa013520..6d9fb30db 100644 --- a/front/src/app/services/app/app.service.ts +++ b/front/src/app/services/app/app.service.ts @@ -16,4 +16,12 @@ export class AppService { alert: BehaviorSubject = new BehaviorSubject( null ) + /** + * Cache previous URL + */ + previousUrl: string | null = null + /** + * Cache current URL + */ + currentUrl: string | null = null }