diff --git a/app/Http/Controllers/Settings/Settings.php b/app/Http/Controllers/Settings/Settings.php index 4a3a8d554..f84bfd6a7 100644 --- a/app/Http/Controllers/Settings/Settings.php +++ b/app/Http/Controllers/Settings/Settings.php @@ -177,4 +177,4 @@ class Settings extends Controller break; } } -} +} \ No newline at end of file diff --git a/app/Http/Controllers/Wizard/Companies.php b/app/Http/Controllers/Wizard/Companies.php index d28d95afc..366a0fb87 100644 --- a/app/Http/Controllers/Wizard/Companies.php +++ b/app/Http/Controllers/Wizard/Companies.php @@ -33,7 +33,7 @@ class Companies extends Controller { $company = Company::find(company_id()); - return view('wizard.companies.edit', compact('company')); + return $this->response('wizard.companies.edit', compact('company')); } /** @@ -52,6 +52,7 @@ class Companies extends Controller $skip_keys = ['company_id', '_method', '_token']; $file_keys = ['company.logo']; + $uploaded_file_keys = ['company.uploaded_logo']; foreach ($fields as $key => $value) { // Don't process unwanted keys @@ -70,13 +71,18 @@ class Companies extends Controller $real_key = 'company.' . $key; } - // Process file uploads - if (in_array($real_key, $file_keys)) { + // change dropzone middleware already uploaded file + if (in_array($real_key, $uploaded_file_keys)) { + continue; + } + + // Process file uploads + if (in_array($real_key, $file_keys)) { // Upload attachment if ($request->file($key)) { $media = $this->getMedia($request->file($key), 'settings'); - $company->attachMedia($media, Str::snake($key)); + $company->attachMedia($media, Str::snake($real_key)); $value = $media->id; } @@ -87,25 +93,18 @@ class Companies extends Controller } } - setting()->set($real_key, $value); + setting()->set($real_key, $value); } // Save all settings setting()->save(); - $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 2)]); - - $response = [ + return response()->json([ 'status' => null, 'success' => true, 'error' => false, - 'message' => $message, + 'message' => trans('messages.success.updated', ['type' => trans_choice('general.companies', 2)]), 'data' => null, - 'redirect' => route('wizard.currencies.index'), - ]; - - flash($message)->success(); - - return response()->json($response); + ]); } } diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index 16fa0bbeb..0e5f9f259 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -44,7 +44,7 @@ class Currencies extends Controller $codes[$key] = $key; } - return view('wizard.currencies.index', compact('currencies', 'codes')); + return $this->response('wizard.currencies.index', compact('currencies', 'codes')); } /** @@ -58,19 +58,14 @@ class Currencies extends Controller { $response = $this->ajaxDispatch(new CreateCurrency($request)); - $response['redirect'] = route('wizard.currencies.index'); - if ($response['success']) { - $message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['message'] = $message; + return response()->json($response); } @@ -86,18 +81,14 @@ class Currencies extends Controller { $response = $this->ajaxDispatch(new UpdateCurrency($currency, $request)); - $response['redirect'] = route('wizard.currencies.index'); - if ($response['success']) { $message = trans('messages.success.updated', ['type' => $currency->name]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['message'] = $message; + return response()->json($response); } @@ -110,20 +101,19 @@ class Currencies extends Controller */ public function destroy(Currency $currency) { - $response = $this->ajaxDispatch(new DeleteCurrency($currency)); + $currency_id = $currency->id; - $response['redirect'] = route('wizard.currencies.index'); + $response = $this->ajaxDispatch(new DeleteCurrency($currency)); if ($response['success']) { $message = trans('messages.success.deleted', ['type' => $currency->name]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['currency_id'] = $currency_id; + $response['message'] = $message; + return response()->json($response); } } diff --git a/app/Http/Controllers/Wizard/Data.php b/app/Http/Controllers/Wizard/Data.php new file mode 100644 index 000000000..fa3a43b9f --- /dev/null +++ b/app/Http/Controllers/Wizard/Data.php @@ -0,0 +1,150 @@ +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'); + } + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function index() + { + $translations = [ + 'company' => [ + 'title' => trans_choice('general.companies', 1), + 'api_key' => trans('modules.api_key'), + 'form_enter' => trans('general.form.enter'), + 'get_api_key' => trans('modules.get_api_key'), + 'tax_number' => trans('general.tax_number'), + 'financial_start' => trans('settings.localisation.financial_start'), + 'address' => trans('settings.company.address'), + 'logo' => trans('settings.company.logo'), + 'skip' => trans('general.skip'), + 'save' => trans('general.save'), + ], + + 'currencies' => [ + 'title' => trans_choice('general.currencies', 2), + 'add_new' => trans('general.add_new'), + 'name' => trans('general.name'), + 'code' => trans('currencies.code'), + 'rate' => trans('currencies.rate'), + 'enabled' => trans('general.enabled'), + 'actions' => trans('general.actions') , + 'yes' => trans('general.yes'), + 'no' => trans('general.no'), + 'edit' => trans('general.edit'), + 'delete' => trans('general.delete'), + 'save' => trans('general.save'), + 'precision' => trans('currencies.precision'), + 'symbol' => trans('currencies.symbol.symbol'), + 'position' => trans('currencies.symbol.position'), + 'decimal_mark' => trans('currencies.decimal_mark'), + 'thousands_separator' => trans('currencies.thousands_separator'), + 'previous' => trans('pagination.previous'), + 'next' => trans('pagination.next'), + 'delete_confirm' => trans('general.delete_confirm'), + 'cancel' => trans('general.cancel'), + ], + + 'taxes' => [ + 'title' => trans_choice('general.taxes', 2), + 'add_new' => trans('general.add_new'), + 'name' => trans('general.name'), + 'rate_percent' => trans('taxes.rate_percent'), + 'enabled' => trans('general.enabled'), + 'actions' => trans('general.actions'), + 'yes' => trans('general.yes'), + 'no' => trans('general.no'), + 'edit' => trans('general.edit'), + 'delete' => trans('general.delete'), + 'name' => trans('general.name'), + 'rate' => trans('currencies.rate'), + 'enabled' => trans('general.enabled'), + 'save' => trans('general.save'), + 'previous' => trans('pagination.previous'), + 'next' => trans('pagination.next'), + 'cancel' => trans('general.cancel'), + ], + + 'finish' => [ + 'title' => trans_choice('general.finish', 1), + 'recommended_apps' => trans('modules.recommended_apps'), + 'no_apps' => trans('modules.no_apps'), + 'developer' => trans('modules.developer'), + 'previous' => trans('pagination.previous'), + 'go_to_dashboard' => trans('general.go_to_dashboard'), + 'error_message' => trans('errors.title.500'), + ] + ]; + + $currencies = Currency::collect(); + + // Prepare codes + $codes = []; + $money_currencies = MoneyCurrency::getCurrencies(); + + foreach ($money_currencies as $key => $item) { + $codes[$key] = $key; + } + + $taxes = Tax::collect(); + + $modules = $this->getFeaturedModules([ + 'query' => [ + 'limit' => 4 + ] + ]); + + $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->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, + ], + ]); + } +} diff --git a/app/Http/Controllers/Wizard/Finish.php b/app/Http/Controllers/Wizard/Finish.php index 393bf48f3..128bc7145 100644 --- a/app/Http/Controllers/Wizard/Finish.php +++ b/app/Http/Controllers/Wizard/Finish.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Wizard; -use Illuminate\Routing\Controller; +use App\Abstracts\Http\Controller; use App\Traits\Modules; class Finish extends Controller @@ -38,6 +38,21 @@ class Finish extends Controller $modules = $this->getFeaturedModules($data); - return view('wizard.finish.index', compact('modules')); + return $this->response('wizard.finish.index', compact('modules')); + } + + /** + * Show the form for creating a new resource. + * + * @return Response + */ + public function update() + { + setting()->set('wizard.completed', 1); + + // Save all settings + setting()->save(); + + return response()->json([]); } } diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php index 5ba794d2e..70d1722c1 100644 --- a/app/Http/Controllers/Wizard/Taxes.php +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -32,7 +32,7 @@ class Taxes extends Controller { $taxes = Tax::collect(); - return view('wizard.taxes.index', compact('taxes')); + return $this->response('wizard.taxes.index', compact('taxes')); } /** @@ -46,18 +46,14 @@ class Taxes extends Controller { $response = $this->ajaxDispatch(new CreateTax($request)); - $response['redirect'] = route('wizard.taxes.index'); - if ($response['success']) { $message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['message'] = $message; + return response()->json($response); } @@ -73,18 +69,14 @@ class Taxes extends Controller { $response = $this->ajaxDispatch(new UpdateTax($tax, $request)); - $response['redirect'] = route('wizard.taxes.index'); - if ($response['success']) { $message = trans('messages.success.updated', ['type' => $tax->name]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['message'] = $message; + return response()->json($response); } @@ -97,20 +89,19 @@ class Taxes extends Controller */ public function destroy(Tax $tax) { - $response = $this->ajaxDispatch(new DeleteTax($tax)); + $tax_id = $tax->id; - $response['redirect'] = route('wizard.taxes.index'); + $response = $this->ajaxDispatch(new DeleteTax($tax)); if ($response['success']) { $message = trans('messages.success.deleted', ['type' => $tax->name]); - - flash($message)->success(); } else { $message = $response['message']; - - flash($message)->error()->important(); } + $response['tax_id'] = $tax_id; + $response['message'] = $message; + return response()->json($response); } } diff --git a/resources/assets/js/Wizard.vue b/resources/assets/js/Wizard.vue new file mode 100644 index 000000000..609523d1c --- /dev/null +++ b/resources/assets/js/Wizard.vue @@ -0,0 +1,131 @@ + + + + + + + diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index 59075215c..95e0e3168 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -12,6 +12,7 @@ :disabled="disabled" > diff --git a/resources/assets/js/components/AkauntingDropzoneFileUpload.vue b/resources/assets/js/components/AkauntingDropzoneFileUpload.vue index 742b1bc90..303280227 100644 --- a/resources/assets/js/components/AkauntingDropzoneFileUpload.vue +++ b/resources/assets/js/components/AkauntingDropzoneFileUpload.vue @@ -231,6 +231,42 @@ export default { async mounted() { this.initDropzone(); }, + + watch: { + attachments: function (attachments) { + attachments.forEach((attachment) => { + if(attachment.length != undefined) { + var mockFile = { + id: attachment[0].id, + name: attachment[0].name, + size: attachment[0].size, + type: attachment[0].type, + download: attachment[0].downloadPath, + dropzone: 'edit', + }; + this.dropzone.emit("addedfile", mockFile); + this.dropzone.options.thumbnail.call(this.dropzone, mockFile, attachment[0].path); + + // Make sure that there is no progress bar, etc... + this.dropzone.emit("complete", mockFile); + + this.files.forEach(async (attachment) => { + if (attachment.download) { + attachment.previewElement.querySelector("[data-dz-download]").href = attachment.download; + attachment.previewElement.querySelector("[data-dz-download]").classList.remove("d-none"); + } + }); + + if (this.preview == 'single' && attachments.length == 1) { + this.$nextTick(() => { + document.querySelector("#dropzone-" + this._uid).classList.add("dz-max-files-reached"); + }); + } + } + }, this); + + }, + }, } diff --git a/resources/assets/js/components/forms/AkauntingRadioGroup.vue b/resources/assets/js/components/forms/AkauntingRadioGroup.vue index c958cc29e..8ce8a78c2 100644 --- a/resources/assets/js/components/forms/AkauntingRadioGroup.vue +++ b/resources/assets/js/components/forms/AkauntingRadioGroup.vue @@ -3,7 +3,7 @@ {{ text }} - + { this.success = false; diff --git a/resources/assets/js/mixins/wizardAction.js b/resources/assets/js/mixins/wizardAction.js new file mode 100644 index 000000000..dd1c3d7a7 --- /dev/null +++ b/resources/assets/js/mixins/wizardAction.js @@ -0,0 +1,171 @@ + +export default { + data: function () { + return { + current_tab: undefined, + new_datas: false, + model: { + name: "", + rate: "", + select: "", + enabled: 1 + }, + error_field: {}, + } + }, + methods: { + onAddItem() { + this.new_datas = true; + this.current_tab = undefined; + this.error_field = {}; + + if (this.model) { + this.model.name = ''; + this.model.rate = ''; + this.model.select = ''; + } + }, + + onEditItem(item, index) { + this.new_datas = false; + this.current_tab = index; + this.error_field = {}; + + if (this.model) { + this.model.name = item.name ? item.name : ''; + this.model.rate = item.rate ? item.rate : ''; + this.model.select = item.code ? item.code : ''; + } + }, + + onCancelItem() { + this.current_tab = undefined; + }, + + onDataChange() { + this.new_datas = false; + this.current_tab = undefined; + this.model.name = ''; + this.model.rate = ''; + this.model.select = ''; + this.model.enabled = 1; + }, + + onSuccessMessage(response) { + let type = response.data.success ? 'success' : 'error'; + let timeout = 1000; + + if (response.data.important) { + timeout = 0; + } + + this.$notify({ + message: response.data.message, + timeout: timeout, + icon: "fas fa-bell", + type, + }); + + this.onDataChange(); + }, + + onDeleteItemMessage(event) { + let type = event.success ? 'success' : 'error'; + let timeout = 1000; + + if (event.important) { + timeout = 0; + } + + this.$notify({ + message: event.message, + timeout: timeout, + icon: "fas fa-bell", + type, + }); + + this.onDataChange(); + }, + + onStatusControl(status_form, status_item, event) { + status_form.forEach((status) => { + if (status.id == status_item) { + status.enabled = event.target.checked; + } + }); + }, + + onSubmitEvent(form_method, form_url, plus_data, form_list, form_id) { + const formData = new FormData(this.$refs["form"]); + const data = {}; + + for (let [key, val] of formData.entries()) { + Object.assign(data, { + [key]: val, + }); + } + + if(plus_data == 'type') { + Object.assign(data, { + ['type']: 'normal', + }); + } + + window.axios({ + method: form_method, + url: form_url, + data: data, + }) + .then(response => { + if(form_list.length && form_list.length != undefined) { + if(form_method == 'POST') { + form_list.push({ + "id": response.data.data.id, + "name": response.data.data.name, + "code": response.data.data.code, + "rate": response.data.data.rate, + "enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true' + }); + } + + if(form_method == 'PATCH') { + form_list.forEach(item => { + if (item.id == form_id) { + item.name = response.data.data.name; + item.code = response.data.data.code; + item.rate = response.data.data.rate; + } + }); + } + } + this.onSuccessMessage(response); + }, this) + .catch(error => { + this.onFailError(error); + }, this); + }, + + onEjetItem(event, form_list, event_id) { + form_list.forEach(function (item, index) { + if (item.id == event_id) { + form_list.splice(index, 1); + return; + } + }, this); + + this.component = ""; + + this.onDeleteItemMessage(event); + }, + + onFailErrorGet(field_name) { + if(this.error_field[field_name]) { + return this.error_field[field_name][0]; + } + }, + + onFailError(error) { + this.error_field = error.response.data.errors; + } + } +} diff --git a/resources/assets/js/views/wizard/Company.vue b/resources/assets/js/views/wizard/Company.vue new file mode 100644 index 000000000..fa9f484ec --- /dev/null +++ b/resources/assets/js/views/wizard/Company.vue @@ -0,0 +1,243 @@ + + + + {{ translations.company.title }} + + + + + + + + + + + + + + + + + + + Click here + to get your API key. + + + + + + + + + + + + + + + + + {{ + translations.company.logo + }} + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/assets/js/views/wizard/Currencies.vue b/resources/assets/js/views/wizard/Currencies.vue new file mode 100644 index 000000000..3323360c2 --- /dev/null +++ b/resources/assets/js/views/wizard/Currencies.vue @@ -0,0 +1,422 @@ + + + + {{ translations.currencies.title }} + + + + + + + + + + + + + + + {{ translations.currencies.add_new }} + + + + + + + + + {{ translations.currencies.name }} + + + {{ translations.currencies.code }} + + + {{ translations.currencies.rate }} + + + {{ translations.currencies.enabled }} + + + {{ translations.currencies.actions }} + + + + + + + {{ item.name }} + + {{ item.code }} + {{ item.rate }} + + + + + + + + + + + + + + + + {{ translations.currencies.edit }} + + + + {{ translations.currencies.delete }} + + + + + + + + + + + + + + + + + + + + + {{ translations.currencies.cancel }} + + {{ translations.currencies.save }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ translations.currencies.save }} + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/assets/js/views/wizard/Finish.vue b/resources/assets/js/views/wizard/Finish.vue new file mode 100644 index 000000000..beaeb4868 --- /dev/null +++ b/resources/assets/js/views/wizard/Finish.vue @@ -0,0 +1,143 @@ + + + {{ translations.finish.title }} + + + + + + + + + + + + + + + {{ translations.finish.recommended_apps }} + + + + + + + + {{ item.name }} + + + + + + + + + + + + + + + + + diff --git a/resources/assets/js/views/wizard/Taxes.vue b/resources/assets/js/views/wizard/Taxes.vue new file mode 100644 index 000000000..bc6e311b4 --- /dev/null +++ b/resources/assets/js/views/wizard/Taxes.vue @@ -0,0 +1,315 @@ + + + {{ translations.taxes.title }} + + + + + + + + + + + + {{ translations.taxes.add_new }} + + + + + + + + {{ translations.taxes.name }} + + + {{ translations.taxes.rate }} + + + {{ translations.taxes.enabled }} + + + {{ translations.taxes.actions }} + + + + + + + {{ item.name }} + + {{ item.rate }} + + + + + + + + + + + + + + + + {{ translations.taxes.edit }} + + + + {{ translations.taxes.delete }} + + + + + + + + + + + + {{ translations.taxes.cancel }} + {{ translations.taxes.save }} + + + + + + + + + + + + + + + + + + + {{ translations.taxes.save }} + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/assets/js/views/wizard/company.js b/resources/assets/js/views/wizard/company.js deleted file mode 100644 index a982c5005..000000000 --- a/resources/assets/js/views/wizard/company.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * First we will load all of this project's JavaScript dependencies which - * includes Vue and other libraries. It is a great starting point when - * building robust, powerful web applications using Vue and Laravel. - */ - -require('./../../bootstrap'); - -import Vue from 'vue'; - -import DashboardPlugin from './../../plugins/dashboard-plugin'; - -import Global from './../../mixins/global'; - -import Form from './../../plugins/form'; - -import {Step, Steps} from 'element-ui'; - -// plugin setup -Vue.use(DashboardPlugin, Step, Steps); - -const app = new Vue({ - el: '#app', - - mixins: [ - Global - ], - - components: { - [Step.name]: Step, - [Steps.name]: Steps, - }, - - data: function () { - return { - form: new Form('company'), - active: 0 - } - }, - - methods: { - - } -}); diff --git a/resources/assets/js/views/wizard/currencies.js b/resources/assets/js/views/wizard/currencies.js deleted file mode 100644 index 9287755ef..000000000 --- a/resources/assets/js/views/wizard/currencies.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * First we will load all of this project's JavaScript dependencies which - * includes Vue and other libraries. It is a great starting point when - * building robust, powerful web applications using Vue and Laravel. - */ - -require('../../bootstrap'); - -import Vue from 'vue'; - -import DashboardPlugin from './../../plugins/dashboard-plugin'; - -import Global from '../../mixins/global'; - -import Form from '../../plugins/form'; -import BulkAction from './../../plugins/bulk-action'; - -import {Step, Steps} from 'element-ui'; - -// plugin setup -Vue.use(DashboardPlugin, Step, Steps); - -const app = new Vue({ - el: '#app', - - mixins: [ - Global - ], - - components: { - [Step.name]: Step, - [Steps.name]: Steps, - }, - - data: function () { - return { - form: new Form('currency'), - active: 1, - bulk_action: new BulkAction(url + '/settings/currencies'), - show: false, - currency: { - name: '', - code: '', - rate: '1', - enabled: 1 - }, - submit_function: '', - } - }, - - methods: { - onAddCurrency() { - this.submit_function = 'onStoreCurrency'; - this.form.method = 'post'; - this.form.action = url + '/wizard/currencies'; - - this.form.name = ''; - this.form.code = ''; - this.form.rate = ''; - this.form.enabled = 1; - this.form.precision = ''; - this.form.symbol = ''; - this.form.symbol_first = ''; - this.form.decimal_mark = ''; - this.form.thousands_separator = ''; - - this.show = true; - }, - - onEditCurrency(currency_id) { - this.submit_function = 'onUpdateCurrency'; - this.form.method = 'patch'; - this.form.action = url + '/wizard/currencies/' + currency_id; - - currencies.forEach(currency => { - if (currency.id == currency_id) { - this.form.name = currency.name; - this.form.code = currency.code; - this.form.rate = currency.rate; - this.form.enabled = currency.enabled; - this.form.precision = currency.precision; - this.form.symbol = currency.symbol; - this.form.symbol_first = currency.symbol_first; - this.form.decimal_mark = currency.decimal_mark; - this.form.thousands_separator = currency.thousands_separator; - } - }); - - this.show = true; - }, - - onChangeCode(code) { - axios.get(url + '/settings/currencies/config', { - params: { - code: code - } - }) - .then(response => { - this.form.rate = response.data.rate; - this.form.precision = response.data.precision; - this.form.symbol = response.data.symbol; - this.form.symbol_first = response.data.symbol_first; - this.form.decimal_mark = response.data.decimal_mark; - this.form.thousands_separator = response.data.thousands_separator; - }) - .catch(error => { - }); - }, - - onSubmit() { - this.form.oldSubmit(); - }, - } -}); diff --git a/resources/assets/js/views/wizard/finish.js b/resources/assets/js/views/wizard/finish.js deleted file mode 100644 index 090fb9857..000000000 --- a/resources/assets/js/views/wizard/finish.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * First we will load all of this project's JavaScript dependencies which - * includes Vue and other libraries. It is a great starting point when - * building robust, powerful web applications using Vue and Laravel. - */ - -require('./../../bootstrap'); - -import Vue from 'vue'; - -import DashboardPlugin from './../../plugins/dashboard-plugin'; - -import Global from './../../mixins/global'; - -import {Step, Steps} from 'element-ui'; - -// plugin setup -Vue.use(DashboardPlugin, Step, Steps); - -const app = new Vue({ - el: '#app', - - mixins: [ - Global - ], - - components: { - [Step.name]: Step, - [Steps.name]: Steps, - }, - - data: function () { - return { - active: 3, - } - }, - - methods: { - - } -}); diff --git a/resources/assets/js/views/wizard/taxes.js b/resources/assets/js/views/wizard/taxes.js deleted file mode 100644 index ca0e9cff8..000000000 --- a/resources/assets/js/views/wizard/taxes.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * First we will load all of this project's JavaScript dependencies which - * includes Vue and other libraries. It is a great starting point when - * building robust, powerful web applications using Vue and Laravel. - */ - -require('../../bootstrap'); - -import Vue from 'vue'; - -import DashboardPlugin from './../../plugins/dashboard-plugin'; - -import Global from '../../mixins/global'; - -import Form from '../../plugins/form'; -import BulkAction from './../../plugins/bulk-action'; - -import {Step, Steps} from 'element-ui'; - -// plugin setup -Vue.use(DashboardPlugin, Step, Steps); - -const app = new Vue({ - el: '#app', - - mixins: [ - Global - ], - - components: { - [Step.name]: Step, - [Steps.name]: Steps, - }, - - data: function () { - return { - form: new Form('tax'), - active: 2, - bulk_action: new BulkAction(url + '/settings/taxes'), - show: false, - tax: { - name: '', - code: '', - type: 'normal', - enabled: 1 - }, - submit_function: '' - } - }, - - methods: { - onAddTax() { - this.submit_function = 'onStoreTax'; - this.form.method = 'post'; - this.form.action = url + '/wizard/taxes'; - - this.form.name = ''; - this.form.rate = ''; - this.form.type = 'normal'; - this.form.enabled = 1; - - this.show = true; - }, - - onEditTax(tax_id) { - this.submit_function = 'onUpdateTax'; - this.form.method = 'patch'; - this.form.action = url + '/wizard/taxes/' + tax_id; - - taxes.forEach(tax => { - if (tax.id == tax_id) { - this.form.name = tax.name; - this.form.rate = tax.rate; - this.form.type = tax.type; - this.form.enabled = tax.enabled; - } - }); - - this.show = true; - }, - - onSubmit() { - this.form.oldSubmit(); - }, - } -}); diff --git a/resources/assets/js/wizard.js b/resources/assets/js/wizard.js new file mode 100644 index 000000000..f710cb3bf --- /dev/null +++ b/resources/assets/js/wizard.js @@ -0,0 +1,67 @@ + +require('./bootstrap'); + +import Vue from 'vue'; +import VueRouter from 'vue-router'; +import DashboardPlugin from './plugins/dashboard-plugin'; + +Vue.use(DashboardPlugin); +Vue.use(VueRouter); + +import Wizard from './Wizard.vue'; +import Company from './views/wizard/Company.vue'; +import Currencies from './views/wizard/Currencies.vue'; +import Taxes from './views/wizard/Taxes.vue'; +import Finish from './views/wizard/Finish.vue'; + +var global_path = new URL(url).protocol + '//' + window.location.host; +var base_path = url.replace(global_path, ''); + +const router = new VueRouter({ + mode: 'history', + base: base_path, + routes: [ + { + path: '/wizard', + name: 'Wizard', + component: Company + }, + { + path: '/wizard/companies', + name: 'Company', + component: Company + }, + { + path: '/wizard/currencies', + name: 'Currencies', + component: Currencies + }, + { + path: '/wizard/taxes', + name: 'Taxes', + component: Taxes +}, +{ + path: '/wizard/finish', + name: 'Finish', + component: Finish +} + ], + linkActiveClass: 'active', + scrollBehavior: (to, from ,savedPosition) => { + if (savedPosition) { + return savedPosition; + } + if (to.hash) { + return { selector: to.hash }; + } + return { x: 0, y: 0 }; +} +}); + +new Vue({ + el : '#app', + router, + render: h => h(Wizard), +}); + diff --git a/resources/views/layouts/wizard.blade.php b/resources/views/layouts/wizard.blade.php index 720fe0c4d..cce3d002b 100644 --- a/resources/views/layouts/wizard.blade.php +++ b/resources/views/layouts/wizard.blade.php @@ -1,4 +1,4 @@ - + @include('partials.wizard.head') @@ -7,15 +7,22 @@ @stack('body_start') + + + + + + - @include('partials.wizard.content') + @include('flash::message') + @yield('content') + - @stack('body_end') @include('partials.wizard.scripts') - - + +
+ + + Click here + to get your API key. + + +