@@ -52,6 +52,26 @@ div.flex
5252
5353 q-separator( v-if ="props.identity?._id" size ='3px' vertical )
5454
55+ div( ref ='targetEl' style ='display: height: 36px;' )
56+ q-tooltip.text-body2 ( :target ="targetEl" anchor ="top middle" self ="bottom middle" ) État du cycle de vie : {{ stateName }}
57+ q-btn-dropdown.q-pl-sm.full-height ( icon ='mdi-clock' color ='purple-8' square unelevated dense )
58+ q-list
59+ q-item(
60+ v-for ='stateItem in stateList' : key= 'stateItem.key'
61+ @click ="switchLifecycle(stateItem.key)"
62+ :active ='stateItem.key === props.identity.lifecycle'
63+ active-class ="bg-purple-8 text-white"
64+ clickable v-close-popup
65+ )
66+ q-item-section( avatar )
67+ q-icon( :name ="stateItem.icon || 'mdi-help-rhombus-outline'" : color= "stateItem.color" )
68+ q-item-section
69+ q-item-label
70+ span( v-text ='stateItem.label' )
71+ |
72+ small( v-text ='("(" + stateItem.key + ")")' )
73+ q-separator( size ='3px' vertical )
74+
5575 q-btn-dropdown.text-white ( v-if ="props.identity?._id" dropdown-icon ="mdi-dots-vertical" style ='background-color: rgba(0, 0, 0, .6)' padding ='5px 10px' dense no-caps )
5676 q-list
5777 a( :href ="'/jobs?filters[:concernedTo.id]=' + props.identity?._id" target ="_blank" style ='text-decoration: none; color: inherit' @click.prevent ="dialogLog = true" )
@@ -128,6 +148,7 @@ import InputNewPassword from '~/components/inputNewPassword.vue'
128148const resetPasswordModal = ref (false )
129149const forcePasswordModal = ref (false )
130150
151+ const targetEl = ref ()
131152const newpassword = ref (' ' )
132153type IdentityResponse = operations [' IdentitiesController_search' ][' responses' ][' 200' ][' content' ][' application/json' ]
133154type Identity = components [' schemas' ][' IdentitiesDto' ]
@@ -157,6 +178,7 @@ const props = defineProps({
157178const $q = useQuasar ()
158179const router = useRouter ()
159180const { getStateColor, getStateName } = useIdentityStates ()
181+ const { getLifecycleColor, getLifecycleName, getLifecycleIcon, stateList } = await useIdentityLifecycles ()
160182const { handleError } = useErrorHandling ()
161183
162184const emits = defineEmits ([' submit' , ' sync' , ' logs' , ' create' , ' delete' ])
@@ -166,6 +188,27 @@ const validationsModal = ref(false)
166188const dialogLog = ref (false )
167189const dialogLifecycle = ref (false )
168190
191+ async function switchLifecycle(lifecycle : string ) {
192+ const requestOptions = { method: ' POST' , body: JSON .stringify ({ lifecycle }) }
193+ try {
194+ const data = await $http .patch (` /management/identities/${props .identity ._id }/lifecycle ` , requestOptions )
195+ $q .notify ({
196+ message: ' Le cycle de vie a été mis à jour : ' + data ._data ?.data ?.lifecycle ,
197+ color: ' positive' ,
198+ position: ' top-right' ,
199+ icon: ' mdi-check-circle-outline' ,
200+ })
201+ props ?.refreshTarget (props .identity )
202+ } catch (error ) {
203+ $q .notify ({
204+ message: ' Impossible de modifier le cycle de vie : ' + error .response ._data .message ,
205+ color: ' negative' ,
206+ position: ' top-right' ,
207+ icon: ' mdi-alert-circle-outline' ,
208+ })
209+ }
210+ }
211+
169212async function doChangePassword() {
170213 const requestOptions = { method: ' POST' , body: JSON .stringify ({ id: props .identity ._id , newPassword: newpassword .value }) }
171214 try {
@@ -346,11 +389,26 @@ const stateName = computed(() => {
346389 return getStateName (state )
347390})
348391
392+ const lifecycleName = computed (() => {
393+ const lifecycle = props .identity ?.lifecycle
394+ return getLifecycleName (lifecycle )
395+ })
396+
349397const stateColor = computed (() => {
350398 const state = props .identity ?.state
351399 return getStateColor (state )
352400})
353401
402+ const lifecycleColor = computed (() => {
403+ const lifecycle = props .identity ?.lifecycle
404+ return getLifecycleColor (lifecycle )
405+ })
406+
407+ const lifecycleIcon = computed (() => {
408+ const lifecycle = props .identity ?.lifecycle
409+ return getLifecycleIcon (lifecycle )
410+ })
411+
354412async function sync() {
355413 emits (' sync' )
356414}
0 commit comments