Skip to content

Commit 0cc47d1

Browse files
committed
feat: update identity lifecycle and table components for improved identity handling
1 parent 8e1756e commit 0cc47d1

File tree

3 files changed

+76
-13
lines changed

3 files changed

+76
-13
lines changed

src/constants/enums.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ export enum IdentityState {
1010
}
1111

1212
export enum IdentityLifecycle {
13-
IMPORTED = 3,
14-
OFFICIAL = 2,
15-
ACTIVE = 1,
16-
PROVISIONAL = 0,
17-
INACTIVE = -1,
18-
DELETED = -2,
13+
WAIT = "W",
14+
OFFICIAL = "O",
15+
ACTIVE = "A",
16+
PROVISIONAL = "P",
17+
INACTIVE = "I",
18+
DELETED = "D",
19+
20+
// IMPORTED = 3,
21+
// OFFICIAL = 2,
22+
// ACTIVE = 1,
23+
// PROVISIONAL = 0,
24+
// INACTIVE = -1,
25+
// DELETED = -2,
1926
}

src/pages/jobs/table.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,24 @@
1717
<template v-slot:body="props">
1818
<q-tr :props="props" :class="{ 'bg-primary': props.expand, 'text-white': props.expand }">
1919
<q-td v-for="col in props.cols" :key="col.name" :props="props">
20-
{{ col.name === 'state' ? getStatusText(col.value) : col.value }}
20+
<template v-if="col.name === 'identity'">
21+
<q-chip
22+
v-if="props.row?.concernedTo?.name"
23+
@click="open(`/identities?read=${props.row?.concernedTo?.id}&skip=0&limit=16&sort[metadata.lastUpdatedAt]=desc`)"
24+
icon="mdi-account"
25+
clickable
26+
dense
27+
>
28+
{{ props.row.concernedTo?.name }}
29+
</q-chip>
30+
<span v-else>Inconnu</span>
31+
</template>
32+
<template v-else-if="col.name === 'state'">
33+
<span>{{ col.name === 'state' ? getStatusText(col.value) : col.value }}</span>
34+
</template>
35+
<template v-else>
36+
<span>{{ col.value || col.field(props.row) || '' }}</span>
37+
</template>
2138
</q-td>
2239
<q-td class="text-center" auto-width>
2340
<q-btn size="sm" :disable="!props.row?.result" :color="getColorState(props.row.state)" round dense @click="expandRow(props)" :icon="getIconState(props.row.state)" />
@@ -48,7 +65,7 @@ const columns = [
4865
{
4966
name: 'identity',
5067
title: 'Identité',
51-
field: (row) => row?.concernedTo?.name,
68+
field: (row) => row?.concernedTo || {},
5269
align: 'left',
5370
label: 'Identité',
5471
},
@@ -125,6 +142,10 @@ function push(path) {
125142
router.push(path)
126143
}
127144
145+
function open(path) {
146+
window.open(path, '_blank')
147+
}
148+
128149
function expandRow(props) {
129150
expanded.value = expanded.value.includes(props.row.jobId) ? [] : [props.row.jobId]
130151
// props.expand = !props.expand

src/pages/lifecycles/table.vue

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@
2828
v-for="col in props.cols.filter(c => c.name !== 'expand')"
2929
:key="col.name"
3030
:props="props"
31-
) {{ col.value }}
31+
)
32+
template(v-if="col.name === 'identity'")
33+
q-chip(
34+
v-if="props.row?.refId?.inetOrgPerson?.cn"
35+
@click="push(`/identities?read=${props.row.refId._id}&skip=0&limit=16&sort[metadata.lastUpdatedAt]=desc`)"
36+
icon="mdi-account" clickable dense
37+
) {{ props.row?.refId?.inetOrgPerson?.cn }}
38+
span(v-else) Inconnu
39+
template(v-else)
40+
span {{ col.value || col.field(props.row) || "" }}
3241
q-td.text-center(auto-width)
3342
q-btn(
3443
@click="expandRow(props)"
@@ -71,17 +80,16 @@ export default {
7180
name: 'identity',
7281
align: 'center',
7382
label: 'Identité(e)',
74-
field: (row) => row?.refId?.inetOrgPerson?.cn || '<Inconnu>',
75-
format: (cn) => `${cn}`,
83+
field: (row) => row?.refId || {},
7684
sortable: true,
7785
},
7886
{
7987
name: 'lifecycle',
8088
required: true,
81-
label: 'Cycle',
89+
label: 'Cycle déclanché',
8290
align: 'left',
8391
field: (row) => row.lifecycle,
84-
format: (lifecycle) => `${lifecycle}`,
92+
format: (lifecycle) => `${this.cycleToText(lifecycle)}`,
8593
sortable: true,
8694
},
8795
{
@@ -97,6 +105,8 @@ export default {
97105
}
98106
},
99107
async setup() {
108+
const router = useRouter()
109+
100110
const {
101111
data: rows,
102112
pending,
@@ -106,9 +116,14 @@ export default {
106116
method: 'GET',
107117
transform: (context: { statusCode: number; data: any[] }) => context?.data || [],
108118
})
119+
109120
return {
110121
rows,
111122
pending,
123+
error,
124+
refresh,
125+
126+
router,
112127
}
113128
},
114129
computed: {
@@ -144,6 +159,26 @@ export default {
144159
this.expanded = this.expanded.includes(props.row._id) ? [] : [props.row._id]
145160
// props.expand = !props.expand
146161
},
162+
cycleToText(cycle) {
163+
switch (cycle) {
164+
case IdentityLifecycle.DELETED:
165+
return 'Suppression'
166+
case IdentityLifecycle.INACTIVE:
167+
return 'Inactif'
168+
case IdentityLifecycle.PROVISIONAL:
169+
return 'Provisionnel'
170+
case IdentityLifecycle.ACTIVE:
171+
return 'Actif'
172+
case IdentityLifecycle.OFFICIAL:
173+
return 'Officiel'
174+
175+
default:
176+
return 'Inconnu'
177+
}
178+
},
179+
push(path) {
180+
window.open(path, '_blank')
181+
},
147182
},
148183
onMounted() {
149184
this.$nextTick(() => {

0 commit comments

Comments
 (0)