<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF 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.
-->

<script type="text/ng-template" id="cubeAssignment.html">
  <div class="modal-header">
    <h4>Cube Assignment</h4>
  </div>
  <div ng-if="status==='view'" class="modal-body" style="background-color: white">
    <div ui-grid="assignmentGridOptions" ui-grid-pagination class="grid"></div>
  </div>
  <div ng-if="status==='edit'" class="modal-body" style="background-color: white">
    <div class="row">
      <div class="col-sm-3 font-color-default text-center" style="font-weight:bolder;">Replica Set ID</div>
      <div class="col-sm-8 font-color-default text-center" style="font-weight:bolder;">Partition</div>
    </div>
    <div ng-repeat="replicaSet in currentAssignment" class="row">
      <div class="col-sm-3 form-group">
        <select class="form-control"  ng-model="replicaSet.rs_id" style="height: 31px;">
          <option ng-repeat="replicaSetId in replicaSetIds" ng-value="replicaSetId">{{replicaSetId}}</option>
        </select>
      </div>
      <div class="col-sm-8">
        <ui-select multiple ng-model="replicaSet.partitions" theme="bootstrap" sortable="true" close-on-select="false" class="form-control">
          <ui-select-match placeholder="Select Partition...">{{$item.partition_id}}</ui-select-match>
          <ui-select-choices repeat="partition as partition in cubePartitions | filter:$select.search">
            {{partition.partition_id}}
          </ui-select-choices>
        </ui-select>
      </div>
      <div class="col-sm-1">
        <i class="fa fa-minus" style="margin-top:10px;cursor:pointer;" ng-click="removeReplicaSet($index)"></i>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-offset-11 col-sm-1">
        <i class="fa fa-plus" style="margin-top:10px;cursor:pointer;" ng-click="addReplicaSet()"></i>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button ng-if="status==='view'" class="btn btn-primary" ng-click="editAssignment()">Edit</button>
    <button ng-if="status==='edit'" class="btn btn-primary" ng-click="reAssignCube()">Save</button>
    <button class="btn btn-warning" ng-click="cancel()">Close</button>
  </div>
</script>