<ion-view view-title="允许谁看工作汇报" hide-nav-bar="false">
    <ion-nav-buttons side="right">
        <button class="button button-icon ion-ios-more" ng-if="isshowdelete.showDelete!=true" ng-click="popover.show($event)"></button>
        <button class="button button-clear" ng-if="isshowdelete.showDelete" ng-click="ok();">完成</button>
    </ion-nav-buttons>
    <ion-content>
        <ion-refresher pulling-text="下拉刷新" on-refresh="doRefresh()"></ion-refresher>
        <div class="item item-divider dividercolor">可以设置每个人的查看范围</div>
        <div ng-if="loading" class="center init-load action-sheet-backdrop">
            <ion-spinner icon="android"></ion-spinner>
        </div>
        <ion-list show-delete="isshowdelete.showDelete">
            <ion-item class="item item-icon-right item-remove-animate item-text-wrap" ng-repeat="item in userlist.results" ng-click="toSelectDeptOrItem(item)">
                <span>{{item.username}}</span>
                <p> 
                    <span ng-if="item.depts.length == 0 && item.users.length == 0 && item.all">全体成员</span>
                    <span ng-repeat="dept in item.depts">{{dept.depname}}{{$last ? '' : '、'}}</span>
                    <span ng-if="item.depts.length > 0 && item.users.length > 0">、</span>
                    <span ng-repeat="user in item.users">{{user.username}}{{$last ? '' : '、'}}</span>
                </p>
                <ion-delete-button class="ion-minus-circled" ng-click="remove(item)">
                </ion-delete-button>
                <i class="icon ion-chevron-right icon-accessory"></i>
            </ion-item>
        </ion-list>
        <ion-infinite-scroll spinner="android" ng-if="moreCanBeLoaded()" on-infinite="loadMore()" distance="1%" immediate-check="false"></ion-infinite-scroll>
    </ion-content>
    <script id="templates/add.html" type="text/ng-template">
        <ion-popover-view class="popver_view">
            <ion-content>
                <ion-list>
                    <ion-item class="item item-button" type="item-text-wrap" ng-click="toadd();">添加成员</ion-item>
                    <ion-item class="item item-button" type="item-text-wrap" ng-click="displayremove();">移除成员</ion-item>
                </ion-list>
            </ion-content>
        </ion-popover-view>
    </script>
</ion-view>