Add change handler to clin field components
- emit clin type and obligated amount
This commit is contained in:
parent
4074f11e25
commit
c775c7322c
@ -1,7 +1,11 @@
|
|||||||
import DateSelector from './date_selector'
|
import DateSelector from './date_selector'
|
||||||
|
import { emitEvent } from '../lib/emitters'
|
||||||
import optionsinput from './options_input'
|
import optionsinput from './options_input'
|
||||||
import textinput from './text_input'
|
import textinput from './text_input'
|
||||||
|
|
||||||
|
const JEDI_CLIN_TYPE = "jedi_clin_type"
|
||||||
|
const OBLIGATED_AMOUNT = "obligated_amount"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'clin-fields',
|
name: 'clin-fields',
|
||||||
|
|
||||||
@ -17,6 +21,7 @@ export default {
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
initialClinType: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
@ -27,9 +32,14 @@ export default {
|
|||||||
clinIndex: this.initialClinIndex,
|
clinIndex: this.initialClinIndex,
|
||||||
indexOffset: this.initialLoaCount,
|
indexOffset: this.initialLoaCount,
|
||||||
loas: loas,
|
loas: loas,
|
||||||
|
clinType: this.initialClinType,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted: function() {
|
||||||
|
this.$root.$on('field-change', this.handleFieldChange)
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
addLoa: function(event) {
|
addLoa: function(event) {
|
||||||
++this.loas
|
++this.loas
|
||||||
@ -38,5 +48,20 @@ export default {
|
|||||||
loaIndex: function(index) {
|
loaIndex: function(index) {
|
||||||
return index + this.indexOffset - 1
|
return index + this.indexOffset - 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleFieldChange: function(event) {
|
||||||
|
if (this._uid === event.parent_uid) {
|
||||||
|
if (event.name.includes(JEDI_CLIN_TYPE)) {
|
||||||
|
this.clinType = event.value
|
||||||
|
}
|
||||||
|
else if (event.name.includes(OBLIGATED_AMOUNT)) {
|
||||||
|
emitEvent('clin-change', this, {
|
||||||
|
clinType: this.clinType,
|
||||||
|
amount: event.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
initialClinCount: Number,
|
initialClinCount: Number,
|
||||||
|
initialObligated: Number,
|
||||||
|
initialTotal: Number,
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
@ -35,8 +37,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
clins,
|
clins,
|
||||||
clinIndex,
|
clinIndex,
|
||||||
totalClinAmount: 0,
|
obligated: this.initialObligated || 0,
|
||||||
additionalObligatedAmount: 0,
|
total: this.initialTotal || 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -51,9 +53,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
calculateClinAmounts: function (event) {
|
calculateClinAmounts: function (event) {
|
||||||
this.totalClinAmount += parseFloat(event.amount - this.totalClinAmount)
|
this.total += parseFloat(event.amount - this.total)
|
||||||
if (event.clinType.includes('1') || event.clinType.includes('3')) {
|
if (event.clinType.includes('1') || event.clinType.includes('3')) {
|
||||||
this.additionalObligatedAmount += parseFloat(event.amount - this.additionalObligatedAmount)
|
this.obligated += parseFloat(event.amount - this.obligated)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -5,18 +5,16 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
name: String,
|
name: String,
|
||||||
additionalObligated: Number,
|
obligated: Number,
|
||||||
additionalContractAmount: Number,
|
contractAmount: Number,
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
computed: {
|
||||||
return {
|
formattedObligated: function () {
|
||||||
obligated: formatDollars(
|
return formatDollars(this.obligated)
|
||||||
this.additionalObligated
|
},
|
||||||
),
|
formattedContractAmount: function () {
|
||||||
contractAmount: formatDollars(
|
return formatDollars(this.contractAmount)
|
||||||
this.additionalContractAmount
|
},
|
||||||
),
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<clin-fields
|
<clin-fields
|
||||||
v-bind:initial-clin-index='{{ index }}'
|
v-bind:initial-clin-index='{{ index }}'
|
||||||
v-bind:initial-loa-count="{{ fields.loas.data | length }}"
|
v-bind:initial-loa-count="{{ fields.loas.data | length }}"
|
||||||
|
v-bind:initial-clin-type="'{{ fields.jedi_clin_type.data }}'"
|
||||||
inline-template>
|
inline-template>
|
||||||
<div>
|
<div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -102,7 +103,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<form id="new-task-order" action='{{ action }}' method="POST" autocomplete="off" enctype="multipart/form-data">
|
<form id="new-task-order" action='{{ action }}' method="POST" autocomplete="off" enctype="multipart/form-data">
|
||||||
{{ form.csrf_token }}
|
{{ form.csrf_token }}
|
||||||
<to-form inline-template v-bind:initial-clin-count="{{ form.clins.data | length }}">
|
|
||||||
|
{% set obligated = task_order.total_obligated_funds if task_order else 0 %}
|
||||||
|
{% set total = task_order.total_contract_amount if task_order else 0 %}
|
||||||
|
|
||||||
|
<to-form
|
||||||
|
inline-template
|
||||||
|
v-bind:initial-obligated='{{ obligated }}'
|
||||||
|
v-bind:initial-total='{{ total }}'
|
||||||
|
v-bind:initial-clin-count="{{ form.clins.data | length }}">
|
||||||
<div>
|
<div>
|
||||||
{% call StickyCTA(text="Add Funding") %}
|
{% call StickyCTA(text="Add Funding") %}
|
||||||
<span class="action-group">
|
<span class="action-group">
|
||||||
@ -382,26 +391,26 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ UploadInput(form.pdf, watch=True) }}
|
{{ UploadInput(form.pdf, watch=True) }}
|
||||||
</div>
|
</div>
|
||||||
{{ TotalsBox(task_order=task_order) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<totals-box
|
<totals-box
|
||||||
inline-template
|
inline-template
|
||||||
v-bind:additional-obligated='additionalObligatedAmount'
|
v-bind:obligated='obligated'
|
||||||
v-bind:additional-contract-amount='totalClinAmount'
|
v-bind:contract-amount='total'
|
||||||
>
|
>
|
||||||
<div class="col totals-box">
|
<div class="col totals-box">
|
||||||
<div class="h4">Total obligated funds</div>
|
<div class="h4">Total obligated funds</div>
|
||||||
<div class="h3">!{ obligated }</div>
|
<div class="h3" v-html="formattedObligated"></div>
|
||||||
<div>This is the funding allocated to cloud services. It may be 100% or a portion of the total task order budget.</div>
|
<div>This is the funding allocated to cloud services. It may be 100% or a portion of the total task order budget.</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="h4">Total contract amount</div>
|
<div class="h4">Total contract amount</div>
|
||||||
<div class="h3">!{ contractAmount }</div>
|
<div class="h3" v-html="formattedContractAmount"></div>
|
||||||
<div>This is the value of all funds obligated for this contract, including -- but not limited to -- funds obligated for the cloud.</div>
|
<div>This is the value of all funds obligated for this contract, including -- but not limited to -- funds obligated for the cloud.</div>
|
||||||
</div>
|
</div>
|
||||||
</totals-box>
|
</totals-box>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user