mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-29 12:41:10 -04:00
Add File based templates
This commit is contained in:
committed by
Mohit Panjwani
parent
00961bcae1
commit
d1dd704cdf
@ -7,14 +7,19 @@
|
||||
:key="index"
|
||||
:class="{
|
||||
'border border-solid border-primary-500':
|
||||
selectedTemplate === template.id,
|
||||
selectedTemplate === template.name,
|
||||
}"
|
||||
class="relative flex flex-col m-2 border border-gray-200 border-solid cursor-pointer hover:border-primary-300"
|
||||
@click="selectedTemplate = template.id"
|
||||
class="relative flex flex-col m-2 border border-gray-200 border-solid cursor-pointer hover:border-primary-300"
|
||||
>
|
||||
<img :src="template.path" alt="template-image" />
|
||||
<img
|
||||
v-if="selectedTemplate === template.id"
|
||||
:src="template.path"
|
||||
:alt="template.name"
|
||||
class="w-full"
|
||||
@click="selectedTemplate = template.name"
|
||||
/>
|
||||
<img
|
||||
v-if="selectedTemplate === template.name"
|
||||
:alt="template.name"
|
||||
class="absolute z-10 w-5 h-5 text-primary-500"
|
||||
style="top: -6px; right: -5px"
|
||||
src="/assets/img/tick.png"
|
||||
@ -24,8 +29,8 @@
|
||||
'w-full p-1 bg-gray-200 text-sm text-center absolute bottom-0 left-0',
|
||||
{
|
||||
'text-primary-500 bg-primary-100':
|
||||
selectedTemplate === template.id,
|
||||
'text-gray-600': selectedTemplate != template.id,
|
||||
selectedTemplate === template.name,
|
||||
'text-gray-600': selectedTemplate != template.name,
|
||||
},
|
||||
]"
|
||||
>
|
||||
@ -53,16 +58,16 @@ import { mapActions, mapGetters } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
selectedTemplate: 1,
|
||||
selectedTemplate: null,
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('modal', ['modalData']),
|
||||
...mapGetters('estimate', ['getTemplateId']),
|
||||
...mapGetters('estimate', ['getTemplateName']),
|
||||
},
|
||||
mounted() {
|
||||
this.selectedTemplate = this.getTemplateId
|
||||
this.selectedTemplate = this.getTemplateName
|
||||
},
|
||||
methods: {
|
||||
...mapActions('estimate', ['setTemplate']),
|
||||
@ -77,7 +82,7 @@ export default {
|
||||
}
|
||||
},
|
||||
closeEstimateModal() {
|
||||
this.selectedTemplate = this.getTemplateId
|
||||
this.selectedTemplate = this.getTemplateName
|
||||
this.closeModal()
|
||||
this.resetModalData()
|
||||
},
|
||||
|
||||
@ -7,14 +7,19 @@
|
||||
:key="index"
|
||||
:class="{
|
||||
'border border-solid border-primary-500':
|
||||
selectedTemplate === template.id,
|
||||
selectedTemplate === template.name,
|
||||
}"
|
||||
class="relative flex flex-col m-2 border border-gray-200 border-solid cursor-pointer hover:border-primary-300"
|
||||
@click="selectedTemplate = template.id"
|
||||
class="relative flex flex-col m-2 border border-gray-200 border-solid cursor-pointer hover:border-primary-300"
|
||||
>
|
||||
<img :src="template.path" alt="template-image" />
|
||||
<img
|
||||
v-if="selectedTemplate === template.id"
|
||||
:src="template.path"
|
||||
:alt="template.name"
|
||||
class="w-full"
|
||||
@click="selectedTemplate = template.name"
|
||||
/>
|
||||
<img
|
||||
v-if="selectedTemplate === template.name"
|
||||
:alt="template.name"
|
||||
class="absolute z-10 w-5 h-5 text-primary-500"
|
||||
style="top: -6px; right: -5px"
|
||||
src="/assets/img/tick.png"
|
||||
@ -53,16 +58,16 @@ import { mapActions, mapGetters } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
selectedTemplate: 1,
|
||||
selectedTemplate: null,
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('modal', ['modalData']),
|
||||
...mapGetters('invoice', ['getTemplateId']),
|
||||
...mapGetters('invoice', ['getTemplateName']),
|
||||
},
|
||||
mounted() {
|
||||
this.selectedTemplate = this.getTemplateId
|
||||
this.selectedTemplate = this.getTemplateName
|
||||
},
|
||||
methods: {
|
||||
...mapActions('invoice', ['setTemplate']),
|
||||
@ -77,7 +82,7 @@ export default {
|
||||
}
|
||||
},
|
||||
closeInvoiceModal() {
|
||||
this.selectedTemplate = this.getTemplateId
|
||||
this.selectedTemplate = this.getTemplateName
|
||||
this.closeModal()
|
||||
this.resetModalData()
|
||||
},
|
||||
|
||||
@ -60,10 +60,7 @@ export const fetchEstimate = ({ commit, dispatch, state }, id) => {
|
||||
window.axios
|
||||
.get(`/api/v1/estimates/${id}`)
|
||||
.then((response) => {
|
||||
commit(
|
||||
types.SET_TEMPLATE_ID,
|
||||
response.data.estimate.estimate_template_id
|
||||
)
|
||||
commit(types.SET_TEMPLATE_NAME, response.data.estimate.template_name)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -297,7 +294,7 @@ export const resetItem = ({ commit, dispatch, state }) => {
|
||||
|
||||
export const setTemplate = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit(types.SET_TEMPLATE_ID, data)
|
||||
commit(types.SET_TEMPLATE_NAME, data)
|
||||
resolve({})
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export const estimates = (state) => state.estimates
|
||||
export const selectAllField = (state) => state.selectAllField
|
||||
export const getTemplateId = (state) => state.estimateTemplateId
|
||||
export const getTemplateName = (state) => state.estimateTemplateName
|
||||
export const selectedEstimates = (state) => state.selectedEstimates
|
||||
export const totalEstimates = (state) => state.totalEstimates
|
||||
export const selectedCustomer = (state) => state.selectedCustomer
|
||||
|
||||
@ -4,7 +4,7 @@ import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
estimates: [],
|
||||
estimateTemplateId: 1,
|
||||
estimateTemplateName: null,
|
||||
selectAllField: false,
|
||||
selectedEstimates: [],
|
||||
totalEstimates: 0,
|
||||
|
||||
@ -9,7 +9,7 @@ export const RESET_CUSTOMER = 'RESET_CUSTOMER'
|
||||
export const RESET_ITEM = 'RESET_ITEM'
|
||||
export const SET_CUSTOMER = 'SET_CUSTOMER'
|
||||
export const SET_ITEM = 'SET_ITEM'
|
||||
export const SET_TEMPLATE_ID = 'SET_TEMPLATE_ID'
|
||||
export const SET_TEMPLATE_NAME = 'SET_TEMPLATE_NAME'
|
||||
export const SELECT_CUSTOMER = 'SELECT_CUSTOMER'
|
||||
export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
|
||||
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
|
||||
|
||||
@ -52,8 +52,8 @@ export default {
|
||||
state.selectAllField = false
|
||||
},
|
||||
|
||||
[types.SET_TEMPLATE_ID](state, templateId) {
|
||||
state.estimateTemplateId = templateId
|
||||
[types.SET_TEMPLATE_NAME](state, templateName) {
|
||||
state.estimateTemplateName = templateName
|
||||
},
|
||||
|
||||
[types.SELECT_CUSTOMER](state, data) {
|
||||
|
||||
@ -21,7 +21,7 @@ export const fetchInvoice = ({ commit, dispatch, state }, id) => {
|
||||
window.axios
|
||||
.get(`/api/v1/invoices/${id}`)
|
||||
.then((response) => {
|
||||
commit(types.SET_TEMPLATE_ID, response.data.invoice.invoice_template_id)
|
||||
commit(types.SET_TEMPLATE_NAME, response.data.invoice.template_name)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -219,7 +219,7 @@ export const resetCustomer = ({ commit, dispatch, state }) => {
|
||||
|
||||
export const setTemplate = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit(types.SET_TEMPLATE_ID, data)
|
||||
commit(types.SET_TEMPLATE_NAME, data)
|
||||
resolve({})
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export const invoices = (state) => state.invoices
|
||||
export const selectAllField = (state) => state.selectAllField
|
||||
export const getTemplateId = (state) => state.invoiceTemplateId
|
||||
export const getTemplateName = (state) => state.invoiceTemplateName
|
||||
export const selectedInvoices = (state) => state.selectedInvoices
|
||||
export const totalInvoices = (state) => state.totalInvoices
|
||||
export const selectedCustomer = (state) => state.selectedCustomer
|
||||
|
||||
@ -4,7 +4,7 @@ import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
invoices: [],
|
||||
invoiceTemplateId: 1,
|
||||
invoiceTemplateName: null,
|
||||
selectedInvoices: [],
|
||||
selectAllField: false,
|
||||
totalInvoices: 0,
|
||||
|
||||
@ -12,7 +12,7 @@ export const SET_CUSTOMER = 'SET_CUSTOMER'
|
||||
export const RESET_ITEM = 'RESET_ITEM'
|
||||
export const SET_ITEM = 'SET_ITEM'
|
||||
|
||||
export const SET_TEMPLATE_ID = 'SET_TEMPLATE_ID'
|
||||
export const SET_TEMPLATE_NAME = 'SET_TEMPLATE_NAME'
|
||||
|
||||
export const SELECT_CUSTOMER = 'SELECT_CUSTOMER'
|
||||
export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
|
||||
|
||||
@ -51,8 +51,8 @@ export default {
|
||||
state.selectedInvoices = []
|
||||
},
|
||||
|
||||
[types.SET_TEMPLATE_ID](state, templateId) {
|
||||
state.invoiceTemplateId = templateId
|
||||
[types.SET_TEMPLATE_NAME](state, templateName) {
|
||||
state.invoiceTemplateName = templateName
|
||||
},
|
||||
|
||||
[types.SELECT_CUSTOMER](state, data) {
|
||||
|
||||
@ -266,8 +266,8 @@
|
||||
variant="gray"
|
||||
@click="openTemplateModal"
|
||||
>
|
||||
<span class="flex text-black">
|
||||
{{ $t('estimates.estimate_template') }} {{ getTemplateId }}
|
||||
<span class="flex text-black capitalize">
|
||||
{{ getTemplateName }}
|
||||
<pencil-icon class="h-5 ml-2 -mr-1" />
|
||||
</span>
|
||||
</sw-button>
|
||||
@ -514,9 +514,9 @@ export default {
|
||||
...mapGetters('company', ['defaultCurrency']),
|
||||
|
||||
...mapGetters('estimate', [
|
||||
'getTemplateId',
|
||||
'selectedCustomer',
|
||||
'selectedNote',
|
||||
'getTemplateName',
|
||||
]),
|
||||
|
||||
...mapGetters('estimateTemplate', ['getEstimateTemplates']),
|
||||
@ -708,6 +708,7 @@ export default {
|
||||
'selectCustomer',
|
||||
'updateEstimate',
|
||||
'resetSelectedNote',
|
||||
'setTemplate',
|
||||
]),
|
||||
|
||||
...mapActions('item', ['fetchItems']),
|
||||
@ -789,6 +790,7 @@ export default {
|
||||
this.estimateNumAttribute = res4.data.nextNumber
|
||||
this.estimatePrefix = res4.data.prefix
|
||||
}
|
||||
this.setTemplate(this.getEstimateTemplates[0].name)
|
||||
} else {
|
||||
this.estimatePrefix = res4.data.prefix
|
||||
}
|
||||
@ -903,7 +905,7 @@ export default {
|
||||
total: this.total,
|
||||
tax: this.totalTax,
|
||||
user_id: null,
|
||||
estimate_template_id: this.getTemplateId,
|
||||
template_name: this.getTemplateName,
|
||||
}
|
||||
|
||||
if (this.selectedCustomer != null) {
|
||||
|
||||
@ -183,7 +183,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters('estimate', ['getTemplateId', 'selectedCustomer']),
|
||||
...mapGetters('estimate', ['getTemplateName', 'selectedCustomer']),
|
||||
},
|
||||
|
||||
created() {
|
||||
|
||||
@ -259,7 +259,7 @@
|
||||
@click="openTemplateModal"
|
||||
>
|
||||
<span class="flex text-black">
|
||||
{{ $t('invoices.template') }} {{ getTemplateId }}
|
||||
{{ getTemplateName }}
|
||||
<pencil-icon class="h-5 ml-2 -mr-1" />
|
||||
</span>
|
||||
</sw-button>
|
||||
@ -510,7 +510,7 @@ export default {
|
||||
...mapGetters('notes', ['notes']),
|
||||
|
||||
...mapGetters('invoice', [
|
||||
'getTemplateId',
|
||||
'getTemplateName',
|
||||
'selectedCustomer',
|
||||
'selectedNote',
|
||||
]),
|
||||
@ -710,6 +710,7 @@ export default {
|
||||
'selectCustomer',
|
||||
'updateInvoice',
|
||||
'resetSelectedNote',
|
||||
'setTemplate',
|
||||
]),
|
||||
|
||||
...mapActions('invoiceTemplate', ['fetchInvoiceTemplates']),
|
||||
@ -784,6 +785,7 @@ export default {
|
||||
this.invoiceNumAttribute = res4.data.nextNumber
|
||||
this.invoicePrefix = res4.data.prefix
|
||||
}
|
||||
this.setTemplate(this.getInvoiceTemplates[0].name)
|
||||
} else {
|
||||
this.invoicePrefix = res4.data.prefix
|
||||
}
|
||||
@ -899,7 +901,7 @@ export default {
|
||||
total: this.total,
|
||||
tax: this.totalTax,
|
||||
user_id: null,
|
||||
invoice_template_id: this.getTemplateId,
|
||||
template_name: this.getTemplateName,
|
||||
}
|
||||
|
||||
if (this.selectedCustomer != null) {
|
||||
|
||||
@ -185,7 +185,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters('invoice', ['getTemplateId', 'selectedCustomer']),
|
||||
...mapGetters('invoice', ['getTemplateName', 'selectedCustomer']),
|
||||
},
|
||||
|
||||
created() {
|
||||
|
||||
Reference in New Issue
Block a user