-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
99 lines (86 loc) · 3.01 KB
/
form.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.2.805/js/angular.min.js"></script>
<script src="http://oemobiledemo.progress.com/jsdo/progress.jsdo.min.js"></script>
<style>
table {
border: 1px solid black;
border-collapse: collapse;
float: left;
}
table td {
border: 1px solid black;
}
table tr {
cursor: pointer;
}
.selected {
background: green;
}
form {
float: left;
}
</style>
</head>
<body ng-app="app" ng-controller="Main">
<div ng-hide="customers">Loading ...</div>
<table ng-show="customers">
<caption>Click a table row</caption>
<tr ng-repeat="customer in customers" ng-click="selectCustomer(customer)" class="{{selection === customer ? 'selected': ''}}">
<td>{{customer.CustNum}}</td>
<td>{{customer.Name}}</td>
<td>{{customer.State}}</td>
<td>{{customer.Country}}</td>
</tr>
</table>
<form ng-show="selection" ng-submit="save()">
<fieldset>
<legend>Details for {{selection.CustNum}}</legend>
<div>
<label for="Name">Name: </label><input ng-model="selection.Name" id="Name">
</div>
<div>
<label for="Sate">State: </label><input ng-model="selection.State" id="Sate">
</div>
<div>
<label for="Country">Country: </label><input ng-model="selection.Country" id="Country">
</div>
<div>
<button type="submit">Save</button>
</div>
</fieldset>
</form>
<script>
var serviceURI = 'http://oemobiledemo.progress.com/CustomerService';
var catalogURI = 'http://oemobiledemo.progress.com/CustomerService/static/mobile/CustomerService.json';
var resourceName = 'Customer';
var session = new progress.data.Session();
session.login(serviceURI, "", "");
session.addCatalog(catalogURI);
var jsdo = new progress.data.JSDO({ name: resourceName });
var app = angular.module("app", []);
app.controller("Main", ["$scope", MainController]);
function MainController($scope) {
jsdo.fill().done(function() {
$scope.$apply(function() {
$scope.customers = jsdo.eCustomer.getData();
});
});
$scope.selectCustomer = function(customer) {
$scope.selection = customer;
};
$scope.save = function() {
if ($scope.selection) {
var jsrecord = jsdo.eCustomer.findById($scope.selection._id);
jsrecord.assign($scope.selection);
jsdo.saveChanges();
}
};
}
</script>
</body>
</html>