@@ -115,29 +115,29 @@ btnPrimaryBlock ( buttonId, labelText, msg ) =
115115 ]
116116
117117
118- viewKeyedRow : Int -> Row -> ( String , Html Msg )
119- viewKeyedRow index row =
120- ( toString row. id, Html . Lazy . lazy2 viewRow index row )
118+ viewKeyedRow : Row -> ( String , Html Msg )
119+ viewKeyedRow row =
120+ ( toString row. id, Html . Lazy . lazy viewRow row )
121121
122122
123- viewRow : Int -> Row -> Html Msg
124- viewRow index { id, label, selected } =
123+ viewRow : Row -> Html Msg
124+ viewRow { id, label, selected } =
125125 tr
126126 [ classList [ ( " danger" , selected ) ] ]
127127 [ td [ class " col-md-1" ] [ text ( toString id) ]
128128 , td
129129 [ class " col-md-4" ]
130130 [ a
131131 [ href " #"
132- , onClick ( Select index )
132+ , onClick ( Select id )
133133 ]
134134 [ text label ]
135135 ]
136136 , td
137137 [ class " col-md-1" ]
138138 [ a
139139 [ href " #"
140- , onClick ( Remove index )
140+ , onClick ( Remove id )
141141 ]
142142 [ span
143143 [ class " glyphicon glyphicon-remove"
@@ -173,7 +173,7 @@ view model =
173173 [ class " table table-hover table-striped test-data" ]
174174 [ tbody
175175 []
176- ( List . indexedMap viewKeyedRow model. rows)
176+ ( List . map viewKeyedRow model. rows)
177177 ]
178178 , span
179179 [ class " preloadicon glyphicon glyphicon-remove"
@@ -290,16 +290,10 @@ update msg model =
290290 ( model, Cmd . none )
291291
292292 Remove id ->
293- ( { model
294- | rows =
295- List . take id model. rows
296- ++ List . drop ( id + 1 ) model. rows
297- }
298- , Cmd . none
299- )
293+ ( { model | rows = List . filter ( \ r -> r. id /= id) model. rows }, Cmd . none )
300294
301- Select index ->
302- ( { model | rows = List . indexedMap ( select index ) model. rows }, Cmd . none )
295+ Select id ->
296+ ( { model | rows = List . map ( select id ) model. rows }, Cmd . none )
303297
304298 UpdateSeed seed ->
305299 ( { model | seed = Just seed }, Cmd . none )
@@ -313,9 +307,9 @@ updateRow index row =
313307 row
314308
315309
316- select : Int -> Int -> Row -> Row
317- select targetIndex index ( { id, label, selected } as row) =
318- if index == targetIndex then
310+ select : Int -> Row -> Row
311+ select targetId ( { id, label, selected } as row) =
312+ if id == targetId then
319313 Row id label True
320314 else if selected == True then
321315 Row id label False
0 commit comments