invoice - add density selector, refactor invoice css

This commit is contained in:
Marek Fraczyk
2021-05-17 14:02:44 +03:00
parent 0bd6b24a27
commit 8846d52faf
7 changed files with 63 additions and 31 deletions

View File

@ -1,6 +1,9 @@
{ {
"back": "Back", "back": "Back",
"book": "Book", "book": "Book",
"density": "Density",
"compact": "Compact",
"comfortable": "Comfortable",
"download_pdf": "Download PDF", "download_pdf": "Download PDF",
"delete": "Delete", "delete": "Delete",
"delete_modal": { "delete_modal": {

View File

@ -1,15 +1,36 @@
.invoice-container { .invoice {
overflow-x: auto; &-container {
} overflow-x: auto;
}
.invoice-box { &-box {
margin: auto; margin: auto;
padding: 30px; padding: 30px;
min-width: var(--breakpoint-md); min-width: var(--breakpoint-md);
box-shadow: $box-shadow-light-1; box-shadow: $box-shadow-light-1;
font-size: 16px; font-size: 16px;
line-height: 24px; line-height: 24px;
font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
}
&__row {
&-control {
position: absolute;
top: 12px;
right: -30px;
}
}
&__rows {
&--compact {
th, td {
padding: 4px 16px;
}
.invoice__row-control {
top: 0;
}
}
}
} }
@page { @page {
@ -30,9 +51,3 @@
box-shadow: none; box-shadow: none;
} }
} }
.remove-invoice-row {
position: absolute;
right: -30px;
top: 10px;
}

View File

@ -20,7 +20,13 @@
<template slot="button-content"> <template slot="button-content">
<i class="material-icons">more_vert</i> <i class="material-icons">more_vert</i>
</template> </template>
<b-dropdown-item-button @click="print">{{ $t('download_pdf') }} </b-dropdown-item-button> <b-dropdown-group :header="$t('density')">
<b-dropdown-item-button @click="toggleCompact">
{{ invoice.is_compact ? $t('comfortable') : $t('compact') }}
</b-dropdown-item-button>
</b-dropdown-group>
<b-dropdown-divider/>
<b-dropdown-item-button @click="print">{{ $t('download_pdf') }}</b-dropdown-item-button>
<b-dropdown-item-button @click="deleteInvoice">{{ $t('delete') }}</b-dropdown-item-button> <b-dropdown-item-button @click="deleteInvoice">{{ $t('delete') }}</b-dropdown-item-button>
</b-dropdown> </b-dropdown>
</div> </div>
@ -31,14 +37,17 @@
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import NotificationService from '@/services/notification.service'; import NotificationService from '@/services/notification.service';
import { BDropdown, BDropdownItemButton } from 'bootstrap-vue'; import { BDropdown, BDropdownDivider, BDropdownGroup, BDropdownItemButton } from 'bootstrap-vue';
import AppSelect from '@/components/form/AppSelect'; import AppSelect from '@/components/form/AppSelect';
export default { export default {
i18nOptions: { namespaces: ['invoice-controls', 'statuses'] }, i18nOptions: { namespaces: ['invoice-controls', 'statuses'] },
components: { components: {
BDropdown, BDropdown,
BDropdownDivider,
BDropdownItemButton, BDropdownItemButton,
BDropdownGroup,
AppSelect, AppSelect,
}, },
computed: { computed: {
@ -94,6 +103,9 @@ export default {
invoiceId: this.invoice.id, invoiceId: this.invoice.id,
}); });
}, },
toggleCompact() {
this.updateProp({ is_compact: !this.invoice.is_compact });
},
print() { print() {
window.print(); window.print();
}, },

View File

@ -21,7 +21,7 @@
@change="updateProp({ notes: $event })"/> @change="updateProp({ notes: $event })"/>
</div> </div>
<div class="row"> <div class="row">
<table class="table"> <table class="table" :class="{'invoice__rows--compact': invoice.is_compact}">
<InvoiceRowsHeader :invoice="invoice"/> <InvoiceRowsHeader :invoice="invoice"/>
<tbody> <tbody>
<InvoiceRow v-for="(row, index) in invoice.rows" :errors="errors" <InvoiceRow v-for="(row, index) in invoice.rows" :errors="errors"

View File

@ -38,7 +38,8 @@
</td> </td>
<td class="text-right position-relative"> <td class="text-right position-relative">
{{ (row.quantity * row.price) | currency }} {{ (row.quantity * row.price) | currency }}
<button class="btn btn-sm remove-invoice-row d-print-none" @click="removeRow(row)"> <button class="btn btn-sm d-print-none invoice__row-control"
@click="removeRow(row)">
<i class="material-icons md-18 pointer">remove</i> <i class="material-icons md-18 pointer">remove</i>
</button> </button>
</td> </td>

View File

@ -1,15 +1,15 @@
<template> <template>
<thead> <thead>
<tr> <tr>
<th>{{ $t('item') }}</th> <th>{{ $t('item') }}</th>
<th>{{ $t('quantity') }}</th> <th>{{ $t('quantity') }}</th>
<th>{{ $t('unit') }}</th> <th>{{ $t('unit') }}</th>
<th>{{ $t('price') }}</th> <th>{{ $t('price') }}</th>
<th v-for="tax in taxes" :key="tax.id"> <th v-for="tax in taxes" :key="tax.id">
{{ tax.label }} % {{ tax.label }} %
</th> </th>
<th class="text-right">{{ $t('sum') }}</th> <th class="text-right">{{ $t('sum') }}</th>
</tr> </tr>
</thead> </thead>
</template> </template>

View File

@ -15,6 +15,7 @@ export default class Invoice extends Model {
number: this.attr(''), number: this.attr(''),
status: this.attr('draft'), status: this.attr('draft'),
issued_at: this.attr(''), issued_at: this.attr(''),
is_compact: this.attr(false),
due_at: this.attr(''), due_at: this.attr(''),
late_fee: this.attr(''), late_fee: this.attr(''),
currency: this.attr(''), currency: this.attr(''),