stockor 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +15 -0
  4. data/Gemfile +3 -1
  5. data/Gemfile.lock +97 -193
  6. data/client/skr/Extension.coffee +8 -4
  7. data/client/skr/api.js +21 -0
  8. data/client/skr/api.scss +148 -0
  9. data/client/skr/api/Components/AddressForm.cjsx +47 -0
  10. data/client/skr/api/Components/Base.coffee +7 -0
  11. data/client/skr/api/Components/SaleHistory.cjsx +32 -0
  12. data/client/skr/api/Components/SingleItemCart.cjsx +30 -0
  13. data/client/skr/api/Models/Base.coffee +10 -0
  14. data/client/skr/api/Models/Cart.coffee +40 -0
  15. data/client/skr/api/Models/Sale.coffee +43 -0
  16. data/client/skr/api/Models/SalesHistory.coffee +17 -0
  17. data/client/skr/api/Models/Sku.coffee +16 -0
  18. data/client/skr/api/SingleItemCheckout.cjsx +99 -0
  19. data/client/skr/api/namespace.js +6 -0
  20. data/client/skr/api/onReady.coffee +23 -0
  21. data/client/skr/components/CreditCardForm.cjsx +35 -0
  22. data/client/skr/components/CustomerFinder.cjsx +0 -3
  23. data/client/skr/components/InvoiceFinder.cjsx +1 -0
  24. data/client/skr/components/LatexSnippets.cjsx +65 -0
  25. data/client/skr/components/LocationChooser.cjsx +5 -1
  26. data/client/skr/components/PrintButton.cjsx +33 -0
  27. data/client/skr/components/PrintFormChooser.cjsx +10 -10
  28. data/client/skr/components/SalesOrderFinder.cjsx +2 -1
  29. data/client/skr/components/SystemSettings.cjsx +69 -9
  30. data/client/skr/components/address/index.js +1 -0
  31. data/client/skr/models/Address.coffee +3 -0
  32. data/client/skr/models/CreditCard.coffee +49 -0
  33. data/client/skr/models/CreditCardGateway.coffee +27 -0
  34. data/client/skr/models/Invoice.coffee +13 -5
  35. data/client/skr/models/Location.coffee +6 -4
  36. data/client/skr/models/Payment.coffee +33 -13
  37. data/client/skr/models/SalesOrder.coffee +7 -3
  38. data/client/skr/models/SequentialId.coffee +17 -0
  39. data/client/skr/models/Sku.coffee +1 -1
  40. data/client/skr/models/TimeEntry.coffee +3 -4
  41. data/client/skr/models/mixins/PrintSupport.coffee +4 -1
  42. data/client/skr/models/mixins/SkuLine.coffee +1 -1
  43. data/client/skr/screens/customer-maint/CustomerMaint.cjsx +1 -2
  44. data/client/skr/screens/customer-projects/CustomerProjects.cjsx +7 -3
  45. data/client/skr/screens/customer-projects/index.scss +1 -0
  46. data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +1 -1
  47. data/client/skr/screens/gl-accounts/GlAccounts.cjsx +1 -1
  48. data/client/skr/screens/gl-transactions/GlTransactions.cjsx +1 -1
  49. data/client/skr/screens/invoice/Invoice.cjsx +9 -17
  50. data/client/skr/screens/invoice/Payment.cjsx +94 -13
  51. data/client/skr/screens/invoice/index.scss +32 -0
  52. data/client/skr/screens/locations/Locations.cjsx +3 -2
  53. data/client/skr/screens/payment-category/PaymentCategory.cjsx +1 -1
  54. data/client/skr/screens/payments/Payments.cjsx +5 -4
  55. data/client/skr/screens/sale-report/SaleReport.cjsx +73 -0
  56. data/client/skr/screens/sale-report/index.js +5 -0
  57. data/client/skr/screens/sale-report/index.scss +9 -0
  58. data/client/skr/screens/sales-order/SalesOrder.cjsx +4 -4
  59. data/client/skr/screens/sku-maint/SkuMaint.cjsx +5 -0
  60. data/client/skr/screens/sku-maint/SkuUomList.cjsx +45 -56
  61. data/client/skr/screens/sku-maint/index.scss +33 -13
  62. data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +2 -2
  63. data/client/skr/screens/time-tracking/EditEntry.cjsx +2 -4
  64. data/client/skr/screens/time-tracking/TimeTracking.cjsx +1 -1
  65. data/client/skr/screens/vendor-maint/VendorMaint.cjsx +1 -1
  66. data/client/skr/vendor/index.js +2438 -0
  67. data/config/lanes.rb +10 -3
  68. data/config/routes.rb +9 -7
  69. data/config/screens.rb +39 -13
  70. data/db/migrate/20160517032350_create_remove_location_logos.rb +11 -0
  71. data/db/migrate/20160531014306_create_public_skus.rb +7 -0
  72. data/db/migrate/20160604195848_create_null_addresses.rb +9 -0
  73. data/db/migrate/20160605024432_create_sku_associations_views.rb +48 -0
  74. data/db/migrate/20160608023553_create_invoice_payments.rb +9 -0
  75. data/db/migrate/20160620010455_add_payments_to_inv_details.rb +54 -0
  76. data/db/schema.sql +206 -38
  77. data/db/seed.rb +6 -0
  78. data/lib/skr.rb +1 -1
  79. data/lib/skr/access_roles.rb +6 -1
  80. data/lib/skr/concerns/has_gl_transaction.rb +8 -0
  81. data/lib/skr/concerns/inv_extensions.rb +11 -0
  82. data/lib/skr/concerns/is_order_like.rb +3 -3
  83. data/lib/skr/concerns/visible_id_identifier.rb +3 -8
  84. data/lib/skr/configuration.rb +2 -0
  85. data/lib/skr/extension.rb +6 -0
  86. data/lib/skr/handlers/credit_card_gateway.rb +31 -0
  87. data/lib/skr/handlers/invoice_from_time_entries.rb +12 -26
  88. data/lib/skr/handlers/sales.rb +44 -0
  89. data/lib/skr/handlers/sequential_ids.rb +46 -0
  90. data/lib/skr/handlers/skus.rb +36 -0
  91. data/lib/skr/jobs/fresh_books/import.rb +3 -1
  92. data/lib/skr/merchant_gateway.rb +37 -0
  93. data/lib/skr/models/address.rb +7 -5
  94. data/lib/skr/models/bank_account.rb +12 -0
  95. data/lib/skr/models/business_entity.rb +1 -1
  96. data/lib/skr/models/gl_transaction.rb +3 -0
  97. data/lib/skr/models/inv_line.rb +7 -2
  98. data/lib/skr/models/inventory_adjustment.rb +0 -5
  99. data/lib/skr/models/invoice.rb +25 -36
  100. data/lib/skr/models/location.rb +1 -1
  101. data/lib/skr/models/payment.rb +56 -10
  102. data/lib/skr/models/po_receipt.rb +0 -8
  103. data/lib/skr/models/sales_order.rb +7 -2
  104. data/lib/skr/models/sequential_id.rb +6 -1
  105. data/lib/skr/models/sku.rb +3 -0
  106. data/lib/skr/print.rb +1 -0
  107. data/lib/skr/print/context.rb +19 -0
  108. data/lib/skr/print/form.rb +7 -1
  109. data/lib/skr/version.rb +1 -1
  110. data/npm-build/package.json +26 -0
  111. data/npm-build/vendor.js +10 -0
  112. data/npm-build/webpack.config.js +25 -0
  113. data/spec/fixtures/skr/bank_account.yml +9 -0
  114. data/spec/fixtures/skr/customer.yml +10 -0
  115. data/spec/fixtures/skr/inv_line.yml +12 -0
  116. data/spec/fixtures/skr/invoice.yml +17 -0
  117. data/spec/fixtures/skr/payment_category.yml +6 -0
  118. data/spec/fixtures/skr/sales_order.yml +1 -1
  119. data/spec/fixtures/skr/sku.yml +10 -0
  120. data/spec/fixtures/skr/sku_loc.yml +4 -0
  121. data/spec/fixtures/skr/uom.yml +6 -0
  122. data/spec/server/handlers/invoice_from_time_entries_spec.rb +13 -6
  123. data/spec/server/handlers/sequential_ids_spec.rb +22 -0
  124. data/spec/server/models/invoice_spec.rb +36 -0
  125. data/spec/server/models/payment_spec.rb +50 -22
  126. data/spec/server/models/sales_order_spec.rb +12 -0
  127. data/spec/server/print/form_spec.rb +20 -4
  128. data/spec/skr/api/SingleItemCheckoutSpec.cjsx +10 -0
  129. data/spec/skr/screens/sale-report/SaleReportSpec.coffee +5 -0
  130. data/stockor.gemspec +5 -4
  131. data/templates/print/layout.tex.erb +1 -1
  132. data/templates/print/packages/INSTALL +7 -0
  133. data/templates/print/packages/qrcode.sty +3051 -0
  134. data/templates/print/packages/svgnam.def +186 -0
  135. data/templates/print/packages/x11nam.def +352 -0
  136. data/templates/print/packages/xcolor.pro +58 -0
  137. data/templates/print/packages/xcolor.sty +1460 -0
  138. data/templates/print/types/invoice/default.tex.erb +2 -0
  139. data/templates/print/types/invoice/labor.tex.erb +2 -1
  140. data/templates/print/types/invoice/ticket.tex.erb +41 -0
  141. data/templates/print/types/payment/default.tex.erb +13 -12
  142. metadata +78 -12
@@ -0,0 +1,99 @@
1
+ class OrderingForm extends Skr.Api.Components.Base
2
+
3
+ dataObjects:
4
+ sale: 'props'
5
+
6
+ onPurchase: (ev) ->
7
+ ev.preventDefault()
8
+ @sale.copySkusFromCart(@props.cart)
9
+ @setState(isSaving: true, isSaveComplete: false)
10
+ @sale.save().then (a, b) =>
11
+ @setState(isSaveComplete: true)
12
+ _.delay =>
13
+ @setState(isSaving: false)
14
+ @setState(isSaveComplete: false)
15
+ @props.onComplete() unless @sale.errors
16
+ , 1100
17
+
18
+ render: ->
19
+ classNames = _.classnames( 'order', {
20
+ 'is-saving': @state.isSaving,
21
+ 'is-complete': @state.isSaveComplete
22
+ })
23
+ <div className={classNames}>
24
+ <Skr.Api.Components.SaleHistory />
25
+ <div className="mask">
26
+ <div className="msg">
27
+ <i /> <span>Submitting&#8230;</span>
28
+ </div>
29
+ </div>
30
+ <div className="section">
31
+ <Skr.Api.Components.SingleItemCart cart={@props.cart} />
32
+ </div>
33
+ {<div className="errors">{@sale.errorMessage}</div> if @sale.errorMessage}
34
+ <div className="section">
35
+ <Skr.Api.Components.AddressForm address={@sale.billing_address} />
36
+ </div>
37
+ <div className="section">
38
+ <Skr.Components.CreditCardForm card={@sale.credit_card } />
39
+ </div>
40
+ <button className="purchase" onClick={@onPurchase}>Purchase</button>
41
+ </div>
42
+
43
+ class OrderingComplete extends Skr.Api.Components.Base
44
+
45
+ dataObjects:
46
+ sale: 'props'
47
+
48
+ render: ->
49
+ <div className="order-complete">
50
+ <Skr.Api.Components.SaleHistory />
51
+ <h3>Order number {@sale.visible_id} was successfully saved</h3>
52
+ <a target='_blank' href={@sale.pdfDownloadUrl()}>Download Receipt</a>
53
+ <div>
54
+ <button onClick={@props.onComplete}>Place new order</button>
55
+ </div>
56
+ </div>
57
+
58
+
59
+ class ErrorFetching extends Skr.Api.Components.Base
60
+
61
+ render: ->
62
+ <h1>Error loading sale item {@props.skuCode}</h1>
63
+
64
+ class Skr.SingleItemCheckout extends Skr.Api.Components.Base
65
+
66
+ statics:
67
+ render: (options) ->
68
+ new Lanes.React.Viewport(_.extend(options, {
69
+ rootProps:
70
+ _.pick(options, 'sale_options', 'skuCode', 'customer')
71
+ pubSubDisabled: true
72
+ rootComponent: @
73
+ }))
74
+
75
+ getInitialState: ->
76
+ showingOrder: true
77
+
78
+ dataObjects:
79
+ cart: -> new Skr.Api.Models.Cart
80
+ sale: -> new Skr.Api.Models.Sale(@props.sale_options)
81
+
82
+ componentWillMount: ->
83
+ @cart.addBySkuCode(@props.skuCode).then =>
84
+ @setState(errorFetching: true) if @cart.skus.length is 0
85
+
86
+ onTypeSwitch: ->
87
+ if @state.showingOrder
88
+ Skr.Api.Models.SalesHistory.record(@sale)
89
+ else
90
+ @sale.clear()
91
+ @setState(showingOrder: not @state.showingOrder)
92
+
93
+ render: ->
94
+ return <ErrorFetching skuCode={@props.skuCode} /> if @state.errorFetching
95
+
96
+ Component = if @state.showingOrder then OrderingForm else OrderingComplete
97
+ <div className="skr-simple-checkout">
98
+ <Component sale={@sale} cart={@cart} onComplete={@onTypeSwitch} />
99
+ </div>
@@ -0,0 +1,6 @@
1
+ Lanes.namespace("Skr.Models");
2
+ Lanes.namespace("Skr.Vendor");
3
+
4
+ Lanes.namespace("Skr.Views");
5
+ Lanes.namespace("Skr.Api.Models");
6
+ Lanes.namespace("Skr.Api.Components");
@@ -0,0 +1,23 @@
1
+ Skr.onDocumentReady = (fn) ->
2
+ if document.readyState isnt 'loading'
3
+ fn()
4
+ else if document.addEventListener
5
+ document.addEventListener 'DOMContentLoaded', fn
6
+ else
7
+ document.attachEvent 'onreadystatechange', ->
8
+ fn() if document.readyState != 'loading'
9
+
10
+
11
+ SCRIPT_PATH = /\/assets\/skr\/api\.js$/
12
+
13
+ Skr.onDocumentReady ->
14
+ for tag in document.querySelectorAll('script')
15
+ if tag.src.match SCRIPT_PATH
16
+ Lanes.config.api_host = tag.src.replace(SCRIPT_PATH, '')
17
+ Lanes.config.api_path = Lanes.config.api_host + "/api"
18
+ break
19
+ if Lanes.config.api_host
20
+ css = Lanes.config.api_host + "/assets/skr/api.css"
21
+ new Lanes.lib.AssetLoader([css], Lanes.emptyFn)
22
+ else
23
+ console.error("Unable to find script tag that Stockor was loaded from")
@@ -0,0 +1,35 @@
1
+ class Skr.Components.CreditCardForm extends Lanes.React.Component
2
+
3
+ dataObjects:
4
+ card: 'props'
5
+
6
+ setField: (ev) ->
7
+ @card[ev.target.name] = ev.target.value
8
+
9
+ componentDidMount: ->
10
+ @cardPreview ||= new Skr.Vendor.Card({
11
+ form: _.dom(@, 'form').el, container: _.dom(@, '.preview').el
12
+ })
13
+
14
+ render: ->
15
+ fieldProps =
16
+ onChange: @setField
17
+ type: 'text'
18
+
19
+ <div className="credit-card-form section">
20
+ <div className='preview'></div>
21
+
22
+ <form className="credit-card section">
23
+ <input {...fieldProps}
24
+ value={@card.number || ''}
25
+ placeholder="Card number" name="number" />
26
+ <input {...fieldProps} value={@card.name || ''}
27
+ placeholder="Full name" name="name" />
28
+ <div className="row">
29
+ <input {...fieldProps}
30
+ value={@card.expiry} placeholder="MM/YY" name="expiry" />
31
+ <input {...fieldProps}
32
+ value={@card.cvc} placeholder="CVC" name="cvc" />
33
+ </div>
34
+ </form>
35
+ </div>
@@ -25,9 +25,6 @@ class Skr.Components.CustomerFinder extends Lanes.React.Component
25
25
 
26
26
  render: ->
27
27
  props = _.clone(@props)
28
- if @model.hasAttribute('customer_code')
29
- props.defaultLabel = @model.customer_code
30
-
31
28
  if props.selectField
32
29
  <LC.SelectField labelField='code' sm=2 labelField="code" {...props} />
33
30
  else
@@ -12,6 +12,7 @@ class Skr.Components.InvoiceFinder extends Lanes.React.Component
12
12
  new Lanes.Models.Query({
13
13
  initialFieldIndex: 1
14
14
  title: 'Invoice'
15
+ defaultSort: 'visible_id', sortAscending: false
15
16
  syncOptions: Lanes.Models.Query.mergedSyncOptions(
16
17
  @props.syncOptions, { with: [ 'with_details' ] }
17
18
  ), autoRetrieve: true
@@ -0,0 +1,65 @@
1
+ class Skr.Components.LatexSnippets extends Lanes.React.Component
2
+
3
+ getInitialState: ->
4
+ name: ''
5
+ latex: ''
6
+
7
+ componentWillMount: ->
8
+ @props.settings['latex_snippets'] ||= {}
9
+
10
+ saveSnippet: (ev) ->
11
+ @setState(latex: ev.target.value)
12
+ name = @refs.name.value
13
+ if @state.name
14
+ @props.settings['latex_snippets'][@state.name] = ev.target.value
15
+
16
+ updateName: (ev) ->
17
+ @setState(name: ev.target.value)
18
+
19
+
20
+ setSnippet: (choice) ->
21
+ @setState(name: choice.id, latex: @props.settings['latex_snippets'][choice.id])
22
+
23
+ getSnippets: ->
24
+ snippets = []
25
+ for name, latex of @props.settings['latex_snippets']
26
+ snippets.push {id: name}
27
+ snippets
28
+
29
+ onRemove: ->
30
+ delete @props.settings['latex_snippets'][@state.name]
31
+ @setState(name: '', latex: '')
32
+
33
+ render: ->
34
+
35
+ <div className="latex-snippets">
36
+ <BS.FormGroup>
37
+ <h3>Print Form Snippets</h3>
38
+ <Lanes.Vendor.ReactWidgets.DropdownList
39
+ data={@getSnippets()}
40
+ valueField='id' textField='id'
41
+ value={@state.currentSnippet}
42
+ onChange={@setSnippet}
43
+ />
44
+ </BS.FormGroup>
45
+ <BS.Row>
46
+ <BS.FormGroup>
47
+ <BS.Col componentClass={BS.ControlLabel} sm={2}>
48
+ Snippet name
49
+ </BS.Col>
50
+ <BS.Col sm={9}>
51
+ <BS.FormControl type="text" ref='name'
52
+ value={@state.name} onChange={@updateName}/>
53
+ </BS.Col>
54
+ <BS.Col sm={1}>
55
+ <LC.Icon type="trash" onClick={@onRemove} />
56
+ </BS.Col>
57
+ </BS.FormGroup>
58
+ </BS.Row>
59
+ <BS.FormGroup>
60
+ <BS.ControlLabel>Latex</BS.ControlLabel>
61
+ <BS.FormControl componentClass="textarea"
62
+ value={@state.latex} onChange={@saveSnippet} />
63
+ </BS.FormGroup>
64
+
65
+ </div>
@@ -3,6 +3,7 @@ class Skr.Components.LocationChooser extends Lanes.React.Component
3
3
  propTypes:
4
4
  onModelSet: React.PropTypes.func
5
5
  name: React.PropTypes.string
6
+ hideSingle: React.PropTypes.bool
6
7
 
7
8
  getDefaultProps: ->
8
9
  label: 'Location', name: 'location'
@@ -22,6 +23,9 @@ class Skr.Components.LocationChooser extends Lanes.React.Component
22
23
  })
23
24
 
24
25
  render: ->
26
+ if @props.hideSingle and Skr.Models.Location.all.length < 2
27
+ return LC.SelectField.renderEmptyColumn(@props)
28
+
25
29
  props = _.clone(@props)
26
30
  if props.displayFinder
27
31
  <LC.RecordFinder ref="finder" sm=3 autoFocus
@@ -31,4 +35,4 @@ class Skr.Components.LocationChooser extends Lanes.React.Component
31
35
  {...props} />
32
36
  else
33
37
  <LC.SelectField {...props} choices={Skr.Models.Location.all.models}
34
- labelField='code' model={@props.model} />
38
+ fetchOnSelect={false} labelField='code' model={@props.model} />
@@ -0,0 +1,33 @@
1
+ class Skr.Components.PrintButton extends Lanes.React.BaseComponent
2
+
3
+ propTypes:
4
+ onPrint: React.PropTypes.func
5
+
6
+
7
+ componentWillMount: -> window.matchMedia('print')?.addListener(@onWindowPrint)
8
+ componentWillUnmount: -> window.matchMedia('print')?.removeListener(@onWindowPrint)
9
+ onWindowPrint: (mm) ->
10
+ return if mm.matches # true == print is starting, false == complete
11
+ _.delay( =>
12
+ @props.onPrint?(false)
13
+ , 1000)
14
+
15
+ print: ->
16
+ _.delay ->
17
+ window.print()
18
+ , 50 # a bit of time for all rendering to complete, and for the loading mask to hide
19
+
20
+ onPrintClick: ->
21
+ wait = @props.onPrint?(true)
22
+ if _.isPromise(wait)
23
+ wait.then @print
24
+ else
25
+ @print()
26
+
27
+ render: ->
28
+ if @props.iconOnly
29
+ <LC.Icon type="print" onClick={@onPrintClick} />
30
+ else
31
+ <BS.Button className="print" onClick={@onPrintClick} bsSize='small'>
32
+ <LC.Icon type="print" />Print
33
+ </BS.Button>
@@ -1,5 +1,7 @@
1
1
  class Skr.Components.PrintFormChooser extends Lanes.React.Component
2
2
 
3
+ mixins: [ Lanes.Components.Form.FieldMixin ]
4
+
3
5
  propTypes:
4
6
  label: React.PropTypes.string.isRequired
5
7
  model: Lanes.PropTypes.Model.isRequired
@@ -14,16 +16,14 @@ class Skr.Components.PrintFormChooser extends Lanes.React.Component
14
16
  else
15
17
  @props.model[@props.name] = val
16
18
 
17
- renderValue: (value) ->
18
- value
19
19
 
20
- render: ->
20
+ renderEdit: (props) ->
21
+
21
22
  choices = @props.choices || @props.model.constructor.Templates
22
23
  value = @props.value or @props.model[@props.name]
23
- <LC.FieldWrapper {...@props} value={value}>
24
- <Lanes.Vendor.ReactWidgets.DropdownList
25
- data={choices}
26
- value={value}
27
- onChange={@onChange}
28
- />
29
- </LC.FieldWrapper>
24
+
25
+ <Lanes.Vendor.ReactWidgets.DropdownList
26
+ data={choices}
27
+ value={value}
28
+ onChange={@onChange}
29
+ />
@@ -14,13 +14,14 @@ class Skr.Components.SalesOrderFinder extends Lanes.React.Component
14
14
  query: ->
15
15
  new Lanes.Models.Query({
16
16
  initialFieldIndex: 1, title: 'Sales Order', autoRetrieve: true
17
+ defaultSort: 'visible_id', sortAscending: false
17
18
  syncOptions: Lanes.Models.Query.mergedSyncOptions(
18
19
  @props.syncOptions, { with: [ 'with_details' ] }
19
20
  )
20
21
  src: Skr.Models.SalesOrder, fields: [
21
22
  { id: 'id', visible: false }
22
23
  { id: 'visible_id', title: 'SO #', fixedWidth: 100}
23
- { id: 'customer_code', title: 'Customer', fixedWidth: 120}
24
+ { id: 'customer_code', title: 'Customer', fixedWidth: 150}
24
25
  { id: 'order_date', fixedWidth: 120}
25
26
  { id: 'po_num', title: 'PO', fixedWidth: 120}
26
27
  { id: 'notes', flex: 1}
@@ -3,6 +3,13 @@ class Skr.Components.SystemSettings extends Lanes.React.Component
3
3
  dataObjects:
4
4
  banks: ->
5
5
  Skr.Models.BankAccount.Collection.fetch()
6
+ sequentialIds: ->
7
+ new Skr.Models.SequentialId
8
+ ccgateway: ->
9
+ Skr.Models.CreditCardGateway.fetchById()
10
+
11
+ componentWillMount: ->
12
+ @sequentialIds.fetch()
6
13
 
7
14
  setBankAccount: (value) ->
8
15
  Lanes.config.system_settings
@@ -13,15 +20,68 @@ class Skr.Components.SystemSettings extends Lanes.React.Component
13
20
  id = Lanes.config.system_settings.forExtension('skr').bank_account_id
14
21
  if id then {id} else undefined
15
22
 
23
+ SequentialId: ({si}) ->
24
+ {id, name, count} = si
25
+ onChange = (num) => @sequentialIds.updateValue(id, num)
26
+ <BS.Row>
27
+ <BS.Col sm=8>{name}</BS.Col>
28
+ <BS.Col sm=4>
29
+ <Lanes.Vendor.ReactWidgets.NumberPicker value={count} onChange={onChange} />
30
+ </BS.Col>
31
+ </BS.Row>
32
+
33
+ onSave: ->
34
+ @sequentialIds.save() if @sequentialIds.isDirty
35
+ @ccgateway.save()
36
+
37
+
38
+ setGatewayType: (type) ->
39
+ @ccgateway.type = type.id
40
+
41
+ renderCreditCardGateway: ->
42
+
43
+ <BS.Col sm=4>
44
+
45
+ <LC.FormGroup sm=12 label="Credit Card Gateway">
46
+ <Lanes.Vendor.ReactWidgets.DropdownList
47
+ ref="ccgateway"
48
+ data={Skr.Models.CreditCardGateway.allTypes()}
49
+ valueField='id' textField='name'
50
+ value={@ccgateway.type}
51
+ onChange={@setGatewayType}
52
+ />
53
+ </LC.FormGroup>
54
+ <LC.Input sm=12 name='login' model={@ccgateway} />
55
+ <LC.Input sm=12 type='password' name='password' model={@ccgateway} />
56
+ </BS.Col>
57
+
58
+
59
+
16
60
  render: ->
17
- <BS.Row className="skr-system-settings">
61
+ <div className="skr-system-settings">
62
+ <BS.Row>
63
+ <BS.Col sm=3>
64
+ <SC.BankAccountFinder selectField sm=12
65
+ label="Default Bank Account"
66
+ model={Lanes.config.system_settings}
67
+ choices={this.banks.models}
68
+ setSelection={@setBankAccount}
69
+ getSelection={@getBankAccount}
70
+ />
71
+ </BS.Col>
18
72
 
19
- <SC.BankAccountFinder selectField
20
- sm=3 label="Default Bank Account"
21
- model={Lanes.config.system_settings}
22
- choices={this.banks.models}
23
- setSelection={@setBankAccount}
24
- getSelection={@getBankAccount}
25
- />
73
+ <LC.FormGroup sm=4 label="Auto Assigned next ID">
74
+ {for si in @sequentialIds.ids
75
+ <@SequentialId si={si} key={si.id} />}
76
+ </LC.FormGroup>
26
77
 
27
- </BS.Row>
78
+ {@renderCreditCardGateway()}
79
+
80
+ </BS.Row>
81
+ <BS.Row>
82
+ <BS.Col sm=6>
83
+ <SC.LatexSnippets settings={@props.settings} />
84
+ </BS.Col>
85
+ </BS.Row>
86
+
87
+ </div>