Skip to content

Commit daa9684

Browse files
committed
Refactor code to use optional chaining for accessing nested properties
1 parent 4a4500f commit daa9684

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

src/components/2pan/index.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,19 @@ const getTitle = computed(() => {
311311
return Object.values(valuesList).join(' ')
312312
})
313313
314+
function clearSelected() {
315+
selected.value = []
316+
}
317+
314318
defineExpose({
315319
cancel,
316320
create,
317321
read,
318322
update,
319323
remove,
320324
refresh,
325+
selected,
326+
clearSelected,
321327
})
322328
323329
onMounted(async () => {

src/components/appbar/RightButtons.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
div
33
//q-btn(v-for="button in buttons" :key="button.icon" round flat :icon="button.icon" size="md").q-mx-sm
44
q-tooltip.text-body2(transition-show="scale" transition-hide="scale") {{ button.name }}
5-
q-btn-dropdown(icon="mdi-account-circle-outline" round flat size="md")
5+
q-btn(icon="mdi-sync" square color="amber-9" size="md" :label="badgesValues.TO_SYNC +' items à Synchroniser'" @click="syncAll")
6+
q-btn-dropdown(icon="mdi-account-circle-outline" :label="auth?.user?.displayName" round flat size="md")
67
q-list
78
q-item.q-pa-none(v-for="button in buttons" :key="button.name")
89
q-btn.full-width.items-baseline.q-pa-sm(
@@ -17,7 +18,17 @@ div
1718
</template>
1819

1920
<script lang="ts" setup>
21+
import { useIdentityStateStore } from "~/stores/identityState"
22+
23+
24+
const identityStateStore = useIdentityStateStore()
25+
26+
const badgesValues = ref({
27+
TO_SYNC: computed(() => (identityStateStore.getToSyncCount > 9999 ? '9999+' : identityStateStore.getToSyncCount)),
28+
})
29+
2030
const auth = useAuth()
31+
console.log(auth)
2132
const buttons = [
2233
// {
2334
// icon: 'mdi-cog',
@@ -44,4 +55,15 @@ const buttons = [
4455
},
4556
},
4657
]
58+
59+
async function syncAll() {
60+
await useHttp('/core/backends/syncall', {
61+
method: 'POST',
62+
params: {
63+
async: true,
64+
},
65+
})
66+
await identityStateStore.fetchToSyncCount()
67+
await identityStateStore.fetchSyncedCount()
68+
}
4769
</script>

src/components/identityForm/actions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ div
55
q-btn.q-mx-xs(@click="sync" color="primary" v-if="identity" :disabled="props.identity.state != IdentityState.TO_VALIDATE" icon="mdi-sync")
66
q-tooltip.text-body2(slot="trigger" v-if="props.identity.state == IdentityState.TO_VALIDATE") Synchroniser l'identité
77
q-tooltip.text-body2(slot="trigger" v-else) L'état de l'identité ne permet pas de la synchroniser
8-
q-btn.q-mx-xs(@click="logs" color="primary" icon="mdi-file-document")
8+
q-btn.q-mx-xs(@click="logs" color="primary" icon="mdi-file-document" :href="'/jobs?filters[:concernedTo.id]=' + props.identity._id")
99
q-tooltip.text-body2(slot="trigger") Voir les logs de l'identité
1010
</template>
1111

src/components/table/top-left.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const props = defineProps({
3131
})
3232
3333
const emit = defineEmits(['updateLifestep', 'clear', 'refresh'])
34+
const { getToSyncCount, fetchAllStateCount } = useIdentityStateStore()
3435
3536
const { getStateName } = useIdentityStates()
3637
const { getStateValue } = useIdentityStateStore()
@@ -111,6 +112,7 @@ async function updateIdentity(identities, state: IdentityState) {
111112
message: `Les identités ont été mises à jour avec succès`,
112113
color: 'positive',
113114
})
115+
await fetchAllStateCount()
114116
emit('refresh')
115117
emit('clear')
116118
}

src/pages/identities/index.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ div
2424
q-icon(name="mdi-circle" :color="getStateColor(props.target.state)" :class="`q-mr-xs`")
2525
q-tooltip.text-body2(slot="trigger") {{ getStateName(props.target.state) }}
2626
template(#top-left-btn-grp="{selectedValues}")
27-
sesame-table-top-left(:selected="selectedValues" @refresh="refresh" @clear="selected = []")
27+
sesame-table-top-left(:selected="selectedValues" @refresh="refresh" @clear="clearSelected")
2828
template(#body-cell-states="props")
2929
sesame-table-state-col(:identity="props.row")
3030
template(#right-panel-actions-content-after="{target}")
@@ -49,9 +49,12 @@ import type { components, operations } from '#build/types/service-api'
4949
import { useErrorHandling } from '#imports'
5050
import { useIdentityStates } from '~/composables'
5151
import { identity } from '@vueuse/core'
52+
import { useIdentityStateStore } from "~/stores/identityState"
5253
type Identity = components['schemas']['IdentitiesDto']
5354
type Response = operations['IdentitiesController_search']['responses']['200']['content']['application/json']
5455
56+
const identityStateStore = useIdentityStateStore()
57+
5558
defineOptions({
5659
name: 'Identities',
5760
})
@@ -68,8 +71,9 @@ onMounted(() => {
6871
initializePagination(identities.value?.total)
6972
})
7073
71-
function refreshTarget(target: Identity) {
74+
async function refreshTarget(target: Identity) {
7275
twopan.value.read(target)
76+
await identityStateStore.fetchToSyncCount()
7377
refreshEvent()
7478
}
7579
@@ -101,6 +105,10 @@ const { columns, visibleColumns, columnsType } = useColumnsIdentites()
101105
102106
const selected = ref([])
103107
108+
function clearSelected() {
109+
(twopan as any).value.clearSelected()
110+
}
111+
104112
function refreshEvent() {
105113
refresh()
106114
selected.value = []

0 commit comments

Comments
 (0)