Disabled editor buttons while uploading changes

This commit is contained in:
Basti 2018-04-01 15:52:51 +02:00
parent f2fe1f5530
commit c7a4faf5b2
3 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { observer } from '@ember/object';
import { computed, observer } from '@ember/object';
import { alias } from '@ember/object/computed';
import { scheduleOnce } from '@ember/runloop';
import JSONTreeView from 'npm:json-tree-view';
@ -12,6 +12,11 @@ export default Component.extend({
classNames: ['file-preview'],
fileLoaded: false,
uploadingChanges: false,
showEditor: null,
hideEditor: computed.not('showEditor'),
fileContent: null,
objectURL: null,
metaData: null,
@ -123,6 +128,7 @@ export default Component.extend({
if (this.get('isJSON') && this.get('jsonShowTree')) {
const content = JSON.stringify(this.get('jsonTreeView.value'));
this.set('uploadingChanges', true);
this.get('storage.client')
.storeFile('application/json', path, content)
@ -135,6 +141,8 @@ export default Component.extend({
}).catch(err => {
alert('Failed to update the file. Check the console for more info.');
console.error(err);
}).finally(() => {
this.set('uploadingChanges', false);
});
} else {
console.warn('not implemented');

View File

@ -21,8 +21,8 @@
{{#if showEditor}}
<div class="actions">
<button {{action "saveChanges"}}>Save changes</button>
<button {{action "cancelEditor"}}>Cancel editing</button>
<button {{action "saveChanges"}} disabled={{uploadingChanges}}>Save changes</button>
<button {{action "cancelEditor"}} disabled={{uploadingChanges}}>Cancel editing</button>
</div>
{{/if}}
{{/if}}

View File

@ -60,7 +60,6 @@
isJSON=documentIsJSON
isEditable=documentIsEditableHide
showEditor=documentShowEditor
hideEditor=documentHideEditor
jsonShowTree=jsonShowTree
jsonShowSource=jsonShowSource}}
</section>