diff --git a/atst/models/clin.py b/atst/models/clin.py index 081ab764..dd4bdd76 100644 --- a/atst/models/clin.py +++ b/atst/models/clin.py @@ -27,3 +27,10 @@ class CLIN(Base, mixins.TimestampsMixin): end_date = Column(Date, nullable=False) obligated_amount = Column(Numeric(scale=2), nullable=False) jedi_clin_type = Column(SQLAEnum(JEDICLINType, native_enum=False), nullable=False) + + def to_dictionary(self): + return { + c.name: getattr(self, c.name) + for c in self.__table__.columns + if c.name not in ["id"] + } diff --git a/atst/models/task_order.py b/atst/models/task_order.py index 93131078..9f37854a 100644 --- a/atst/models/task_order.py +++ b/atst/models/task_order.py @@ -129,6 +129,9 @@ class TaskOrder(Base, mixins.TimestampsMixin): def to_dictionary(self): return { "portfolio_name": self.portfolio_name, + "clins": [ + clin.to_dictionary() for clin in self.clins + ], **{ c.name: getattr(self, c.name) for c in self.__table__.columns diff --git a/js/components/clin_fields.js b/js/components/clin_fields.js index df3d3b83..808c764b 100644 --- a/js/components/clin_fields.js +++ b/js/components/clin_fields.js @@ -6,87 +6,14 @@ export default { name: 'clin-fields', components: { - DateSelector, - optionsinput, textinput, }, props: { - clinIndex: String, + initialClinIndex: Number, + }, + + data: function() { + return {clinIndex: this.initialClinIndex} }, - // get clin index from props and pass into template - template: ` -
- - -
- - - -
-
- -
Start Date -
-
-
- -
- - -
-
- - -
-
- - -
- -
-

-

-
-
- -
End Date -
-
-
- -
- - -
-
- - -
-
- - -
- -
-

-

-
-
- - - -
-
`, } diff --git a/js/components/forms/to_form.js b/js/components/forms/to_form.js index 5d19d982..49913beb 100644 --- a/js/components/forms/to_form.js +++ b/js/components/forms/to_form.js @@ -17,15 +17,16 @@ export default { }, props: { - initialClinCount: String, + initialClinCount: Number, }, data: function() { const clins = this.initialClinCount == 0 ? [''] : [] + const clinIndex = this.initialClinCount == 0 ? 0 : this.initialClinCount - 1 return { clins, - clinCount: this.initalClinCount - 1, + clinIndex, } // pass initialCLINIndex in props and add one each time a clin is added... // this way we can keep track of the clin id for the html name/id/etc @@ -34,7 +35,7 @@ export default { methods: { addClin: function(event) { this.clins.push('') - this.clinCount = this.clinCount + 1 + this.clinIndex = this.clinIndex + 1 }, }, } diff --git a/templates/task_orders/edit.html b/templates/task_orders/edit.html index 169a4263..eee3d470 100644 --- a/templates/task_orders/edit.html +++ b/templates/task_orders/edit.html @@ -12,47 +12,126 @@ {{ TextInput(fields.number) }} {{ DatePicker(fields.start_date) }} {{ DatePicker(fields.end_date) }} - {{ TextInput(fields.obligated_amount) }} + {{ TextInput(fields.obligated_amount, validation='dollars') }} {% endmacro %} {% block portfolio_content %}
{% include "fragments/flash.html" %} - - {% if task_order_id %} - {% set action = url_for("task_orders.update", portfolio_id=portfolio.id, task_order_id=task_order_id) %} - {% else %} - {% set action = url_for("task_orders.update", portfolio_id=portfolio.id) %} - {% endif %} -
- {{ form.csrf_token }} - - Add Funding - - - {{ "common.cancel" | translate }} - - {{ SaveButton(text=('common.save' | translate), element='input', form='new-task-order') }} -

- {{ "task_orders.new.form_help_text" | translate }} -

-
- {{ TextInput(form.number, validation='taskOrderNumber') }} - {% for clin in form.clins %} - {{ CLINFields(clin) }} - {% endfor %} -
- - - - - - - -
+ + {% if task_order_id %} + {% set action = url_for("task_orders.update", portfolio_id=portfolio.id, task_order_id=task_order_id) %} + {% else %} + {% set action = url_for("task_orders.update", portfolio_id=portfolio.id) %} + {% endif %} + + {{ form.csrf_token }} + + Add Funding + + + {{ "common.cancel" | translate }} + + + {{ "task_orders.new.form_help_text" | translate }} +
+ {{ TextInput(form.number, validation='taskOrderNumber') }} + {% for clin in form.clins %} + {{ CLINFields(clin) }} + {% endfor %} +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
Start Date +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+ +
+

+

+
+
+ +
End Date +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+ +
+

+

+
+
+ + + +
+
+
+