{{extend 'layout.html'}}

{{block sectionclass}}step{{end}}

<h2>{{=T('New Application Wizard')}}</h2>

<div id="wizard_nav" class="f20 controls">
{{if request.function=='index':}}
  <h3>{{=T('Start a new app')}}</h3>
{{else:}}
  <div class="box">
    <h3>{{=T('Basics')}}</h3>
    <p>{{=button(URL('index'), T('restart'))}}</p>
    <p><strong>App Name:</strong> {{=session.app['name']}}</p>
  </div>
  <div class="box">
    <h3>Current settings</h3>      
    <p>{{=button(URL('step1'), T('edit'))}}</p>
    <ul id="current_settings">
    	{{for key,value in session.app['params']:}}
    	<li><b>{{=key}}:</b> {{=value}}</li>
    	{{pass}}
    </ul>
  </div>
  <div class="box">
    <h3>Tables</h3>
    <p>{{=button(URL('step2'), T('edit all'))}}</p>
    <ul>
    	{{for i,table in enumerate(session.app['tables']):}}
    	<li>{{=button(URL('step3',args=i), T('edit'))}} <strong>{{=table}}</strong></li>
    	{{pass}}
    </ul>
  </div>
  <div class="box">
    <h3>Pages</h3>
    <p>{{=button(URL('step4'), T('edit all'))}}</p>
    <ul>
      {{for i,page in enumerate(session.app['pages']):}}
      <li>{{=button(URL('step5',args=i), T('edit'))}} <strong>{{=page}}</strong></li>
      {{pass}}
    </ul>
  </div>
  <div class="box">
    <h3>{{=T('Generate')}}</h3>
    <p>{{=button(URL('step6'), T('go!'))}}</p>
  </div>
{{pass}}
</div>

<div id="wizard_form" class="fl20 controls">

  <!-- FORM -->
  
  {{if 'step' in request.function:}}
  <h3>{{=T('Step')}} {{=step}}</h3>
  {{if request.function!='step1':}}
  {{=button(URL('step' + str(int(request.function[-1])-1)), T('back'))}}
  {{pass}}
  {{else:}}
  <h3>{{=T('Begin')}}</h3>
  {{pass}}
  {{if request.function in ('step1','step2','step3','step4','step5'):}}
  {{=button(URL('step6'), T('skip to generate'))}}
  {{pass}}
  <br /><br />
  {{if request.function in ('step1','step6'):}}
  <img src="{{=LAYOUTS_APP}}/static/plugin_layouts/layouts/{{=dict(session.app['params'])['layout_theme']}}/preview.png" alt="" align="right" id="preview"/>
  {{pass}}
  <div class="form">
    {{=form}}
  </div>
  <script>
jQuery(document).ready(function(){
        var t=jQuery('#no_table_layout_theme');
  t.change(function(){
           jQuery('#preview').attr('src','{{=LAYOUTS_APP}}/static/plugin_layouts/layouts/'+t.val()+'/preview.png');
      });
});
  </script>
  
  <!-- INSTRUCTIONS -->
  <div class="box">
    <h4>Instructions</h4>
    <div class="help">
      {{if request.function=='index':}}
      <ul>
      	<li>Insert the name of a new app.</li>
      	<li>If the app exists and was created with the wizard, you will be able to edit it, but any manual editing to the app <b>will be lost</b>.</li>
      </ul>
      {{elif request.function=='step1':}}
      <ul>
        <li>This Wizard will help you build a new web2py app.</li>	
      	<li>You can create an app with a name that already exists.</li>
      	<li>If you do not have an email server set email server to "logging".</li>
      	<li>If you want to use Janrain Engage for login: 1) Sign up for a <a href="http://www.janrain.com/products/engage">Janrain Engage</a> account; 2) Register you hostname, domain, and obtain an api key; 3) Set Login Config above to "domain:api_key".</li>
	<li>ATTENTION: you can use the wizard to download plugins BUT we cannot guarantee the stability or backward compatibility of plugins. Moreover plugins may conflict with each other. Anyway, we do recommend installing plugin "wiki" with adds CMS like capabilities to your app.</li>
      </ul>
      {{elif request.function=='step2':}}
      <ul>
        <li>List the names of table that you need.</li>
      	<li>If you do not need authentication remove the table "auth_user".</li>
      	<li>Press enter to create a new input row.</li>
      	<li>Empty rows are ignored.</li>
      	<li>Other tables for role based access control will be created automatically, and do not need to be listed.</li>
        <li>You will be able to add fields later.</li>	
      </ul>
      {{elif request.function=='step3':}}
      <ul>
      	<li>List the fields for this table (do not include an id field, it is automatic), for example "name unique" or "birthday date" or "image upload" or "comments multiple" or "description wiki required"</li>
      	<li>The first keyword(s) for each entry will be used to generate a name for the table field and its label. You can use spaces an other unicode characters.</li>
        <li>Keywords "string" (default), "text", "integer", "boolean", "float", "double", "file", "date", "time", "datetime", "file", "upload" will be used to determine the field type and they will not be made part of the field name.</ li>
        <li>For a reference field use a field name, followed by the name of the referenced table.</li>
      	<li>Other special keywords are "required", "notnull" or "notempty", "unique". They map into equivalent validators but (at this time) should only be used with string and text types.</li>
      	<li>The keywords "html" and "wiki" force a text type and set a representation for the field value as sanitized HTML and MARKMIN resepectively.</li>
        <li>string, integer and reference fields can be "multiple", i.e. multiple values will be allowed</li>
      	<li>For the "auth_user" table do not add attributes to the default fields (username, first_name, last_name, password and email). They are handled automatically.</li>
        <li>Some fields will be added automatically upon creation and handled automatically: "created_by", "created_on", "modified_by", "modified_on", "active" (only active fields can be selected).</li>
        <li>For every table "table" another table "table_archive" is created and it contains the previous versions of each record. This is only accessible via appadmin or programmatically.</li> 
      </ul>
      {{elif request.function=='step4':}}
      <ul>
      	<li>List the names of the pages you want to create.</li>
        <li>Some pages are listed automatically because they expose Create/Read/Update/Delete for each tables you have created.</li>
        <li>All pages, except "error" and those with name starting in underscore willbe listed in the menu. You will be able to edit the menu later.</li>
        <li>You should have page "index", the starting point of your app, and page "error", where web2py will redirect to in case of error.</li>
            </ul>
            {{elif request.function=='step5':}}
            <ul>
        <li>Use the markmin syntax to add text to your pages.</li>
            </ul>
            {{elif request.function=='step6':}}
            <ul>
        <li>Almost done. Click on the button above to create your new app.</li>
        <li>Once done you will be able to edit it as any normal web2py app.</li>
      </ul>
      {{pass}}
    </div>
  </div>
</div>

