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 { ...@@ -326,6 +326,7 @@ export default {
:task-status="state.taskStatus" :task-status="state.taskStatus"
:issuable-type="issuableType" :issuable-type="issuableType"
:update-url="updateEndpoint" :update-url="updateEndpoint"
:lock-version="state.lock_version"
/> />
<edited-component <edited-component
v-if="hasUpdated" v-if="hasUpdated"
......
...@@ -35,6 +35,10 @@ export default { ...@@ -35,6 +35,10 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
lockVersion: {
type: Number,
required: false,
},
}, },
data() { data() {
return { return {
...@@ -67,8 +71,10 @@ export default { ...@@ -67,8 +71,10 @@ export default {
new TaskList({ new TaskList({
dataType: this.issuableType, dataType: this.issuableType,
fieldName: 'description', fieldName: 'description',
lockVersion: this.lockVersion,
selector: '.detail-page-description', selector: '.detail-page-description',
onSuccess: this.taskListUpdateSuccess.bind(this), onSuccess: this.taskListUpdateSuccess.bind(this),
onError: this.taskListUpdateError.bind(this),
}); });
} }
}, },
...@@ -82,6 +88,10 @@ export default { ...@@ -82,6 +88,10 @@ export default {
} }
}, },
taskListUpdateError(data) {
// stub for error handling
},
updateTaskStatusText() { updateTaskStatusText() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/); const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/);
const $issuableHeader = $('.issuable-meta'); const $issuableHeader = $('.issuable-meta');
......
...@@ -8,8 +8,9 @@ export default class TaskList { ...@@ -8,8 +8,9 @@ export default class TaskList {
this.selector = options.selector; this.selector = options.selector;
this.dataType = options.dataType; this.dataType = options.dataType;
this.fieldName = options.fieldName; this.fieldName = options.fieldName;
this.lockVersion = options.lockVersion;
this.onSuccess = options.onSuccess || (() => {}); this.onSuccess = options.onSuccess || (() => {});
this.onError = function showFlash(e) { this.onError = options.onError || function showFlash(e) {
let errorMessages = ''; let errorMessages = '';
if (e.response.data && typeof e.response.data === 'object') { if (e.response.data && typeof e.response.data === 'object') {
...@@ -43,6 +44,7 @@ export default class TaskList { ...@@ -43,6 +44,7 @@ export default class TaskList {
const patchData = {}; const patchData = {};
patchData[this.dataType] = { patchData[this.dataType] = {
[this.fieldName]: $target.val(), [this.fieldName]: $target.val(),
['lock_version']: this.lockVersion,
}; };
return axios return axios
......
...@@ -162,10 +162,13 @@ module IssuableActions ...@@ -162,10 +162,13 @@ module IssuableActions
end end
format.json do format.json do
# We want to pass back the latest valid data, so reload the model
@issuable.reload
render json: { render json: {
errors: [ 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." "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 }, status: :conflict
end end
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