Commit 83306d24 authored by Brett Walker's avatar Brett Walker Committed by Fatih Acet

Pass tasklist lock version

receive data on when there is a conflict
parent f1acd505
......@@ -326,6 +326,7 @@ export default {
:task-status="state.taskStatus"
:issuable-type="issuableType"
:update-url="updateEndpoint"
:lock-version="state.lock_version"
/>
<edited-component
v-if="hasUpdated"
......
......@@ -35,6 +35,10 @@ export default {
required: false,
default: null,
},
lockVersion: {
type: Number,
required: false,
},
},
data() {
return {
......@@ -67,8 +71,10 @@ export default {
new TaskList({
dataType: this.issuableType,
fieldName: 'description',
lockVersion: this.lockVersion,
selector: '.detail-page-description',
onSuccess: this.taskListUpdateSuccess.bind(this),
onError: this.taskListUpdateError.bind(this),
});
}
},
......@@ -82,6 +88,10 @@ export default {
}
},
taskListUpdateError(data) {
// stub for error handling
},
updateTaskStatusText() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/);
const $issuableHeader = $('.issuable-meta');
......
......@@ -8,8 +8,9 @@ export default class TaskList {
this.selector = options.selector;
this.dataType = options.dataType;
this.fieldName = options.fieldName;
this.lockVersion = options.lockVersion;
this.onSuccess = options.onSuccess || (() => {});
this.onError = function showFlash(e) {
this.onError = options.onError || function showFlash(e) {
let errorMessages = '';
if (e.response.data && typeof e.response.data === 'object') {
......@@ -43,6 +44,7 @@ export default class TaskList {
const patchData = {};
patchData[this.dataType] = {
[this.fieldName]: $target.val(),
['lock_version']: this.lockVersion,
};
return axios
......
......@@ -162,10 +162,13 @@ module IssuableActions
end
format.json do
# We want to pass back the latest valid data, so reload the model
@issuable.reload
render json: {
errors: [
"Someone edited this #{issuable.human_class_name} at the same time you did. Please refresh your browser and make sure your changes will not unintentionally remove theirs."
]
],
data: serializer.represent(@issuable)
}, status: :conflict
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment