Skip to content

Commit 3937809

Browse files
committed
Refactor identity form actions and add delete functionality
1 parent 7f3b608 commit 3937809

File tree

7 files changed

+62
-18
lines changed

7 files changed

+62
-18
lines changed

src/assets/sass/global.sass

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ body.body--dark
3030
.sesame-table-td-highlight
3131
color: $primary
3232
font-weight: bold
33+
34+
.fallback-image
35+
background-image: url('/no-photo.jpg')
36+
display: inline-block
37+
min-height: 400px
38+
background-position: center center
39+
background-size: cover
40+
background-repeat: no-repeat

src/components/identityForm/actions.vue

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<template lang="pug">
2-
div
3-
q-btn(color="positive" icon='mdi-content-save-plus' @click="create" v-show="isNew" v-if="crud.create")
4-
q-tooltip.text-body2 Créer
5-
q-btn.q-mx-xs(@click="sendInit" color="primary" icon="mdi-email-arrow-right" :disabled="props.identity.state != IdentityState.SYNCED")
6-
q-tooltip.text-body2(slot="trigger") Envoyer le mail d'invitation
7-
q-btn.q-mx-xs(@click="submit" color="positive" icon="mdi-check" v-show="!isNew" v-if="crud.update")
8-
q-tooltip.text-body2(slot="trigger") Enregistrer les modifications
9-
q-btn.q-mx-xs(v-if="props.identity?._id" @click="sync" color="orange-8" :disabled="props.identity.state != IdentityState.TO_VALIDATE" icon="mdi-sync")
10-
q-tooltip.text-body2(slot="trigger" v-if="props.identity.state == IdentityState.TO_VALIDATE") Synchroniser l'identité
11-
q-tooltip.text-body2(slot="trigger" v-else) L'état de l'identité ne permet pas de la synchroniser
12-
q-btn.q-mx-xs(v-if="props.identity?._id" @click="logs" color="grey-8" icon="mdi-file-document" :href="'/jobs?filters[:concernedTo.id]=' + props.identity?._id")
13-
q-tooltip.text-body2(slot="trigger") Voir les logs de l'identité
2+
div.flex
3+
div
4+
q-btn(color="positive" icon='mdi-content-save-plus' @click="create" v-show="isNew" v-if="crud.create")
5+
q-tooltip.text-body2 Créer
6+
q-btn.q-mx-xs(@click="sendInit" color="primary" icon="mdi-email-arrow-right" :disabled="props.identity.state != IdentityState.SYNCED")
7+
q-tooltip.text-body2(slot="trigger") Envoyer le mail d'invitation
8+
q-btn.q-mx-xs(@click="submit" color="positive" icon="mdi-check" v-show="!isNew" v-if="crud.update")
9+
q-tooltip.text-body2(slot="trigger") Enregistrer les modifications
10+
q-btn.q-mx-xs(v-if="props.identity?._id" @click="sync" color="orange-8" :disabled="props.identity.state != IdentityState.TO_VALIDATE" icon="mdi-sync")
11+
q-tooltip.text-body2(slot="trigger" v-if="props.identity.state == IdentityState.TO_VALIDATE") Synchroniser l'identité
12+
q-tooltip.text-body2(slot="trigger" v-else) L'état de l'identité ne permet pas de la synchroniser
13+
q-btn.q-mx-xs(v-if="props.identity?._id" @click="logs" color="grey-8" icon="mdi-file-document" :href="'/jobs?filters[:concernedTo.id]=' + props.identity?._id")
14+
q-tooltip.text-body2(slot="trigger") Voir les logs de l'identité
15+
q-separator.q-mx-sm(vertical)
16+
div
17+
q-btn.q-mx-xs(v-if="props.identity?._id" @click="deleteIdentity" color="negative" icon="mdi-delete")
18+
q-tooltip.text-body2(slot="trigger") Supprimer l'identité
1419
</template>
1520

1621
<script lang="ts" setup>
@@ -45,7 +50,7 @@ const router = useRouter()
4550
const { getStateColor, getStateName } = useIdentityStates()
4651
const { handleError } = useErrorHandling()
4752
48-
const emits = defineEmits(['submit', 'sync', 'logs', 'create'])
53+
const emits = defineEmits(['submit', 'sync', 'logs', 'create', 'delete'])
4954
5055
async function submit() {
5156
// console.log('submit from actions')
@@ -57,6 +62,11 @@ async function create() {
5762
emits('create')
5863
}
5964
65+
66+
async function deleteIdentity() {
67+
emits('delete')
68+
}
69+
6070
const stateName = computed(() => {
6171
const state = props.identity?.state
6272
return getStateName(state)

src/components/identityForm/index.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ function getTabValidations(tab: string) {
174174
return validations.value?.hasOwnProperty(tab) ? 'red' : false
175175
}
176176
177+
async function deleteIdentity() {
178+
await useHttp('/core/backends/delete', {
179+
method: 'POST',
180+
body: {
181+
payload: [
182+
props.identity._id,
183+
],
184+
},
185+
})
186+
}
187+
177188
async function sync() {
178189
const { data: result, pending, error, refresh } = await useHttp<any>(`/management/identities/${props.identity._id}/state`, {
179190
method: 'PATCH',
@@ -210,6 +221,7 @@ defineExpose({
210221
sync,
211222
logs,
212223
back,
224+
deleteIdentity,
213225
})
214226
</script>
215227

src/components/quasar-jsonform/controls/QFileControlRenderer.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template lang="pug">
22
//control-wrapper(v-bind="controlWrapper" :styles="styles" :isFocused="isFocused" :appliedOptions="appliedOptions")
33
div(style="cursor: pointer")
4+
//- @click="open"
5+
@update:model-value="onChangeControl"
46
q-input(
57
:id="control.id + '-input'"
68
:disable="!control.enabled"
@@ -9,8 +11,6 @@ div(style="cursor: pointer")
911
:model-value="control.data"
1012
:clearable="true"
1113
readonly
12-
@click="open"
13-
@update:model-value="onChangeControl"
1414
@focus="isFocused = true"
1515
@blur="isFocused = false"
1616
:style="{paddingBottom: control.errors !== '' ? 'revert-layer' : 0}"
@@ -19,7 +19,7 @@ div(style="cursor: pointer")
1919
template(v-slot:prepend)
2020
q-icon(name="mdi-paperclip")
2121
q-card(style="border-radius: 0")
22-
img(:src="baseUrl + '/management/identities/photo/raw?' + photoUrlQuery.params")
22+
q-img(:src="baseUrl + '/management/identities/photo/raw?' + photoUrlQuery.params" placeholder-src='/no-photo.jpg' fit='contain' height='400px')
2323
</template>
2424

2525
<script lang="ts">

src/layouts/default.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ q-layout(view="hHh LpR lff" style="margin-top: -1px;")
2828
div
2929
.text-weight-bold.q-px-md.text-center
3030
| Synchronisation en cours&nbsp;&nbsp;
31-
q-badge(color="amber-10") {{ eventSeamlessCurrent }}/{{ eventSeamlessTotal }}
31+
q-badge(color="amber-10" v-show="eventSeamlessCurrent > 0") {{ eventSeamlessCurrent }}/{{ eventSeamlessTotal }}
3232
q-space
3333
q-btn(flat round icon="mdi-close" v-close-popup)
3434
q-footer(:class="$q.dark.isActive ? 'bg-dark' : 'bg-white'" bordered)

src/pages/identities/index.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ q-page.container
3030
template(#body-cell-states="props")
3131
sesame-table-state-col(:identity="props.row")
3232
template(#right-panel-actions-content-after="{target, crud, isNew}")
33-
sesame-identity-form-actions(:identity="target" @submit="submit($event)" @create="create($event)" @sync="sync" @logs="logs" :crud="crud" :isNew="isNew")
33+
sesame-identity-form-actions(
34+
:identity="target"
35+
@submit="submit($event)"
36+
@create="create($event)"
37+
@sync="sync"
38+
@logs="logs"
39+
@delete="deleteIdentity"
40+
:crud="crud"
41+
:isNew="isNew"
42+
)
3443
template(#right-panel-content="{payload, isNew}")
3544
sesame-identity-form(
3645
:identity="{...payload.target}"
@@ -144,6 +153,11 @@ async function sync(identity: Identity) {
144153
form.value.sync()
145154
}
146155
156+
async function deleteIdentity(identity: Identity) {
157+
console.log('deleteIdentity')
158+
form.value.deleteIdentity()
159+
}
160+
147161
function logs(identity: Identity & { _id: string }) {
148162
router.push(`/logs?filters[:concernedTo.id]=${identity?._id}`)
149163
}

src/public/no-photo.jpg

14.3 KB
Loading

0 commit comments

Comments
 (0)