wisedog/ladybug

View on GitHub
views/milestone/milestone_index.tmpl

Summary

Maintainability
Test Coverage
{{define "title"}}Test Execution{{ end }}
{{define "more_style"}}
<link rel="stylesheet" type="text/css" href="/public/libs/bootstrap-sweetalert/dist/sweetalert.css">
{{end}}
{{define "content"}}
<div class="content-wrapper">
  <!-- Content header -->
  <section class="content-header">
    <h1>
      Milestone
      <small>Manage your milestone</small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="/project/{{.ProjectName}}/dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
      <li class="active">Milestone</li>
    </ol>
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="row bottom7">
      <div class="col-md-12">
        <button class="btn btn-primary btn-xs btn-flat" data-toggle="modal" data-target="#myModal">
          <i class='fa fa-plus right7'></i>Milestone
        </button>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="box box-primary">
          <div class="box-header with-border">
            <label>
              Milestone list
            </label>
          </div>
          <div class="box-body">
            <div class='table-responsive'>
              <table class='table table-striped'>
                <thead>
                  <tr>
                    <th>Name</th>
                    <th>Status</th>
                    <th>Due Date</th>
                    <th>Description</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                {{range .Milestones}}
                <tr>
                  <td>{{.Name}}
                  </td>
                  <td>
                    {{if eq .Status 1}}
                      Active
                    {{else if eq .Status 2}}
                      Done
                    {{else}}
                      Unknown
                    {{end}}
                  </td>
                  <td>
                     {{.DueDate.Format "Jan 02, 2006"}}
                  </td>
                  <td>{{.Description}}</td>
                  <td>
                    <a href='javascript:deny({{.ID}});' class="glyphicon glyphicon-ban-circle"></a>
                    <a href='javascript:remove({{.ID}});' class="glyphicon glyphicon-remove"></a>
                  </td>
                </tr>
                {{end}}
                </tbody>
              </table>
            </div> <!-- .table-responsive -->
          </div> <!-- .box-body -->
        </div> <!-- .box -->
      </div>  <!-- .col-md-12 -->
    </div><!-- .row -->
  </section><!-- /.content -->
</div><!-- /.content-wrapper -->
{{end}}
{{define "more_scripts"}}
<script src="/public/libs/bootstrap-sweetalert/dist/sweetalert.min.js"></script> 
<script>
  var target = -1;
  function remove(p){
    swal({
      title: "Delete Test Execution",
      text: "You can not undo request",   
      type: "warning",   
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      closeOnConfirm: false,  
      showLoaderOnConfirm: true, 
      confirmButtonText: "Yes, delete it!",
    }, 
    function(){   
      $.post('/project/{{.ProjectName}}/exec/remove', {id: p})
      .done(function(data){
        if(data.status == 200){
        }
        else{
          console.log("Failed to response : ", data);
        }
        location.reload();
      });
    });
  }

  function deny(p){
    swal({
      title: "You just deny the execution",
      type: "warning",
      text: "Please give me a reason to deny the test execution",
      type: "input",   
      showCancelButton: true,
      closeOnConfirm: false,   
      showLoaderOnConfirm: true, 
      animation: "slide-from-top",   
      inputPlaceholder: "Write why" }, 
      function(inputValue){   
        if (inputValue === false) 
          return false;      
        if (inputValue === "") {
          swal.showInputError("You need to write something!");
          return false
        }
        $.post('/project/{{.ProjectName}}/exec/deny'
            , {id: p, msg: inputValue})
          .done(function(data){
            if(data.status == 200){
              location.reload()
            }else{
              swal.showInputError("Something wrong....");
            }
          });
      });
  }
</script>
{{end}}