Simplify code

This commit is contained in:
Björn Fromme
2019-10-02 16:22:37 +02:00
parent 3c32cfc05b
commit 2d6d8e840c
3 changed files with 52 additions and 60 deletions
@@ -19,8 +19,7 @@
</template> </template>
</div> </div>
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<div class="checkbox" v-for="action in crmData.actions" <div class="checkbox" v-for="action in crmData.actions" v-if="action.changeable === true">
v-if="action.changeable === true">
<label :class="{ disabled: !action.changeable}"> <label :class="{ disabled: !action.changeable}">
<input type="checkbox" class="form-control" <input type="checkbox" class="form-control"
v-model="action.value" :disabled="!action.changeable"/> v-model="action.value" :disabled="!action.changeable"/>
@@ -56,18 +55,6 @@
} }
}, },
created () { created () {
this.load()
},
methods: {
...mapMutations(['beginLoading', 'endLoading', 'alert']),
getClient () {
return axios.create({
headers: {
'Authorization': 'Bearer ' + this.authToken
}
});
},
load () {
this.beginLoading(); this.beginLoading();
return this.getClient().get('/api/crm-selections') return this.getClient().get('/api/crm-selections')
@@ -82,6 +69,15 @@
this.endLoading() this.endLoading()
}); });
}, },
methods: {
...mapMutations(['beginLoading', 'endLoading', 'alert']),
getClient () {
return axios.create({
headers: {
'Authorization': 'Bearer ' + this.authToken
}
});
},
save () { save () {
this.beginLoading(); this.beginLoading();
@@ -61,11 +61,6 @@
} }
}, },
created () { created () {
this.load()
},
methods: {
...mapMutations(['beginLoading', 'endLoading', 'alert']),
load () {
this.beginLoading(); this.beginLoading();
const client = axios.create({ const client = axios.create({
@@ -86,6 +81,8 @@
this.endLoading(); this.endLoading();
}); });
}, },
methods: {
...mapMutations(['beginLoading', 'endLoading', 'alert']),
formatBookingDate (date) { formatBookingDate (date) {
if (!date) { if (!date) {
return '-' return '-'
@@ -60,9 +60,13 @@
{{ timeFrame | period }} {{ timeFrame | period }}
</label> </label>
</div> </div>
<form-checkbox :value.sync="userData.monthLong"> <div class="checkbox">
<label>
<input type="checkbox" class="form-control" v-model="userData.monthLong"/>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
Ich habe Zeit und würde gerne über einen Monat am Stück in eine Destination. Ich habe Zeit und würde gerne über einen Monat am Stück in eine Destination.
</form-checkbox> </label>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -84,12 +88,10 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import 'dayjs/locale/de' import 'dayjs/locale/de'
import FormGroup from './components/FormGroup'; import FormGroup from './components/FormGroup';
import FormCheckbox from './components/FormCheckbox';
export default { export default {
components: { components: {
FormGroup, FormGroup
FormCheckbox
}, },
data () { data () {
return { return {
@@ -112,19 +114,6 @@
} }
}); });
}, },
load () {
this.beginLoading();
return this.getClient().get('/api/teamer-data')
.then(response => {
this.abilities = response.data.abilities;
this.timeFrames = response.data.timeFrames;
this.jobProfiles = response.data.jobProfiles;
}).catch(error => {
}).finally(() => {
this.endLoading();
});
},
save () { save () {
const data = { const data = {
abilities: this.userData.abilities, abilities: this.userData.abilities,
@@ -156,7 +145,17 @@
} }
}, },
created () { created () {
this.load() this.beginLoading();
return this.getClient().get('/api/teamer-data')
.then(response => {
this.abilities = response.data.abilities;
this.timeFrames = response.data.timeFrames;
this.jobProfiles = response.data.jobProfiles;
}).catch(error => {
}).finally(() => {
this.endLoading();
});
}, },
computed: { computed: {
...mapState(['userData', 'loading', 'authToken']) ...mapState(['userData', 'loading', 'authToken'])