edit column re-factoring dynamic
This commit is contained in:
		@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Modals;
 | 
			
		||||
use App\Abstracts\Http\Controller;
 | 
			
		||||
use App\Http\Requests\Setting\Setting as Request;
 | 
			
		||||
 | 
			
		||||
class InvoiceItemColumns extends Controller
 | 
			
		||||
class DocumentItemColumns extends Controller
 | 
			
		||||
{
 | 
			
		||||
    public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template'];
 | 
			
		||||
 | 
			
		||||
@@ -25,21 +25,23 @@ class InvoiceItemColumns extends Controller
 | 
			
		||||
     */
 | 
			
		||||
    public function edit()
 | 
			
		||||
    {
 | 
			
		||||
        $type = request()->get('type', 'invoice');
 | 
			
		||||
 | 
			
		||||
        $item_names = [
 | 
			
		||||
            'settings.invoice.item' => trans('settings.invoice.item'),
 | 
			
		||||
            'settings.invoice.product' => trans('settings.invoice.product'),
 | 
			
		||||
            'settings.invoice.service' =>  trans('settings.invoice.service'),
 | 
			
		||||
            'settings.invoice.item' => trans('settings.' . $type . '.item'),
 | 
			
		||||
            'settings.invoice.product' => trans('settings.' . $type . '.product'),
 | 
			
		||||
            'settings.invoice.service' =>  trans('settings.' . $type . '.service'),
 | 
			
		||||
            'custom' => trans('settings.invoice.custom'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $price_names = [
 | 
			
		||||
            'settings.invoice.price' => trans('settings.invoice.price'),
 | 
			
		||||
            'settings.invoice.rate' => trans('settings.invoice.rate'),
 | 
			
		||||
            'settings.invoice.price' => trans('settings.' . $type . '.price'),
 | 
			
		||||
            'settings.invoice.rate' => trans('settings.' . $type . '.rate'),
 | 
			
		||||
            'custom' => trans('settings.invoice.custom'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $quantity_names = [
 | 
			
		||||
            'settings.invoice.quantity' => trans('settings.invoice.quantity'),
 | 
			
		||||
            'settings.invoice.quantity' => trans('settings.' . $type . '.quantity'),
 | 
			
		||||
            'custom' => trans('settings.invoice.custom'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
@@ -52,7 +54,8 @@ class InvoiceItemColumns extends Controller
 | 
			
		||||
            '90' => trans('settings.invoice.due_days', ['days' => 90]),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $html = view('modals.invoices.item_columns', compact(
 | 
			
		||||
        $html = view('modals.documents.item_columns', compact(
 | 
			
		||||
            'type',
 | 
			
		||||
            'item_names',
 | 
			
		||||
            'price_names',
 | 
			
		||||
            'quantity_names',
 | 
			
		||||
@@ -6,14 +6,17 @@ use Illuminate\View\Component;
 | 
			
		||||
 | 
			
		||||
class EditItemColumns extends Component
 | 
			
		||||
{
 | 
			
		||||
    /*  string */
 | 
			
		||||
    public $type;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new component instance.
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    public function __construct(string $type = 'invoice')
 | 
			
		||||
    {
 | 
			
		||||
        //
 | 
			
		||||
        $this->type = $type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -34,8 +34,8 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    type: {
 | 
			
		||||
      type: String,
 | 
			
		||||
      default: 'sale',
 | 
			
		||||
      description: 'Show item price'
 | 
			
		||||
      default: 'invoice',
 | 
			
		||||
      description: 'document type'
 | 
			
		||||
    },
 | 
			
		||||
    editColumn: {
 | 
			
		||||
        type: Object,
 | 
			
		||||
@@ -67,7 +67,9 @@ export default {
 | 
			
		||||
    onEditItemColumns() {
 | 
			
		||||
      let edit_column = this.edit_column;
 | 
			
		||||
 | 
			
		||||
      window.axios.get(url + '/modals/invoices/item-columns/edit')
 | 
			
		||||
      window.axios.get(url + '/modals/documents/item-columns/edit', {
 | 
			
		||||
          type: 
 | 
			
		||||
      })
 | 
			
		||||
      .then(response => {
 | 
			
		||||
          edit_column.show = true;
 | 
			
		||||
          edit_column.html = response.data.html;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
<akaunting-edit-item-columns
 | 
			
		||||
    type="{{ $type }}"
 | 
			
		||||
    :edit-column="{{ json_encode([
 | 
			
		||||
        'status' => true,
 | 
			
		||||
        'text' => trans('general.add_new'),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								resources/views/modals/documents/item_columns.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								resources/views/modals/documents/item_columns.blade.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
{!! Form::open([
 | 
			
		||||
    'id' => 'form-item-column',
 | 
			
		||||
    'method' => 'PATCH',
 | 
			
		||||
    'route' => 'modals.documents.item-columns.update',
 | 
			
		||||
    '@submit.prevent' => 'onSubmit',
 | 
			
		||||
    '@keydown' => 'form.errors.clear($event.target.name)',
 | 
			
		||||
    'files' => true,
 | 
			
		||||
    'role' => 'form',
 | 
			
		||||
    'class' => 'form-loading-button',
 | 
			
		||||
    'novalidate' => true,
 | 
			
		||||
]) !!}
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        {{ Form::invoice_text('item_name', trans('settings.invoice.item_name'), 'font', $item_names, setting($type . '.item_name'), [], 'item_name_input', setting($type . '.item_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::invoice_text('price_name', trans('settings.invoice.price_name'), 'font', $price_names, setting($type . '.price_name'), [], 'price_name_input', setting($type . '.price_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::invoice_text('quantity_name', trans('settings.invoice.quantity_name'), 'font', $quantity_names, setting($type . '.quantity_name'), [], 'quantity_name_input', setting($type . '.quantity_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_item_name', trans('settings.invoice.hide.item_name'), setting($type . '.hide_item_name', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_item_description', trans('settings.invoice.hide.item_description'), setting($type . '.hide_item_description', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_quantity', trans('settings.invoice.hide.quantity'), setting($type . '.hide_quantity', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_price', trans('settings.invoice.hide.price'), setting($type . '.hide_price', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_amount', trans('settings.invoice.hide.amount'), setting($type . '.hide_amount', null)) }}
 | 
			
		||||
 | 
			
		||||
        {!! Form::hidden('type', $type) !!}
 | 
			
		||||
        {!! Form::hidden('_prefix', $type) !!}
 | 
			
		||||
    </div>
 | 
			
		||||
{!! Form::close() !!}
 | 
			
		||||
@@ -1,31 +0,0 @@
 | 
			
		||||
{!! Form::open([
 | 
			
		||||
    'id' => 'form-item-column',
 | 
			
		||||
    'method' => 'PATCH',
 | 
			
		||||
    'route' => 'modals.invoices.item-columns.update',
 | 
			
		||||
    '@submit.prevent' => 'onSubmit',
 | 
			
		||||
    '@keydown' => 'form.errors.clear($event.target.name)',
 | 
			
		||||
    'files' => true,
 | 
			
		||||
    'role' => 'form',
 | 
			
		||||
    'class' => 'form-loading-button',
 | 
			
		||||
    'novalidate' => true,
 | 
			
		||||
]) !!}
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        {{ Form::invoice_text('item_name', trans('settings.invoice.item_name'), 'font', $item_names, setting('invoice.item_name'), [], 'item_name_input', setting('invoice.item_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::invoice_text('price_name', trans('settings.invoice.price_name'), 'font', $price_names, setting('invoice.price_name'), [], 'price_name_input', setting('invoice.price_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::invoice_text('quantity_name', trans('settings.invoice.quantity_name'), 'font', $quantity_names, setting('invoice.quantity_name'), [], 'quantity_name_input', setting('invoice.quantity_name_input', null), 'col-md-12') }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_item_name', trans('settings.invoice.hide.item_name'), setting('invoice.hide_item_name', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_item_description', trans('settings.invoice.hide.item_description'), setting('invoice.hide_item_description', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_quantity', trans('settings.invoice.hide.quantity'), setting('invoice.hide_quantity', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_price', trans('settings.invoice.hide.price'), setting('invoice.hide_price', null)) }}
 | 
			
		||||
 | 
			
		||||
        {{ Form::radioGroup('hide_amount', trans('settings.invoice.hide.amount'), setting('invoice.hide_amount', null)) }}
 | 
			
		||||
 | 
			
		||||
        {!! Form::hidden('_prefix', 'invoice') !!}
 | 
			
		||||
    </div>
 | 
			
		||||
{!! Form::close() !!}
 | 
			
		||||
@@ -230,8 +230,8 @@ Route::group(['as' => 'modals.', 'prefix' => 'modals'], function () {
 | 
			
		||||
    Route::resource('vendors', 'Modals\Vendors');
 | 
			
		||||
    Route::resource('items', 'Modals\Items');
 | 
			
		||||
    Route::patch('invoice-templates', 'Modals\InvoiceTemplates@update')->name('invoice-templates.update');
 | 
			
		||||
    Route::get('invoices/item-columns/edit', 'Modals\InvoiceItemColumns@edit')->name('invoices.item-columns.edit');
 | 
			
		||||
    Route::patch('invoices/item-columns', 'Modals\InvoiceItemColumns@update')->name('invoices.item-columns.update');
 | 
			
		||||
    Route::get('documents/item-columns/edit', 'Modals\DocumentItemColumns@edit')->name('documents.item-columns.edit');
 | 
			
		||||
    Route::patch('documents/item-columns', 'Modals\DocumentItemColumns@update')->name('documents.item-columns.update');
 | 
			
		||||
    Route::resource('invoices/{invoice}/transactions', 'Modals\InvoiceTransactions', ['names' => 'invoices.invoice.transactions', 'middleware' => ['date.format', 'money']]);
 | 
			
		||||
    Route::resource('bills/{bill}/transactions', 'Modals\BillTransactions', ['names' => 'bills.bill.transactions', 'middleware' => ['date.format', 'money']]);
 | 
			
		||||
    Route::resource('taxes', 'Modals\Taxes');
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user