From 2c5bfea04655d2df23e26d1ef05575e1014af387 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Wed, 10 Feb 2016 10:51:43 +0100 Subject: [PATCH] columnSelect: render initial selected state --- .../app/controllers/layout_ref.coffee | 2 +- .../app/lib/app_post/column_select.coffee | 10 ++++++-- .../app/views/generic/column_select.jst.eco | 24 +++++++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/app/controllers/layout_ref.coffee b/app/assets/javascripts/app/controllers/layout_ref.coffee index ac2c9397f..0d905ff37 100644 --- a/app/assets/javascripts/app/controllers/layout_ref.coffee +++ b/app/assets/javascripts/app/controllers/layout_ref.coffee @@ -1478,7 +1478,7 @@ class InputsRef extends App.ControllerContent name: 'project-name' id: 'project-name-123' placeholder: 'Enter Project Name' - options: [{value:0,name:'Apple'},{value:1,name:'Microsoft',selected:true},{value:2,name:'Google'},{value:3,name:'Deutsche Bahn'},{value:4,name:'Sparkasse'},{value:5,name:'Deutsche Post'},{value:6,name:'Mitfahrzentrale'},{value:7,name:'Starbucks'},{value:8,name:'Mac Donalds'},{value:9,name:'Flixbus'},{value:10,name:'Betahaus'},{value:11,name:'Bruno Banani'},{value:12,name:'Alpina'},{value:13,name:'Samsung'},{value:14,name:'ChariTea'},{value:15,name:'fritz-kola'},{value:16,name:'Vitamin Water'},{value:17,name:'Znuny'},{value:18,name:'Max & Moritz'}] + options: [{value:0,name:'Apple',selected:true},{value:1,name:'Microsoft',selected:true},{value:2,name:'Google'},{value:3,name:'Deutsche Bahn'},{value:4,name:'Sparkasse'},{value:5,name:'Deutsche Post'},{value:6,name:'Mitfahrzentrale'},{value:7,name:'Starbucks'},{value:8,name:'Mac Donalds'},{value:9,name:'Flixbus'},{value:10,name:'Betahaus'},{value:11,name:'Bruno Banani'},{value:12,name:'Alpina'},{value:13,name:'Samsung'},{value:14,name:'ChariTea'},{value:15,name:'fritz-kola'},{value:16,name:'Vitamin Water'},{value:17,name:'Znuny'},{value:18,name:'Max & Moritz'}] @$('.searchableSelectPlaceholder').replaceWith( searchableSelectObject.element() ) # selectable search diff --git a/app/assets/javascripts/app/lib/app_post/column_select.coffee b/app/assets/javascripts/app/lib/app_post/column_select.coffee index a6d7e37bb..8ce6a520c 100644 --- a/app/assets/javascripts/app/lib/app_post/column_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/column_select.coffee @@ -23,11 +23,17 @@ class App.ColumnSelect extends Spine.Controller constructor: -> super - @values = [] @render() render: -> - @html App.view('generic/column_select')( @options.attribute ) + @values = [] + _.each @options.attribute.options, (option) => + if option.selected + @values.push option.value + + @html App.view('generic/column_select') + attribute: @options.attribute + values: @values # keep inital height # disabled for now since controls in modals get rendered hidden diff --git a/app/assets/javascripts/app/views/generic/column_select.jst.eco b/app/assets/javascripts/app/views/generic/column_select.jst.eco index 5b2a8da44..b60d40b1b 100644 --- a/app/assets/javascripts/app/views/generic/column_select.jst.eco +++ b/app/assets/javascripts/app/views/generic/column_select.jst.eco @@ -1,24 +1,24 @@
-
<%- @T('Nothing selected') %>
- <% for option in @options: %> - +
<%- @T('Nothing selected') %>
+ <% for option in @attribute.options: %> +
<%= option.name %>
<% end %>
- <% if @options.length > 10: %> + <% if @attribute.options.length > 10: %> <% end %>
- <% for option in @options: %> -
<%= option.name %>
+ <% for option in @attribute.options: %> +
<%= option.name %>
<% end %>
\ No newline at end of file