<NME> blueprint.twig
<BEF> {% extends "_layouts/cp" %}
{% set title = "The Architect"|t %}

{% import "_includes/forms" as forms %}

{% set tabs = {
    tab1: { label: "Raw Input"|t, url: url('thearchitect') },
    tab2: { label: "Available Files"|t, url: url('thearchitect/files') },
    tab3: { label: "Export"|t, url: url('thearchitect/blueprint') },
    tab4: { label: "Migrations"|t, url: url('thearchitect/migrations') },
    tab5: { label: "Matrix to Neo Export"|t, url: url('thearchitect/convert') },
} %}

{% set selectedTab = 'tab3' %}

{% set content %}
<div class="the-architect">

    <form class="field toolbar" action="" method="post" accept-charset="UTF-8">
        <input type="hidden" name="action" value="theArchitect/constructblueprint">
        {{ getCsrfInput() }}
        <h1>Fields</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxfield">
                            <input type="checkbox" id="allFields" class="checkbox" name="allFields" value="all"><label for="allFields"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                    <th>Type</th>
                    <th>Group</th>
                </tr>
            </thead>
            <tbody class="fields">
                {% for field in craft.fields.getAllFields() %}
                {% set utilizedFields = {} %}
                {% if field.type == 'Neo' %}
                    {% for blockType in craft.theArchitect.getNeoBlockTypesByFieldId(field.id) %}
                        {% for blockTab in blockType.getFieldLayout().getTabs() %}
                            {% for tabField in blockTab.getFields() %}
                                {% set utilizedFields = utilizedFields | merge([tabField.fieldId]) %}
                            {% endfor %}
                <tr class="field" data-id="{{ field.id }}" data-groupid="{{ field.group.id }}" data-name="{{ field }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <div class="field checkboxfield">
                            <input type="checkbox" id="field{{ field.id }}" class="checkbox{% if field.type == 'SuperTable' %} disabled" disabled="{% endif %}" name="fieldSelection[]" value="{{ field.id }}"> <label for="field{{ field.id }}">{{ field }}</label>
                        </div>
                    </th>
                    <td>
                    <td>
                        <code>{{ field.handle }}</code>
                    </td>
                    <td>
                        {{ field.type }}
                    </td>
                    <td>
                        {{ field.group }}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Sections</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxsection">
                            <input type="checkbox" id="allSections" class="checkbox" name="allSections" value="all"><label for="allSections"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                    <th>Type</th>
                    <th>URL Format</th>
                </tr>
            </thead>
            <tbody class="sections">
                {% for section in craft.sections.getAllSections() %}
                {% set utilizedFields = {} %}
                {% for entryType in section.getEntryTypes() %}
                    {% for fieldId in craft.fields.getLayoutById(entryType.fieldLayoutId).getFieldIds() %}
                        {% set utilizedFields = utilizedFields | merge([fieldId]) %}
                    {% endfor %}
                {% endfor %}
                <tr class="section" data-id="{{ section.id }}" data-name="{{ section }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <div class="section checkboxsection">
                            <input type="checkbox" id="section{{ section.id }}" class="checkbox" name="sectionSelection[]" value="{{ section.id }}"> <label for="section{{ section.id }}">{{ section }}</label>
                        </div>
                    </th>
                    <td>
                        <code>{{ section.handle }}</code>
                    </td>
                    <td>
                        {{ section.type }}
                    </td>
                    <td>
                        {{ section.urlFormat }}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Sources</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxsource">
                            <input type="checkbox" id="allAssetSources" class="checkbox" name="allAssetSources" value="all"><label for="allAssetSources"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                    <th>Type</th>
                </tr>
            </thead>
            <tbody class="assetSources">
                {% for assetSource in assetSources %}
                {% set utilizedFields = {} %}
                {% for sourceTab in assetSource.getFieldLayout().getTabs() %}
                    {% for tabField in sourceTab.getFields() %}
                        {% set utilizedFields = utilizedFields | merge([tabField.fieldId]) %}
                    {% endfor %}
                {% endfor %}
                <tr class="assetSource" data-id="{{ assetSource.id }}" data-name="{{ assetSource }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="assetSource{{ assetSource.id }}" class="checkbox" name="assetSourceSelection[]" value="{{ assetSource.id }}"> <label for="assetSource{{ assetSource.id }}">{{ assetSource }}</label>
                    </th>
                    <td>
                        <code>{{ assetSource.handle }}</code>
                    </td>
                    <td>
                        {{ assetSource.type }}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Transforms</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxtransform">
                            <input type="checkbox" id="allAssetTransforms" class="checkbox" name="allAssetTransforms" value="all"><label for="allAssetTransforms"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                    <th>Mode</th>
                    <th>Dimensions</th>
                    <th>Format</th>
                </tr>
            </thead>
            <tbody class="assetTransforms">
                {% for assetTransform in assetTransforms %}
                <tr>
                    <th scope="row" class="name">
                        <input type="checkbox" id="assetTransform{{ assetTransform.id }}" class="checkbox" name="assetTransformSelection[]" value="{{ assetTransform.id }}"> <label for="assetTransform{{ assetTransform.id }}">{{ assetTransform }}</label>
                    </th>
                    <td>
                        <code>{{ assetTransform.handle }}</code>
                    </td>
                    <td>
                        {{ assetTransform.mode }}
                    </td>
                    <td>
                        <code>{{ assetTransform.width }} &times; {{ assetTransform.height }}</code>
                    </td>
                    <td>
                        {{ (assetTransform.format) ? assetTransform.format : 'auto' }}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Globals</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxglobal">
                            <input type="checkbox" id="allGlobals" class="checkbox" name="allGlobals" value="all"><label for="allGlobals"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                </tr>
            </thead>
            <tbody class="globals">
                {% for global in craft.globals.getAllSets() %}
                {% set utilizedFields = {} %}
                {% for sourceTab in global.getFieldLayout().getTabs() %}
                    {% for tabField in sourceTab.getFields() %}
                        {% set utilizedFields = utilizedFields | merge([tabField.fieldId]) %}
                    {% endfor %}
                {% endfor %}
                <tr class="global" data-id="{{ global.id }}" data-name="{{ global }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="global{{ global.id }}" class="checkbox" name="globalSelection[]" value="{{ global.id }}"> <label for="global{{ global.id }}">{{ global }}</label>
                    </th>
                    <td>
                        <code>{{ global.handle }}</code>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Categories</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxcategory">
                            <input type="checkbox" id="allCategories" class="checkbox" name="allCategories" value="all"><label for="allCategories"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                </tr>
            </thead>
            <tbody class="categories">
                {% for category in craft.categoryGroups.getAllGroups() %}
                {% set utilizedFields = {} %}
                {% for sourceTab in category.getFieldLayout().getTabs() %}
                    {% for tabField in sourceTab.getFields() %}
                        {% set utilizedFields = utilizedFields | merge([tabField.fieldId]) %}
                    {% endfor %}
                {% endfor %}
                <tr class="category" data-id="{{ category.id }}" data-name="{{ category }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="category{{ category.id }}" class="checkbox" name="categorySelection[]" value="{{ category.id }}"> <label for="category{{ category.id }}">{{ category }}</label>
                    </th>
                    <td>
                        <code>{{ category.handle }}</code>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Routes</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxroute">
                            <input type="checkbox" id="allRoutes" class="checkbox" name="allRoutes" value="all"><label for="allRoutes"></label>
                            URI
                        </div>
                    </th>
                    <th>Template</th>
                </tr>
            </thead>
            <tbody class="routes">
                {% for route in craft.routes.getDbRoutes() %}
                <tr class="route" data-id="{{ route.id }}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="route{{ route.id }}" class="checkbox" name="routeSelection[]" value="{{ route.id }}"> <label for="route{{ route.id }}">{{ route.urlDisplayHtml | raw }}</label>
                    </th>
                    <td>
                        <code>{{ route.template }}</code>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Tags</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxtag">
                            <input type="checkbox" id="allTags" class="checkbox" name="allTags" value="all"><label for="allTags"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                </tr>
            </thead>
            <tbody class="tags">
                {% for tag in craft.theArchitect.getAllTagGroups() %}
                <tr class="tag" data-id="{{ tag.id }}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="tag{{ tag.id }}" class="checkbox" name="tagSelection[]" value="{{ tag.id }}"> <label for="tag{{ tag.id }}">{{ tag.name | raw }}</label>
                    </th>
                    <td>
                        <code>{{ tag.handle }}</code>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>Users</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxuser">
                            <input type="checkbox" id="allUsers" class="checkbox" name="allUsers" value="all"><label for="allUsers"></label>
                            Name
                        </div>
                    </th>
                    <th>Username</th>
                    <th>Email</th>
                </tr>
            </thead>
            <tbody class="users">
                {% for user in craft.theArchitect.getAllUsers() %}
                {% set utilizedGroups = {} %}
                {% for group in user.getGroups() %}
                    {% set utilizedGroups = utilizedGroups | merge([group.id]) %}
                {% endfor %}
                <tr class="user" data-id="{{ user.id }}" data-name="{{ user }}" data-groups="{% for id in utilizedGroups %}{{ id }} {% endfor %}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="user{{ user.id }}" class="checkbox" name="userSelection[]" value="{{ user.id }}"> <label for="user{{ user.id }}">{{ user.firstName }} {{ user.lastName }}</label>
                    </th>
                    <td>
                        {{ user.username }}
                    </td>
                    <td>
                        {{ user.email }}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        <h1>User Groups</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxusergroup">
                            <input type="checkbox" id="allGroups" class="checkbox" name="allGroups" value="all"><label for="allGroups"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                </tr>
            </thead>
            <tbody class="groups">
                {% if craft.userGroups is not null %}
                    {% for group in craft.userGroups.getAllGroups() %}
                    <tr class="group" data-id="{{ group.id }}" data-name="{{ group }}">
                        <th scope="row" class="name">
                            <input type="checkbox" id="group{{ group.id }}" class="checkbox" name="groupSelection[]" value="{{ group.id }}"> <label for="group{{ group.id }}">{{ group }}</label>
                        </th>
                        <td>
                            <code>{{ group.handle }}</code>
                        </td>
                    </tr>
                    {% endfor %}
                {% endif %}
            </tbody>
        </table>
        <hr>
        {% if craft.plugins.getPlugin('commerce') %}
        <h1>Product Types</h1>
        <table class="data fullwidth collapsible">
            <thead>
                <tr>
                    <th>
                        <div class="field checkboxproducttype">
                            <input type="checkbox" id="allProductTypes" class="checkbox" name="allProductTypes" value="all"><label for="allProductTypes"></label>
                            Name
                        </div>
                    </th>
                    <th>Handle</th>
                    <th>Title Format</th>
                    <th>Template</th>
                </tr>
            </thead>
            <tbody class="productTypes">
                {% for productType in craft.commerce.getProductTypes() %}
                <tr class="productType" data-id="{{ productType.id }}" data-name="{{ productType }}">
                    <th scope="row" class="name">
                        <input type="checkbox" id="productType{{ productType.id }}" class="checkbox" name="productTypeSelection[]" value="{{ productType.id }}"> <label for="productType{{ productType.id }}">{{ productType.name }}</label>
                    </th>
                    <td>
                        <code>{{ productType.handle }}</code>
                    </td>
                    <td>
                        <code>{{ productType.titleFormat }}</code>
                    </td>
                    <td>
                        <code>{{ productType.template }}</code>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        <hr>
        {% endif %}
        <div class="buttons clearafter">
            <input type="submit" class="btn submit export-btn" value="Export Selected">
            <input type="submit" class="btn submit disabled export-btn" disabled="" value="Export All">
        </div>
    </form>

</div>
{% endset %}

<MSG> Fix some crashing when requiredFields was not set and when it was not an array.

SuperTable exporting is enabled and working. Deep nesting of super table and matrix fields causes issues with craft. Keep them simple.

<DFF> @@ -46,7 +46,7 @@
                 <tr class="field" data-id="{{ field.id }}" data-groupid="{{ field.group.id }}" data-name="{{ field }}" data-fields="{% for id in utilizedFields %}{{ id }} {% endfor %}">
                     <th scope="row" class="name">
                         <div class="field checkboxfield">
-                            <input type="checkbox" id="field{{ field.id }}" class="checkbox{% if field.type == 'SuperTable' %} disabled" disabled="{% endif %}" name="fieldSelection[]" value="{{ field.id }}"> <label for="field{{ field.id }}">{{ field }}</label>
+                            <input type="checkbox" id="field{{ field.id }}" class="checkbox" name="fieldSelection[]" value="{{ field.id }}"> <label for="field{{ field.id }}">{{ field }}</label>
                         </div>
                     </th>
                     <td>

Fix some crashing when requiredFields was not set and when it was not an array.