{{!
  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.modal"}}

<div class="row wr-device-board">
    <div class="col-lg-12 wr-secondary-bar">
            <span class="page-sub-title">
                Policy List by priority order
            </span>
    </div>
    <div class="row">
        <div class="col-md-12">
            <span id="policy-listing-status-msg">{{policyListingStatusMsg}}</span>
            <div class="wr-list-group wr-sortable policy-list">
                {{#each policyListToView}}
                    <span class="list-group-item " place="place_{{id}}" id="{{id}}">
                            <div class="row no-gutter">
                                <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 clearfix">
                                    <span class="wr-sortable-icon"><i class="fw fw-sort"></i></span>
                                    <span class="editable-text wr-sort-index">
                                        <input type="text" id="dd" class="index">
                                        <span class="icon fw-stack">
                                            <i class="fw fw-circle-outline fw-stack-2x"></i>
                                            <i class="fw fw-edit fw-stack-1x"></i>
                                        </span>
                                    </span>
                                    <span class="wr-list-icon">
                                            <i class=" fw fw-{{platform}}"></i>
                                    </span>
                                    <span class="wr-list-desc">
                                        <h3 class="wr-list-name">{{name}}</h3>
                                        <span class="wr-list-username">{{platform}}</span>
                                    </span>
                                </div>
                                <div class="col-xs-12 col-sm-8 col-md-8 col-lg-8">
                                    <div class="row no-gutter">
                                        <div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4">
                                            <div>
                                                <b>Ownership Type : </b> {{ownershipType}}
                                            </div>
                                        </div>
                                        {{#equal roles "None"}}
                                            <div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4">
                                                <div>
                                                    <b>Assigned User(s) : </b> {{users}}
                                                </div>
                                            </div>
                                        {{/equal}}
                                        {{#equal users "None"}}
                                            <div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4">
                                                <div>
                                                    <b>Assigned Role(s) : </b> {{roles}}
                                                </div>
                                            </div>
                                        {{/equal}}
                                        <div class="wr-desc-list-configs col-xs-12 col-sm-4 col-md-4 col-lg-4">
                                            <div>
                                                <b>Compliance Type :</b> {{compliance}}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </span>
                {{/each}}
            </div>
            {{#equal noPolicy false}}
                <div id="save-new-priorities-button" class="wr-input-control wr-btn-grp">
                    <button class="wr-btn hide" id="sortUpdateBtn" data-policycount="{{policyCount}}"
                            data-enabled="{{saveNewPrioritiesButtonEnabled}}" disabled>Save New Priority Order
                    </button>
                    <button class="wr-btn" id="applyChangesBtn">Apply Changes to Devices</button>
                </div>
            {{/equal}}
        </div>
    </div>
</div>

{{#zone "bottomJs"}}
    {{js "js/policy-priority.js"}}
    {{js "js/sortable-list.js"}}
{{/zone}}