mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-30 21:21:09 -04:00 
			
		
		
		
	Refactor Customization Page
This commit is contained in:
		| @ -127,14 +127,15 @@ | ||||
|           <div class="row mt-4"> | ||||
|             <div class="col collapse-input"> | ||||
|               <label>{{ $t('estimates.estimate_number') }}<span class="text-danger"> * </span></label> | ||||
|               <base-input | ||||
|                 :invalid="$v.newEstimate.estimate_number.$error" | ||||
|                 :read-only="true" | ||||
|                 v-model="newEstimate.estimate_number" | ||||
|               <base-prefix-input | ||||
|                 v-model="estimateNumAttribute" | ||||
|                 :invalid="$v.estimateNumAttribute.$error" | ||||
|                 :prefix="estimatePrefix" | ||||
|                 icon="hashtag" | ||||
|                 @input="$v.newEstimate.estimate_number.$touch()" | ||||
|                 @input="$v.estimateNumAttribute.$touch()" | ||||
|               /> | ||||
|               <span v-show="$v.newEstimate.estimate_number.$error && !$v.newEstimate.estimate_number.required" class="text-danger mt-1"> {{ $tc('estimates.errors.required') }}  </span> | ||||
|               <span v-show="$v.estimateNumAttribute.$error && !$v.estimateNumAttribute.required" class="text-danger mt-1"> {{ $tc('estimates.errors.required') }}  </span> | ||||
|               <span v-show="!$v.estimateNumAttribute.numeric" class="text-danger mt-1"> {{ $tc('validation.numbers_only') }}  </span> | ||||
|             </div> | ||||
|             <div class="col collapse-input"> | ||||
|               <label>{{ $t('estimates.ref_number') }}</label> | ||||
| @ -320,7 +321,7 @@ import { validationMixin } from 'vuelidate' | ||||
| import Guid from 'guid' | ||||
| import TaxStub from '../../stub/tax' | ||||
| import Tax from './EstimateTax' | ||||
| const { required, between, maxLength } = require('vuelidate/lib/validators') | ||||
| const { required, between, maxLength, numeric } = require('vuelidate/lib/validators') | ||||
|  | ||||
| export default { | ||||
|   components: { | ||||
| @ -361,7 +362,9 @@ export default { | ||||
|       discountPerItem: null, | ||||
|       initLoading: false, | ||||
|       isLoading: false, | ||||
|       maxDiscount: 0 | ||||
|       maxDiscount: 0, | ||||
|       estimatePrefix: null, | ||||
|       estimateNumAttribute: null | ||||
|     } | ||||
|   }, | ||||
|   validations () { | ||||
| @ -373,9 +376,6 @@ export default { | ||||
|         expiry_date: { | ||||
|           required | ||||
|         }, | ||||
|         estimate_number: { | ||||
|           required | ||||
|         }, | ||||
|         discount_val: { | ||||
|           between: between(0, this.subtotal) | ||||
|         }, | ||||
| @ -388,6 +388,10 @@ export default { | ||||
|       }, | ||||
|       selectedCustomer: { | ||||
|         required | ||||
|       }, | ||||
|       estimateNumAttribute: { | ||||
|         required, | ||||
|         numeric | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
| @ -559,6 +563,8 @@ export default { | ||||
|           this.taxPerItem = response.data.tax_per_item | ||||
|           this.selectedCurrency = this.defaultCurrency | ||||
|           this.estimateTemplates = response.data.estimateTemplates | ||||
|           this.estimatePrefix = response.data.estimate_prefix | ||||
|           this.estimateNumAttribute = response.data.nextEstimateNumber | ||||
|         } | ||||
|         this.initLoading = false | ||||
|         return | ||||
| @ -574,8 +580,9 @@ export default { | ||||
|         let today = new Date() | ||||
|         this.newEstimate.estimate_date = moment(today).toString() | ||||
|         this.newEstimate.expiry_date = moment(today).add(7, 'days').toString() | ||||
|         this.newEstimate.estimate_number = response.data.nextEstimateNumber | ||||
|         this.itemList = response.data.items | ||||
|         this.estimatePrefix = response.data.estimate_prefix | ||||
|         this.estimateNumAttribute = response.data.nextEstimateNumber | ||||
|       } | ||||
|       this.initLoading = false | ||||
|     }, | ||||
| @ -604,6 +611,7 @@ export default { | ||||
|       } | ||||
|  | ||||
|       this.isLoading = true | ||||
|       this.newEstimate.estimate_number = this.estimatePrefix + '-' + this.estimateNumAttribute | ||||
|  | ||||
|       let data = { | ||||
|         ...this.newEstimate, | ||||
| @ -637,7 +645,11 @@ export default { | ||||
|         this.isLoading = false | ||||
|       }).catch((err) => { | ||||
|         this.isLoading = false | ||||
|         console.log(err) | ||||
|         if (err.response.data.errors.estimate_number) { | ||||
|           window.toastr['error'](err.response.data.errors.estimate_number) | ||||
|           return true | ||||
|         } | ||||
|         window.toastr['error'](err.response.data.message) | ||||
|       }) | ||||
|     }, | ||||
|     submitUpdate (data) { | ||||
| @ -650,7 +662,11 @@ export default { | ||||
|         this.isLoading = false | ||||
|       }).catch((err) => { | ||||
|         this.isLoading = false | ||||
|         console.log(err) | ||||
|         if (err.response.data.errors.estimate_number) { | ||||
|           window.toastr['error'](err.response.data.errors.estimate_number) | ||||
|           return true | ||||
|         } | ||||
|         window.toastr['error'](err.response.data.message) | ||||
|       }) | ||||
|     }, | ||||
|     checkItemsData (index, isValid) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user