Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

remove utils.objectToArray #18

Merged
merged 1 commit into from
Apr 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/buttons/buttonbar.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
KDView = require './../../core/view.coffee'
KDButtonView = require './buttonview'
KDFormView = require '../forms/formview.coffee'

module.exports = class KDButtonBar extends KDView
constructor: (options = {}, data) ->
Expand All @@ -11,7 +12,7 @@ module.exports = class KDButtonBar extends KDView

{ buttons } = options

for buttonOptions in @utils.objectToArray buttons
for buttonOptions in KDFormView.sanitizeFormOptions buttons
button = @createButton buttonOptions
@addSubView button
@buttons[buttonOptions.key] = button
Expand Down
5 changes: 5 additions & 0 deletions src/components/forms/formview.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ module.exports = class KDFormView extends KDView

return inputs

@sanitizeFormOptions = (options) ->
for key, option of options
option.title ?= key
option.key = key
option

###
INSTANCE LEVEL
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/formviewwithfields.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = class KDFormViewWithFields extends KDFormView

{fields,buttons} = @getOptions()

@createFields @utils.objectToArray fields if fields
@createFields KDFormView.sanitizeFormOptions fields if fields

if buttons
@createButtons buttons
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/tabviewwithforms.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = class KDTabViewWithForms extends KDTabView
{forms} = @getOptions()

if forms
@createTabs forms = @utils.objectToArray forms
@createTabs forms = KDFormViewWithFields.sanitizeFormOptions forms
@showPane @panes[0]

if forms.length is 1
Expand Down
6 changes: 0 additions & 6 deletions src/core/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,6 @@ module.exports =
arr = arr.filter Boolean if filterEmpty
return arr

objectToArray: (options)->
for key, option of options
option.title ?= key
option.key = key
option

arrayToObject: (list, key) ->
dict = {}
dict[obj[key]] = obj for obj in list when obj[key]?
Expand Down