{{!
  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

  WSO2 Inc. licenses this file to you under the Apache License,
  Version 2.0 (the "License"); you may not use this file except
  in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied. See the License for the
  specific language governing permissions and limitations
  under the License.
}}

{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{unit "cdmf.unit.ui.modal"}}

{{#zone "breadcrumbs"}}
    <li>
        <a href="{{@app.context}}/">
            <i class="icon fw fw-home"></i>
        </a>
    </li>
    <li>
        <!--suppress HtmlUnknownTarget -->
        <a href="{{@app.context}}/roles">
            Roles
        </a>
    </li>
{{/zone}}

{{#zone "navbarActions"}}
    {{#unless isCloud}}
        <li>
            <!--suppress HtmlUnknownTarget -->
            <a href="{{@app.context}}/role/add" class="cu-btn">
            <span class="icon fw-stack">
                <i class="fw fw-add fw-stack-1x"></i>
                <i class="fw fw-circle-outline fw-stack-2x"></i>
            </span>
                Add Role
            </a>
        </li>
    {{/unless}}
{{/zone}}

{{#zone "content"}}
    {{#if hasRoles}}
        <div id="loading-content" class="col-centered">
            {{#unless isCloud}}
                {{#if removePermitted}}
                    <input type="hidden" id="can-remove" value="true"/>
                {{/if}}
                {{#if editPermitted}}
                    <input type="hidden" id="can-edit" value="true"/>
                {{/if}}
            {{/unless}}
            {{#if isCloud}}
                <input type="hidden" id="is-cloud" value="true"/>
            {{/if}}
            <i class="fw fw-settings fw-spin fw-2x"></i>
            Loading roles . . .
            <br>
        </div>

        <div id="role-table" data-cloud={{isCloud}} data-role={{adminRole}}>
            <table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
                   id="role-grid">
                <thead>
                <tr class="sort-row">
                    <th>By Role Name</th>
                </tr>
                <tr class="bulk-action-row">
                    <th colspan="3"></th>
                </tr>
                </thead>
                <tbody id="ast-container" data-app-context="{{@app.context}}/"></tbody>
            </table>
        </div>

        <div id="content-filter-types" style="display: none">
            <div class="sort-title">Sort By</div>
            <div class="sort-options">
                <!--suppress HtmlUnknownTag -->
                <th>By Role name</th>
            </div>
        </div>

    {{else}}

        <div id="user-created-msg" class="container col-centered wr-content">
            <div class="wr-form">
                <p class="page-sub-title">You Haven't created roles yet.</p>
                <br>Please click <b>"Add A New Role"</b>, if you wish to add a role.
                <hr/>

                <a href="{{@app.context}}/role/add" class="cu-btn-inner">
                        <span class="fw-stack">
                            <i class="fw fw-circle-outline fw-stack-2x"></i>
                            <i class="fw fw-add fw-stack-1x"></i>
                        </span>
                    Add Role
                </a>
            </div>
        </div>

    {{/if}}
{{/zone}}

{{#zone "bottomJs"}}
    <!--suppress HtmlUnknownTarget -->
    <script id="role-listing" data-current-user="{{@user.username}}"
            src="{{@page.publicUri}}/templates/role-listing.hbs" type="text/x-handlebars-template"></script>
    {{js "js/role-listing.js"}}
{{/zone}}