diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-08-11 09:09:01 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-08-11 09:09:01 +0200 |
commit | e9cdd68412587cc876c96b859c30b605d24e1b9f (patch) | |
tree | dd4be2079b7170b903b0242eeacd73dce843a3f4 /core | |
parent | 411f6c7704dbf24c45dee9edde4c7ef4a8cd9464 (diff) | |
parent | 76ab097ee277daf597c531b2db254fd84002a6de (diff) | |
download | nextcloud-server-e9cdd68412587cc876c96b859c30b605d24e1b9f.tar.gz nextcloud-server-e9cdd68412587cc876c96b859c30b605d24e1b9f.zip |
Merge pull request #10285 from owncloud/sharing_set_correct_min_date
[sharing] set minDate always to today + one day
Diffstat (limited to 'core')
-rw-r--r-- | core/js/share.js | 10 | ||||
-rw-r--r-- | core/js/tests/specs/shareSpec.js | 8 |
2 files changed, 13 insertions, 5 deletions
diff --git a/core/js/share.js b/core/js/share.js index 1b4e519f201..eceb6b98f1e 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -724,8 +724,11 @@ OC.Share={ */ showExpirationDate:function(date, shareTime) { var now = new Date(); + // min date should always be the next day + var minDate = new Date(); + minDate.setDate(minDate.getDate()+1); var datePickerOptions = { - minDate: now, + minDate: minDate, maxDate: null }; if (_.isNumber(shareTime)) { @@ -757,6 +760,9 @@ OC.Share={ $(document).ready(function() { if(typeof monthNames != 'undefined'){ + // min date should always be the next day + var minDate = new Date(); + minDate.setDate(minDate.getDate()+1); $.datepicker.setDefaults({ monthNames: monthNames, monthNamesShort: $.map(monthNames, function(v) { return v.slice(0,3)+'.'; }), @@ -764,7 +770,7 @@ $(document).ready(function() { dayNamesMin: $.map(dayNames, function(v) { return v.slice(0,2); }), dayNamesShort: $.map(dayNames, function(v) { return v.slice(0,3)+'.'; }), firstDay: firstDay, - minDate : new Date() + minDate : minDate }); } $(document).on('click', 'a.share', function(event) { diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 32fecf82b65..893f816833b 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -259,6 +259,7 @@ describe('OC.Share tests', function() { var shareData; var shareItem; var clock; + var expectedMinDate; function showDropDown() { OC.Share.showDropDown( @@ -274,6 +275,7 @@ describe('OC.Share tests', function() { beforeEach(function() { // pick a fake date clock = sinon.useFakeTimers(new Date(2014, 0, 20, 14, 0, 0).getTime()); + expectedMinDate = new Date(2014, 0, 21, 14, 0, 0); shareItem = { displayname_owner: 'root', expiration: null, @@ -358,7 +360,7 @@ describe('OC.Share tests', function() { showDropDown(); $('#dropdown [name=linkCheckbox]').click(); $('#dropdown [name=expirationCheckbox]').click(); - expect($.datepicker._defaults.minDate).toEqual(new Date()); + expect($.datepicker._defaults.minDate).toEqual(expectedMinDate); expect($.datepicker._defaults.maxDate).toEqual(null); }); it('limits the date range to X days after share time when enforced', function() { @@ -367,7 +369,7 @@ describe('OC.Share tests', function() { oc_appconfig.core.defaultExpireDateEnforced = true; showDropDown(); $('#dropdown [name=linkCheckbox]').click(); - expect($.datepicker._defaults.minDate).toEqual(new Date()); + expect($.datepicker._defaults.minDate).toEqual(expectedMinDate); expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0)); }); it('limits the date range to X days after share time when enforced, even when redisplayed the next days', function() { @@ -380,7 +382,7 @@ describe('OC.Share tests', function() { oc_appconfig.core.defaultExpireDateEnabled = true; oc_appconfig.core.defaultExpireDateEnforced = true; showDropDown(); - expect($.datepicker._defaults.minDate).toEqual(new Date()); + expect($.datepicker._defaults.minDate).toEqual(expectedMinDate); expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0)); }); }); |