eHealthAfrica/direct-delivery-dashboard

View on GitHub
src/app/planning/schedule/index.html

Summary

Maintainability
Test Coverage
<div id="print-area">
  <h4><i class="fa fa-truck"></i> Schedules for Delivery Round: {{
    srCtrl.deliveryRound._id }}</h4>
  <div class="panel panel-default">
    <div class="panel-heading hidden-print">
      <div class="row">
        <div class="col-sm-12">
          <div class="btn-group pull-right">
            <button class="btn btn-primary btn-lg"
                    ng-click="srCtrl.saveAll()"
                    ng-disabled="!srCtrl.isScheduleComplete()">
              <i class="fa fa-floppy-o"></i>
              <span>Scheduling and Routing Complete</span>
            </button>

            <button class="btn btn-default btn-lg"
                    ng-click="srCtrl.openImportDialog()">
              <i class="fa fa-cloud-upload"></i>
              <span>Upload Schedule Info</span>
            </button>

            <button class="btn btn-default btn-lg"
                    ng-csv="srCtrl.exportForRouting"
                    csv-header="srCtrl.exportHeader"
                    filename="delivery-round-{{ srCtrl.deliveryRound._id }}.csv">
              <i class="fa fa-cloud-download"></i>
              <span>Export for Routing</span>
            </button>

            <a class="btn btn-default btn-lg"
               ui-sref="planning.manageFacilities({ roundId: srCtrl.deliveryRound._id })">
              <i class="fa fa-exchange"></i>
              <span>Import Facilities</span>
            </a>
            <button ng-if="srCtrl.facilityDeliveries.length > 0" class="btn btn-primary btn-lg" type="button"  ng-click="srCtrl.print()">
              <i class="fa fa-print"></i> Print
            </button>
          </div>
        </div>
      </div>
    </div>

    <div class="panel-body" >
      <div class="panel-body alert alert-info" ng-show="srCtrl.facilityDeliveries.length === 0">
        <i class="fa fa-lg fa-info-circle"></i>
        <span> No daily deliveries found, please import facilities to create new delivery schedules.</span>
      </div>

      <table datatable="ng" class="table table-striped row-border hover" dt-options="srCtrl.dtOptions" t-column-defs="srCtrl.dtColumnDefs">
        <thead>
        <tr>
          <th>#</th>
          <th class="col-sm-2">Facility</th>
          <th class="col-sm-2">Zone</th>
          <th class="col-sm-1">LGA</th>
          <th class="col-sm-1">Ward</th>
          <th class="col-sm-2">Delivery Date</th>
          <th class="col-sm-2">Driver</th>
          <th class="col-sm-1">Drop</th>
          <th class="col-sm-2">Window</th>
          <th class="col-sm-1">Distance (KM)</th>
          <th class="col-sm-1">Status</th>
          <th class="col-sm-1 hidden-print">Action</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="facRnd in srCtrl.facilityDeliveries track by $index"
            ng-class="{'success': srCtrl.isUpdated(facRnd) , 'bg-success': facRnd.scheduleComplete, 'bg-warning': !facRnd.scheduleComplete}">
          <td ng-bind="($index + 1)"></td>
          <td ng-bind="::facRnd.facility.name"></td>
          <td ng-bind="::facRnd.facility.zone"></td>
          <td ng-bind="::facRnd.facility.lga"></td>
          <td ng-bind="::facRnd.facility.ward"></td>
          <td>
            <span
              ng-bind="srCtrl.getDate(facRnd.date)"
              editable-bsdate="facRnd.date"
              e-name="deliveryDate"
              e-form="rowform"
              e-init-date="false"
              e-datepicker-popup
              e-ng-click="dateOpened = !dateOpened"
              e-is-open="dateOpened"
              buttons="no"
              editable-bsdate="facRnd.date"
            ></span>
          </td>
          <td>
          <span editable-select="facRnd.driverID"
                e-name="driverID"
                e-form="rowform"
                e-ng-options="driver.value as driver.text for driver in srCtrl.drivers">
            {{ facRnd.driverID || '' }}
          </span>
          </td>
          <td>
          <span editable-select="srCtrl.facilityDeliveries[$index].drop"
                e-name="drop"
                e-form="rowform"
                e-ng-options="drop.value as drop.text for drop in srCtrl.dropList">

          </span>
            {{ facRnd.drop || '' }}
          </td>
          <td>
            <span
              editable-select="facRnd.window"
              e-name="window"
              e-form="rowform"
              e-reqiured
              e-ng-options="window.value as window.text for window in srCtrl.scheduleWindows">
              </span>
            {{ facRnd.window || '' }}
          </td>
          <td>
          <span editable-number="srCtrl.facilityDeliveries[$index].distance" e-name="distance" e-form="rowform"
                e-required></span>
            {{ facRnd.distance || '' }}
          </td>
          <td ng-class="facRnd | deliveryStatus:true">
          <span editable-select="srCtrl.facilityDeliveries[$index].status"
                e-ng-class="danger | deliveryStatus"
                e-ng-options="status as status for status in srCtrl.deliveryStatuses"
                e-name="status"
                e-form="rowform">
          </span>
            {{ facRnd.status || 'Please set status' }}
          </td>
          <td class="hidden-print">
            <!-- form -->
            <form editable-form name="rowform" onbeforesave="srCtrl.saveRow($data, srCtrl.facilityDeliveries[$index])"
                  ng-show="rowform.$visible" class="form-buttons form-inline"
                  shown="inserted === facRnd">
              <button type="submit" ng-disabled="rowform.$waiting"
                      class="btn btn-primary">
                <span>Save</span>
              </button>
              <button type="button" ng-disabled="rowform.$waiting"
                      ng-click="rowform.$cancel()"
                      class="btn btn-default">
                <span>Cancel</span>
              </button>
            </form>
            <div class="buttons" ng-show="!rowform.$visible">
              <button class="btn btn-primary btn-block" ng-click="rowform.$show()">Edit</button>
            </div>
          </td>
        </tr>
        </tbody>
      </table>
      </div>
    </div>
  </div>
</div>