Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
brkcvn committed May 28, 2021
1 parent c08c080 commit aaa7f79
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
33 changes: 18 additions & 15 deletions resources/assets/js/Wizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

<script>
export default {
name: 'Wizard',
data: function () {
return {
page_loaded: true,
}
},
name: "Wizard",
data: function () {
return {
page_loaded: true,
};
},
created() {
let self = this;
Expand All @@ -36,9 +36,12 @@ export default {
return data.currency_codes[key];
});
setTimeout(function() {
setTimeout(
function () {
self.page_loaded = false;
}.bind(self), 800);
}.bind(self),
800
);
});
},
Expand Down Expand Up @@ -93,24 +96,24 @@ export default {
.form-container .has-error {
position: relative;
margin-bottom:unset !important;
margin-bottom: unset !important;
}
.form-container .has-error .form-control {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-right:1px solid;
border-right: 1px solid;
}
.el-step__icon {
-webkit-transition: unset;
transition: unset;
}
.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;
margin-bottom: 1.5rem !important;
}
.current-tab-btn {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/components/Inputs/BaseInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
description: "Input label (text before input)"
},
error: {
type: [String, Object, Array],
type: String,
description: "Input error (below input)"
},
footerError: {
Expand Down
10 changes: 3 additions & 7 deletions resources/assets/js/mixins/spa-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export default {
select: "",
enabled: 1
},
error_field: {}
error_field: {},
}
},

methods: {
addItem() {
this.newDatas = true;
Expand Down Expand Up @@ -99,7 +98,6 @@ export default {
onEditEvent(form_method, form_url, plus_data, form_list, form_id) {
const formData = new FormData(this.$refs["form"]);
const data = {};
let file = {};

for (let [key, val] of formData.entries()) {
Object.assign(data, {
Expand Down Expand Up @@ -131,7 +129,6 @@ export default {
}

this.onSuccessEvent(response);

}, this)
.catch(error => {
this.onFailError(error)
Expand Down Expand Up @@ -169,7 +166,6 @@ export default {
});

this.onSuccessEvent(response);

}, this)
.catch(error => {
this.onFailError(error);
Expand Down Expand Up @@ -199,8 +195,8 @@ export default {
}

const formData = new FormData(this.$refs["form"]);

let data_name = {};

for (let [key, val] of formData.entries()) {
Object.assign(data_name, {
[key]: val,
Expand All @@ -210,6 +206,7 @@ export default {
['_method']: 'POST',
});
}

formData.appendRecursive(data_name);

window.axios({
Expand All @@ -224,7 +221,6 @@ export default {
})
.then(response => {
this.onSuccessEvent(response);

}, this)
.catch(error => {
this.onFailError(error)
Expand Down
11 changes: 8 additions & 3 deletions resources/assets/js/views/wizard/Company.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
/>
<p class="mb-0 mt--3">
<small>
<div v-html="translations.company.get_api_key"></div>
<div><a href="https://akaunting.com/dashboard" target="_blank">Click here</a>
to get your API key.
</div>
</small>
</p>
</div>
Expand Down Expand Up @@ -123,6 +125,10 @@ export default {
translations: {
type: [Object, Array],
},
url: {
type: String,
default: 'text'
}
},
data() {
return {
Expand All @@ -133,9 +139,7 @@ export default {
},
mounted() {
let company_data = this.company;
setTimeout(() => {
this.dataWatch(company_data);
}, 500);
},
watch: {
company: function (company) {
Expand All @@ -159,6 +163,7 @@ export default {
this.real_date = company.financial_start;
}
},
next() {
if (this.active++ > 2);
this.$router.push("/wizard/currencies");
Expand Down
3 changes: 0 additions & 3 deletions resources/assets/js/views/wizard/Currencies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,14 @@ import MixinsSpaGlobal from "./../../mixins/spa-global";
export default {
name: "Currencies",
mixins: [MixinsGlobal, MixinsSpaGlobal],
components: {
[Step.name]: Step,
[Steps.name]: Steps,
[Select.name]: Select,
[Option.name]: Option,
AkauntingRadioGroup,
},
props: {
currencies: {
type: [Object, Array],
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/js/views/wizard/Taxes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export default {
this.onStatus(item.id, event);
this.onStatusControl(this.taxes, item.id, event);
},
handleClickDelete(item) {
this.confirmDelete(
`${
Expand All @@ -275,14 +276,17 @@ export default {
this.translations.taxes.delete
);
},
next() {
if (this.active++ > 2);
this.$router.push("/wizard/finish");
},
prev() {
if (this.active-- > 2);
this.$router.push("/wizard/currencies");
},
onEditSave(item) {
this.onEditEvent(
"PATCH",
Expand All @@ -292,9 +296,11 @@ export default {
item.id
);
},
onSubmitForm() {
this.onSubmitEvent("POST", url + "/wizard/taxes", "type", this.taxes);
},
deleteCurrency(event) {
this.onDeleteEvent(event, this.taxes, event.tax_id);
},
Expand Down

0 comments on commit aaa7f79

Please sign in to comment.