2016-08-17 16:15:03 +00:00
|
|
|
//= require vue
|
2016-07-31 15:24:51 +00:00
|
|
|
|
2016-08-12 18:36:55 +00:00
|
|
|
class MergeConflictResolver {
|
2016-08-01 11:43:57 +00:00
|
|
|
|
2016-07-31 15:24:51 +00:00
|
|
|
constructor() {
|
|
|
|
this.dataProvider = new MergeConflictDataProvider()
|
|
|
|
this.initVue()
|
|
|
|
}
|
|
|
|
|
2016-08-01 11:43:57 +00:00
|
|
|
|
2016-07-31 15:24:51 +00:00
|
|
|
initVue() {
|
|
|
|
const that = this;
|
|
|
|
this.vue = new Vue({
|
|
|
|
el : '#conflicts',
|
|
|
|
name : 'MergeConflictResolver',
|
|
|
|
data : this.dataProvider.getInitialData(),
|
|
|
|
created : this.fetchData(),
|
|
|
|
computed : this.setComputedProperties(),
|
|
|
|
methods : {
|
|
|
|
handleSelected(sectionId, selection) {
|
|
|
|
that.dataProvider.handleSelected(sectionId, selection);
|
|
|
|
},
|
|
|
|
handleViewTypeChange(newType) {
|
|
|
|
that.dataProvider.updateViewType(newType);
|
2016-08-02 12:16:21 +00:00
|
|
|
},
|
|
|
|
commit() {
|
|
|
|
that.commit();
|
2016-07-31 15:24:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-08 10:26:09 +00:00
|
|
|
setComputedProperties() {
|
|
|
|
const dp = this.dataProvider;
|
|
|
|
|
|
|
|
return {
|
|
|
|
conflictsCount() { return dp.getConflictsCount() },
|
2016-08-12 18:48:02 +00:00
|
|
|
resolvedCount() { return dp.getResolvedCount() },
|
|
|
|
readyToCommit() { return dp.isReadyToCommit() },
|
|
|
|
commitButtonText() { return dp.getCommitButtonText() }
|
2016-08-08 10:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 15:24:51 +00:00
|
|
|
fetchData() {
|
2016-08-02 11:51:43 +00:00
|
|
|
const dp = this.dataProvider;
|
|
|
|
|
2016-08-11 03:40:00 +00:00
|
|
|
$.get($('#conflicts').data('conflictsPath'))
|
2016-08-08 14:24:52 +00:00
|
|
|
.done((data) => {
|
2016-08-02 11:51:43 +00:00
|
|
|
dp.decorateData(this.vue, data);
|
|
|
|
})
|
2016-08-08 14:24:52 +00:00
|
|
|
.error((data) => {
|
2016-08-02 11:51:43 +00:00
|
|
|
dp.handleFailedRequest(this.vue, data);
|
|
|
|
})
|
2016-08-08 14:24:52 +00:00
|
|
|
.always(() => {
|
2016-08-02 11:51:43 +00:00
|
|
|
this.vue.isLoading = false;
|
2016-08-08 14:24:52 +00:00
|
|
|
|
|
|
|
this.vue.$nextTick(() => {
|
|
|
|
$('#conflicts .js-syntax-highlight').syntaxHighlight();
|
|
|
|
});
|
|
|
|
|
2016-09-19 23:02:52 +00:00
|
|
|
$('.content-wrapper .container-fluid')
|
|
|
|
.toggleClass('container-limited', !this.vue.isParallel && this.vue.fixedLayout);
|
2016-08-02 11:51:43 +00:00
|
|
|
})
|
2016-07-31 15:24:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 12:16:21 +00:00
|
|
|
commit() {
|
2016-08-08 10:26:09 +00:00
|
|
|
this.vue.isSubmitting = true;
|
|
|
|
|
2016-08-11 03:40:00 +00:00
|
|
|
$.post($('#conflicts').data('resolveConflictsPath'), this.dataProvider.getCommitData())
|
2016-08-08 14:24:52 +00:00
|
|
|
.done((data) => {
|
2016-08-08 10:26:09 +00:00
|
|
|
window.location.href = data.redirect_to;
|
|
|
|
})
|
|
|
|
.error(() => {
|
|
|
|
this.vue.isSubmitting = false;
|
2016-08-19 11:12:50 +00:00
|
|
|
new Flash('Something went wrong!');
|
2016-08-08 10:26:09 +00:00
|
|
|
});
|
2016-08-02 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:24:51 +00:00
|
|
|
}
|