<section ng-controller="FeatureMappersController" ng-init="find()">
    <div class="page-header">
        <h2>Feature Mapper List</h2>
        Click on a row to edit or delete that item
    </div>

    <!-- Bootstrap Grid System with panels -->
    <div class ="container">

        <div class="form-group">
            <div class="input-group">
                <div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
                <div class="col-lg-6">
                    <input type="text" class="form-control" placeholder="Search Pattern 1" ng-model="Pattern1">
                </div>
                <div class="col-lg-6">
                    <input type="text" class="form-control" placeholder="Search Pattern 2" ng-model="Pattern2">
                </div>
                <div class="col-lg-4">
                    <label>Omit sites with placement waiver?</label>
                </div>
                <div class="col-lg-2">
                    <input type="checkbox" ng-model="PlacementPattern1" ng-true-value="{placement_waiver: '!Y'}" ng-false-value="''" checked>
                </div>
                <div class="col-lg-4">
                    <label>Omit sites with placement exception?</label>
                </div>
                <div class="col-lg-2">
                    <input type="checkbox" ng-model="PlacementPattern2" ng-true-value="{placement_exception: '!Y'}" ng-false-value="''" checked>
                </div>
            </div>
        </div>


        <div class="panel panel-group panel-default">
            <div class="panel-heading">
                <div class ="row">
                    <div class="col-lg-2">
                        <a href="#" ng-click="sortType = ['address.city', 'address.state', 'address.country'] | uppercase; sortReverse = !sortReverse">
                            <b>Location</b>
                            <span ng-show="(sortType.indexOf('address.city') >= 0) && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="(sortType.indexOf('address.city') >= 0) && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>

                    <div class="col-lg-1">
                        <a href="#" ng-click="sortType = ['clli', 'cluster'] | uppercase; sortReverse = !sortReverse">
                            <b>CLLI</b>
                            <span ng-show="(sortType.indexOf('clli') >= 0) && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="(sortType.indexOf('clli') >= 0) && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>
                    <div class="col-lg-1">
                        <a href="#" ng-click="sortType = ['zone', 'cluster']; sortReverse = !sortReverse">
                            <b>Site</b>
                            <span ng-show="(sortType.indexOf('zone') >= 0) && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="(sortType.indexOf('zone') >= 0) && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>
                    <div class="col-lg-1">
                        <a href="#" ng-click="sortType = ['placement_waiver', 'placement_exception']; sortReverse = !sortReverse">
                            <b>Placement W/E</b>{{OmitPlacement}}
                            <span ng-show="(sortType.indexOf('placement_waiver') >= 0) && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="(sortType.indexOf('placement_waiver') >= 0) && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>
                    <div class="col-lg-3">
                        <a href="#" ng-click="sortType = 'site_description'; sortReverse = !sortReverse">
                            <b>Site Description</b>
                            <span ng-show="sortType === 'site_description' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="sortType === 'site_description' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>

                    <div class="col-lg-2">
                        <a href="#" ng-click="sortType = 'site_type'; sortReverse = !sortReverse">
                            <b>Site Type</b>
                            <span ng-show="sortType === 'site_type' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="sortType === 'site_type' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>
                    <div class="col-lg-1">
                        <a href="#" ng-click="sortType = 'aic_version'; sortReverse = !sortReverse">
                            <b>AIC Version</b>
                            <span ng-show="sortType === 'aic_version' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
                            <span ng-show="sortType === 'aic_version' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
                        </a>
                    </div>
                    <div class="col-lg-1">
                        <b>Clone</b>
                    </div>
                </div>
            </div>

            <div class="panel panel-body">
                <div ng-repeat="featureMapper in featureMappers| orderBy:sortType:sortReverse | filter: Pattern1 | filter: Pattern2 | filter: PlacementPattern1 | filter: PlacementPattern2"
                     ui-sref="featureMappers.view({featureMapperId: featureMapper._id})">
                    <div class="row" ng-class-odd="'alt'">
                        <div class="col-lg-2">
                            {{featureMapper.address.city| uppercase}}, {{featureMapper.address.state| uppercase}}, {{featureMapper.address.country| uppercase}}
                        </div>
                        <div class="col-lg-1">
                            {{featureMapper.clli| uppercase}}
                        </div>
                        <div class="col-lg-1">
                            {{featureMapper.zone| uppercase}}{{featureMapper.cluster| uppercase}}
                        </div>
                        <div class="col-lg-1">
                            <div ng-if="featureMapper.placement_waiver.length > 0">W</div>
                            <div ng-if="featureMapper.placement_exception.length > 0">E</div>                            
                        </div>
                        <div class="col-lg-3">
                            {{featureMapper.site_description}}
                        </div>

                        <div class="col-lg-2">
                            {{featureMapper.site_type}}
                        </div>
                        <div class="col-lg-1">
                            {{featureMapper.aic_version}}
                        </div>
                        <div class="col-lg-1">
                            <a class="btn btn-primary" ng-click="replicate(featureMapper)">
                                <i class="glyphicon glyphicon-duplicate"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="alert alert-warning text-center" ng-if="featureMappers.$resolved && featureMappers.length < 1">
        No featureMappers yet, why don't you <a ui-sref="featureMappers.create"> create one</a>?
    </div>
</section>