Skip to content

Commit

Permalink
new scaffolding partial stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Techwraith committed Nov 3, 2012
1 parent ec419f1 commit 3b72978
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 72 deletions.
38 changes: 5 additions & 33 deletions templates/scaffold/realtime/views/ejs/add.html.ejs.ejs
Expand Up @@ -11,40 +11,12 @@
</ul>
</div>
<%% } %>
<% for(var i in properties) { -%>
<% if(properties[i].name !== 'id') { -%>
<div class="control-group">
<label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
<div class="controls">
<% if(properties[i].type === 'string') { -%>
<% if(properties[i].name === 'password') { -%>
<@- contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<@- contentTag('input', '', {type:'text', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } -%>
<% } else if(properties[i].type === 'text') { -%>
<@- contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10}) @>
<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
<@- contentTag('input', '', {type:'number', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'boolean') { -%>
<select name="<%= properties[i].name %>", class="span1">
<option selected>false</option>
<option>true</option>
</select>
<% } else if(properties[i].type === 'datetime') { -%>
<@- contentTag('input', '', {type:'datetime', class:'span3', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'date') { -%>
<@- contentTag('input', '', {type:'date', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<%= properties[i].type %>
<% } -%>
</div>

<@- partial('form', {user: {}}) @>

<div class="form-actions">
<@- contentTag('input', 'Add', {type: 'submit', class: 'btn btn-primary'}) @>
</div>
<% } -%>
<% } -%>
<div class="form-actions">
<@- contentTag('input', 'Add', {type: 'submit', class: 'btn btn-primary'}) @>
</div>
</fieldset>
</form>
</div>
45 changes: 6 additions & 39 deletions templates/scaffold/realtime/views/ejs/edit.html.ejs.ejs
Expand Up @@ -11,46 +11,13 @@
</ul>
</div>
<%% } %>
<% for(var i in properties) { -%>
<% if(properties[i].name !== 'id') { -%>
<div class="control-group">
<label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
<div class="controls">
<% if(properties[i].type === 'string') { -%>
<% if(properties[i].name === 'password') { -%>
<@- contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'text', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } -%>
<% } else if(properties[i].type === 'text') { -%>
<@- contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10}) @>
<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'number', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'boolean') { -%>
<select name="<%= properties[i].name %>", class="span1">
<@ if(<%= names.property.singular %>.<%= properties[i].name %>) { -@>
<option>false</option>
<option selected>true</option>
<@ } else { -@>
<option selected>false</option>
<option>true</option>
<@ } -@>
</select>
<% } else if(properties[i].type === 'datetime') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'datetime', class:'span3', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'date') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'date', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<%= properties[i].type %>
<% } -%>
</div>

<@- partial('form', {user: user}) @>

<div class="form-actions">
<@- contentTag('input', 'Save', {type: 'submit', class: 'btn btn-primary'}) @>
<@- contentTag('button', 'Remove', {type: 'submit', formaction: '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'}) @>
</div>
<% } -%>
<% } -%>
<div class="form-actions">
<@- contentTag('input', 'Save', {type: 'submit', class: 'btn btn-primary'}) @>
<@- contentTag('button', 'Remove', {type: 'submit', formaction: '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'}) @>
</div>
</fieldset>
</form>
</div>
36 changes: 36 additions & 0 deletions templates/scaffold/realtime/views/ejs/form.html.ejs.ejs
@@ -0,0 +1,36 @@
<% for(var i in properties) { -%>
<% if(properties[i].name !== 'id') { -%>
<div class="control-group">
<label for="<%= properties[i].name %>" class="control-label"><%= properties[i].name %></label>
<div class="controls">
<% if(properties[i].type === 'string') { -%>
<% if(properties[i].name === 'password') { -%>
<@- contentTag('input', '', {type:'password', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'text', class:'span6', name:'<%= properties[i].name %>'}) @>
<% } -%>
<% } else if(properties[i].type === 'text') { -%>
<@- contentTag('textarea', '', {class: 'span6', name: '<%= properties[i].name %>', rows: 10}) @>
<% } else if(properties[i].type === 'number' || properties[i].type === 'int') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'number', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'boolean') { -%>
<select name="<%= properties[i].name %>", class="span1">
<@ if(<%= names.property.singular %>.<%= properties[i].name %>) { -@>
<option>false</option>
<option selected>true</option>
<@ } else { -@>
<option selected>false</option>
<option>true</option>
<@ } -@>
</select>
<% } else if(properties[i].type === 'datetime') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'datetime', class:'span3', name:'<%= properties[i].name %>'}) @>
<% } else if(properties[i].type === 'date') { -%>
<@- contentTag('input', <%= names.property.singular %>.<%= properties[i].name %>, {type:'date', class:'span2', name:'<%= properties[i].name %>'}) @>
<% } else { -%>
<%= properties[i].type %>
<% } -%>
</div>
</div>
<% } -%>
<% } -%>

0 comments on commit 3b72978

Please sign in to comment.