3232 template( v-if ="col.name === 'identity'" )
3333 q-chip(
3434 v-if ="props.row?.refId?.inetOrgPerson?.cn"
35- @click ="push(`/identities?read=${props.row.refId._id}&skip=0&limit=16&sort[metadata.lastUpdatedAt]=desc`)"
35+ @click ="push(`/identities?read=${props.row.refId._id}&filters[^inetOrgPerson.cn]=/${props.row?.refId?.inetOrgPerson?.cn}/i& skip=0&limit=16&sort[metadata.lastUpdatedAt]=desc`)"
3636 icon ="mdi-account" clickable dense
3737 ) {{ props.row?.refId?.inetOrgPerson?.cn }}
3838 span( v-else ) Inconnu
4949 q-tr( v-if ="props.expand" : props= "props" )
5050 q-td( colspan ="100%" style ="padding: 0;" )
5151 MonacoEditor(
52+ v-if ="isMounted"
5253 :model-value ="JSON.stringify(props.row, null, 2)"
5354 lang ="json"
5455 :options ="monacoOptions"
5859</template >
5960
6061<script lang="ts">
61- import exp from ' constants'
6262import dayjs from ' dayjs'
63+ import { IdentityLifecycle } from ' ~/composables/useIdentityLifecycle'
64+
65+ // Helper function to convert cycle to text
66+ function cycleToText(cycle : string ): string {
67+ switch (cycle ) {
68+ case IdentityLifecycle .DELETED :
69+ return ' Suppression'
70+ case IdentityLifecycle .INACTIVE :
71+ return ' Inactif'
72+ case IdentityLifecycle .PROVISIONAL :
73+ return ' Provisionnel'
74+ case IdentityLifecycle .ACTIVE :
75+ return ' Actif'
76+ case IdentityLifecycle .OFFICIAL :
77+ return ' Officiel'
78+ default :
79+ return ' Inconnu'
80+ }
81+ }
6382
6483export default {
6584 name: ' LifecyclesTablePage' ,
6685 data() {
6786 return {
87+ isMounted: false ,
6888 tableRef: ref (),
6989 filter: ref (' ' ),
7090 expanded: ref <any []>([]),
71- pagination: ref ({
72- sortBy: ' desc' ,
73- descending: false ,
74- page: 1 ,
75- rowsPerPage: 3 ,
76- rowsNumber: 10 ,
77- }),
7891 columns: [
7992 {
8093 name: ' identity' ,
@@ -89,7 +102,7 @@ export default {
89102 label: ' Cycle déclanché' ,
90103 align: ' left' ,
91104 field : (row ) => row .lifecycle ,
92- format : (lifecycle ) => ` ${ this . cycleToText (lifecycle )} ` ,
105+ format : (lifecycle ) => cycleToText (lifecycle ),
93106 sortable: true ,
94107 },
95108 {
@@ -105,19 +118,49 @@ export default {
105118 }
106119 },
107120 async setup() {
121+ const route = useRoute ()
108122 const router = useRouter ()
109123
124+ const pagination = ref ({
125+ sortBy: ' desc' ,
126+ descending: false ,
127+ page: route .query .page ? parseInt (route .query .page as string , 10 ) : 1 ,
128+ rowsPerPage: route .query .limit ? parseInt (route .query .limit as string , 10 ) : 16 ,
129+ rowsNumber: 0 ,
130+ })
131+
132+ const query = computed (() => {
133+ return {
134+ page: pagination .value .page ,
135+ limit: pagination .value .rowsPerPage ,
136+ ' sort[date]' : ' desc' ,
137+ ... route .query ,
138+ }
139+ })
140+
110141 const {
111142 data : rows,
112143 pending,
113144 error,
114145 refresh,
115146 } = await useHttp (` /management/lifecycle/recent ` , {
116147 method: ' GET' ,
148+ query ,
149+ onRequest() {
150+ pagination .value .page = parseInt (route .query .page as string , 10 ) || 1
151+ pagination .value .rowsPerPage = parseInt (route .query .limit as string , 10 ) || 16
152+ // pagination.value.sortBy = sortBy
153+ // pagination.value.descending = descending
154+ },
155+ onResponse({ response }) {
156+ pagination .value .rowsNumber = response ._data .total || 0
157+ },
117158 transform : (context : { statusCode: number ; data: any [] }) => context ?.data || [],
118159 })
119160
120161 return {
162+ pagination ,
163+
121164 rows ,
122165 pending ,
123166 error ,
@@ -142,48 +185,42 @@ export default {
142185 }
143186 },
144187 },
188+ mounted() {
189+ this .isMounted = true
190+ },
191+ beforeUnmount() {
192+ this .isMounted = false
193+ },
145194 methods: {
146195 onRequest(props ) {
147- const { page, rowsPerPage, sortBy, descending } = props .pagination
196+ const { page, rowsPerPage : limit , sortBy, descending } = props .pagination
148197 const filter = props .filter
149198
150199 console .log (' Requesting data with:' , {
151200 page ,
152- rowsPerPage ,
201+ limit ,
153202 sortBy ,
154203 descending ,
155204 filter ,
156205 })
206+
207+ this .router .push ({
208+ query: {
209+ ... this .router .currentRoute .value .query ,
210+ page ,
211+ limit ,
212+ // 'sort[date]': descending ? `-${sortBy}` : sortBy,
213+ // filter,
214+ },
215+ })
157216 },
158217 expandRow(props ) {
159218 this .expanded = this .expanded .includes (props .row ._id ) ? [] : [props .row ._id ]
160219 // props.expand = !props.expand
161220 },
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- },
179221 push(path ) {
180222 window .open (path , ' _blank' )
181223 },
182224 },
183- onMounted() {
184- this .$nextTick (() => {
185- this .tableRef .value .requestServerInteraction ()
186- })
187- },
188225}
189226 </script >
0 commit comments