Skip to content

Commit

Permalink
refactor: use remaining_weight instead of calculating it
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Oct 3, 2023
1 parent b076fb1 commit 4635026
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/dialogs/SpoolmanChangeSpoolDialogRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<td class="text-center text-no-wrap">{{ material }}</td>
<td class="text-right text-no-wrap">{{ last_used }}</td>
<td class="text-right text-no-wrap">
<strong>{{ rest_weight_format }}</strong>
<strong>{{ remaining_weight_format }}</strong>
<small class="ml-1">/ {{ total_weight_format }}</small>
</td>
</tr>
Expand All @@ -32,6 +32,10 @@ import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types'
export default class SpoolmanChangeSpoolDialogRow extends Mixins(BaseMixin) {
@Prop({ required: true }) declare readonly spool: ServerSpoolmanStateSpool
mounted() {
window.console.log(this.spool)
}
get color() {
const color = this.spool.filament?.color_hex ?? '000'
Expand All @@ -54,16 +58,16 @@ export default class SpoolmanChangeSpoolDialogRow extends Mixins(BaseMixin) {
return this.spool.filament?.material ?? '--'
}
get used_weight() {
return this.spool.used_weight ?? 0
get remaining_weight() {
return this.spool.remaining_weight ?? 0
}
get total_weight() {
return this.spool.filament?.weight ?? 0
}
get rest_weight_format() {
return `${(this.total_weight - this.used_weight).toFixed(0)}g`
get remaining_weight_format() {
return `${this.remaining_weight.toFixed(0)}g`
}
get total_weight_format() {
Expand Down

0 comments on commit 4635026

Please sign in to comment.