diff --git a/atst/routes/task_orders/new.py b/atst/routes/task_orders/new.py index 1f6a271b..bfce2c26 100644 --- a/atst/routes/task_orders/new.py +++ b/atst/routes/task_orders/new.py @@ -42,7 +42,12 @@ def edit(portfolio_id, task_order_id=None): def update(portfolio_id, task_order_id=None): form_data = {**http_request.form, **http_request.files} - form = TaskOrderForm(form_data) + form = None + if task_order_id: + task_order = TaskOrders.get(task_order_id) + form = TaskOrderForm(form_data, obj=task_order) + else: + form = TaskOrderForm(form_data) if form.validate(): task_order = None diff --git a/js/components/upload_input.js b/js/components/upload_input.js index 843bdf62..a94d394a 100644 --- a/js/components/upload_input.js +++ b/js/components/upload_input.js @@ -26,24 +26,27 @@ export default { data: function() { return { + hasInitialData: !!this.initialData, attachment: this.initialData || null, showErrors: this.initialErrors, + changed: false, } }, methods: { - showUploadInput: function() { - this.showUpload = true - }, addAttachment: function(e) { this.attachment = e.target.value this.showErrors = false + this.changed = true }, removeAttachment: function(e) { e.preventDefault() this.attachment = null - this.$refs.attachmentInput.value = null + if (this.$refs.attachmentInput) { + this.$refs.attachmentInput.value = null + } this.showErrors = false + this.changed = true }, }, @@ -56,5 +59,8 @@ export default { hasAttachment: function() { return !!this.attachment }, + hideInput: function() { + return this.hasInitialData && !this.changed + }, }, } diff --git a/templates/components/upload_input.html b/templates/components/upload_input.html index f2835baf..8eaa43dd 100644 --- a/templates/components/upload_input.html +++ b/templates/components/upload_input.html @@ -20,7 +20,7 @@ {{ field.label }} {% endif %} {{ field.description }} -
+