</div>
</div>
- <div class="form-group">
- <div class="col-md-offset-4 col-md-6">
- <span ng-show="pendingXacts" class="label label-warning">[% l('Unprocessed offline transactions waiting for upload') %]</span>
+ <div class="form-group" ng-if="pendingXacts">
+ <div class="col-md-offset-4 col-md-8">
+ <div class="alert alert-warning">
+ [% | l('{{pendingXacts | date:"short"}}') %]
+ Unprocessed offline transactions waiting for upload.
+ Last transaction added at [_1].
+ [% END %]
+ </div>
</div>
</div>
return info.schema.db.delete().from(info.table).exec();
}
+// Delete rows from selected table where field equals value
+function deleteWhereEqual(schemaName, tableName, field, value) {
+ var info = getTableInfo(schemaName, tableName);
+ if (info.error) { return Promise.reject(info.error); }
+
+ return info.schema.db.delete().from(info.table)
+ .where(info.table[field].eq(value)).exec();
+}
+
// Resolves to true if the selected table contains any rows.
function hasRows(schemaName, tableName) {
deleteAll(data.schema, data.table).then(replySuccess, replyError);
break;
+ case 'deleteWhereEqual':
+ deleteWhereEqual(data.schema, data.table, data.field, data.value)
+ .then(replySuccess, replyError);
+ break;
+
case 'hasRows':
hasRows(data.schema, data.table).then(replySuccess, replyError);
break;
// Connects if necessary to the active schemas then relays the request.
service.request = function(args) {
+ // useful, but very chatty, leaving commented out.
+ // console.debug('egLovfield sending request: ', args);
return service.connectToSchemas().then(
function() {
return service.relayRequest(args);
);
}
+ // Remove all pending offline transactions and delete the cached
+ // offline transactions date to indicate no transactions remain.
service.destroyPendingOfflineXacts = function () {
return service.request({
schema: 'offline',
table: 'OfflineXact',
action: 'deleteAll'
+ }).then(function() {
+ return service.request({
+ schema: 'cache',
+ table: 'CacheDate',
+ action: 'deleteWhereEqual',
+ field: 'type',
+ value: '_offlineXact'
+ });
});
}
+ // Returns the cache date when xacts exit, null otherwise.
service.havePendingOfflineXacts = function () {
return service.request({
- schema: 'offline',
- table: 'OfflineXact',
- action: 'hasRows'
+ schema: 'cache',
+ table: 'CacheDate',
+ action: 'selectWhereEqual',
+ field: 'type',
+ value: '_offlineXact'
+ }).then(function(results) {
+ return results[0] ? results[0].cachedate : null;
});
}
});
}
+ // Add an offline transaction and update the cache indicating
+ // now() as the most recent addition of an offline xact.
+ service.addOfflineXact = function (obj) {
+ return service.request({
+ schema: 'offline',
+ table: 'OfflineXact',
+ action: 'insertOrReplace',
+ rows: [{value: obj}]
+ }).then(function() {
+ return service.request({
+ schema: 'cache',
+ table: 'CacheDate',
+ action: 'insertOrReplace',
+ rows: [{type: '_offlineXact', cachedate : new Date()}]
+ });
+ });
+ }
+
service.populateBlockList = function() {
return service.request({
action: 'populateBlockList',
});
}
- service.addOfflineXact = function (obj) {
- return service.request({
- schema: 'offline',
- table: 'OfflineXact',
- action: 'insertOrReplace',
- rows: [{value: obj}]
- });
- }
-
service.setStatCatsCache = function (statcats) {
if (lf.isOffline || !statcats || statcats.length === 0)
return $q.when();