Skip to content

Commit

Permalink
feat: export feature completed
Browse files Browse the repository at this point in the history
clear
  • Loading branch information
devansh-webkul committed Sep 5, 2023
1 parent 2973f69 commit beb00ac
Show file tree
Hide file tree
Showing 22 changed files with 354 additions and 693 deletions.
9 changes: 4 additions & 5 deletions packages/Webkul/Admin/src/Exports/DataGridExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@ public function __construct(protected $gridData = [])
{
}

/**
/**
* function to create a blade view for export.
*
*/
public function view(): View
{
$columns = [];

foreach($this->gridData as $key => $gridData) {
foreach ($this->gridData as $key => $gridData) {
$columns = array_keys((array) $gridData);

break;
}

return view('admin::export.temp', [
return view('admin::components.datagrid.export.temp', [
'columns' => $columns,
'records' => $this->gridData,
]);
}
}
}
43 changes: 0 additions & 43 deletions packages/Webkul/Admin/src/Http/Controllers/ExportController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,70 +30,30 @@
Language - {{ core()->getCurrentLocale()->name }}
</p>
</div>

<div class="p-[6px] items-center cursor-pointer transition-all hover:bg-gray-100 hover:rounded-[6px]">
<!-- Export Modal -->
<x-admin::modal ref="exportModal">
<x-slot:toggle>
<p class="text-gray-600 font-semibold leading-[24px]">
Export
</p>
</x-slot:toggle>

<x-slot:header>
<p class="text-[18px] text-gray-800 font-bold">
@lang('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"
id="format"
>
<option value="xls">XLS</option>
<option value="csv">CLS</option>
</x-admin::form.control-group.control>
</x-admin::form.control-group>
</x-admin::form>
</div>
</x-slot:content>
<x-slot:footer>
<!-- Save Button -->
<button
type="submit"
class="primary-button"
>
@lang('Export')
</button>
</x-slot:footer>
</x-admin::modal>
</div>
</div>
</x-slot:content>
</x-admin::dropdown>

<!-- Export Modal -->
<x-admin::datagrid.export src="{{ route('admin.catalog.products.index') }}"></x-admin::datagrid.export>

{!! view_render_event('bagisto.admin.catalog.products.create.before') !!}

@if (bouncer()->hasPermission('catalog.products.create'))
<v-create-product-form>
<button
<button
type="button"
class="primary-button"
>
@lang('admin::app.catalog.products.index.create-btn')
</button>
</v-create-product-form>
@endif

{!! view_render_event('bagisto.admin.catalog.products.create.after') !!}
</div>
</div>

{!! view_render_event('bagisto.admin.catalog.products.list.before') !!}

{{-- Datagrid --}}
Expand All @@ -106,20 +66,20 @@ class="primary-button"
class="flex gap-[10px] items-center select-none"
v-for="(columnGroup, index) in [['name', 'sku', 'attribute_family'], ['base_image', 'price', 'quantity', 'product_id'], ['status', 'category_name', 'type']]"
>
<label
<label
class="flex gap-[4px] items-center w-max cursor-pointer select-none"
for="mass_action_select_all_records"
v-if="! index"
>
<input
type="checkbox"
<input
type="checkbox"
name="mass_action_select_all_records"
id="mass_action_select_all_records"
class="hidden peer"
:checked="['all', 'partial'].includes(applied.massActions.meta.mode)"
@change="selectAllRecords"
>

<span
class="icon-uncheckbox cursor-pointer rounded-[6px] text-[24px]"
:class="[
Expand Down Expand Up @@ -174,17 +134,17 @@ class="row grid grid-cols-[2fr_1fr_1fr] grid-rows-1 px-[16px] py-[10px] border-b
>
{{-- Name, SKU, Attribute Family Columns --}}
<div class="flex gap-[10px]">
<input
type="checkbox"
<input
type="checkbox"
:name="`mass_action_select_record_${record.product_id}`"
:id="`mass_action_select_record_${record.product_id}`"
:value="record.product_id"
class="hidden peer"
v-model="applied.massActions.indices"
@change="setCurrentSelectionMode"
>
<label

<label
class="icon-uncheckbox rounded-[6px] text-[24px] cursor-pointer peer-checked:icon-checked peer-checked:text-blue-600"
:for="`mass_action_select_record_${record.product_id}`"
></label>
Expand Down Expand Up @@ -234,7 +194,7 @@ class="absolute bottom-[1px] left-[1px] text-[12px] font-bold text-white bg-dark
</div>

<div class="flex flex-col gap-[6px]">
<p
<p
class="text-[16px] text-gray-800 font-semibold"
v-text="$admin.formatPrice(record.price)"
>
Expand All @@ -257,7 +217,7 @@ class="text-gray-600"
@lang('admin::app.catalog.products.index.datagrid.out-of-stock')
</span>
</p>

<p class="text-gray-600">
@{{ "@lang('admin::app.catalog.products.index.datagrid.id-value')".replace(':id', record.product_id) }}
</p>
Expand Down Expand Up @@ -306,7 +266,7 @@ class="text-gray-600"
<div>
<!-- Product Create Button -->
@if (bouncer()->hasPermission('catalog.products.create'))
<button
<button
type="button"
class="primary-button"
@click="$refs.productCreateModal.toggle()"
Expand All @@ -329,16 +289,16 @@ class="text-[18px] text-gray-800 font-bold"
v-if="! attributes.length"
>
@lang('admin::app.catalog.products.index.create.title')
</p>
</p>

<p
class="text-[18px] text-gray-800 font-bold"
v-else
>
@lang('admin::app.catalog.products.index.create.configurable-attributes')
</p>
</p>
</x-slot:header>

<x-slot:content>
<!-- Modal Content -->
<div class="px-[16px] py-[10px] border-b-[1px] border-gray-300">
Expand All @@ -349,7 +309,7 @@ class="text-[18px] text-gray-800 font-bold"
<x-admin::form.control-group.label class="required">
@lang('admin::app.catalog.products.index.create.type')
</x-admin::form.control-group.label>

<x-admin::form.control-group.control
type="select"
name="type"
Expand All @@ -362,15 +322,15 @@ class="text-[18px] text-gray-800 font-bold"
</option>
@endforeach
</x-admin::form.control-group.control>

<x-admin::form.control-group.error control-name="type"></x-admin::form.control-group.error>
</x-admin::form.control-group>

<x-admin::form.control-group>
<x-admin::form.control-group.label class="required">
@lang('admin::app.catalog.products.index.create.family')
</x-admin::form.control-group.label>

<x-admin::form.control-group.control
type="select"
name="attribute_family_id"
Expand All @@ -383,23 +343,23 @@ class="text-[18px] text-gray-800 font-bold"
</option>
@endforeach
</x-admin::form.control-group.control>

<x-admin::form.control-group.error control-name="attribute_family_id"></x-admin::form.control-group.error>
</x-admin::form.control-group>

<x-admin::form.control-group class="mb-[10px]">
<x-admin::form.control-group.label class="required">
@lang('admin::app.catalog.products.index.create.sku')
</x-admin::form.control-group.label>

<x-admin::form.control-group.control
type="text"
name="sku"
::rules="{ required: true, regex: /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$/ }"
:label="trans('admin::app.catalog.products.index.create.sku')"
>
</x-admin::form.control-group.control>

<x-admin::form.control-group.error control-name="sku"></x-admin::form.control-group.error>
</x-admin::form.control-group>

Expand Down Expand Up @@ -436,7 +396,7 @@ class="icon-cross text-white text-[18px] ml-[5px] cursor-pointer"
</div>
</div>
</x-slot:content>

<x-slot:footer>
<!-- Modal Submission -->
<div class="flex gap-x-[10px] items-center">
Expand All @@ -449,7 +409,7 @@ class="transparent-button hover:bg-gray-200"
@lang('admin::app.catalog.products.index.create.back-btn')
</button>

<button
<button
type="submit"
class="primary-button"
>
Expand Down Expand Up @@ -526,4 +486,4 @@ class="primary-button"
</script>
@endPushOnce

</x-admin::layouts>
</x-admin::layouts>
52 changes: 6 additions & 46 deletions packages/Webkul/Admin/src/Resources/views/cms/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,17 @@
Language - {{ core()->getCurrentLocale()->name }}
</p>
</div>

<div class="p-[6px] items-center cursor-pointer transition-all hover:bg-gray-100 hover:rounded-[6px]">
<!-- Export Modal -->
<x-admin::modal ref="exportModal">
<x-slot:toggle>
<p class="text-gray-600 font-semibold leading-[24px]">
Export
</p>
</x-slot:toggle>

<x-slot:header>
<p class="text-[18px] text-gray-800 font-bold">
@lang('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"
id="format"
>
<option value="xls">XLS</option>
<option value="csv">CLS</option>
</x-admin::form.control-group.control>
</x-admin::form.control-group>
</x-admin::form>
</div>
</x-slot:content>
<x-slot:footer>
<!-- Save Button -->
<button
type="submit"
class="primary-button"
>
@lang('Export')
</button>
</x-slot:footer>
</x-admin::modal>
</div>
</div>
</x-slot:content>
</x-admin::dropdown>

<!-- Export Modal -->
<x-admin::datagrid.export src="{{ route('admin.cms.index') }}"></x-admin::datagrid.export>

{{-- Create New Pages Button --}}
@if (bouncer()->hasPermission('cms.pages.create'))
<a
href="{{ route('admin.cms.create') }}"
<a
href="{{ route('admin.cms.create') }}"
class="primary-button"
>
@lang('admin::app.cms.index.create-btn')
Expand All @@ -91,4 +51,4 @@ class="primary-button"
</div>

<x-admin::datagrid src="{{ route('admin.cms.index') }}"></x-admin::datagrid>
</x-admin::layouts>
</x-admin::layouts>
Loading

0 comments on commit beb00ac

Please sign in to comment.