Skip to content

Commit 41061dd

Browse files
committed
Allow user to finish typing date before formatting
Debounce `onExpirationChange` to avoid calling `formatDateToString` on invalid on uncompletely inputed date strings. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent c179408 commit 41061dd

5 files changed

Lines changed: 842 additions & 3 deletions

File tree

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ export default {
221221
*
222222
* @param {Date} date
223223
*/
224-
onExpirationChange(date) {
224+
onExpirationChange: debounce((date) => {
225225
this.share.expireDate = this.formatDateToString(new Date(date))
226-
},
227-
226+
}, 500),
228227
/**
229228
* Uncheck expire date
230229
* We need this method because @update:checked
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
3+
*
4+
* @author Vincent Petry <vincent@nextcloud.com>
5+
*
6+
* @license AGPL-3.0-or-later
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
describe('OCA.Trashbin.App tests', function() {
24+
var App = OCA.Trashbin.App;
25+
26+
beforeEach(function() {
27+
$('#testArea').append(
28+
'<div id="app-navigation">' +
29+
'<ul><li data-id="files"><a>Files</a></li>' +
30+
'<li data-id="trashbin"><a>Trashbin</a></li>' +
31+
'</div>' +
32+
'<div id="app-content">' +
33+
'<div id="app-content-files" class="hidden">' +
34+
'</div>' +
35+
'<div id="app-content-trashbin" class="hidden">' +
36+
'</div>' +
37+
'</div>' +
38+
'</div>'
39+
);
40+
App.initialize($('#app-content-trashbin'));
41+
});
42+
afterEach(function() {
43+
App._initialized = false;
44+
App.fileList = null;
45+
});
46+
47+
describe('initialization', function() {
48+
it('creates a custom filelist instance', function() {
49+
App.initialize();
50+
expect(App.fileList).toBeDefined();
51+
expect(App.fileList.$el.is('#app-content-trashbin')).toEqual(true);
52+
});
53+
54+
it('registers custom file actions', function() {
55+
var fileActions;
56+
App.initialize();
57+
58+
fileActions = App.fileList.fileActions;
59+
60+
expect(fileActions.actions.all).toBeDefined();
61+
expect(fileActions.actions.all.Restore).toBeDefined();
62+
expect(fileActions.actions.all.Delete).toBeDefined();
63+
64+
expect(fileActions.actions.all.Rename).not.toBeDefined();
65+
expect(fileActions.actions.all.Download).not.toBeDefined();
66+
67+
expect(fileActions.defaults.dir).toEqual('Open');
68+
});
69+
});
70+
});

0 commit comments

Comments
 (0)