2016-07-31 11:24:51 -04:00
|
|
|
//= require lib/vue
|
|
|
|
|
2016-08-12 14:36:55 -04:00
|
|
|
class MergeConflictResolver {
|
2016-08-01 07:43:57 -04:00
|
|
|
|
2016-07-31 11:24:51 -04:00
|
|
|
constructor() {
|
|
|
|
this.dataProvider = new MergeConflictDataProvider()
|
|
|
|
this.initVue()
|
|
|
|
}
|
|
|
|
|
2016-08-01 07:43:57 -04:00
|
|
|
|
2016-07-31 11:24:51 -04: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 08:16:21 -04:00
|
|
|
},
|
|
|
|
commit() {
|
|
|
|
that.commit();
|
2016-07-31 11:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-08 06:26:09 -04:00
|
|
|
setComputedProperties() {
|
|
|
|
const dp = this.dataProvider;
|
|
|
|
|
|
|
|
return {
|
|
|
|
conflictsCount() { return dp.getConflictsCount() },
|
2016-08-12 14:48:02 -04:00
|
|
|
resolvedCount() { return dp.getResolvedCount() },
|
|
|
|
readyToCommit() { return dp.isReadyToCommit() },
|
|
|
|
commitButtonText() { return dp.getCommitButtonText() }
|
2016-08-08 06:26:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-31 11:24:51 -04:00
|
|
|
fetchData() {
|
2016-08-02 07:51:43 -04:00
|
|
|
const dp = this.dataProvider;
|
|
|
|
|
2016-08-10 23:40:00 -04:00
|
|
|
$.get($('#conflicts').data('conflictsPath'))
|
2016-08-08 10:24:52 -04:00
|
|
|
.done((data) => {
|
2016-08-02 07:51:43 -04:00
|
|
|
dp.decorateData(this.vue, data);
|
|
|
|
})
|
2016-08-08 10:24:52 -04:00
|
|
|
.error((data) => {
|
2016-08-02 07:51:43 -04:00
|
|
|
dp.handleFailedRequest(this.vue, data);
|
|
|
|
})
|
2016-08-08 10:24:52 -04:00
|
|
|
.always(() => {
|
2016-08-02 07:51:43 -04:00
|
|
|
this.vue.isLoading = false;
|
2016-08-08 10:24:52 -04:00
|
|
|
|
|
|
|
this.vue.$nextTick(() => {
|
|
|
|
$('#conflicts .js-syntax-highlight').syntaxHighlight();
|
|
|
|
});
|
|
|
|
|
2016-08-08 10:24:13 -04:00
|
|
|
if (this.vue.diffViewType === 'parallel') {
|
|
|
|
$('.content-wrapper .container-fluid').removeClass('container-limited');
|
|
|
|
}
|
2016-08-02 07:51:43 -04:00
|
|
|
})
|
2016-07-31 11:24:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 08:16:21 -04:00
|
|
|
commit() {
|
2016-08-08 06:26:09 -04:00
|
|
|
this.vue.isSubmitting = true;
|
|
|
|
|
2016-08-10 23:40:00 -04:00
|
|
|
$.post($('#conflicts').data('resolveConflictsPath'), this.dataProvider.getCommitData())
|
2016-08-08 10:24:52 -04:00
|
|
|
.done((data) => {
|
2016-08-08 06:26:09 -04:00
|
|
|
window.location.href = data.redirect_to;
|
|
|
|
})
|
|
|
|
.error(() => {
|
|
|
|
new Flash('Something went wrong!');
|
2016-08-02 08:16:21 -04:00
|
|
|
})
|
2016-08-08 06:26:09 -04:00
|
|
|
.always(() => {
|
|
|
|
this.vue.isSubmitting = false;
|
|
|
|
});
|
2016-08-02 08:16:21 -04:00
|
|
|
}
|
|
|
|
|
2016-07-31 11:24:51 -04:00
|
|
|
}
|