Wizard page re-factoring..
This commit is contained in:
parent
0536942bbd
commit
fdd1011b3a
@ -1,39 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wizard;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Models\Common\Media;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Traits\Modules;
|
||||
use App\Models\Common\Company;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class Data extends Controller
|
||||
class Wizard
|
||||
{
|
||||
use Modules;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function compose(View $view)
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-common-companies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-companies')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-common-companies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-common-companies')->only('destroy');
|
||||
$translations = $this->getTransalations();
|
||||
|
||||
$currencies = $this->getCurrencies();
|
||||
|
||||
// Prepare codes
|
||||
$codes = $this->getCurrencyCodes();
|
||||
|
||||
$taxes = $this->getTaxes();
|
||||
|
||||
$modules = $this->getFeaturedModules([
|
||||
'query' => [
|
||||
'limit' => 4
|
||||
]
|
||||
]);
|
||||
|
||||
$company = $this->getCompany();
|
||||
|
||||
$view->with([
|
||||
'translations' => $translations,
|
||||
'company' => $company,
|
||||
'currencies' => $currencies,
|
||||
'currency_codes' => $codes,
|
||||
'taxes' => $taxes,
|
||||
'modules' => $modules,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
/* Wizard page transactions */
|
||||
protected function getTransalations()
|
||||
{
|
||||
$translations = [
|
||||
return [
|
||||
'company' => [
|
||||
'title' => trans_choice('general.companies', 1),
|
||||
'api_key' => trans('modules.api_key'),
|
||||
@ -101,10 +120,15 @@ class Data extends Controller
|
||||
'error_message' => trans('errors.title.500'),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$currencies = Currency::collect();
|
||||
protected function getCurrencies()
|
||||
{
|
||||
return Currency::all();
|
||||
}
|
||||
|
||||
// Prepare codes
|
||||
protected function getCurrencyCodes()
|
||||
{
|
||||
$codes = [];
|
||||
$money_currencies = MoneyCurrency::getCurrencies();
|
||||
|
||||
@ -112,39 +136,28 @@ class Data extends Controller
|
||||
$codes[$key] = $key;
|
||||
}
|
||||
|
||||
$taxes = Tax::collect();
|
||||
return $codes;
|
||||
}
|
||||
|
||||
$modules = $this->getFeaturedModules([
|
||||
'query' => [
|
||||
'limit' => 4
|
||||
]
|
||||
]);
|
||||
protected function getTaxes()
|
||||
{
|
||||
return Tax::all();
|
||||
}
|
||||
|
||||
protected function getCompany()
|
||||
{
|
||||
$company = company();
|
||||
|
||||
$company->api_key = setting('apps.api_key');
|
||||
$company->financial_start = setting('localisation.financial_start');
|
||||
|
||||
if ($company->logo) {
|
||||
$logo = \Plank\Mediable\Media::find($company->logo);
|
||||
$logo_id = setting('company.logo');
|
||||
|
||||
$logo = Media::find($logo_id);
|
||||
$logo->path = route('uploads.get', $logo->id);
|
||||
|
||||
$company->logo = $logo;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'errors' => false,
|
||||
'message' => 'Get all data...',
|
||||
'data' => [
|
||||
'translations' => $translations,
|
||||
'company' => $company,
|
||||
'currencies' => $currencies,
|
||||
'currency_codes' => $codes,
|
||||
'taxes' => $taxes,
|
||||
'modules' => $modules,
|
||||
],
|
||||
]);
|
||||
return $company;
|
||||
}
|
||||
}
|
@ -73,6 +73,11 @@ class ViewComposer extends Provider
|
||||
['documents.*', 'portal.documents.*'],
|
||||
'App\Http\ViewComposers\DocumentType'
|
||||
);
|
||||
|
||||
// Wizard
|
||||
View::composer(
|
||||
'layouts.wizard', 'App\Http\ViewComposers\Wizard'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,42 +13,35 @@
|
||||
<script>
|
||||
export default {
|
||||
name: "Wizard",
|
||||
|
||||
created() {
|
||||
let self = this;
|
||||
this.translations = wizard_translations;
|
||||
this.company = wizard_company;
|
||||
this.currencies = wizard_currencies;
|
||||
this.currency_codes = wizard_currency_codes;
|
||||
this.taxes = wizard_taxes;
|
||||
this.modules = wizard_modules;
|
||||
|
||||
window
|
||||
.axios({
|
||||
method: "GET",
|
||||
url: url + "/wizard/data",
|
||||
})
|
||||
.then((response) => {
|
||||
let data = response.data.data;
|
||||
|
||||
for (let item in data) {
|
||||
self[item] = data[item];
|
||||
}
|
||||
|
||||
Object.keys(data.currency_codes).map((key) => {
|
||||
return data.currency_codes[key];
|
||||
Object.keys(this.currency_codes).map((key) => {
|
||||
return this.currency_codes[key];
|
||||
});
|
||||
|
||||
self.page_loaded = false;
|
||||
});
|
||||
this.page_loaded = false;
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
currencies: [],
|
||||
currency_codes: [],
|
||||
taxes: [],
|
||||
modules: {},
|
||||
company: {},
|
||||
translations: {
|
||||
company: {},
|
||||
currencies: {},
|
||||
taxes: {},
|
||||
finish: {},
|
||||
},
|
||||
company: {},
|
||||
currencies: [],
|
||||
currency_codes: [],
|
||||
taxes: [],
|
||||
modules: {},
|
||||
page_loaded: true
|
||||
};
|
||||
},
|
||||
|
@ -3,6 +3,7 @@
|
||||
<h1 class="text-white">
|
||||
{{ translations.company.title }}
|
||||
</h1>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header wizard-header p-3">
|
||||
<el-steps :active="active" finish-status="success" align-center>
|
||||
@ -12,14 +13,16 @@
|
||||
<el-step :title="translations.finish.title"></el-step>
|
||||
</el-steps>
|
||||
</div>
|
||||
<form ref="form" class="w-100">
|
||||
|
||||
<form ref="form" class="w-100 mb-0">
|
||||
<div class="card-body">
|
||||
<div class="document-loading" v-if="pageLoad">
|
||||
<div>
|
||||
<i class="fas fa-spinner fa-pulse fa-7x"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
|
||||
<div class="row mb-0">
|
||||
<div class="col-12 mb-4">
|
||||
<base-input
|
||||
:label="translations.company.api_key"
|
||||
@ -29,18 +32,18 @@
|
||||
prepend-icon="fas fa-key"
|
||||
v-model="company.api_key"
|
||||
/>
|
||||
|
||||
<p class="mb-0 mt--3">
|
||||
<small>
|
||||
<div>
|
||||
<a href="https://akaunting.com/dashboard" target="_blank"
|
||||
>Click here</a
|
||||
>
|
||||
<a href="https://akaunting.com/dashboard" target="_blank">Click here</a>
|
||||
to get your API key.
|
||||
</div>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-6 mb-4">
|
||||
|
||||
<div class="col-6">
|
||||
<base-input
|
||||
type="text"
|
||||
:label="translations.company.tax_number"
|
||||
@ -51,7 +54,7 @@
|
||||
v-model="company.tax_number"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6 mb-4">
|
||||
<div class="col-6">
|
||||
<akaunting-date
|
||||
:title="translations.company.financial_start"
|
||||
data-name="financial_start"
|
||||
@ -66,7 +69,8 @@
|
||||
v-model="real_date"
|
||||
></akaunting-date>
|
||||
</div>
|
||||
<div class="col-12 mb-4">
|
||||
|
||||
<div class="col-12">
|
||||
<base-input :label="translations.company.address">
|
||||
<textarea
|
||||
class="form-control"
|
||||
@ -78,10 +82,9 @@
|
||||
></textarea>
|
||||
</base-input>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<label class="form-control-label">{{
|
||||
translations.company.logo
|
||||
}}</label>
|
||||
|
||||
<div class="col-3 mb-0">
|
||||
<label class="form-control-label">{{ translations.company.logo }}</label>
|
||||
<akaunting-dropzone-file-upload
|
||||
ref="dropzoneWizard"
|
||||
preview-classes="single"
|
||||
@ -92,6 +95,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
@ -100,11 +104,9 @@
|
||||
type="success"
|
||||
native-type="button"
|
||||
@click="onEditSave()"
|
||||
>{{ translations.company.save }}</base-button
|
||||
>
|
||||
<base-button type="white" native-type="submit" @click="next()">{{
|
||||
translations.company.skip
|
||||
}}</base-button>
|
||||
>{{ translations.company.save }}</base-button>
|
||||
|
||||
<base-button type="white" native-type="submit" @click="next()">{{ translations.company.skip }}</base-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,6 +4,15 @@
|
||||
<script src="{{ asset('public/vendor/bootstrap/dist/js/bootstrap.bundle.min.js') }}"></script>
|
||||
<script src="{{ asset('public/vendor/js-cookie/js.cookie.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var wizard_translations = {!! json_encode($translations) !!};
|
||||
var wizard_company = {!! json_encode($company) !!};
|
||||
var wizard_currencies = {!! json_encode($currencies) !!};
|
||||
var wizard_currency_codes = {!! json_encode($currency_codes) !!};
|
||||
var wizard_taxes = {!! json_encode($taxes) !!};
|
||||
var wizard_modules = {!! json_encode($modules) !!};
|
||||
</script>
|
||||
|
||||
<script src="{{ asset('public/js/wizard/wizard.js?v=' . version('short')) }}"></script>
|
||||
|
||||
@stack('body_css')
|
||||
|
@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
|
||||
Route::group(['as' => 'wizard.'], function () {
|
||||
Route::get('data', 'Wizard\Data@index')->name('data.index');
|
||||
|
||||
Route::get('companies', 'Wizard\Companies@edit')->name('companies.edit');
|
||||
Route::post('companies', 'Wizard\Companies@update')->middleware('dropzone')->name('companies.update');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user