Make usage of moment consistent throughout app

This always includes the user's language preference when loading moment.
It also deletes the moment global, so if you don't require it somehow
you will get an error trying to call `moment`'.

This is setup to provide moment to both angular and plain JavaScript
modules. In angular modules, just add `moment` as a dependency. In plain
js use `import moment from 'tower/shared/moment/moment';`.
This commit is contained in:
Joe Fiorini
2015-06-01 16:23:32 -04:00
parent fdb8fdf24a
commit 884423f86c
12 changed files with 70 additions and 19 deletions

View File

@@ -7,8 +7,8 @@
/* jshint unused: vars */
export default
[ '$rootScope',
function() {
[ 'moment',
function(moment) {
return {
restrict: 'E',
scope: {

View File

@@ -16,8 +16,7 @@ import datePicker from './date-picker/main';
export default
angular.module('systemTracking',
[ 'angularMoment',
utilities.name,
[ utilities.name,
shared.name,
datePicker.name
])

View File

@@ -4,6 +4,8 @@
* All Rights Reserved
*************************************************/
import moment from 'tower/shared/moment/moment';
export function searchDateRange(dateString) {
var date;

View File

@@ -6,7 +6,8 @@
export default
[ 'amDateFormatFilter',
function(dateFormat) {
'moment',
function(dateFormat, moment) {
return function(string, format) {
if (moment.isMoment(string)) {
return dateFormat(string, format);

View File

@@ -15,7 +15,7 @@ function controller($rootScope,
initialFactData,
getDataForComparison,
waitIndicator,
moment,
_) {
// var inventoryId = $routeParams.id;
var hostIds = $routeParams.hosts.split(',');
@@ -201,6 +201,7 @@ export default
'factScanData',
'getDataForComparison',
'Wait',
'moment',
'lodashAsPromised',
controller
];

View File

@@ -5,6 +5,7 @@
*************************************************/
import {searchDateRange} from './search-date-range';
import moment from 'tower/shared/moment/moment';
export default {
name: 'systemTracking',