Skip to content

Commit

Permalink
fix manage composer
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Mar 18, 2024
1 parent a70c5d1 commit ba3a91c
Show file tree
Hide file tree
Showing 96 changed files with 7,792 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@props([
'isActive' => true,
])

<v-accordion
is-active="{{ $isActive }}"
{{ $attributes }}
>
<x-admin::shimmer.accordion class="w-[360px] h-[271px]"></x-admin::shimmer.accordion>

@isset($header)
<template v-slot:header>
{{ $header }}
</template>
@endisset

@isset($content)
<template v-slot:content>
<div>
{{ $content }}
</div>
</template>
@endisset
</v-accordion>

@pushOnce('scripts')
<script type="text/x-template" id="v-accordion-template">
<div {{ $attributes->merge(['class' => 'bg-white dark:bg-gray-900 rounded-[4px] box-shadow']) }}>
<div :class="`flex items-center justify-between p-[6px] ${isOpen ? 'active' : ''}`">
<slot name="header">
Default Header
</slot>

<span
:class="`text-[24px] p-[6px] rounded-[6px] cursor-pointer transition-all hover:bg-gray-100 dark:hover:bg-gray-950 ${isOpen ? 'icon-arrow-up' : 'icon-arrow-down'}`"
@click="toggle"
></span>
</div>

<div class="px-[16px] pb-[16px]" v-if="isOpen">
<slot name="content">
Default Content
</slot>
</div>
</div>
</script>

<script type="module">
app.component('v-accordion', {
template: '#v-accordion-template',
props: [
'isActive',
],
data() {
return {
isOpen: this.isActive,
};
},
methods: {
toggle() {
this.isOpen = ! this.isOpen;
this.$emit('toggle', { isActive: this.isOpen });
},
},
});
</script>
@endPushOnce
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@props([
'name' => '',
'entity' => null,
])

<div class="flex justify-start mt-[30px] max-lg:hidden">
<div class="flex gap-x-[14px] items-center">
{{ Breadcrumbs::view('shop::partials.breadcrumbs', $name, $entity) }}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<v-charts-bar {{ $attributes }}></v-charts-bar>

@pushOnce('scripts')
{{-- SEO Vue Component Template --}}
<script type="text/x-template" id="v-charts-bar-template">
<canvas
:id="$.uid + '_chart'"
class="flex items-end w-full aspect-[3.23/1]"
></canvas>
</script>

<script type="module">
app.component('v-charts-bar', {
template: '#v-charts-bar-template',
props: ['labels', 'datasets'],
data() {
return {
chart: undefined,
}
},
mounted() {
this.prepare();
},
methods: {
prepare() {
if (this.chart) {
this.chart.destroy();
}
this.chart = new Chart(document.getElementById(this.$.uid + '_chart'), {
type: 'bar',
data: {
labels: this.labels,
datasets: this.datasets,
},
options: {
aspectRatio: 3.17,
plugins: {
legend: {
display: false
},
{{-- tooltip: {
enabled: false,
} --}}
},
scales: {
x: {
beginAtZero: true,
border: {
dash: [8, 4],
}
},
y: {
beginAtZero: true,
border: {
dash: [8, 4],
}
}
}
}
});
}
}
});
</script>
@endPushOnce
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<v-charts-line {{ $attributes }}></v-charts-line>

@pushOnce('scripts')
{{-- SEO Vue Component Template --}}
<script type="text/x-template" id="v-charts-line-template">
<canvas
:id="$.uid + '_chart'"
class="flex items-end w-full aspect-[3.23/1]"
></canvas>
</script>

<script type="module">
app.component('v-charts-line', {
template: '#v-charts-line-template',
props: ['labels', 'datasets'],
data() {
return {
chart: undefined,
}
},
mounted() {
this.prepare();
},
methods: {
prepare() {
if (this.chart) {
this.chart.destroy();
}
this.chart = new Chart(document.getElementById(this.$.uid + '_chart'), {
type: 'line',
data: {
labels: this.labels,
datasets: this.datasets,
},
options: {
aspectRatio: 3.17,
plugins: {
legend: {
display: false
},
{{-- tooltip: {
enabled: false,
} --}}
},
scales: {
x: {
beginAtZero: true,
border: {
dash: [8, 4],
}
},
y: {
beginAtZero: true,
border: {
dash: [8, 4],
}
}
}
}
});
}
}
});
</script>
@endPushOnce
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<v-datagrid-export {{ $attributes }}>
<div class="p-[6px] items-center cursor-pointer transition-all hover:bg-gray-200 dark:hover:bg-gray-800 hover:rounded-[6px]">
<p class="text-gray-600 dark:text-gray-300 font-semibold leading-[24px]">
@lang('manage::app.export.export')
</p>
</div>
</v-datagrid-export>

@pushOnce('scripts')
<script type="text/x-template" id="v-datagrid-export-template">
<div class="p-[6px] items-center cursor-pointer transition-all hover:bg-gray-200 dark:hover:bg-gray-800 hover:rounded-[6px]">
<x-admin::modal ref="exportModal">
<x-slot:toggle>
<p class="text-gray-600 dark:text-gray-300 font-semibold leading-[24px]">
@lang('manage::app.export.export')
</p>
</x-slot:toggle>

<x-slot:header>
<p class="text-[18px] text-gray-800 dark:text-white font-bold">
@lang('manage::app.export.download')
</p>
</x-slot:header>

<x-slot:content>
<div class="p-[16px]">
<x-admin::form action="">
<x-admin::form.control-group>
<x-admin::form.control-group.control
type="select"
name="format"
v-model="format"
>
<option value="xls">@lang('manage::app.export.xls')</option>
<option value="csv">@lang('manage::app.export.csv')</option>
</x-admin::form.control-group.control>
</x-admin::form.control-group>
</x-admin::form>
</div>
</x-slot:content>

<x-slot:footer>
<button
type="button"
class="primary-button"
@click="download"
>
@lang('manage::app.export.export')
</button>
</x-slot:footer>
</x-admin::modal>
</div>
</script>

<script type="module">
app.component('v-datagrid-export', {
template: '#v-datagrid-export-template',
props: ['src'],
data() {
return {
format: 'xls',
available: null,
applied: null,
};
},
mounted() {
this.registerEvents();
},
methods: {
registerEvents() {
this.$emitter.on('change-datagrid', this.updateProperties);
},
updateProperties({available, applied }) {
this.available = available;
this.applied = applied;
},
download() {
if (! this.available?.records?.length) {
this.$emitter.emit('add-flash', { type: 'warning', message: '@lang('manage::app.export.no-records')' });
this.$refs.exportModal.toggle();
} else {
let params = {
export: 1,
format: this.format,
sort: {},
filters: {},
};
if (
this.applied.sort.column &&
this.applied.sort.order
) {
params.sort = this.applied.sort;
}
this.applied.filters.columns.forEach(column => {
params.filters[column.index] = column.value;
});
this.$axios
.get(this.src, {
params,
responseType: 'blob',
})
.then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
/**
* Link generation.
*/
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `${(Math.random() + 1).toString(36).substring(7)}.${this.format}`);
/**
* Adding a link to a document, clicking on the link, and then removing the link.
*/
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.$refs.exportModal.toggle();
});
}
},
},
});
</script>
@endPushOnce
Loading

0 comments on commit ba3a91c

Please sign in to comment.