Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,4 +22,4 @@ module.exports = {
"ecmaVersion": 11,
"sourceType": "module"
}
}
}
9 changes: 0 additions & 9 deletions client/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 client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 8 additions & 12 deletions client/src/js/models/visit.js
Original file line number Diff line number Diff line change
@@ -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()
},

Expand Down Expand Up @@ -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') + ')')
}

})

Expand Down
44 changes: 17 additions & 27 deletions client/src/js/modules/calendar/views/calendar-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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()
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/samples/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define(['marionette',
GetView,
Sample, Samples,
Protein, Proteins,
Ligand, Ligands
Ligand, Ligands,
Crystal, Crystals,
Instance,
ProposalLookup) {
Expand Down
Loading