Time for action – Creating a computer view
Now, let's create a simple view for Computer
. It will be named computerList.views.ComputerView
:
package computerList.views; import computerList.models.Computer; import js.Dom; import js.Lib; class ComputerView { var computer:Computer; public var mainNode:js.HtmlDom; //To let the parent view know when we delete our object public var on Delete:ComputerView -> Void; public function new(comp:Computer) { computer = comp; mainNode = Lib.document.createElement("tr"); var nameCell = Lib.document.createElement("td"); nameCell.appendChild(Lib.document.createTextNode(computer.name)); var osCell = Lib.document.createElement("td"); var detailsCell = Lib.document.createElement("td"); osCell.appendChild(Lib.document.createTextNode) switch(computer.operatingSystem) { case Linux(distro): detailsCell.appendChild(Lib.document.createTextNode...