Service reminder implemented.

This commit is contained in:
2015-10-21 20:32:37 -04:00
parent e42fcd16fa
commit 93065de77f
26 changed files with 652 additions and 89 deletions
+5 -2
View File
@@ -5,6 +5,8 @@
$('#page-match-status').html('<span class="label label-warning"><i class="fa fa-spinner fa-spin"></i> Matching In Progress</span> for ' + total + ' fuel logs. <strong>Keep page open until complete.</strong>');
$('#page-match-status').after('<div class="progress progress-striped active"><div class="bar" style="width:0%"></div><div>');
$(".match-status a").addClass('pull-right');
submitNext();
var unmatchedCount = 0;
var errorCount = 0;
@@ -41,10 +43,11 @@
}
$('.match-message', $row).text(result.Message);
}
if (result.Action != undefined && result.Action != null) {
$('.match-status', $row).append(" " + result.Action);
var $action = $("a[matchcount]", $row);
matchCountFunc.apply($action);
$("a", $row).addClass('pull-right');
matchCountFunc.apply($("a[matchcount]", $row));
}
submitNext();
+78 -11
View File
@@ -75,7 +75,7 @@ $(function () {
var $recentLogs = $("#RecentLogs");
if ($recentLogs.length > 0) {
$.ajax({
url: "/FuelLog/RecentLogs",
url: "/CreateLog/RecentLogs",
success: function (data) {
$recentLogs.append(data);
}
@@ -83,12 +83,69 @@ $(function () {
}
});
/**
Ability to run the defered promises in sequence
*/
(function ($) {
"use strict";
var copy = function (a) {
return Array.prototype.slice.call(a);
};
/**
Handle a sequence of methods, stopping on failure by default
@param Array<Function> chain List of methods to execute. Non-deferred return values will be treated as successful deferreds.
@param Boolean continueOnFailure Continue executing even if one of the returned deferreds fails.
@returns Deferred
*/
$.sequence = function (chain, continueOnFailure) {
var handleStep, handleResult,
steps = copy(chain),
def = new $.Deferred(),
defs = [],
results = [];
handleStep = function () {
if (!steps.length) {
def.resolveWith(defs, [results]);
return;
}
var step = steps.shift(),
result = step; // used to be step();, but we're already dealing with promises
handleResult(
$.when(result).always(function () {
defs.push(this);
}).done(function () {
results.push({ resolved: copy(arguments) });
}).fail(function () {
results.push({ rejected: copy(arguments) });
})
);
};
handleResult = continueOnFailure ?
function (result) {
result.always(function () {
handleStep();
});
} :
function (result) {
result.done(handleStep)
.fail(function () {
def.rejectWith(defs, [results]);
});
};
handleStep();
return def.promise();
};
}(this.jQuery));
var matchCountFunc = function() {
var $link = $(this);
var url = $link.attr("matchcount");
$link.append(' <span class="badge"><i class="fa fa-spinner fa-spin"></i></span>');
return $.ajax({
url: url,
success: function(matchcount) {
success: function (matchcount) {
$('span', $link).remove();
if (matchcount > 0) {
$link.append(" <span class='badge badge-info'>" + matchcount + "</span>");
} else {
@@ -101,7 +158,7 @@ var matchCountFunc = function() {
// add get match count for all the current items
$(function () {
var $requests = $("a[matchcount]").map(matchCountFunc);
$.when.apply($, $requests);
$.sequence($requests);
});
$(function() {
@@ -124,7 +181,7 @@ $(function() {
var idNavActiveRegex = {
'fuellog-nav': /\/fuellog/i,
'log-nav': /\/log/i,
'vehicle-nav': /\/vehicle/i,
'vehicle-nav': /\/vehicle|\/servicereminder/i,
'user-nav': /\/user/i,
'config-nav': /\/City|\/Purpose/i
};
@@ -142,23 +199,33 @@ $(function() {
function addButtonIcons () {
var textToIcon = {
'Edit': 'edit',
'Enter Log': 'plus',
'Edit': 'edit',
'Filter': 'filter',
'Details' : 'zoom-in',
'Details': 'info-circle',
'Delete': 'trash',
'Add': 'plus',
'Export': 'download',
'Import': 'upload',
'Driver Mileage': 'user',
'Vehicle Mileage': 'car',
'Show Active': 'ok-circle',
'Show Inactive': 'ban-circle',
'Set Inactive' : 'ban-circle',
'Reactivate' : 'ok-circle'
'Show Active': 'check-circle',
'Show Inactive': 'ban',
'Set Inactive' : 'ban',
'Reactivate': 'check-circle',
'Config': 'cog',
'Cities': 'map',
'Purposes': 'arrow-right',
'Vehicle Service': 'wrench',
'Vehicle': 'car',
'Reminder': 'clock-o',
'Fuel Logs': 'tachometer',
'Users': 'user',
'Logs': 'road'
};
$.each(textToIcon, function(text, icon) {
$("a:contains('" + text + "'):not(:has(i))")
.prepend('<i class="icon-' + icon + '" /> ');
.prepend('<i class="fa fa-'+ icon +'"></i> ');
});
$(".navbar-inverse a[title='Manage']:not(:has(i))")