Show loading button while Ajax request is in progress.
This commit is contained in:
parent
b79378cae8
commit
41f7cee991
4 changed files with 35 additions and 18 deletions
|
@ -11,6 +11,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
|
|||
hasError : false,
|
||||
isParallel : diffViewType === 'parallel',
|
||||
diffViewType : diffViewType,
|
||||
isSubmitting : false,
|
||||
conflictsData : {},
|
||||
resolutionData : {}
|
||||
}
|
||||
|
@ -18,7 +19,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
|
|||
|
||||
|
||||
decorateData(vueInstance, data) {
|
||||
this.vueInstance = vueInstance;
|
||||
this.vueInstance = vueInstance;
|
||||
|
||||
if (data.type === 'error') {
|
||||
vueInstance.hasError = true;
|
||||
|
@ -34,6 +35,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
|
|||
}
|
||||
|
||||
vueInstance.conflictsData = data;
|
||||
vueInstance.isSubmitting = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,7 +235,7 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
|
|||
|
||||
|
||||
isAllResolved() {
|
||||
return this.getConflictsCount() === this.getResolvedCount();
|
||||
return !this.vueInstance.isSubmitting && this.getConflictsCount() === this.getResolvedCount();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,17 @@ window.MergeConflictResolver = class MergeConflictResolver {
|
|||
}
|
||||
|
||||
|
||||
setComputedProperties() {
|
||||
const dp = this.dataProvider;
|
||||
|
||||
return {
|
||||
conflictsCount() { return dp.getConflictsCount() },
|
||||
resolvedCount() { return dp.getResolvedCount() },
|
||||
allResolved() { return dp.isAllResolved() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fetchData() {
|
||||
const dp = this.dataProvider;
|
||||
|
||||
|
@ -47,21 +58,19 @@ window.MergeConflictResolver = class MergeConflictResolver {
|
|||
}
|
||||
|
||||
|
||||
setComputedProperties() {
|
||||
const dp = this.dataProvider;
|
||||
|
||||
return {
|
||||
conflictsCount() { return dp.getConflictsCount() },
|
||||
resolvedCount() { return dp.getResolvedCount() },
|
||||
allResolved() { return dp.isAllResolved() }
|
||||
}
|
||||
}
|
||||
|
||||
commit() {
|
||||
this.vue.isSubmitting = true;
|
||||
|
||||
$.post('./resolve_conflicts', this.dataProvider.getCommitData())
|
||||
.then( (data) => {
|
||||
window.location.href = data.redirect_to
|
||||
.done( (data) => {
|
||||
window.location.href = data.redirect_to;
|
||||
})
|
||||
.error(() => {
|
||||
new Flash('Something went wrong!');
|
||||
})
|
||||
.always(() => {
|
||||
this.vue.isSubmitting = false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -137,4 +137,8 @@ $unselected_line: #f8f8f8;
|
|||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-success .fa-spinner {
|
||||
color: #FFF;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,8 +126,10 @@
|
|||
%textarea.form-control.js-commit-message{":disabled" => "!allResolved", "v-model" => "conflictsData.commitMessage"}
|
||||
{{{conflictsData.commitMessage}}}
|
||||
|
||||
%button{type: 'button', class: 'btn btn-success js-submit-button', ":disabled" => "!allResolved", "@click" => "commit()"}
|
||||
Commit conflict resolution
|
||||
%button{type: "button", class: "btn btn-success js-submit-button", ":disabled" => "!allResolved", "@click" => "commit()"}
|
||||
%span Commit conflict resolution
|
||||
%a.fa.fa-spin.fa-spinner{":class" => "{'hidden': !isSubmitting}"}
|
||||
|
||||
/ %button{type: 'button', class: 'btn btn-cancel'}
|
||||
/ Cancel
|
||||
/ FIXME: Hardcoded path
|
||||
%a.btn.btn-cancel{"href" => "diffs"}
|
||||
Cancel
|
||||
|
|
Loading…
Reference in a new issue