Skip to content

Commit

Permalink
fix(maz-ui): MazDialogPromise - change button texts with options data…
Browse files Browse the repository at this point in the history
….cancelText and data.confirmText
  • Loading branch information
LouisMazel committed Oct 11, 2024
1 parent e3c49ec commit 13c26be
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions packages/lib/components/MazDialogPromise.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,29 @@ const { dialogState, rejectDialog, resolveDialog, data: composableData } = useMa
const customButtons = computed(() => props.buttons ?? props.data?.buttons ?? composableData.value.buttons)
const currentData = computed<DialogData>(() => ({
...defaultData,
...composableData.value,
...props.data,
}))
const cancelButtonData = computed(() => {
const hasButton
= composableData.value?.cancelButton ?? props.data?.cancelButton ?? defaultData.cancelButton
if (!hasButton)
return
return {
const mergedData = {
...defaultData.cancelButton,
...composableData.value?.cancelButton,
...props.data?.cancelButton,
}
return {
...mergedData,
text: currentData.value.cancelText || mergedData.text,
}
})
const confirmButtonData = computed(() => {
const hasButton
Expand All @@ -70,18 +81,17 @@ const confirmButtonData = computed(() => {
if (!hasButton)
return
return {
const mergedData = {
...defaultData.confirmButton,
...composableData.value?.confirmButton,
...props.data?.confirmButton,
}
})
const currentData = computed<DialogData>(() => ({
...defaultData,
...composableData.value,
...props.data,
}))
return {
...mergedData,
text: currentData.value.confirmText || mergedData.text,
}
})
const currentModal = computed(
() => dialogState.value.find(({ id }) => id === props.identifier) as DialogState,
Expand Down Expand Up @@ -171,7 +181,7 @@ function customButtonAction(currentModal: DialogState, button: DialogCustomButto
@slot cancel-text slot - Place your cancel text
-->
<slot name="cancel-text">
{{ cancelButtonData.text || currentData?.cancelText }}
{{ cancelButtonData.text }}
</slot>
</MazBtn>
Expand All @@ -184,7 +194,7 @@ function customButtonAction(currentModal: DialogState, button: DialogCustomButto
@slot confirm-text slot - Place your confirm text
-->
<slot name="confirm-text">
{{ confirmButtonData.text || currentData.confirmText }}
{{ confirmButtonData.text }}
</slot>
</MazBtn>
</template>
Expand Down

0 comments on commit 13c26be

Please sign in to comment.