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 @@
-
+
@include('partials.wizard.scripts') - - + + \ No newline at end of file diff --git a/resources/views/partials/wizard/content.blade.php b/resources/views/partials/wizard/content.blade.php deleted file mode 100644 index 0e7ffc823..000000000 --- a/resources/views/partials/wizard/content.blade.php +++ /dev/null @@ -1,22 +0,0 @@ -@stack('content_start') - @stack('content_header_start') - -

- @yield('title') - @yield('new_button') -

- - @stack('content_header_end') - - @stack('content_content_start') - - @yield('content') - - @stack('content_content_end') - - - -
- - -@stack('content_end') diff --git a/resources/views/partials/wizard/pagination.blade.php b/resources/views/partials/wizard/pagination.blade.php deleted file mode 100644 index 78fdcd35b..000000000 --- a/resources/views/partials/wizard/pagination.blade.php +++ /dev/null @@ -1,14 +0,0 @@ -@stack('pagination_start') - @if ($items->firstItem()) -
- {{ trans('pagination.showing', ['first' => $items->firstItem(), 'last' => $items->lastItem(), 'total' => $items->total(), 'type' => strtolower(trans_choice('general.' . $type, 2))]) }} -
-
- {!! $items->withPath(request()->url())->withQueryString()->links() !!} -
- @else -
- {{ trans('general.no_records') }} -
- @endif -@stack('pagination_end') diff --git a/resources/views/partials/wizard/scripts.blade.php b/resources/views/partials/wizard/scripts.blade.php index 5daf78cc5..81f7b1b8e 100644 --- a/resources/views/partials/wizard/scripts.blade.php +++ b/resources/views/partials/wizard/scripts.blade.php @@ -4,6 +4,8 @@ + + @stack('body_css') @stack('body_stylesheet') diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index 108e49a0f..81921fd2b 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -3,84 +3,5 @@ @section('title', trans('general.wizard')) @section('content') -
- {!! Form::model($company, [ - 'method' => 'PATCH', - 'route' => ['wizard.companies.update'], - 'id' => 'company', - '@submit.prevent' => 'onSubmit', - '@keydown' => 'form.errors.clear($event.target.name)', - 'files' => true, - 'role' => 'form', - 'class' => 'form-loading-button mb-0', - 'novalidate' => true - ]) !!} -
- @include('partials.wizard.steps') - -
-
-
-
-
- {!! Form::label('api-key', trans('modules.api_key'), ['class' => 'form-control-label']) !!} - -
-
- - - -
- - {!! Form::text('api_key', setting('apps.api_key', null), array_merge([ - 'class' => 'form-control', - 'data-name' => 'api_key', - 'data-value' => setting('apps.api_key', null), - 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_key')]), - 'v-model' => 'form.api_key' - ], [])) !!} -
- -
-
- -

- {!! trans('modules.get_api_key', ['url' => 'https://akaunting.com/dashboard']) !!} -

- -
-
- - {{ Form::textGroup('tax_number', trans('general.tax_number'), 'percent', []) }} - - {{ Form::dateGroup('financial_start', trans('settings.localisation.financial_start'), 'calendar', ['id' => 'financial_start', 'class' => 'form-control datepicker', 'show-date-format' => 'j F', 'date-format' => 'd-m', 'autocomplete' => 'off'], Date::now()->startOfYear()->format('d-m')) }} - - {{ Form::textareaGroup('address', trans('settings.company.address')) }} - - {{ Form::fileGroup('logo', trans('settings.company.logo'), '', ['dropzone-class' => 'form-file']) }} -
-
- - - - {!! Form::close() !!} -
@endsection - -@push('scripts_start') - -@endpush diff --git a/resources/views/wizard/currencies/index.blade.php b/resources/views/wizard/currencies/index.blade.php index eedfab90d..293e01e4b 100644 --- a/resources/views/wizard/currencies/index.blade.php +++ b/resources/views/wizard/currencies/index.blade.php @@ -3,143 +3,5 @@ @section('title', trans('general.wizard')) @section('content') -
- @include('partials.wizard.steps') - -
-
-
- -
-
-
- -
- {!! Form::open([ - 'route' => 'wizard.currencies.store', - 'id' => 'currency', - '@submit.prevent' => 'onSubmit', - '@keydown' => 'form.errors.clear($event.target.name)', - 'files' => true, - 'role' => 'form', - 'class' => 'form-loading-button mb-0', - 'novalidate' => true - ]) !!} - - - - - - - - - - - - @foreach($currencies as $item) - - - - - - - - @endforeach - - - - - - - - - -
@sortablelink('name', trans('general.name'))@sortablelink('code', trans('currencies.code'))@sortablelink('rate', trans('currencies.rate'))@sortablelink('enabled', trans('general.enabled')){{ trans('general.actions') }}
- - {{ $item->name }} - - {{ $item->code }}{{ $item->rate }} - @if (user()->can('update-settings-currencies')) - {{ Form::enabledGroup($item->id, $item->name, $item->enabled) }} - @else - @if ($item->enabled) - {{ trans('general.yes') }} - @else - {{ trans('general.no') }} - @endif - @endif - - -
- {{ Form::textGroup('name', trans('general.name'), 'font', [], null, '') }} - - {{ Form::selectGroup('code', trans('currencies.code'), 'code', $codes, null, ['required' => 'required', 'change' => 'onChangeCode', 'model' => 'form.code'], '') }} - - {{ Form::textGroup('rate', trans('currencies.rate'), 'percentage', ['required' => 'required'], null, '') }} - - {{ Form::radioGroup('enabled', trans('general.enabled')) }} - - {!! Form::button( - trans('general.save'), [ - ':disabled' => 'form.loading', - 'type' => 'submit', - 'class' => 'btn btn-success', - ]) !!} - -
- {{ Form::numberGroup('precision', trans('currencies.precision'), 'bullseye') }} - - {{ Form::textGroup('symbol', trans('currencies.symbol.symbol'), 'font') }} - - {{ Form::selectGroup('symbol_first', trans('currencies.symbol.position'), 'text-width', ['1' => trans('currencies.symbol.before'), '0' => trans('currencies.symbol.after')]) }} - - {{ Form::textGroup('decimal_mark', trans('currencies.decimal_mark'), 'columns') }} - - {{ Form::textGroup('thousands_separator', trans('currencies.thousands_separator'), 'columns', []) }} -
-
- - {!! Form::close() !!} -
- - -
+ @endsection - -@push('scripts_start') - - - -@endpush diff --git a/resources/views/wizard/finish/index.blade.php b/resources/views/wizard/finish/index.blade.php index f17e5dc0c..d28fb8948 100644 --- a/resources/views/wizard/finish/index.blade.php +++ b/resources/views/wizard/finish/index.blade.php @@ -3,68 +3,5 @@ @section('title', trans('general.wizard')) @section('content') -
- @include('partials.wizard.steps') - -
-
-
-
-

{{ trans('modules.recommended_apps') }}

-
- - @if ($modules) -
- @foreach ($modules->data as $module) - @include('partials.modules.item') - @endforeach -
- -
- -
- @else -
-
-

- {{ trans('modules.no_apps') }} -

- -

- {!! trans('modules.developer') !!} -

-
-
- @endif -
-
-
- - -
+ @endsection - -@push('scripts_start') - -@endpush diff --git a/resources/views/wizard/taxes/index.blade.php b/resources/views/wizard/taxes/index.blade.php index 193955c38..d28fb8948 100644 --- a/resources/views/wizard/taxes/index.blade.php +++ b/resources/views/wizard/taxes/index.blade.php @@ -3,125 +3,5 @@ @section('title', trans('general.wizard')) @section('content') -
- @include('partials.wizard.steps') - -
-
-
- -
-
-
- -
- {!! Form::open([ - 'route' => 'wizard.taxes.store', - 'id' => 'tax', - '@submit.prevent' => 'onSubmit', - '@keydown' => 'form.errors.clear($event.target.name)', - 'files' => true, - 'role' => 'form', - 'class' => 'form-loading-button mb-0', - 'novalidate' => true - ]) !!} - - - - - - - - - - - @foreach($taxes as $item) - - - - - - - @endforeach - - - - - - - - -
@sortablelink('name', trans('general.name'))@sortablelink('rate', trans('taxes.rate_percent'))@sortablelink('enabled', trans('general.enabled')){{ trans('general.actions') }}
- - {{ $item->name }} - - {{ $item->rate }} - @if (user()->can('update-settings-taxes')) - {{ Form::enabledGroup($item->id, $item->name, $item->enabled) }} - @else - @if ($item->enabled) - {{ trans('general.yes') }} - @else - {{ trans('general.no') }} - @endif - @endif - - -
- {{ Form::textGroup('name', trans('general.name'), 'font', [], null, '') }} - - {{ Form::textGroup('rate', trans('currencies.rate'), 'percentage', ['required' => 'required'], null, '') }} - - {{ Form::radioGroup('enabled', trans('general.enabled')) }} - - {!! Form::button( - trans('general.save'), [ - ':disabled' => 'form.loading', - 'type' => 'submit', - 'class' => 'btn btn-success', - ]) !!} -
- - {!! Form::close() !!} -
- - -
+ @endsection - -@push('scripts_start') - - - -@endpush diff --git a/routes/wizard.php b/routes/wizard.php index fc0decf1f..3f3f951ec 100644 --- a/routes/wizard.php +++ b/routes/wizard.php @@ -9,8 +9,10 @@ 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::patch('companies', 'Wizard\Companies@update')->name('companies.update'); + Route::post('companies', 'Wizard\Companies@update')->middleware('dropzone')->name('companies.update'); Route::get('currencies/{currency}/enable', 'Settings\Currencies@enable')->name('currencies.enable'); Route::get('currencies/{currency}/disable', 'Settings\Currencies@disable')->name('currencies.disable'); @@ -21,4 +23,5 @@ Route::group(['as' => 'wizard.'], function () { Route::resource('taxes', 'Wizard\Taxes'); Route::get('finish', 'Wizard\Finish@index')->name('finish.index'); + Route::patch('finish', 'Wizard\Finish@update')->name('finish.update'); }); diff --git a/tests/Feature/Wizard/CompaniesTest.php b/tests/Feature/Wizard/CompaniesTest.php index 4e43f77e4..4d0d712f7 100644 --- a/tests/Feature/Wizard/CompaniesTest.php +++ b/tests/Feature/Wizard/CompaniesTest.php @@ -11,18 +11,22 @@ class CompaniesTest extends FeatureTestCase $this->loginAs() ->get(route('wizard.companies.edit')) ->assertStatus(200) - ->assertSeeText(trans('modules.api_key')); + ->assertSeeText(trans('general.wizard')); } public function testItShouldUpdateCompany() { $request = $this->getRequest(); - $this->loginAs() - ->patch(route('wizard.companies.update'), $request) - ->assertStatus(200); + $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 2)]); - $this->assertFlashLevel('success'); + $this->loginAs() + ->post(route('wizard.companies.update'), $request) + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); } public function getRequest() diff --git a/tests/Feature/Wizard/CurrenciesTest.php b/tests/Feature/Wizard/CurrenciesTest.php index b3405a455..a1d93c6dd 100644 --- a/tests/Feature/Wizard/CurrenciesTest.php +++ b/tests/Feature/Wizard/CurrenciesTest.php @@ -12,18 +12,22 @@ class CurrenciesTest extends FeatureTestCase $this->loginAs() ->get(route('wizard.currencies.index')) ->assertStatus(200) - ->assertSeeText(trans('demo.currencies.usd')); + ->assertSeeText(trans('general.wizard')); } public function testItShouldCreateCurrency() { $request = $this->getRequest(); + $message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]); + $this->loginAs() ->post(route('wizard.currencies.store'), $request) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertDatabaseHas('currencies', [ 'code' => $request['code'], @@ -38,11 +42,15 @@ class CurrenciesTest extends FeatureTestCase $request['name'] = $this->faker->text(15); + $message = trans('messages.success.updated', ['type' => $request['name']]); + $this->loginAs() ->patch(route('wizard.currencies.update', $currency->id), $request) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertDatabaseHas('currencies', [ 'code' => $request['code'], @@ -55,11 +63,15 @@ class CurrenciesTest extends FeatureTestCase $currency = $this->dispatch(new CreateCurrency($request)); + $message = trans('messages.success.deleted', ['type' => $currency->name]); + $this->loginAs() ->delete(route('wizard.currencies.destroy', $currency->id)) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertSoftDeleted('currencies', [ 'code' => $request['code'], diff --git a/tests/Feature/Wizard/TaxesTest.php b/tests/Feature/Wizard/TaxesTest.php index 9f9640aa2..f01fb8863 100644 --- a/tests/Feature/Wizard/TaxesTest.php +++ b/tests/Feature/Wizard/TaxesTest.php @@ -12,18 +12,22 @@ class TaxesTest extends FeatureTestCase $this->loginAs() ->get(route('wizard.taxes.index')) ->assertStatus(200) - ->assertSeeText(trans('general.add_new')); + ->assertSeeText(trans('general.wizard')); } public function testItShouldCreateTax() { $request = $this->getRequest(); + $message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]); + $this->loginAs() ->post(route('wizard.taxes.store'), $request) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertDatabaseHas('taxes', $request); } @@ -36,11 +40,15 @@ class TaxesTest extends FeatureTestCase $request['name'] = $this->faker->text(15); + $message = trans('messages.success.updated', ['type' => $request['name']]); + $this->loginAs() ->patch(route('wizard.taxes.update', $tax->id), $request) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertDatabaseHas('taxes', $request); } @@ -51,11 +59,15 @@ class TaxesTest extends FeatureTestCase $tax = $this->dispatch(new CreateTax($request)); + $message = trans('messages.success.deleted', ['type' => $tax->name]); + $this->loginAs() ->delete(route('wizard.taxes.destroy', $tax->id)) - ->assertStatus(200); - - $this->assertFlashLevel('success'); + ->assertStatus(200) + ->assertJson([ + 'success' => true, + 'message' => $message, + ]); $this->assertDatabaseHas('taxes', $request); } diff --git a/webpack.mix.js b/webpack.mix.js index f1081e3cd..35859fefd 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -58,6 +58,9 @@ mix .js('resources/assets/js/install.js', 'public/js') .js('resources/assets/js/views/install/update.js', 'public/js/install') + //Wizard + .js('resources/assets/js/wizard.js', 'public/js/wizard') + // Modules .js('resources/assets/js/views/modules/item.js', 'public/js/modules') .js('resources/assets/js/views/modules/apps.js', 'public/js/modules') @@ -75,10 +78,4 @@ mix .js('resources/assets/js/views/settings/settings.js', 'public/js/settings') .js('resources/assets/js/views/settings/taxes.js', 'public/js/settings') - // Wizard - .js('resources/assets/js/views/wizard/company.js', 'public/js/wizard') - .js('resources/assets/js/views/wizard/currencies.js', 'public/js/wizard') - .js('resources/assets/js/views/wizard/taxes.js', 'public/js/wizard') - .js('resources/assets/js/views/wizard/finish.js', 'public/js/wizard') - .sass('resources/assets/sass/argon.scss', 'public/css');