set default country and some styling
This commit is contained in:
parent
9a95426d90
commit
643c907d60
@ -68,8 +68,6 @@ class Companies extends Controller
|
||||
$real_key = 'localisation.' . $key;
|
||||
break;
|
||||
case 'country':
|
||||
$countries = trans('countries');
|
||||
$value = array_search($value, $countries);
|
||||
$real_key = 'company.' . $key;
|
||||
break;
|
||||
default:
|
||||
@ -99,6 +97,10 @@ class Companies extends Controller
|
||||
}
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
|
||||
if ($key == 'country') {
|
||||
setting()->set('default.' . $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Save all settings
|
||||
|
@ -89,6 +89,7 @@ class CreateCompany extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
'company.country' => $this->request->get('country'),
|
||||
'default.currency' => $this->request->get('currency'),
|
||||
'default.locale' => $this->request->get('locale', 'en-GB'),
|
||||
'default.country' => $this->request->get('country'),
|
||||
]);
|
||||
|
||||
if (!empty($this->request->settings)) {
|
||||
|
@ -1,121 +1,124 @@
|
||||
<template>
|
||||
<router-view
|
||||
:translations="translations"
|
||||
:currencies="currencies"
|
||||
:taxes="taxes"
|
||||
:modules="modules.data"
|
||||
:currency_codes="currency_codes"
|
||||
:company="company"
|
||||
:pageLoad="page_loaded"
|
||||
></router-view>
|
||||
<router-view
|
||||
:translations="translations"
|
||||
:currencies="currencies"
|
||||
:taxes="taxes"
|
||||
:modules="modules.data"
|
||||
:currency_codes="currency_codes"
|
||||
:company="company"
|
||||
:countries="countries"
|
||||
:pageLoad="page_loaded"
|
||||
></router-view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Wizard",
|
||||
export default {
|
||||
name: "Wizard",
|
||||
|
||||
created() {
|
||||
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;
|
||||
created() {
|
||||
this.translations = wizard_translations;
|
||||
this.company = wizard_company;
|
||||
this.countries = wizard_countries;
|
||||
this.currencies = wizard_currencies;
|
||||
this.currency_codes = wizard_currency_codes;
|
||||
this.taxes = wizard_taxes;
|
||||
this.modules = wizard_modules;
|
||||
|
||||
Object.keys(this.currency_codes).map((key) => {
|
||||
return this.currency_codes[key];
|
||||
});
|
||||
Object.keys(this.currency_codes).map((key) => {
|
||||
return this.currency_codes[key];
|
||||
});
|
||||
|
||||
this.page_loaded = false;
|
||||
},
|
||||
this.page_loaded = false;
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
translations: {
|
||||
company: {},
|
||||
currencies: {},
|
||||
taxes: {},
|
||||
finish: {},
|
||||
},
|
||||
company: {},
|
||||
currencies: [],
|
||||
currency_codes: [],
|
||||
taxes: [],
|
||||
modules: {},
|
||||
page_loaded: true
|
||||
data() {
|
||||
return {
|
||||
translations: {
|
||||
company: {},
|
||||
currencies: {},
|
||||
taxes: {},
|
||||
finish: {},
|
||||
},
|
||||
company: {},
|
||||
countries: {},
|
||||
currencies: [],
|
||||
currency_codes: [],
|
||||
taxes: [],
|
||||
modules: {},
|
||||
page_loaded: true
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.document-loading {
|
||||
width: 1140px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 9999;
|
||||
}
|
||||
.document-loading {
|
||||
width: 1140px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.document-loading div {
|
||||
margin-top: unset;
|
||||
margin-left: unset;
|
||||
}
|
||||
.document-loading div {
|
||||
margin-top: unset;
|
||||
margin-left: unset;
|
||||
}
|
||||
|
||||
.current-tab {
|
||||
background-color: #f6f9fc;
|
||||
}
|
||||
|
||||
.current-tab-btn {
|
||||
text-align: right;
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
flex-flow: row wrap;
|
||||
}
|
||||
|
||||
.form-container .invalid-feedback {
|
||||
position: absolute;
|
||||
bottom: -18px;
|
||||
}
|
||||
|
||||
.form-container .has-error {
|
||||
position: relative;
|
||||
margin-bottom: unset !important;
|
||||
}
|
||||
|
||||
.form-container .has-error .form-control {
|
||||
border-top-right-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
border-right: 1px solid;
|
||||
}
|
||||
|
||||
.el-step__icon {
|
||||
-webkit-transition: unset;
|
||||
transition: unset;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 991px) {
|
||||
.form-container .has-error {
|
||||
position: relative;
|
||||
margin-bottom: 1.5rem !important;
|
||||
.current-tab {
|
||||
background-color: #f6f9fc;
|
||||
}
|
||||
|
||||
.current-tab-btn {
|
||||
padding: 0 15px;
|
||||
text-align: right;
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
flex-direction: column;
|
||||
flex-flow: row wrap;
|
||||
}
|
||||
|
||||
.form-container .form-group {
|
||||
width: 100%;
|
||||
.form-container .invalid-feedback {
|
||||
position: absolute;
|
||||
bottom: -18px;
|
||||
}
|
||||
|
||||
.form-container .has-error {
|
||||
position: relative;
|
||||
margin-bottom: unset !important;
|
||||
}
|
||||
|
||||
.form-container .has-error .form-control {
|
||||
border-top-right-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
border-right: 1px solid;
|
||||
}
|
||||
|
||||
.el-step__icon {
|
||||
-webkit-transition: unset;
|
||||
transition: unset;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 991px) {
|
||||
.form-container .has-error {
|
||||
position: relative;
|
||||
margin-bottom: 1.5rem !important;
|
||||
}
|
||||
|
||||
.current-tab-btn {
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form-container .form-group {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -54,6 +54,7 @@
|
||||
v-model="company.tax_number"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<akaunting-date
|
||||
:title="translations.company.financial_start"
|
||||
@ -69,6 +70,7 @@
|
||||
v-model="real_date"
|
||||
></akaunting-date>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<base-input :label="translations.company.address">
|
||||
<textarea
|
||||
@ -81,28 +83,31 @@
|
||||
></textarea>
|
||||
</base-input>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<base-input :label="translations.company.country">
|
||||
<el-select name="country" v-model="model" filterable>
|
||||
<el-select name="country" v-model="company.country" filterable>
|
||||
<template slot="prefix">
|
||||
<span class="el-input__suffix-inner el-select-icon">
|
||||
<i :class="'select-icon-position el-input__icon fas fa-globe-americas'"></i>
|
||||
</span>
|
||||
</template>
|
||||
<el-option
|
||||
v-for="(country, index) in country_data"
|
||||
:key="index"
|
||||
:label="country"
|
||||
:value="country"
|
||||
v-for="(country, index) in sortedCountries"
|
||||
:key="index"
|
||||
:label="country.value"
|
||||
:value="country.key"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</base-input>
|
||||
</div>
|
||||
|
||||
<div class="col-6 mb-0">
|
||||
<label class="form-control-label">{{ translations.company.logo }}</label>
|
||||
<akaunting-dropzone-file-upload
|
||||
ref="dropzoneWizard"
|
||||
class="form-file"
|
||||
preview-classes="single"
|
||||
:attachments="logo"
|
||||
:v-model="logo"
|
||||
@ -156,6 +161,10 @@ export default {
|
||||
type: [Object, Array],
|
||||
},
|
||||
|
||||
countries: {
|
||||
type: [Object, Array],
|
||||
},
|
||||
|
||||
translations: {
|
||||
type: [Object, Array],
|
||||
},
|
||||
@ -190,21 +199,30 @@ export default {
|
||||
logo: [],
|
||||
real_date: "",
|
||||
lang_data: '',
|
||||
country_data: wizard_country,
|
||||
model: ''
|
||||
sorted_countries: [],
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
if(document.documentElement.lang) {
|
||||
if (document.documentElement.lang) {
|
||||
let lang_split = document.documentElement.lang.split("-");
|
||||
|
||||
if (lang_split[0] !== 'en') {
|
||||
const lang = require(`flatpickr/dist/l10n/${lang_split[0]}.js`).default[lang_split[0]];
|
||||
|
||||
const lang = require(`flatpickr/dist/l10n/${lang_split[0]}.js`).default[lang_split[0]];
|
||||
this.dateConfig.locale = lang;
|
||||
this.dateConfig.locale = lang;
|
||||
}
|
||||
}
|
||||
|
||||
this.setSortedCountries();
|
||||
},
|
||||
|
||||
computed: {
|
||||
sortedCountries() {
|
||||
this.sorted_countries.sort(this.sortBy('value'));
|
||||
|
||||
return this.sorted_countries;
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -214,6 +232,57 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
sortBy(option) {
|
||||
return (firstEl, secondEl) => {
|
||||
let first_element = firstEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
let second_element = secondEl[option].toUpperCase(); // ignore upper and lowercase
|
||||
|
||||
if (first_element < second_element) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (first_element > second_element) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// names must be equal
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
setSortedCountries() {
|
||||
// Reset sorted_countries
|
||||
this.sorted_countries = [];
|
||||
|
||||
let created_options = this.countries;
|
||||
|
||||
// Option set sort_option data
|
||||
if (!Array.isArray(created_options)) {
|
||||
for (const [key, value] of Object.entries(created_options)) {
|
||||
this.sorted_countries.push({
|
||||
key: key.toString(),
|
||||
value: value
|
||||
});
|
||||
}
|
||||
} else {
|
||||
created_options.forEach(function (option, index) {
|
||||
if (typeof(option) == 'string') {
|
||||
this.sorted_countries.push({
|
||||
index: index,
|
||||
key: index.toString(),
|
||||
value: option
|
||||
});
|
||||
} else {
|
||||
this.sorted_countries.push({
|
||||
index: index,
|
||||
key: option.id.toString(),
|
||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
onDataWatch(company) {
|
||||
if (Object.keys(company).length) {
|
||||
if (company.logo) {
|
||||
@ -303,6 +372,7 @@ export default {
|
||||
})
|
||||
.then((response) => {
|
||||
this.onSuccessMessage(response);
|
||||
|
||||
this.$router.push("/wizard/currencies");
|
||||
}, this)
|
||||
.catch((error) => {
|
||||
@ -311,6 +381,7 @@ export default {
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
},
|
||||
|
@ -20,6 +20,7 @@
|
||||
<i class="fas fa-spinner fa-pulse fa-7x"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end mb-3">
|
||||
<base-button
|
||||
type="success"
|
||||
@ -52,6 +53,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(item, index) in currencies"
|
||||
@ -273,7 +275,9 @@
|
||||
</div>
|
||||
|
||||
<notifications></notifications>
|
||||
|
||||
<form id="form-dynamic-component" method="POST" action="#"></form>
|
||||
|
||||
<component
|
||||
v-bind:is="component"
|
||||
@deleted="onDeleteCurrency($event)"
|
||||
@ -286,6 +290,7 @@
|
||||
<base-button type="white" native-type="submit" @click="prev()">{{
|
||||
translations.currencies.previous
|
||||
}}</base-button>
|
||||
|
||||
<base-button type="white" native-type="submit" @click="next()">{{
|
||||
translations.currencies.next
|
||||
}}</base-button>
|
||||
|
80
resources/assets/js/wizard.js
vendored
80
resources/assets/js/wizard.js
vendored
@ -1,4 +1,3 @@
|
||||
|
||||
require('./bootstrap');
|
||||
|
||||
import Vue from 'vue';
|
||||
@ -21,47 +20,48 @@ 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;
|
||||
{
|
||||
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 };
|
||||
}
|
||||
if (to.hash) {
|
||||
return { selector: to.hash };
|
||||
}
|
||||
return { x: 0, y: 0 };
|
||||
}
|
||||
});
|
||||
|
||||
new Vue({
|
||||
el : '#app',
|
||||
router,
|
||||
render: h => h(Wizard),
|
||||
el : '#app',
|
||||
router,
|
||||
render: h => h(Wizard),
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<script type="text/javascript">
|
||||
var wizard_translations = {!! json_encode($translations) !!};
|
||||
var wizard_company = {!! json_encode($company) !!};
|
||||
var wizard_country = {!! json_encode(trans('countries')) !!};
|
||||
var wizard_countries = {!! json_encode(trans('countries')) !!};
|
||||
var wizard_currencies = {!! json_encode($currencies) !!};
|
||||
var wizard_currency_codes = {!! json_encode($currency_codes) !!};
|
||||
var wizard_taxes = {!! json_encode($taxes) !!};
|
||||
|
Loading…
x
Reference in New Issue
Block a user