Refactor InvoicesView to use view in template

This commit is contained in:
Scott Erickson 2015-10-22 15:26:52 -07:00
parent cd065f3ba6
commit b475815e41
2 changed files with 9 additions and 17 deletions

View file

@ -21,32 +21,32 @@ block content
.form .form
.form-group .form-group
label.control-label(for="amount", data-i18n="account_invoices.amount") label.control-label(for="amount", data-i18n="account_invoices.amount")
input#amount.form-control(name="amount", type="text", value="#{amount}") input#amount.form-control(name="amount", type="text", value="#{(view.amount / 100).toFixed(2)}")
.form-group .form-group
label.control-label(for="description", data-i18n="general.description") label.control-label(for="description", data-i18n="general.description")
input#description.form-control(name="description", type="text", value="#{description}") input#description.form-control(name="description", type="text", value="#{view.description}")
button#pay-button.btn.form-control.btn-primary(data-i18n="account_invoices.pay") button#pay-button.btn.form-control.btn-primary(data-i18n="account_invoices.pay")
br br
if state === 'invoice_paid' if view.state === 'invoice_paid'
#declined-alert.alert.alert-success.alert-dismissible #declined-alert.alert.alert-success.alert-dismissible
button.close(type="button" data-dismiss="alert") button.close(type="button" data-dismiss="alert")
span(aria-hidden="true") × span(aria-hidden="true") ×
p= stateMessage p= view.stateMessage
if state === 'validation_error' if view.state === 'validation_error'
#declined-alert.alert.alert-danger.alert-dismissible #declined-alert.alert.alert-danger.alert-dismissible
button.close(type="button" data-dismiss="alert") button.close(type="button" data-dismiss="alert")
span(aria-hidden="true") × span(aria-hidden="true") ×
p= stateMessage p= view.stateMessage
if state === 'declined' if view.state === 'declined'
#declined-alert.alert.alert-danger.alert-dismissible #declined-alert.alert.alert-danger.alert-dismissible
span(data-i18n="account_invoices.declined") span(data-i18n="account_invoices.declined")
button.close(type="button" data-dismiss="alert") button.close(type="button" data-dismiss="alert")
span(aria-hidden="true") × span(aria-hidden="true") ×
if state === 'unknown_error' if view.state === 'unknown_error'
#error-alert.alert.alert-danger.alert-dismissible #error-alert.alert.alert-danger.alert-dismissible
button.close(type="button" data-dismiss="alert") button.close(type="button" data-dismiss="alert")
span(aria-hidden="true") × span(aria-hidden="true") ×
p(data-i18n="loading_error.unknown") p(data-i18n="loading_error.unknown")
p= stateMessage p= view.stateMessage

View file

@ -20,14 +20,6 @@ module.exports = class InvoicesView extends RootView
@amount = utils.getQueryVariable('a', 0) @amount = utils.getQueryVariable('a', 0)
@description = utils.getQueryVariable('d', '') @description = utils.getQueryVariable('d', '')
getRenderData: ->
c = super()
c.amount = (@amount / 100).toFixed(2)
c.description = @description
c.state = @state
c.stateMessage = @stateMessage
c
onPayButton: -> onPayButton: ->
@description = $('#description').val() @description = $('#description').val()