vue component for tracking CLIN total on task order funding page
This commit is contained in:
parent
e8dde759ad
commit
a610e92340
69
js/components/forms/funding.js
Normal file
69
js/components/forms/funding.js
Normal file
@ -0,0 +1,69 @@
|
||||
import createNumberMask from 'text-mask-addons/dist/createNumberMask'
|
||||
import { conformToMask } from 'vue-text-mask'
|
||||
|
||||
import FormMixin from '../../mixins/form'
|
||||
import textinput from '../text_input'
|
||||
|
||||
export default {
|
||||
name: 'funding',
|
||||
|
||||
mixins: [FormMixin],
|
||||
|
||||
components: {
|
||||
textinput,
|
||||
},
|
||||
|
||||
props: {
|
||||
initialData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
const {
|
||||
clin_01 = 0,
|
||||
clin_02 = 0,
|
||||
clin_03 = 0,
|
||||
clin_04 = 0,
|
||||
} = this.initialData
|
||||
|
||||
return {
|
||||
clin_01,
|
||||
clin_02,
|
||||
clin_03,
|
||||
clin_04,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
totalBudget: function () {
|
||||
return [this.clin_01, this.clin_02, this.clin_03, this.clin_04].reduce(
|
||||
function(acc, curr) {
|
||||
curr = curr === null ? 0 : parseInt(curr)
|
||||
return acc + curr;
|
||||
}, 0
|
||||
)
|
||||
},
|
||||
totalBudgetStr: function () {
|
||||
return this.formatDollars(this.totalBudget);
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatDollars: function (intValue) {
|
||||
const mask = createNumberMask({ prefix: '$', allowDecimal: true })
|
||||
return conformToMask(intValue.toString(), mask).conformedValue
|
||||
},
|
||||
updateBudget: function() {
|
||||
document.querySelector('#to-target').innerText = this.totalBudgetStr
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
clin_01: 'updateBudget',
|
||||
clin_02: 'updateBudget',
|
||||
clin_03: 'updateBudget',
|
||||
clin_04: 'updateBudget',
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import toggler from './components/toggler'
|
||||
import NewProject from './components/forms/new_project'
|
||||
import EditEnvironmentRole from './components/forms/edit_environment_role'
|
||||
import EditProjectRoles from './components/forms/edit_project_roles'
|
||||
import funding from './components/forms/funding'
|
||||
import Modal from './mixins/modal'
|
||||
import selector from './components/selector'
|
||||
import BudgetChart from './components/charts/budget_chart'
|
||||
@ -52,6 +53,7 @@ const app = new Vue({
|
||||
EditProjectRoles,
|
||||
RequestsList,
|
||||
ConfirmationPopover,
|
||||
funding,
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
{% include "fragments/flash.html" %}
|
||||
|
||||
<funding inline-template v-bind:initial-data='{{ form.data|tojson }}'>
|
||||
<div>
|
||||
<!-- Get Funding Section -->
|
||||
<h3>Period of Performance</h3>
|
||||
|
||||
@ -73,7 +75,21 @@ other services.
|
||||
</p>
|
||||
{{ TextInput(form.clin_03, validation='dollars', tooltip='The cloud support and assistance packages cannot be used as a primary development resource.') }}
|
||||
{{ TextInput(form.clin_04, validation='dollars', tooltip='The cloud support and assistance packages cannot be used as a primary development resource.') }}
|
||||
<p>Total Task Order Value</p>
|
||||
|
||||
</div>
|
||||
</funding>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block next %}
|
||||
<div class="row">
|
||||
<div class="col col--grow">
|
||||
<p>Total Task Order Value:<br><span id="to-target"></span></p>
|
||||
</div>
|
||||
<div class="col col--grow">
|
||||
{{ super() }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user