<div class="layout-header">
    {{> common_header}}
    {{#if Layout.org_list.result.length}}
    <table class="org-list paged-list">
    <thead>
        <tr>
            <td data-id="creation_date">
                {{i18n "org_list.header.creation_date"}}
            </td>
            <td data-id="name">
                {{i18n "org_list.header.name"}}
            </td>
            <td data-id="admin">
                {{i18n "org_details.prop.owner"}}
            </td>
            <td data-id="tags"></td>
            <td data-id="source">
                {{i18n "org_list.header.source"}}
            </td>
        </tr>
    </thead>
    </table>
    {{/if}}
</div>

<div class="layout-body">
    {{#if Layout.org_list.result.length}}
    <table class="org-list paged-list">
    <tbody>
    {{#each Layout.org_list.result}}
        <tr>
            <td data-id="creation_date">
                <div class="value" data-date="{{this.created}}">
                    {{{html_date this.created}}}
                </div>
                <div class="details">
                    <span title="{{i18n "org_details.header.id"}}:{{i18n "org_details.header.shard"}}">
                        ID {{dash_empty this.id}}{{#if this.shard}}:{{this.shard}}{{/if}}</span>
                    </span>
                    <span data-id="environment" title="{{i18n "org_details.header.environment"}}">@{{dash_empty this.environment}}</span>
                </div>
            </td>
            <td data-id="name">
                <div class="value">
                    <a href="/organizations/{{this.id}}">{{safe_name this}}</a>
                </div>
                <div class="details">
                    {{#unless (empty this.users_count)}}
                    <span data-id="user_count" title="{{i18n "org_list.header.users.full"}}">{{formatted_number this.users_count}}</span>
                    {{/unless}}
                    {{#if this.domains.master}}
                    <a href="{{link_url this.domains.master}}" rel="noopener noreferrer" title="{{i18n "org_details.header.domain"}}">
                        {{this.domains.master}}
                    </a>
                    {{/if}}
                </div>
            </td>
            <td data-id="admin">
                <div class="value" title="{{user_name this.owner.object}}">
                    {{dash_empty this.owner.object.nickname}}
                </div>
                <div class="details">
                    <span title="{{i18n "user_details.prop.uid"}}">UID {{this.owner.object.id}}</span>
                    <a href="/search?query={{this.owner.object.id}}&type=owner_id" title="{{i18n "org_list.tip.search_by_owner"}}" class="symbol">🔍</a>
                </div>
            </td>
            <td data-id="tags">
                {{#if this.subscription_plan}}
                <div class="badge" data-id="subscription_plan" data-value="{{this.subscription_plan}}" title="{{i18n "org_list.tip.subscription_plan." this.subscription_plan}}">
                    {{i18n "org_details.subscription_plan." this.subscription_plan}}
                </div>
                {{/if}}
                {{#if this.vip.length}}
                <div class="badge" data-id="vip" title="{{i18n "org_details.prop.vip"}}">
                    {{i18n "org_details.prop.vip"}}
                </div>
                {{/if}}
            </td>
            <td data-id="source">
                <span title="{{this.source}}">{{this.source}}</span>
            </td>
        </tr>
    {{/each}}
    </tbody>
    </table>

    {{#if Layout.org_list.cut_line}}
    <div class="list-cut-line">{{{Layout.org_list.cut_line}}}</div>
    {{else}}
    {{> page_navigation data=Layout.org_list}}
    {{/if}}

    {{else}}
    <div class="blank-paged-list">
        <div class="icon">∅</div>
        <div class="message">
            {{i18n "org_list.warning.not_found"}}
        </div>
        {{#if Layout.search_tip}}
        <div class="tip">
            {{{Layout.search_tip}}}
        </div>
        {{/if}}
    </div>
    {{/if}}
</div>
