The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[% DEFAULT
    model = {
        description => 'Blog post',
        name => 'Post',
        columns => [
            {
                label => 'ID',
                name => 'id',
                type => 'serial',
            }
        ]
    };
%]

[% BLOCK editable_model_value -%]
<span class="editable" [% is_json ? 'resty_json="1"' : "" %] resty_path="model/[% model.name %][% column ? "/" _ column : "" | html %]" resty_key="[% key | html %]" resty_value="[% resty_value | html %]" resty_type="[% resty_type |html %]">[% value | html %]</span>
[% END -%]

<!-- block begin -->
<div class="ttl">
    <span class="text">
        <a href="#modelrows/[% model.name %]/_all/contains/1">[% model.name %]</a>
    </span>
</div>

<div class="listcon">
    <ul>
        <li><b class="key">Name</b>: [% model.name | html %]</li>
        <li><b class="key">Description</b>: [% INCLUDE editable_model_value key="description", value=model.description %]</li>
        <li><b class="key">Columns</b>:
            <ul id="create-column">
            [%- FOREACH column IN model.columns %]
                <li>
              [%- first_time = 1;
                  col_names = column.keys.sort;
                  col_names = col_names.unshift('name');
                FOREACH key IN col_names %]
                [% NEXT IF NOT first_time AND key == 'name' %]
                [% IF first_time %]
                    [% first_time = 0 %]
                [% END %]
                [%- value = column.$key; %]
                [%- is_json = 0 %]
                [%- resty_type = (key == 'unique' || key == 'not_null') ? 'select':'text' %]
                [%- resty_value = (key == 'unique' || key =='not_null') ? "{'true': 'true','false':'false','selected':'true'}": value %]
                <b class="key">[%- key | html %]</b>: [% INCLUDE editable_model_value column=column.name %] &nbsp;&nbsp;
              [%- END %]
                <b><a class="show-detail" href="javascript:void(0);" onclick="deleteModelColumn('[% model.name %]', '[% column.name %]')">Delete</a></b>
                </li>
            [%- END %]
                <li class="add-col">
                <a class="add-col-link" href="javascript:void(0);" onclick="addNewColumn('[% model.name %]')">Add a new column</a>
                </li>
            </ul>
        </li>
    </ul>
    <ul>
        <li>
            <a class="show-detail" href="#modelrows/[% model.name %]/_all/contains/1">View model rows</a>
            &nbsp; &nbsp; &nbsp;
            <b><a class="show-detail" href="javascript:void(0);" onclick="deleteModel('[% model.name %]', 'models')">Delete this model</a></b>
        </li>
    </ul>
    <div class="clearit"></div>
</ul>

<ul>
<li><b><a href="#models">Back to the model list</a></b></p></li>
</ul>
</div>

<!-- block end -->