Service reminder implemented.
This commit is contained in:
+78
-11
@@ -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))")
|
||||
|
||||
Reference in New Issue
Block a user