Skip to content

Commit

Permalink
update ajust CA panorama label
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJimmyChevallier committed Aug 10, 2023
1 parent c11a82f commit c4e42d3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion front/src/app/routes/panorama/panorama.page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<aj-wrapper
[title]="'Panorama de votre tribunal judiciaire le ' + now.getDate() + ' ' + getMonthString(now) + ' ' + now.getFullYear()"
[title]="'Panorama de votre '+ getInterfaceType() + ' le ' + now.getDate() + ' ' + getMonthString(now) + ' ' + now.getFullYear()"
[subtitleTemplate]="subTitle" class="content-margin-null" [isLoading]="isLoading">
<div class="panorama-container">
<div class="header-panorama">
Expand Down
60 changes: 33 additions & 27 deletions front/src/app/routes/panorama/panorama.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import { sumBy } from 'lodash'
styleUrls: ['./panorama.page.scss'],
})
export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
/**
* Date selected
*/
/**
* Date selected
*/
dateSelected: Date = new Date()
/**
* Date de fin de requête
*/
dateStart: Date = dateAddDays(new Date(), -15)
/**
* Date de début de requête
*/
/**
* Date de début de requête
*/
dateEnd: Date = dateAddDays(new Date(), +15)
/**
* Date de début de requête
Expand Down Expand Up @@ -69,9 +69,9 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
* En cours de chargement
*/
isLoading: boolean = false
/**
* liste des catégories filtrées
*/
/**
* liste des catégories filtrées
*/
categoriesFilterList: HRCategorySelectedInterface[] = []
/**
* Liste des ids catégories
Expand All @@ -96,11 +96,11 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
/**
* Liste des personnes non disponibles dans les 15 prochains jours ou les 15 derniers jours
*/
listUnavailabilities : HumanResourceSelectedInterface[] = []
listUnavailabilities: HumanResourceSelectedInterface[] = []
/**
* Total des effectifs à afficher
*/
totalWorkforce : number = 0
totalWorkforce: number = 0

/**
* Constructor
Expand All @@ -122,10 +122,10 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
this.canViewActivities = this.userService.canViewActivities()
})
)

this.watch(
this.humanResourceService.hrBackup.subscribe((hrBackup: BackupInterface | null) => {
this.onFilterList(hrBackup)
this.onFilterList(hrBackup)
})
)
}
Expand All @@ -134,7 +134,7 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
* Filtre liste RH
*/
onFilterList(backup: BackupInterface | null = null) {
if(!backup) {
if (!backup) {
return
}

Expand All @@ -155,42 +155,42 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
let hrList: HumanResourceSelectedInterface[] = []

list.map((group: any) => {
hrList = hrList.concat(group.hr || [])
hrList = hrList.concat(group.hr || [])

const contentieux = this.humanResourceService.contentieuxReferentielOnly.getValue().map(contentieux => contentieux.id)

hrList.map(hr => {
const activityPercent = sumBy((hr.currentActivities || []).filter(c => contentieux.includes(c.contentieux.id)), 'percent')
const activityPercent = sumBy((hr.currentActivities || []).filter(c => contentieux.includes(c.contentieux.id)), 'percent')

hr.totalAffected = activityPercent
hr.currentActivities = (hr.currentActivities || []).filter(c => contentieux.includes(c.contentieux.id))
hr.currentActivities = (hr.currentActivities || []).filter(c => contentieux.includes(c.contentieux.id))
})

let fifteenDaysLater = today(this.dateSelected)
fifteenDaysLater.setDate(fifteenDaysLater.getDate() + 15)
let fifteenDaysBefore = today(this.dateSelected)
fifteenDaysBefore.setDate(fifteenDaysBefore.getDate() - 15)
for (let i = 0; i < hrList.length ; i++) {
for (let i = 0; i < hrList.length; i++) {
const hr = hrList[i]

// Indisponibilité
if (hr.indisponibilities.length > 0) {
const list = hr.indisponibilities.filter(elem =>
today(elem.dateStart).getTime() >= fifteenDaysBefore.getTime() && today(elem.dateStart).getTime() <= fifteenDaysLater.getTime()
const list = hr.indisponibilities.filter(elem =>
today(elem.dateStart).getTime() >= fifteenDaysBefore.getTime() && today(elem.dateStart).getTime() <= fifteenDaysLater.getTime()
)
if (list.length && !this.listUnavailabilities.includes(hr)){
if (list.length && !this.listUnavailabilities.includes(hr)) {
this.listUnavailabilities.push(hr)
}

}

// Arrivé
if (hr.dateStart) {
if (hr.dateStart) {
if (hr.id === 10171) {
console.log("hr 10171:", hr.dateStart)
}
if (today(hr.dateStart).getTime() >= fifteenDaysBefore.getTime() && today(hr.dateStart).getTime() <= fifteenDaysLater.getTime()) {
if (!this.listArrivals.includes(hr)){
if (today(hr.dateStart).getTime() >= fifteenDaysBefore.getTime() && today(hr.dateStart).getTime() <= fifteenDaysLater.getTime()) {
if (!this.listArrivals.includes(hr)) {
this.listArrivals.push(hr)
}
}
Expand All @@ -199,8 +199,8 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {

//Départ
if (hr.dateEnd) {
if (today(hr.dateEnd).getTime() >= fifteenDaysBefore.getTime() && today(hr.dateEnd).getTime() <= fifteenDaysLater.getTime()) {
if (!this.listDepartures.includes(hr)){
if (today(hr.dateEnd).getTime() >= fifteenDaysBefore.getTime() && today(hr.dateEnd).getTime() <= fifteenDaysLater.getTime()) {
if (!this.listDepartures.includes(hr)) {
this.listDepartures.push(hr)
}
}
Expand All @@ -213,9 +213,15 @@ export class PanoramaPage extends MainClass implements OnInit, OnDestroy {
console.log('Indispos:', this.listUnavailabilities)
this.totalWorkforce = this.listDepartures.length + this.listArrivals.length + this.listUnavailabilities.length
this.isLoading = false
})
})
}

/**
* Récuperer le type de l'app
*/
getInterfaceType() {
return this.userService.interfaceType === 0 ? 'tribunal judiciaire' : 'cours d\'appel'
}
/**
* Destruction du composant
*/
Expand Down
1 change: 0 additions & 1 deletion front/src/app/services/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class UserService {
getInterfaceType() {
return this.serverService.get('users/interface-type').then((data) => {
this.interfaceType = [0, 1].includes(+data.data) ? +data.data : null;
console.log(this.interfaceType)
})
}

Expand Down

0 comments on commit c4e42d3

Please sign in to comment.