Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:betagouv/a-just into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rzafari42 committed Oct 23, 2024
2 parents c0d4e42 + 4565686 commit c77f706
Show file tree
Hide file tree
Showing 45 changed files with 989 additions and 474 deletions.
6 changes: 1 addition & 5 deletions api/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,7 @@ export default class App extends AppBase {
//...scriptSha1Generate([`${__dirname}/front/index.html`]),
],
'default-src': ["'none'"],
'style-src': [
"'self'",
...styleSha1Generate([`${__dirname}/front/index.html`]),
'cdnjs.cloudflare.com',
],
'style-src': ["'self'", ...styleSha1Generate([`${__dirname}/front/index.html`]), 'cdnjs.cloudflare.com'],
'worker-src': ['blob:'],
'frame-src': [
'https://app.videas.fr/',
Expand Down
15 changes: 14 additions & 1 deletion api/src/models/TableHumanresources.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ export default (sequelizeInstance, Model) => {
} else situation.category_id = findCategory.id
}

let findHRToDBByMatricule = await Model.findOne({
where: {
backup_id: backupId,
matricule: list[i].hmatricule,
},
logging: false,
})

if (list[i].hmatricule !== '' && findHRToDBByMatricule) {
importSituation.push(list[i].hmatricule + ' no add by matricule already existing')
continue
}

switch (code) {
case 'MHFJS':
code = 'MHFJ'
Expand Down Expand Up @@ -397,7 +410,7 @@ export default (sequelizeInstance, Model) => {
// prepare person
const options = {
first_name: list[i].prenom || '',
last_name: list[i].nom_usage || list[i].nom_marital || '',
last_name: list[i].nom_usage || list[i].nom_marital || list[i].nom || '',
matricule: list[i].hmatricule || '',
backup_id: backupId,
registration_number: list[i].hRegMatricule,
Expand Down
4 changes: 2 additions & 2 deletions api/src/models/TableTj.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { groupBy, sumBy } from 'lodash'
import { preformatHumanResources } from '../utils/ventilator'
import { listCategories } from '../utils/ventilator'

export default (sequelizeInstance, Model) => {
Model.getAll = async () => {
Expand All @@ -15,7 +15,7 @@ export default (sequelizeInstance, Model) => {
for (let i = 0; i < list.length; i++) {
list[i].users = await Model.models.UserVentilations.getUserVentilationsWithLabel(list[i].label)
const getBackupId = await Model.models.HRBackups.findByLabel(list[i].label)
const agents = getBackupId ? preformatHumanResources(await Model.models.HumanResources.getCache(getBackupId)) : []
const agents = getBackupId ? listCategories(await Model.models.HumanResources.getCache(getBackupId)) : []
const group = groupBy(
agents.filter((a) => a.category),
'category.label'
Expand Down
2 changes: 1 addition & 1 deletion api/src/routes-api/RouteCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class RouteCalculator extends Route {
case 'stocks':
{
const activites = await this.models.Activities.getByMonth(dateStart, backupId, contentieuxId, false)
if (activites.length) {
if (activites && activites.length) {
const acti = activites[0]
if (acti.stock !== null) {
list.push(acti.stock)
Expand Down
22 changes: 11 additions & 11 deletions api/src/routes-api/RouteContentieuxOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class RouteContentieuxOptions extends Route {
* Constructeur
* @param {*} params
*/
constructor(params) {
constructor (params) {
super({ ...params, model: 'ContentieuxOptions' })
}

Expand All @@ -26,7 +26,7 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.canVewContentieuxOptions],
})
async getAll(ctx) {
async getAll (ctx) {
let { juridictionId, backupId } = this.body(ctx)
const backups = await this.model.models.OptionsBackups.getBackup(ctx.state.user.id, juridictionId)
backupId = backups.find((b) => b.id === backupId) ? backupId : backups.length ? backups[backups.length - 1].id : null
Expand All @@ -44,7 +44,7 @@ export default class RouteContentieuxOptions extends Route {
path: 'remove-backup/:backupId',
accesses: [Access.canVewContentieuxOptions],
})
async removeBackup(ctx) {
async removeBackup (ctx) {
const { backupId } = ctx.params

await this.model.models.OptionsBackups.removeBackup(backupId)
Expand All @@ -68,7 +68,7 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.canVewContentieuxOptions],
})
async duplicateBackup(ctx) {
async duplicateBackup (ctx) {
const { backupId, backupName, backupStatus, type, juridictionId } = this.body(ctx)

if (await this.models.OptionsBackups.haveAccess(backupId, juridictionId, ctx.state.user.id)) {
Expand Down Expand Up @@ -96,15 +96,15 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.canVewContentieuxOptions],
})
async saveBackup(ctx) {
async saveBackup (ctx) {
const { backupId, list, backupName, juridictionId, backupStatus, type } = this.body(ctx)
if (
(backupId && (await this.models.OptionsBackups.haveAccess(backupId, juridictionId, ctx.state.user.id))) ||
(!backupId && (await this.models.HRBackups.haveAccess(juridictionId, ctx.state.user.id)))
) {
const newId = await this.model.models.OptionsBackups.saveBackup(ctx.state.user.id, list, backupId, backupName, juridictionId, backupStatus, type)

await this.model.models.HistoriesContentieuxUpdate.addHistory(ctx.state.user.id, newId)
if (newId !== null) await this.model.models.HistoriesContentieuxUpdate.addHistory(ctx.state.user.id, newId)

this.sendOk(ctx, newId)
} else {
Expand All @@ -126,7 +126,7 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.canVewContentieuxOptions],
})
async renameBackup(ctx) {
async renameBackup (ctx) {
const { backupId, backupName, juridictionId } = this.body(ctx)

if (await this.models.OptionsBackups.haveAccess(backupId, juridictionId, ctx.state.user.id)) {
Expand All @@ -144,7 +144,7 @@ export default class RouteContentieuxOptions extends Route {
@Route.Get({
accesses: [Access.isAdmin],
})
async getAllAdmin(ctx) {
async getAllAdmin (ctx) {
const list = await this.models.OptionsBackups.adminGetAll()

const juridictions = await this.models.HRBackups.findAll({
Expand All @@ -170,7 +170,7 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.isAdmin],
})
async updateBackup(ctx) {
async updateBackup (ctx) {
const { id, juridictions } = this.body(ctx)

await this.model.models.OptionsBackupJuridictions.changeRules(id, juridictions)
Expand All @@ -185,7 +185,7 @@ export default class RouteContentieuxOptions extends Route {
path: 'get-backup-details/:backupId',
accesses: [Access.canVewContentieuxOptions],
})
async getBackupDetails(ctx) {
async getBackupDetails (ctx) {
const { backupId } = ctx.params

if (await this.models.OptionsBackups.haveAccessWithoutJuridiction(backupId, ctx.state.user.id)) {
Expand All @@ -207,7 +207,7 @@ export default class RouteContentieuxOptions extends Route {
}),
accesses: [Access.canVewContentieuxOptions],
})
async getLastUpdate(ctx) {
async getLastUpdate (ctx) {
const { backupId, juridictionId } = this.body(ctx)

if (await this.models.OptionsBackups.haveAccess(backupId, juridictionId, ctx.state.user.id)) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/routes/RouteIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class RouteIndex extends Route {
//stream.on('error', (streamErr) => res.end(streamErr))
} else {
const src = createReadStream(file)
ctx.type = mime.getType(file)
ctx.type = mime.getType(file) || 'text/html'
ctx.body = src
}
} else {
Expand Down
16 changes: 15 additions & 1 deletion api/src/utils/ventilator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { findAllIndisponibilities } from './indisponibilities'
import { fixDecimal } from './number'

export const preformatHumanResources = (list, dateSelected, referentielList, fonctionsIds) => {
console.log('fonctionsIds', fonctionsIds)
return orderBy(
list.map((h) => {
const indisponibilities = dateSelected ? findAllIndisponibilities(h, dateSelected) : []
Expand Down Expand Up @@ -63,3 +62,18 @@ export const preformatHumanResources = (list, dateSelected, referentielList, fon
return isFiltered
})
}

export const listCategories = (list) => {
return list.map((h) => {
let currentSituation
const situations = h.situations || []
if (situations.length) {
currentSituation = situations[0]
}

return {
...h,
category: currentSituation && currentSituation.category,
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@
opacity: 0.7;
}

&.bottom-popin {
input {
left: -20px;
top: 100%;
}
}

p.title-select {
color: fColor(titleSelect);
white-space: nowrap;
Expand Down
17 changes: 17 additions & 0 deletions front/src/app/components/input-button/input-button.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@
background-color: fColor(darkModeBgMenu);
border: 1px solid fColor(darkModeBgMenu);

&.search-bar {
.input {
.input-container {
input {
&::placeholder {
color: white;
opacity: 1;
}
}

img {
filter: brightness(0) invert(1);
}
}
}
}

p,
mat-icon,
input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ export class OptionsBackupPanelComponent
.onSaveDatas(isCopy, this.category)
.then((x) => {
if (isCopy && x !== null) {
//this.router.navigate(['/temps-moyens'])
this.contentieuxOptionsService.optionsIsModify.next(false)
}
if (
isCopy === false &&
x !== null &&
this.contentieuxOptionsService.openedFromCockpit.getValue().value !==
true
)
this.router.navigate(['/temps-moyens'])
})
if (
this.contentieuxOptionsService.openedFromCockpit.getValue().value === true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="white-background">
<div *ngIf="ddg && percent===0" class="ddg" [style.backgroundColor]="color">DDG</div>
<div *ngIf="ddg" class="ddg" [style.backgroundColor]="color">DDG</div>
</div>
<div class="background-bar" [style.backgroundColor]="colorOpacity" (click)="changePercent()" [class.seleted]="selected">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

.ddg {
opacity: 1 !important;
z-index: 1;
transform: rotate(-45deg);
position: absolute;
left: -16px;
Expand Down
15 changes: 15 additions & 0 deletions front/src/app/components/tooltips/tooltips.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@
}
}

&.right .tooltip-text {
right: 0;
left: inherit;

>div {
position: relative;
transform: translateX(0);
}

.triangle {
right: 55px;
left: inherit;
}
}

&.top .tooltip-text {
bottom: calc(85% + 4px);

Expand Down
1 change: 1 addition & 0 deletions front/src/app/components/wrapper/wrapper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export class WrapperComponent extends MainClass implements OnDestroy {
*/
onChangeHRBackup(id: number) {
this.humanResourceService.backupId.next(id)
this.router.navigate(['/panorama'])
}

/**
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/routes/average-etp/average-etp.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,6 @@
.sticky-bar {
position: sticky;
top: 0;
z-index: 10;
z-index: 1;
}
}
2 changes: 1 addition & 1 deletion front/src/app/routes/average-etp/average-etp.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export class AverageEtpPage extends MainClass implements AfterViewInit {
* Import d'un référentiel
*/
async import() {
this.enableImport = false
let form = document.getElementById('form') as HTMLFormElement
let name =
(document.getElementById('name') as HTMLTextAreaElement)?.value || ''
Expand All @@ -307,6 +306,7 @@ export class AverageEtpPage extends MainClass implements AfterViewInit {
else if (!file) {
alert('Vous devez saisir une fichier !')
} else if (name.length > 0 && type.length > 0) {
this.enableImport = true
await this.contentieuxOptionsService.createEmpy(
false,
name,
Expand Down
Loading

0 comments on commit c77f706

Please sign in to comment.