Last active
August 29, 2015 14:15
-
-
Save rubys/ff27f31562a67ce78328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'wunderbar/sinatra' | |
require 'wunderbar/react' | |
require 'ruby2js/filter/functions' | |
get '/' do | |
_html do | |
_div.worklist! | |
_script do | |
docTypes = %w(icla grant ccla nda other) | |
class DocumentForm < React | |
def getInitialState | |
{type: 'none'} | |
end | |
def handleDocTypeChange(event) | |
@type = event.target.value; | |
end | |
def render | |
_form.documentForm do | |
_table do | |
_tr docTypes do |docType| | |
_td do | |
_input type: 'radio', name: 'doctype' , value: docType, | |
onChange: self.handleDocTypeChange | |
end | |
end | |
_tr docTypes do |docType| | |
_td docType | |
end | |
end | |
case @type | |
when 'icla' | |
_IclaForm | |
when 'nda' | |
_NdaForm | |
when 'grant' | |
_GrantForm | |
when 'ccla' | |
_CclaForm | |
end | |
_input type: "submit", value: "post" | |
end | |
end | |
end | |
class IclaForm < React | |
def render | |
_div.specificForm do | |
_input name: 'realname', type: 'text' | |
_input name: 'pubname', type: 'text' | |
_input name: 'email', type: 'text' | |
_input name: 'filename', type: 'text' | |
end | |
end | |
end | |
class NdaForm < React | |
def render | |
_div.specificForm do | |
_input name: 'name', type: 'text' | |
_input name: 'id', type: 'text' | |
_input name: 'email', type: 'email' | |
_input name: 'filename', type: 'text' | |
end | |
end | |
end | |
class GrantForm < React | |
def render | |
_div.specificForm do | |
_input name: 'from', type: 'text' | |
_textarea name: 'description', rows: 5 | |
_input name: 'name', type: 'text' | |
_input name: 'email', type: 'email' | |
_input name: 'filename', type: 'text' | |
end | |
end | |
end | |
class CclaForm < React | |
def render | |
_div.specificForm do | |
_input name: 'company', type: 'text' | |
_input name: 'product', type: 'text' | |
_input name: 'contact', type: 'text' | |
_input name: 'email', type: 'text' | |
_textarea name: 'employees', rows: 5 | |
_input name: 'filename', type: 'text' | |
end | |
end | |
end | |
end | |
_.render '#worklist' do | |
_DocumentForm | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment