From 11ee0b14bba1d9a88d1d49072771ba7bc8273f51 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 22 Mar 2017 14:32:26 +0100 Subject: [PATCH] replace autosave with a save button for external storage configuration Signed-off-by: Robin Appelman --- apps/files_external/js/settings.js | 14 +++++--------- apps/files_external/templates/settings.php | 8 +++++++- apps/files_external/tests/js/settingsSpec.js | 13 +++++-------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 0270b7a695..976c0c00b8 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -719,6 +719,10 @@ MountConfigListView.prototype = _.extend({ self.deleteStorageConfig($(this).closest('tr')); }); + this.$el.on('click', 'td.save>img', function () { + self.saveStorageConfig($(this).closest('tr')); + }); + this.$el.on('click', 'td.mountOptionsToggle>img', function() { self._showMountOptionsDropdown($(this).closest('tr')); }); @@ -737,13 +741,6 @@ MountConfigListView.prototype = _.extend({ highlightInput($target); var $tr = $target.closest('tr'); this.updateStatus($tr, null); - - var timer = $tr.data('save-timer'); - clearTimeout(timer); - timer = setTimeout(function() { - self.saveStorageConfig($tr, null, timer); - }, 2000); - $tr.data('save-timer', timer); }, _onSelectBackend: function(event) { @@ -813,8 +810,7 @@ MountConfigListView.prototype = _.extend({ $tr.data('storageConfig', storageConfig); $tr.show(); - $tr.find('td').last().attr('class', 'remove'); - $tr.find('td.mountOptionsToggle').removeClass('hidden'); + $tr.find('td.mountOptionsToggle, td.save, td.remove').removeClass('hidden'); $tr.find('td').last().removeAttr('style'); $tr.removeAttr('id'); $tr.find('select#selectBackend'); diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 53d2412425..9d8c179dd3 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -150,13 +150,19 @@ /> - + <?php p($l->t('Delete')); ?> + + <?php p($l->t('Save')); ?> + diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js index 8f01c16b38..2639f634b2 100644 --- a/apps/files_external/tests/js/settingsSpec.js +++ b/apps/files_external/tests/js/settingsSpec.js @@ -46,7 +46,8 @@ describe('OCA.External.Settings tests', function() { '' + '' + '' + - 'Delete' + + 'Delete' + + 'Save' + '' + '' + '' @@ -195,7 +196,7 @@ describe('OCA.External.Settings tests', function() { $tr = view.$el.find('tr:first'); selectBackend('\\OC\\TestBackend'); }); - it('saves storage after editing config', function() { + it('saves storage after clicking the save button', function() { var $field1 = $tr.find('input[data-parameter=field1]'); expect($field1.length).toEqual(1); $field1.val('test'); @@ -205,7 +206,8 @@ describe('OCA.External.Settings tests', function() { expect($mountOptionsField.length).toEqual(1); $mountOptionsField.val(JSON.stringify({previews:true})); - clock.tick(4000); + var $saveButton = $tr.find('td.save img'); + $saveButton.click(); expect(fakeServer.requests.length).toEqual(1); var request = fakeServer.requests[0]; @@ -242,11 +244,6 @@ describe('OCA.External.Settings tests', function() { // but after closing the dropdown expect(fakeServer.requests.length).toEqual(1); }); - // TODO: tests with "applicableUsers" and "applicableGroups" - // TODO: test with missing mount point value - // TODO: test with personal mounts (no applicable fields) - // TODO: test save triggers: paste, keyup, checkbox - // TODO: test "custom" field with addScript // TODO: status indicator }); describe('validate storage configuration', function() {