Skip to content

Commit

Permalink
refactor(angularjs): remove angular-moment (#2154)
Browse files Browse the repository at this point in the history
As we have no need for the AngularJS filters and directives that
angular-moment provides, remove it completely, referencing moment
as a CommonJS module instead
  • Loading branch information
LoneRifle authored Jun 14, 2021
1 parent 35eeeaf commit 29bbd26
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"angular-cookies": "~1.8.2",
"angular-drag-scroll": "^0.2.1",
"angular-messages": "^1.8.2",
"angular-moment": "~1.3.0",
"angular-permission": "~1.1.1",
"angular-resource": "^1.8.2",
"angular-sanitize": "^1.8.2",
Expand Down
5 changes: 0 additions & 5 deletions src/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const moduleDependencies = [
'ngResource',
'ui.router',
'ui.bootstrap',
'angularMoment',
'vcRecaptcha',
'users',
'ngFileUpload',
Expand Down Expand Up @@ -55,7 +54,6 @@ require('angular-permission/dist/angular-permission')
require('@opengovsg/angular-recaptcha-fallback')
require('angular-resource')
require('angular-sanitize')
require('angular-moment')
require('angular-messages')

require('angular-ui-bootstrap')
Expand Down Expand Up @@ -85,9 +83,6 @@ const appName = 'FormSG'
// Add module dependencies
const app = angular.module(appName, moduleDependencies)

// Override moment using Angular's dependency injection
app.constant('moment', require('moment-timezone'))

// Setting HTML5 Location Mode
angular.module(appName).config([
'$locationProvider',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const { StatusCodes } = require('http-status-codes')
const get = require('lodash/get')
const moment = require('moment-timezone')
const { LogicType } = require('../../../../../types')
const UpdateFormService = require('../../../../services/UpdateFormService')
const UserService = require('../../../../services/UserService')
Expand Down Expand Up @@ -43,7 +44,6 @@ angular
'$uibModal',
'FormData',
'FormFields',
'moment',
'Toastr',
'$state',
'$window',
Expand All @@ -58,7 +58,6 @@ function AdminFormController(
$uibModal,
FormData,
FormFields,
moment,
Toastr,
$state,
$window,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const get = require('lodash/get')
const moment = require('moment-timezone')

const BetaService = require('../../../../services/BetaService')

const UserService = require('../../../../services/UserService')
Expand All @@ -12,7 +14,6 @@ angular
'$scope',
'FormApi',
'$uibModal',
'moment',
'$state',
'$timeout',
'$window',
Expand All @@ -25,7 +26,6 @@ function ListFormsController(
$scope,
FormApi,
$uibModal,
moment,
$state,
$timeout,
$window,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const moment = require('moment-timezone')

const {
processDecryptedContent,
} = require('../../helpers/process-decrypted-content')
Expand All @@ -24,7 +26,6 @@ angular
'$timeout',
'$location',
'$anchorScroll',
'moment',
ViewResponsesController,
])

Expand All @@ -39,7 +40,6 @@ function ViewResponsesController(
$timeout,
$location,
$anchorScroll,
moment,
) {
const vm = this

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const moment = require('moment-timezone')

angular.module('forms').component('endPageComponent', {
templateUrl: 'modules/forms/base/componentViews/end-page.html',
bindings: {
Expand All @@ -13,11 +15,11 @@ angular.module('forms').component('endPageComponent', {
colorTheme: '@',
submissionId: '@',
},
controller: ['SpcpSession', '$window', 'moment', endPageController],
controller: ['SpcpSession', '$window', endPageController],
controllerAs: 'vm',
})

function endPageController(SpcpSession, $window, moment) {
function endPageController(SpcpSession, $window) {
const vm = this

vm.timestamp = moment().format('D MMM YYYY, HH:mm')
Expand Down

0 comments on commit 29bbd26

Please sign in to comment.