package com.sb.elsinore.html;

import com.sb.elsinore.BrewServer;
import org.rendersnake.HtmlCanvas;
import org.rendersnake.Renderable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import static org.rendersnake.HtmlAttributesFactory.id;
import static org.rendersnake.HtmlAttributesFactory.name;
import static org.rendersnake.HtmlAttributesFactory.value;

/**
 * Created by doug on 07/02/15.
 */
public class RecipeListForm implements Renderable {

    @Override
    public void renderOn(HtmlCanvas htmlCanvas) throws IOException {
        ArrayList<String> recipeList = BrewServer.getRecipeList();
        htmlCanvas.div(id("newTriggersForm"))
            .form()
                .select(name("type").class_("holo-spinner")
                .onClick("setRecipe(this);"));
            htmlCanvas.option(value("").selected_if(true))
                    .write("Select Recipe Type")
                    ._option();
            for (String entry: recipeList) {
                htmlCanvas.option(value(entry))
                        .write(entry)
                        ._option();
            }
            htmlCanvas._select()
        ._form()
        ._div()
        .div(id("recipeContent"))._div();
    }
}

@@ -189,30 +189,8 @@
 ist;
-%0Aimport java.util.Map;
 %0A%0Aim
@@ -365,16 +365,67 @@
 e;%0A%0A/**%0A
+ * Render a form allowing selection of the recipe.%0A
  * Creat
@@ -434,13 +434,18 @@
  by 
-d
+D
 oug 
+Edey 
 on 0
@@ -691,19 +691,20 @@
 id(%22
-newTriggers
+selectRecipe
 Form
@@ -761,11 +761,11 @@
 me(%22
-typ
+nam
 e%22).
@@ -938,13 +938,8 @@
 cipe
- Type
 %22)%0A 
@@ -1078,28 +1078,24 @@
             
-    
 .write(entry
@@ -1096,20 +1096,16 @@
 (entry)%0A
-    
         

Improve selection of the Recipe