gitlab-org--gitlab-foss/app/assets/javascripts/merge_conflict_resolver.js.es6
2016-08-12 23:24:44 +03:00

47 lines
1.1 KiB
JavaScript

//= require lib/vue
window.MergeConflictResolver = class MergeConflictResolver {
constructor() {
this.dataProvider = new MergeConflictDataProvider()
this.initVue()
}
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);
}
}
})
}
fetchData() {
$.get('./conflicts.json').done( (data) => {
this.dataProvider.decorateData(this.vue, data);
this.vue.isLoading = false;
})
}
setComputedProperties() {
const dp = this.dataProvider;
return {
conflictsCount() { return dp.getConflictsCount() },
resolvedCount() { return dp.getResolvedCount() },
allResolved() { return dp.isAllResolved() }
}
}
}