diff --git a/client/.eslintrc.js b/client/.eslintrc.js index bb0fd06ac..ecb515818 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { 'backbone/model-defaults': 0, // widely abused issue - so unlikely to be addressed without considerable effort 'backbone/collection-model': 0, // ditto 'backbone/defaults-on-top': 0, // ditto - 'backbone/initialize-on-top': 0 // ditto + 'backbone/initialize-on-top': 0, // ditto + 'backbone/no-silent': 0 }, env: { es6: true, @@ -21,4 +22,4 @@ module.exports = { "ecmaVersion": 11, "sourceType": "module" } -} \ No newline at end of file +} diff --git a/client/package-lock.json b/client/package-lock.json index 3c41082c6..c8ba8a758 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -35,7 +35,6 @@ "jquery.flot": "^0.8.3", "jquery.flot.tooltip": "^0.9.0", "lodash-es": "^4.17.21", - "luxon": "^1.25.0", "markdown": "^0.5.0", "plotly.js": "^1.52.2", "portal-vue": "2.1.7", @@ -11722,14 +11721,6 @@ "yallist": "^3.0.2" } }, - "node_modules/luxon": { - "version": "1.28.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.1.tgz", - "integrity": "sha512-gYHAa180mKrNIUJCbwpmD0aTu9kV0dREDrwNnuyFAsO1Wt0EVYSZelPnJlbj9HplzXX/YWXHFTL45kvZ53M0pw==", - "engines": { - "node": "*" - } - }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", diff --git a/client/package.json b/client/package.json index 4808d17de..6cdd6dbe2 100644 --- a/client/package.json +++ b/client/package.json @@ -83,7 +83,6 @@ "jquery.flot": "^0.8.3", "jquery.flot.tooltip": "^0.9.0", "lodash-es": "^4.17.21", - "luxon": "^1.25.0", "markdown": "^0.5.0", "plotly.js": "^1.52.2", "portal-vue": "2.1.7", diff --git a/client/src/js/models/visit.js b/client/src/js/models/visit.js index f62f49407..7eac421ec 100644 --- a/client/src/js/models/visit.js +++ b/client/src/js/models/visit.js @@ -1,11 +1,10 @@ -define(['backbone', 'backbone-validation', 'luxon'], function(Backbone, BackBoneValidation, luxon) { +define(['backbone', 'backbone-validation'], function(Backbone, BackBoneValidation) { var Visit = Backbone.Model.extend({ idAttribute: 'VISIT', urlRoot: '/proposal/visits', initialize: function(attributes, options) { this.on('change', this.addDate, this) - this.dateTimeZone = window.app.options.get('timezone') this.addDate() }, @@ -47,17 +46,14 @@ define(['backbone', 'backbone-validation', 'luxon'], function(Backbone, BackBone pattern: 'number', }, }, - - addDate: function() { - var { DateTime } = luxon - - this.set('ENISO', DateTime.fromISO(this.get('ENISO'), { zone: this.dateTimeZone })) - this.set('STISO', DateTime.fromISO(this.get('STISO'), { zone: this.dateTimeZone })) - this.set('LEN', Number(this.get('ENISO').diff(this.get('STISO'))/(3600*1000)).toFixed(2)) - this.set('VISITDETAIL', this.get('VISIT')+' ('+this.get('BL')+': '+this.get('ST')+')') - }, - dateTimeZone: 'Europe/London' + addDate: function() { + const enDate = new Date(this.get('ENISO')) + const stDate = new Date(this.get('STISO')) + const diffInHours = (enDate - stDate) / (3600 * 1000) + this.set('LEN', Number(diffInHours).toFixed(2)) + this.set('VISITDETAIL', this.get('VISIT') + ' (' + this.get('BL') + ': ' + this.get('ST') + ')') + } }) diff --git a/client/src/js/modules/calendar/views/calendar-view.vue b/client/src/js/modules/calendar/views/calendar-view.vue index 38dd85181..cdb864bea 100644 --- a/client/src/js/modules/calendar/views/calendar-view.vue +++ b/client/src/js/modules/calendar/views/calendar-view.vue @@ -157,7 +157,6 @@ import Visits from 'collections/visits' import Beamlines from 'collections/bls' import FilterPills from 'app/components/filter-pills.vue' import CalendarDayEvents from 'modules/calendar/views/components/calendar-day-events.vue' -import { DateTime } from 'luxon' export default { name: 'CalendarView', @@ -220,9 +219,9 @@ export default { }, mounted() { const dateTime = this.todayDate - this.currentMonth = dateTime.month - 1 - this.currentDay = dateTime.day - this.currentYear = dateTime.year + this.currentMonth = dateTime.getMonth() + this.currentDay = dateTime.getDate() + this.currentYear = dateTime.getFullYear() this.fetchBeamlinesByType() this.fetchVisitsCalendar() }, @@ -330,19 +329,16 @@ export default { }, {}) }, isToday(date) { - const { month, day, year } = this.todayDate - return date === day && month - 1 === this.currentMonth && year === this.currentYear + const today = this.todayDate + return ( + date === today.getDate() && + this.currentMonth === today.getMonth() && + this.currentYear === today.getFullYear() + ) }, isPastDate(date) { - const dateItem = DateTime.fromObject({ - year: this.currentYear, - month: this.currentMonth + 1, - day: date, - zone: this.timezone - }) - + const dateItem = new Date(this.currentYear, this.currentMonth, date); return dateItem < this.todayDate - }, onHover(ref, addHover) { const hoveredRef = this.$refs[ref][0].$el @@ -409,7 +405,9 @@ export default { return this.appOption['timezone'] }, todayDate() { - return DateTime.local().setZone(this.timezone) + const d = new Date() + d.setHours(0, 0, 0, 0) + return d }, currentSelectedMonth() { return this.months[this.currentMonth] @@ -439,20 +437,12 @@ export default { return this.currentYear + 1 }, daysInMonth() { - return DateTime.fromObject({ - year: this.currentYear, - month: this.currentMonth + 1, - day: 1, - zone: this.timezone - }).daysInMonth + return new Date(this.currentYear, this.currentMonth + 1, 0).getDate() }, startDayOfMonth() { - return DateTime.fromObject({ - year: this.currentYear, - month: this.currentMonth + 1, - day: 1, - zone: this.timezone - }).weekday - 1 + const dateItem = new Date(this.currentYear, this.currentMonth, 1) + const day = dateItem.getDay() + return (day === 0) ? 6 : day - 1 }, sortedVisitsByDay() { return Array(this.daysInMonth).fill('').reduce((acc, curr, index) => { diff --git a/client/src/js/modules/samples/controller.js b/client/src/js/modules/samples/controller.js index 0171bf067..b14f690dc 100644 --- a/client/src/js/modules/samples/controller.js +++ b/client/src/js/modules/samples/controller.js @@ -18,7 +18,7 @@ define(['marionette', GetView, Sample, Samples, Protein, Proteins, - Ligand, Ligands + Ligand, Ligands, Crystal, Crystals, Instance, ProposalLookup) {