Skip to content

Commit 8a0ec5b

Browse files
identificado cual no ha sido sync
1 parent 20fd3c5 commit 8a0ec5b

4 files changed

Lines changed: 59 additions & 9 deletions

File tree

www/css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/* Empty. Add your own CSS if you like */
2+
.ns{
3+
background-color: red;
4+
}

www/index.html

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,33 @@ <h1 class="title">🎂 Birthdays 🎉</h1>
3636
<ion-content>
3737
<ion-toggle ng-model="vm.online" ng-click="vm.setOnline(vm.online)" toggle-class="toggle-calm">online</ion-toggle>
3838
<ion-list>
39+
<div class="item item-divider">
40+
local
41+
</div>
3942
<ion-item ng-repeat="b in vm.birthdays" ng-click="vm.showEditBirthdayModal(b)">
43+
<div style="float: left">{{ b.fbVal.Name }}</div>
44+
<div style="float: right">{{ b.fbKey }}</div>
45+
<!-- | date:"dd MMMM yyyy" -->
46+
</ion-item>
47+
<div class="item item-divider">
48+
temp
49+
</div>
50+
<ion-item ng-class="{ns:vm.isSync(b.fbKey)}" ng-repeat="b in vm.temp" ng-click="vm.showEditBirthdayModal(b)">
51+
<div style="float: left">{{ b.fbVal.Name }}</div>
52+
<div style="float: right">{{ b.fbKey }}</div>
53+
</ion-item>
54+
55+
<div class="item item-divider">
56+
firebase
57+
</div>
58+
<ion-item ng-class="{ns:vm.isSync(b.$id)}" ng-repeat="b in vm.fb" ng-click="vm.showEditBirthdayModal(b)">
4059
<div style="float: left">{{ b.Name }}</div>
41-
<div style="float: right">{{ b.Date | date:"dd MMMM yyyy" }}</div>
60+
<div style="float: right">{{ b.$id }}</div>
4261
</ion-item>
4362
</ion-list>
44-
{{vm.fb | json}}
45-
</br>
46-
---
47-
{{vm.temp | json}}
63+
<!-- {{vm.fb | json}} -->
64+
<!-- </br>
65+
{{vm.temp | json}} -->
4866
</ion-content>
4967
</ion-pane>
5068
<script id="add-or-edit-birthday.html" type="text/ng-template">

www/js/birthday.service.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ var db, birthdays, fbA, tm, temp;
122122
_birthdays = _db.getCollection('birthdays');
123123
if (!_birthdays) {
124124
_birthdays = _db.addCollection('birthdays', {
125+
indices: ['fbKey'],
125126
clone: true
126127
});
128+
_birthdays.ensureUniqueIndex('fbKey');
127129
}
130+
128131
var isEnabled = true;
129132
_birthdays.setChangesApi(isEnabled);
130133
birthdays = _birthdays;
@@ -135,7 +138,8 @@ var db, birthdays, fbA, tm, temp;
135138

136139
if (!_temp) {
137140
_temp = _db.addCollection('temp', {
138-
indices: ['fbKey']
141+
indices: ['fbKey'],
142+
clone: true
139143
});
140144
_temp.ensureUniqueIndex('fbKey');
141145

@@ -216,7 +220,7 @@ var db, birthdays, fbA, tm, temp;
216220

217221
function addBirthday(birthday) {
218222

219-
_birthdays.insert(birthday);
223+
220224
var before = _bd.length - 1;
221225
var o = _bd.$add(birthday)
222226
.then(oK)
@@ -253,6 +257,7 @@ var db, birthdays, fbA, tm, temp;
253257
fbVal: birthday
254258
};
255259
console.log(lastIndex, _bd[lastIndex], key, newObj);
260+
_birthdays.insert(newObj);
256261
_temp.insert(newObj);
257262
}
258263

@@ -285,6 +290,16 @@ var db, birthdays, fbA, tm, temp;
285290

286291
}
287292

293+
function getTempById(key) {
294+
295+
// $timeout(function() {
296+
var obj = temp.by('fbKey', key);
297+
console.log('obj', obj);
298+
return obj;
299+
// }, 200);
300+
301+
}
302+
288303
return {
289304
initDB: initDB,
290305
getAllBirthdays: getAllBirthdays,
@@ -293,7 +308,9 @@ var db, birthdays, fbA, tm, temp;
293308
deleteBirthday: deleteBirthday,
294309
getBdArray: getBdArray,
295310
getBirthdays: getBirthdays,
296-
getTemp: getTemp
311+
getTemp: getTemp,
312+
getTempById: getTempById
313+
297314
};
298315
}
299316
})();

www/js/overview.controller.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
(function() {
2-
angular.module('starter').controller('OverviewController', ['$scope', '$ionicModal', '$ionicPlatform', 'BirthdayService', OverviewController]);
2+
angular.module('starter')
3+
.controller('OverviewController', ['$scope', '$ionicModal', '$ionicPlatform', 'BirthdayService', OverviewController]);
34

45
function OverviewController($scope, $ionicModal, $ionicPlatform, birthdayService) {
56
var vm = this;
67
vm.online = true;
78
vm.fb = birthdayService.getBdArray();
9+
vm.isSync = isSync;
810
// $ionicPlatform.ready(function() {
911

1012
// // Initialize the database.
@@ -17,6 +19,16 @@
1719
// });
1820
// });
1921

22+
function isSync(key) {
23+
if( birthdayService.getTempById(key)){
24+
return true;
25+
}
26+
else{
27+
return false;
28+
}
29+
30+
}
31+
2032

2133
function activate() {
2234
birthdayService.getBirthdays()

0 commit comments

Comments
 (0)