-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular.app.js
More file actions
197 lines (120 loc) · 3.53 KB
/
angular.app.js
File metadata and controls
197 lines (120 loc) · 3.53 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//RESTate a Mini framework for implement RESTFul statless APIs. Written by Bruno Trombi.
var app = angular.module('app', []);
app.filter('filtraArray',filtraArray );
//app.controller('PersonCtrl', function customersController($scope,$http) {
function customersController($scope,$http) {
$scope.bBoxInsertOpen= false;
$scope.actionBoxInsertOpen= function() {
$scope.bBoxInsertOpen= true;
}
$scope.actionBoxInsertClose= function() {
$scope.bBoxInsertOpen= false;
}
//class for sorting
$scope.sort=[];
//$scope.sort[0]= 'sort-false';
//sorting key
this.aSorting= [] //['-1'];
//set it for column filter
$scope.cercaColonna=[];
$scope.this = this;
//console.log( $scope.this.aSorting ,"allo inizio" )
//trova tra gli $scope.records
$scope.trova = function ( idx )
{
for (var i = 0; i < $scope.records.length; i++)
{
//console.log( "trova(" +idx +")",i,$scope.records[i][0] )
if ($scope.records[i][0]== idx )
{
return i;
}
}
return -1;
}
$scope.editCell =function ( iId,iColumn )
{
var iPosRow= $scope.trova( iId );
//console.log( "iPosRow",iPosRow );
//alert("edit:" +iPosRow +" column:" +iColumn);
//$scope.records[iPosRow][iColumn]= 99;
//myQuestion();
function myQuestion( question,value) {
var newValue = prompt(question,value );
if (newValue != null) {
//document.getElementById("myQuestion").innerHTML =
//"Hello " + newValue + "! How are you today?";
//alert( newValue );
$scope.records[iPosRow][iColumn]= newValue;
//var iId= $scope.records[iPosRow][0]; // l'elemento alla posizione 0 e' l'id
restateEdit( iId,iColumn,newValue ) //( iId,iCol,sNewValue )
}
}
myQuestion( "cambua valore",$scope.records[iPosRow][iColumn] );
//$scope.records[iPosRow][iColumn]= "<input type='text' id='p{{i}}' size=7 value='codroipo'/>";
}
$scope.edit =function ( pos )
{
alert("edit:" +pos)
}
//remove data from window and db
$scope.remove = function (idx ) {
console.log( "remove" ,idx )
console.log( "records" ,$scope.records )
var i= $scope.trova( idx );
console.log( "i" ,i )
//se i<0 non esiste attualmente nel db
if( i<0 ) return false;
//elimina dalla window, senza resettare :)
$scope.records.splice(i,1);
//$scope.aTd.splice(i,1);
//elimina dal db, via chiamata rest
restateDelete( idx );
}
function fChangeOrderNew(i) {
//cambia ordine iesimo elemento
//i e' 0 based, ma in js per fortuna c'e +0 che -0 :)
var r;
r=$scope.this.aSorting.indexOf( '-' +i, 0);
//changing the sort icon properly
for( var j=0;j<=15;j++ )
{
$scope.sort[j] =''
}
if(r<0){
$scope.this.aSorting= [ '-' +i]
$scope.sort[i] ='sort-true'
}
else{
$scope.this.aSorting= [ '+' +i]
$scope.sort[i] ='sort-false'
}
//alert("fChangeOrderNew:" +$scope.this.aSorting);
};
$scope.changeOrder = fChangeOrderNew
$scope.getData = function(){
if( $scope.recordHeads===undefined ){
$http.get("./?cmd=columns&bJsonCompact=1")
.success(function(response) {
$scope.recordHeads = response.result;
//console.log( $scope.recordHeads ,"recordHeads")
//set defaults for cercaColonna[i]
for( i= -1+$scope.recordHeads.length ;i>=0 ;i--)
{
$scope.cercaColonna[i]='';
//$scope.cercaColonna[i]= $scope.recordHeads[i]
//console.log( "col",$scope.cercaColonna[i],i,$scope.recordHeads[i])
}
});
}
$http.get("./?cmd=getAll&bArrayResult=true&bJsonCompact=1" )
.success(function(response) {
var i=0, j=0,row,td;
var rows= response.result;
$scope.records = response.result;
});
};
$scope.getData()
//setInterval($scope.getData, 1000);
$scope.changeOrder(0)
}