Skip to content

Commit ef370cc

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 2c0c9bc + 456983b commit ef370cc

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

resources/js/Components/Elements/Buttons/Button.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (props.style == 'primary' || props.style == 'create' || props.style == 'save'
4141
else if (props.style == 'secondary' || props.style == 'edit') styleClass = 'border border-gray-400/80 bg-gray-200 text-gray-700 hover:bg-gray-400/60'
4242
else if (props.style == 'tertiary') styleClass = 'border border-gray-300 dark:border-gray-500 bg-transparent text-gray-700 dark:text-gray-400 hover:bg-gray-200/70 dark:hover:bg-gray-600/90'
4343
else if (props.style == 'delete') styleClass = 'border border-red-400 dark:border-red-600 text-red-500 dark:text-red-600 hover:text-red-800 hover:bg-red-100 dark:hover:bg-red-100/10 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2'
44-
else if (props.style == 'negative') styleClass = 'border border-red-400 dark:border-red-800 text-red-600 dark:text-red-700 hover:text-red-800 hover:bg-red-100 dark:hover:bg-red-100/10 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2'
44+
else if (props.style == 'negative' || props.style == 'cancel') styleClass = 'border border-red-400 dark:border-red-800 text-red-600 dark:text-red-700 hover:text-red-800 hover:bg-red-100 dark:hover:bg-red-100/10 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2'
4545
else if (props.style == 'disabled') styleClass = 'cursor-not-allowed border border-gray-300 dark:border-gray-500 bg-transparent text-gray-700 dark:text-gray-400 hover:bg-gray-200/70 dark:hover:bg-gray-600/90'
4646
else styleClass = 'border border-gray-300 bg-transparent text-gray-700 dark:text-gray-400 hover:bg-gray-200/70'
4747
@@ -130,7 +130,9 @@ const getActionIcon = (icon: any) => {
130130
sizeClass
131131
]" :disabled="style == 'disabled'">
132132
<slot>
133-
<FontAwesomeIcon v-if="getActionIcon(icon)" :icon="getActionIcon(icon)" class="" aria-hidden="true"/>
133+
<slot name="icon">
134+
<FontAwesomeIcon v-if="getActionIcon(icon)" :icon="getActionIcon(icon)" class="" aria-hidden="true"/>
135+
</slot>
134136
<span class="">{{ getActionLabel(label) }}</span>
135137
</slot>
136138
</button>

resources/js/Components/Utils/Popover.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const props = defineProps({
1111
</script>
1212

1313
<template>
14-
<Popover :popover-placement="'bottom-start'">
14+
<Popover :popover-placement="'bottom-start'" v-slot="{ open }">
1515
<PopoverButton>
16-
<slot name="button"></slot>
16+
<slot name="button" :isOpen="open"></slot>
1717
</PopoverButton>
1818

1919
<slot name="popup">

resources/js/Pages/Customer/Banners/BannerWorkshop.vue

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const props = defineProps<{
105105
106106
107107
const user = ref(usePage().props.auth.user)
108-
const isPopoverOpen = ref(false)
108+
const isLoading = ref(false)
109109
const comment = ref('')
110110
const loadingState = ref(false)
111111
const isSetData = ref(false)
@@ -120,18 +120,19 @@ const compCurrentHash = computed(() => {
120120
121121
// When click 'Publish'
122122
const sendDataToServer = async () => {
123+
isLoading.value = true
123124
const formValues = {
124125
...deleteUser(),
125126
...(props.banner.state !== 'unpublished' && { comment: comment.value }),
126127
published_hash: compCurrentHash.value // include Hash to save to server
127128
}
128-
129129
const form = useForm(formValues)
130+
130131
form.patch(
131132
route(props.publishRoute['name'], props.publishRoute['parameters']), {
132133
onSuccess: async (res) => {
133134
await set(getDbRef(dbPath), { published_hash: compCurrentHash.value })
134-
// isPopoverOpen.value = false
135+
isLoading.value = false
135136
router.visit(route(routeExit['route']['name'], routeExit['route']['parameters']))
136137
notify({
137138
title: "success Update",
@@ -240,10 +241,10 @@ const autoSave = () => {
240241
watch(data, updateData, { deep: true })
241242
242243
243-
const validationState=()=>{
244-
if(props.banner.state !== 'live') sendDataToServer()
245-
else isPopoverOpen.value = true
246-
}
244+
// const validationState=()=>{
245+
// if(props.banner.state !== 'live') sendDataToServer()
246+
// else isPopoverOpen.value = true
247+
// }
247248
248249
const intervalAutoSave = ref(null)
249250
@@ -269,17 +270,31 @@ const stopInterval=()=>{
269270
<PageHeading :data="pageHead">
270271
<template #other="{ dataPageHead: head }">
271272
<div class="flex items-center gap-2 relative">
272-
<Popover >
273-
<template #button>
274-
<!-- 'fd186208ae9dab06d40e49141f34bef9' is Hash from empty data -->
275-
<Button label="Publish" :style="compCurrentHash == 'fd186208ae9dab06d40e49141f34bef9' ? 'disabled' : compCurrentHash == data.published_hash ? 'disabled' : 'primary'" :key="compCurrentHash" :icon="['far', 'rocket-launch']" @click="validationState()"
276-
class="">
277-
</Button>
278-
</template>
279273

280-
<template v-if="banner.state == 'unpublished'" #popup>
281-
<div></div>
282-
<!-- Call template to replace the Popover (so the popup isn't appear) -->
274+
<!-- 'fd186208ae9dab06d40e49141f34bef9' is Hash from empty data -->
275+
<Button v-if="banner.state == 'unpublished'"
276+
label="Publish"
277+
:style="compCurrentHash == 'fd186208ae9dab06d40e49141f34bef9' ? 'disabled' : compCurrentHash == data.published_hash ? 'disabled' : 'primary'"
278+
:key="compCurrentHash"
279+
icon="far fa-rocket-launch"
280+
@click="sendDataToServer()"
281+
/>
282+
283+
<!-- If banner already Live, then appear Popover 'comment' before publish -->
284+
<Popover v-else>
285+
<template #button="{ isOpen }">
286+
<Button v-if="!isOpen" label="Publish"
287+
:style="compCurrentHash == 'fd186208ae9dab06d40e49141f34bef9'
288+
? 'disabled'
289+
: compCurrentHash == data.published_hash
290+
? 'disabled'
291+
: isOpen
292+
? 'cancel'
293+
: 'primary'"
294+
:key="compCurrentHash"
295+
icon="far fa-rocket-launch"
296+
/>
297+
<Button v-else :style="`cancel`" icon="fal fa-times" label="Cancel" />
283298
</template>
284299

285300
<!-- Popover: if already live, add comment to publish it again -->
@@ -294,7 +309,12 @@ const stopInterval=()=>{
294309
class="block rounded-md shadow-sm dark:bg-gray-600 dark:text-gray-400 border-gray-300 dark:border-gray-500 focus:border-gray-500 focus:ring-gray-500 sm:text-sm" />
295310
</div>
296311
<div class="flex justify-end">
297-
<Button size="xs" @click="sendDataToServer" icon="far fa-rocket-launch" label="Publish" :key="comment.length" :style="comment.length ? 'primary' : 'disabled'"/>
312+
<Button size="xs" @click="sendDataToServer" icon="far fa-rocket-launch" label="Publish" :key="comment.length" :style="comment.length ? 'primary' : 'disabled'">
313+
<template #icon>
314+
<FontAwesomeIcon v-if="isLoading" icon='fad fa-spinner-third' class='animate-spin' aria-hidden='true' />
315+
<FontAwesomeIcon v-else icon='far fa-rocket-launch' class='' aria-hidden='true' />
316+
</template>
317+
</Button>
298318
</div>
299319
</div>
300320
</template>

0 commit comments

Comments
 (0)