Feat: change type base to editable and add getters for hightlights and

editable
This commit is contained in:
Bertrand Benjamin 2021-08-13 10:42:01 +02:00
parent 5eb9837e1c
commit da86f4b9f1
3 changed files with 50 additions and 31 deletions

View File

@ -19,8 +19,8 @@
</div> </div>
</div> </div>
<div class="datas"> <div class="datas">
<li v-for="cara in monthDesc" :key='cara.name'> <li v-for="cara in description" :key='cara.name'>
<label :for='cara.name'>{{ cara.desc }}</label> <label :for='cara.name'>{{ cara.label }}</label>
<input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value"> <input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value">
</li> </li>
</div> </div>
@ -64,7 +64,7 @@ export default {
'lastMonthDate': 'lastMonthDate', 'lastMonthDate': 'lastMonthDate',
}), }),
...mapGetters('config', { ...mapGetters('config', {
'monthDesc': 'monthDesc', 'description': 'descEditable',
}), }),
formatedDate: function () { formatedDate: function () {
return format(this.monthDate, "MMMM YYY", {locale: frLocal} ) return format(this.monthDate, "MMMM YYY", {locale: frLocal} )
@ -132,6 +132,10 @@ export default {
display: flex; display: flex;
flex-direction: column-reverse; flex-direction: column-reverse;
} }
label{
text-align: right;
font-size: 0.8em;
}
.value { .value {
font-weight: bold; font-weight: bold;
} }

View File

@ -14,15 +14,15 @@
</div> </div>
</div> </div>
<div id="display" v-show="!editing"> <div id="display" v-show="!editing">
<div class="hightlight" v-for="cara in monthDesc" :key='cara.name'> <div class="hightlight" v-for="cara in descHightlights" :key='cara.name'>
<label :for='cara.name'>{{ cara.desc }}</label> <label :for='cara.name'>{{ cara.label }}</label>
<span class="value" >{{ cara.output(TheMonth) ?? "∅"}} {{cara.unit}}</span> <span class="value" >{{ cara.output(TheMonth) ?? "∅"}} {{cara.unit}}</span>
</div> </div>
</div> </div>
<div id="edit" v-show="editing"> <div id="edit" v-show="editing">
<div v-for="cara in monthDesc" :key='cara.name'> <div v-for="cara in descEditable" :key='cara.name' class="cara">
<label :for='cara.name'>{{ cara.desc }}</label> <label :for='cara.name'>{{ cara.label }}</label>
<input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value"> <input type="number" v-model.number="monthCopy[cara.name]" id="cara.name">
</div> </div>
</div> </div>
</div> </div>
@ -51,7 +51,8 @@ export default {
}, },
computed: { computed: {
...mapGetters('config', { ...mapGetters('config', {
'monthDesc': 'monthHightlightDesc', 'descHightlights': 'monthHightlightDesc',
'descEditable': 'descEditable',
}), }),
rawDate: function () { rawDate: function () {
return parseISO(this.TheDate, "yyyy-MM", new Date()) return parseISO(this.TheDate, "yyyy-MM", new Date())
@ -125,6 +126,7 @@ export default {
} }
.value { .value {
font-size: 1.5em; font-size: 1.5em;
text-align: right;
font-weight: bold; font-weight: bold;
} }
@ -137,5 +139,8 @@ export default {
font-size: 0.8em; font-size: 0.8em;
width: auto; width: auto;
} }
.cara {
display: flex;
flex-direction: column-reverse;
}
</style> </style>

View File

@ -17,12 +17,12 @@ const config = {
userDir: './userDir/', userDir: './userDir/',
dataFile: 'datas.csv', dataFile: 'datas.csv',
caProPercentage: 0.5, caProPercentage: 0.5,
monthDesc : [ descAll : [
{ {
name: 'caTheo', name: 'caTheo',
color: '', color: '',
desc: 'CA "scéances effectuées"', label: 'CA "scéances effectuées"',
type: 'base', type: 'editable',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
output: month => month.caTheo, output: month => month.caTheo,
@ -30,8 +30,8 @@ const config = {
{ {
name: 'caRetro', name: 'caRetro',
color: '', color: '',
desc: 'CA "Séances facturées"', label: 'CA "Séances facturées"',
type: 'base', type: 'editable',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
output: month => month.caRetro, output: month => month.caRetro,
@ -39,8 +39,8 @@ const config = {
{ {
name: 'caReact', name: 'caReact',
color: '', color: '',
desc: 'CA "Séances facturées" réactualisé', label: 'CA "Séances facturées" réactualisé',
type: 'base', type: 'editable',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
output: month => month.caReact, output: month => month.caReact,
@ -48,7 +48,7 @@ const config = {
{ {
name: 'sessionQty', name: 'sessionQty',
color: '', color: '',
desc: 'Nombre de séances effectuées', label: 'Nombre de séances effectuées',
unit: '', unit: '',
hightlight: false, hightlight: false,
output: month => month.sessionQty, output: month => month.sessionQty,
@ -56,8 +56,8 @@ const config = {
{ {
name: 'retro', name: 'retro',
color: '', color: '',
desc: 'Montant de la rétrocession', label: 'Montant de la rétrocession',
type: 'base', type: 'editable',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
output: month => month.retro, output: month => month.retro,
@ -65,8 +65,8 @@ const config = {
{ {
name: 'remuneration', name: 'remuneration',
color: '', color: '',
desc: 'Rémuneration', label: 'Rémuneration',
type: 'base', type: 'editable',
unit: '€', unit: '€',
hightlight: true, hightlight: true,
output: month => month.remuneration, output: month => month.remuneration,
@ -74,8 +74,8 @@ const config = {
{ {
name: 'proPercentage', name: 'proPercentage',
color: '', color: '',
desc: 'Pourcentage du CA pour la partie pro', label: 'Pourcentage du CA pour la partie pro',
type: 'base', type: 'editable',
unit: '%', unit: '%',
hightlight: false, hightlight: false,
output: month => month.proPercentage, output: month => month.proPercentage,
@ -83,7 +83,7 @@ const config = {
{ {
name: 'ca', name: 'ca',
color: '', color: '',
desc: 'ca', label: 'ca',
type: 'compute', type: 'compute',
unit: '€', unit: '€',
hightlight: true, hightlight: true,
@ -92,7 +92,7 @@ const config = {
{ {
name: 'notInvoiced', name: 'notInvoiced',
color: '', color: '',
desc: 'Non facturé', label: 'Non facturé',
type: 'compute', type: 'compute',
unit: '€', unit: '€',
hightlight: true, hightlight: true,
@ -101,7 +101,7 @@ const config = {
{ {
name: 'caPro', name: 'caPro',
color: '', color: '',
desc: 'CA pour le partie pro', label: 'CA pour le partie pro',
type: 'compute', type: 'compute',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
@ -110,7 +110,7 @@ const config = {
{ {
name: 'caPerso', name: 'caPerso',
color: '', color: '',
desc: 'CA destiné à la rémuneration', label: 'CA destiné à la rémuneration',
type: 'compute', type: 'compute',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
@ -119,7 +119,7 @@ const config = {
{ {
name: 'caPersoUntouch', name: 'caPersoUntouch',
color: '', color: '',
desc: 'CA destiné à la rémuneration non reversé', label: 'CA destiné à la rémuneration non reversé',
type: 'compute', type: 'compute',
unit: '€', unit: '€',
hightlight: false, hightlight: false,
@ -131,8 +131,18 @@ const config = {
getters: { getters: {
userDir (state) { return state.userDir }, userDir (state) { return state.userDir },
dataFilePath (state) { return path.join(state.userDir, state.dataFile) }, dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
monthDesc (state) { return state.monthDesc }, descAll (state) {
monthHightlightDesc (state) { return state.monthDesc.filter(a => a.hightlight) }, // All description of attributes for months
return state.descAll
},
descEditable (state) {
// All description of attributes for months
return state.descAll.filter(d => d.type == 'editable')
},
descOf: (state) => (desc) => {
return state.descAll.filter(d => d.name == desc)[0]
},
monthHightlightDesc (state) { return state.descAll.filter(a => a.hightlight) },
caProPercentage (state) { return state.caProPercentage }, caProPercentage (state) { return state.caProPercentage },
}, },
mutations: { mutations: {