task weight calc and percentages, new column

This commit is contained in:
Bart van der Braak 2020-02-03 00:53:52 +01:00
parent 2977646d06
commit 9b1c786334
2 changed files with 20 additions and 9 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4"> <main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-4">
<router-view></router-view> <router-view></router-view>
</main> </main>
</template> </template>
@ -20,12 +20,6 @@ export default {
<style scoped> <style scoped>
[role="main"] { [role="main"] {
padding-top: 48px; /* Space for fixed navbar */ padding-top: 48px;
}
@media (min-width: 768px) {
[role="main"] {
padding-top: 48px; /* Space for fixed navbar */
}
} }
</style> </style>

View file

@ -13,7 +13,11 @@
</div> </div>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<b-table striped hover :items="filtered_items" :fields="fields"></b-table> <b-table striped hover :items="filtered_items" :fields="fields">
<template v-slot:cell(task_percentage)="data">
<span class="text-monospace">{{ data.value.toFixed(2) }}%</span>
</template>
</b-table>
</div> </div>
</section> </section>
</template> </template>
@ -65,6 +69,11 @@ export default {
sortable: true, sortable: true,
class: 'd-none', class: 'd-none',
}, },
{
key: 'task_percentage',
label: 'Task chance',
sortable: true,
},
], ],
config: { config: {
combat_level: 60, combat_level: 60,
@ -105,7 +114,15 @@ export default {
}); });
}, },
generateTaskWeights() { generateTaskWeights() {
//calculate total weight
this.total_weight = this.filtered_items.reduce(function(prev, cur) {
return prev + parseInt(cur.taskweight);
}, 0);
//add new entry with calculated task change
this.filtered_items.forEach(item => {
item.task_percentage = item.taskweight / this.total_weight * 100;
})
}, },
}, },
created() { created() {