this.reload())
+ .then(() => {
+ if ('id' in this.$params) this.reload();
+ })
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
diff --git a/modules/travel/front/main/index.spec.js b/modules/travel/front/main/index.spec.js
index 96d819a6f0..6d9db4dc84 100644
--- a/modules/travel/front/main/index.spec.js
+++ b/modules/travel/front/main/index.spec.js
@@ -12,29 +12,38 @@ describe('Travel Component vnTravel', () => {
describe('fetchParams()', () => {
it('should return a range of dates with passed scope days', () => {
- /**
- * Calculates the difference in days between two dates, it also
- * accounts for cases where the two dates in question span a
- * daylight saving time (DST) change.
- *
- * @param {Date} a The start date
- * @param {Date} b The end date
- * @return {Number} The difference in days
- */
- function diffInDays(a, b) {
- const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
- const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
- const msInDay = 86400 * 1000;
- return Math.floor((utc2 - utc1) / msInDay);
- }
+ let params = controller.fetchParams({
+ scopeDays: 2
+ });
+ const shippedFrom = new Date();
+ shippedFrom.setHours(0, 0, 0, 0);
+ const shippedTo = new Date(shippedFrom.getTime());
+ shippedTo.setDate(shippedTo.getDate() + params.scopeDays);
+ shippedTo.setHours(23, 59, 59, 999);
- let params = controller.fetchParams({scopeDays: 2});
- const diff = diffInDays(
- params.shippedFrom,
- new Date(params.shippedTo.getTime() + 1)
- );
+ const expectedParams = {
+ shippedFrom,
+ scopeDays: params.scopeDays,
+ shippedTo
+ };
- expect(diff).toEqual(3);
+ expect(params).toEqual(expectedParams);
+ });
+
+ it('should return default value for scope days', () => {
+ let params = controller.fetchParams({
+ scopeDays: 1
+ });
+
+ expect(params.scopeDays).toEqual(1);
+ });
+
+ it('should return the given scope days', () => {
+ let params = controller.fetchParams({
+ scopeDays: 2
+ });
+
+ expect(params.scopeDays).toEqual(2);
});
});
});
diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html
index afc041f66d..8e7f4140d2 100644
--- a/modules/travel/front/search-panel/index.html
+++ b/modules/travel/front/search-panel/index.html
@@ -1,6 +1,6 @@
-