Replace moment.js with day.js

This commit is contained in:
Björn Fromme
2018-08-17 17:34:26 +02:00
parent 7264dd0a58
commit 67d278d960
11 changed files with 249 additions and 294 deletions
@@ -26,7 +26,8 @@ require('../images/favicon_uch.ico');
// Import dependencies
import Vue from 'vue'
import $ from 'jquery'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
import fancybox from '@fancyapps/fancybox'
global.$ = global.jQuery = $;
@@ -57,7 +58,7 @@ const sliderDot = '<button class="slider-pagination__dot" data-role="none" role=
// Define date filter for vue templates
Vue.filter('date', (value) => {
return moment(value).format('DD.MM.YYYY');
return dayjs(value).format('DD.MM.YYYY');
});
// Initialize vue app
@@ -26,7 +26,8 @@
<script>
import Vue from 'vue'
import $ from 'jquery'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
export default {
props: {
@@ -65,7 +66,7 @@
data () {
return {
showPrev: false,
startDate: moment().startOf('month'),
startDate: dayjs().startOf('month'),
calendarHtml: '',
loading: false
}
@@ -78,7 +79,7 @@
query[this.argumentPrefix + '[year]'] = this.startDate.year();
query[this.argumentPrefix + '[months]'] = this.months;
this.loading = true;
this.showPrev = this.startDate.isAfter(moment());
this.showPrev = this.startDate.isAfter(dayjs());
$.get(this.uri, query, (html) => {
this.calendarHtml = html;
this.loading = false;
@@ -4,7 +4,8 @@
<script>
import Vue from 'vue'
import $ from 'jquery'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
import datepicker from '@fengyuanchen/datepicker'
require('@fengyuanchen/datepicker/dist/datepicker.css');
@@ -36,7 +37,7 @@
if (this.date === null) {
return '';
}
return moment(this.date).format('DD.MM.YYYY');
return dayjs(this.date).format('DD.MM.YYYY');
}
},
watch: {
@@ -66,7 +66,8 @@
<script>
import $ from 'jquery'
import DatePicker from './Datepicker.vue'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
export default {
components: {
@@ -144,26 +145,26 @@
return '';
}
if (this.range.from !== null && this.range.to === null) {
return 'ab ' + moment(this.range.from).format('DD.MM.YYYY');
return 'ab ' + dayjs(this.range.from).format('DD.MM.YYYY');
}
if (this.range.from === null && this.range.to !== null) {
return 'bis ' + moment(this.range.to).format('DD.MM.YYYY');
return 'bis ' + dayjs(this.range.to).format('DD.MM.YYYY');
}
return moment(this.range.from).format('DD.MM.YYYY') + '-' + moment(this.range.to).format('DD.MM.YYYY');
return dayjs(this.range.from).format('DD.MM.YYYY') + '-' + dayjs(this.range.to).format('DD.MM.YYYY');
}
},
methods: {
updateFrom (date) {
if (this.range.to !== null && moment(date).isAfter(this.range.to)) {
this.range.to = moment(date).add(1, 'd');
if (this.range.to !== null && dayjs(date).isAfter(this.range.to)) {
this.range.to = dayjs(date).add(1, 'd');
}
this.range.from = date;
this.dateToMin = date;
this.$emit('selected', this.range);
},
updateTo (date) {
if (this.range.from !== null && moment(date).isBefore(this.range.from)) {
date = moment(this.range.from).add(1, 'd');
if (this.range.from !== null && dayjs(date).isBefore(this.range.from)) {
date = dayjs(this.range.from).add(1, 'd');
}
this.range.to = date;
this.dateFromMax = date;
@@ -10,7 +10,8 @@
import AjaxContent from './AjaxContent.vue'
import Calendar from './Calendar.vue'
import FacebookPixel from './FacebookPixel.vue'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
export default {
template: '#productdetailtpl',
@@ -97,8 +98,8 @@
query[this.argumentPrefix + '[date]'] = dateUid;
$.post(this.uris['pricetable'], query, (json) => {
this.priceTableRows = json.priceTable;
this.dateStart = moment(json.dateStart).format('DD.MM.YYYY');
this.dateEnd = moment(json.dateEnd).format('DD.MM.YYYY');
this.dateStart = dayjs(json.dateStart).format('DD.MM.YYYY');
this.dateEnd = dayjs(json.dateEnd).format('DD.MM.YYYY');
this.servicesIncluded = json.servicesIncluded;
this.loading = false;
}, 'json');
@@ -139,8 +140,8 @@
},
created () {
EventBus.$on('dateRangeUpdate', (range) => {
this.filterSettings.dateFrom = (range.from !== null) ? moment(range.from).format('YYYY-MM-DD') : null;
this.filterSettings.dateTo = (range.to !== null) ? moment(range.to).format('YYYY-MM-DD') : null;
this.filterSettings.dateFrom = (range.from !== null) ? dayjs(range.from).format('YYYY-MM-DD') : null;
this.filterSettings.dateTo = (range.to !== null) ? dayjs(range.to).format('YYYY-MM-DD') : null;
this.loadDates();
});
EventBus.$on('loadDatesTable', () => {
@@ -5,7 +5,8 @@
import DestinationSelect from './DestinationSelect.vue'
import PaxSelect from './PaxSelect.vue'
import PriceRangeSelect from './PriceRangeSelect.vue'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
export default {
components: {
@@ -55,8 +56,8 @@
}
},
updateDateRange (range) {
this.searchParams.dateFrom = range.from ? moment(range.from).format('YYYY-MM-DD') : null;
this.searchParams.dateTo = range.to ? moment(range.to).format('YYYY-MM-DD') : null;
this.searchParams.dateFrom = range.from ? dayjs(range.from).format('YYYY-MM-DD') : null;
this.searchParams.dateTo = range.to ? dayjs(range.to).format('YYYY-MM-DD') : null;
this.loadOptions();
},
updatePax (pax) {
@@ -2,7 +2,6 @@
import $ from 'jquery'
import DestinationSelect from './DestinationSelect.vue'
import PriceRangeSelect from './PriceRangeSelect.vue'
import moment from 'moment'
export default {
components: {
@@ -13,7 +13,8 @@
import BoardTypesSelect from './BoardTypesSelect.vue'
import RoomTypesSelect from './RoomTypesSelect.vue'
import BusSelect from './BusSelect.vue'
import moment from 'moment'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
export default {
components: {
@@ -226,8 +227,8 @@
this.applyFilterSettings();
},
updateDateRange (range) {
this.filterSettings.dateFrom = (range.from !== null) ? moment(range.from).format('YYYY-MM-DD') : null;
this.filterSettings.dateTo = (range.to !== null) ? moment(range.to).format('YYYY-MM-DD') : null;
this.filterSettings.dateFrom = (range.from !== null) ? dayjs(range.from).format('YYYY-MM-DD') : null;
this.filterSettings.dateTo = (range.to !== null) ? dayjs(range.to).format('YYYY-MM-DD') : null;
this.applyFilterSettings();
},
updateDateSelectMobile () {