Richard Allred
2019-08-03 99e73490b45f1f76040216418afeec9ff9770e57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
 
<html ng-app="items">
<head>
    <title>To Do List</title>
 
    <link rel="stylesheet" href="lib/dependencies/css/bootstrap.min.css" />
    <link rel="stylesheet" href="lib/dependencies/css/ng-grid.min.css" />
 
    <!-- build:css css/application.css -->
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <!-- endbuild -->
 
    <script src="lib/dependencies/jquery.min.js"></script>
    <script src="lib/dependencies/angular.min.js"></script>
    <script src="lib/dependencies/angular-resource.min.js"></script>
    <script src="lib/dependencies/ng-grid-2.0.11.min.js"></script>
    <script src="lib/dependencies/ui-bootstrap-tpls.min.js"></script>
 
    <!-- build:js script/all.js -->
    <script src="script/item.js"></script>
    <!-- endbuild -->
</head>
 
<body>
 
<h1>To Do List Application</h1>
 
<br/>
 
<!-- Specify a Angular controller script that binds Javascript variables to the feedback messages.-->
<div class="message" ng-controller="alertMessagesController">
    <alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</alert>
</div>
 
<br>
 
<!-- Specify a Angular controller script that binds Javascript variables to the grid.-->
<div class="grid" ng-controller="itemsListController">
    <div>
        <h3>To Do List</h3>
    </div>
 
    <!-- Binds the grid component to be displayed. -->
    <div class="gridStyle" ng-grid="gridOptions"></div>
 
    <!--  Bind the pagination component to be displayed. -->
    <pagination direction-links="true" boundary-links="true"
                total-items="items.totalResults" items-per-page="items.pageSize"
                ng-model="items.currentPage" ng-change="refreshGrid()">
    </pagination>
</div>
 
<!-- Specify a Angular controller script that binds Javascript variables to the form.-->
<div class="form" ng-controller="itemsFormController">
    <!-- Verify item, if there is no id present, that we are Adding a Item -->
    <div ng-if="item.id == null">
        <h3>Add Task</h3>
    </div>
    <!-- Otherwise it's an Edit -->
    <div ng-if="item.id != null">
        <h3>Edit Task</h3>
    </div>
 
    <div>
        <!-- Specify the function to be called on submit and disable HTML5 validation, since we're using Angular validation-->
        <form name="itemForm" ng-submit="updateItem()" novalidate>
 
            <!-- Display an error if the input is invalid and is dirty (only when someone changes the value) -->
            <div class="form-group" ng-class="{'has-error' : itemForm.description.$invalid && itemForm.description.$dirty}">
                <label for="description">Description:</label>
                <!-- Display a check when the field is valid and was modified -->
                <span ng-class="{'glyphicon glyphicon-ok' : itemForm.description.$valid && itemForm.description.$dirty}"></span>
 
                <input id="description" name="description" type="text" class="form-control" maxlength="100"
                       ng-model="item.description"
                       required ng-minlength="5" ng-maxlength="100"/>
 
                <!-- Validation messages to be displayed on required, minlength and maxlength -->
                <p class="help-block" ng-show="itemForm.description.$error.required">Add Description.</p>
                <p class="help-block" ng-show="itemForm.description.$error.minlength">Description must be at least 5 characters long.</p>
                <p class="help-block" ng-show="itemForm.description.$error.maxlength">Description cannot be longer than 100 characters.</p>
            </div>
 
            <div class="form-group" ng-class="{'has-error' : itemForm.done.$invalid && itemForm.done.$dirty}">
                <label for="done">Completed:</label>
                <!-- Display a check when the field is valid and was modified -->
                <span ng-class="{'glyphicon glyphicon-ok' : itemForm.done.$valid && itemForm.done.$dirty}"></span>
 
                <input id="done" name="done" type="checkbox" class="form-control"
                       ng-model="item.done" />
 
            </div>
 
            <!-- Form buttons. The 'Save' button is only enabled when the form is valid. -->
            <div class="buttons">
                <button type="button" class="btn btn-primary" ng-click="clearForm()">Clear</button>
                <button type="submit" class="btn btn-primary" ng-disabled="itemForm.$invalid">Save</button>
            </div>
        </form>
    </div>
</div>
<div class="footer" ng-controller="hostController">
From host: {{host.hostname}} / {{host.ip}}
</div>
</body>
</html>