mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 13:28:53 +08:00
Fix revert protocol action for linked task changes [SCI-8110] (#5125)
This commit is contained in:
parent
7b93ced541
commit
8acbf0b4f1
5 changed files with 31 additions and 7 deletions
|
@ -40,8 +40,9 @@ function initLinkUpdate() {
|
||||||
var modalTitle = modal.find('.modal-title');
|
var modalTitle = modal.find('.modal-title');
|
||||||
var modalMessage = modal.find('.modal-body .message');
|
var modalMessage = modal.find('.modal-body .message');
|
||||||
var updateBtn = modal.find(".modal-footer [data-action='submit']");
|
var updateBtn = modal.find(".modal-footer [data-action='submit']");
|
||||||
$("[data-action='unlink'], [data-action='revert'], [data-action='update-parent'], [data-action='update-self']")
|
$('.protocol-options-dropdown')
|
||||||
.on('ajax:success', function(e, data) {
|
.on('ajax:success', "[data-action='unlink'], [data-action='revert'], [data-action='update-parent'],"
|
||||||
|
+ "[data-action='update-self']", function(e, data) {
|
||||||
modalTitle.html(data.title);
|
modalTitle.html(data.title);
|
||||||
modalMessage.html(data.message);
|
modalMessage.html(data.message);
|
||||||
updateBtn.text(data.btn_text);
|
updateBtn.text(data.btn_text);
|
||||||
|
|
|
@ -189,6 +189,9 @@
|
||||||
inRepository() {
|
inRepository() {
|
||||||
return this.protocol.attributes.in_repository
|
return this.protocol.attributes.in_repository
|
||||||
},
|
},
|
||||||
|
linked() {
|
||||||
|
return this.protocol.attributes.linked;
|
||||||
|
},
|
||||||
urls() {
|
urls() {
|
||||||
return this.protocol.attributes.urls || {}
|
return this.protocol.attributes.urls || {}
|
||||||
}
|
}
|
||||||
|
@ -232,21 +235,34 @@
|
||||||
if (this.inRepository) return
|
if (this.inRepository) return
|
||||||
// legacy method from app/assets/javascripts/my_modules/protocols.js
|
// legacy method from app/assets/javascripts/my_modules/protocols.js
|
||||||
refreshProtocolStatusBar();
|
refreshProtocolStatusBar();
|
||||||
|
|
||||||
|
// Update protocol options drowpdown for linked tasks
|
||||||
|
this.refreshProtocolDropdownOptions();
|
||||||
|
},
|
||||||
|
refreshProtocolDropdownOptions() {
|
||||||
|
if (!this.linked && this.inRepository) return
|
||||||
|
|
||||||
|
$.get(this.protocolUrl, (result) => {
|
||||||
|
this.protocol.attributes.urls = result.data.attributes.urls;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
updateProtocol(attributes) {
|
updateProtocol(attributes) {
|
||||||
this.protocol.attributes = attributes
|
this.protocol.attributes = attributes
|
||||||
},
|
},
|
||||||
updateName(newName) {
|
updateName(newName) {
|
||||||
this.protocol.attributes.name = newName;
|
this.protocol.attributes.name = newName;
|
||||||
this.refreshProtocolStatus();
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
url: this.urls.update_protocol_name_url,
|
url: this.urls.update_protocol_name_url,
|
||||||
data: { protocol: { name: newName } }
|
data: { protocol: { name: newName } },
|
||||||
|
success: () => {
|
||||||
|
this.refreshProtocolStatus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateDescription(protocol) {
|
updateDescription(protocol) {
|
||||||
this.protocol.attributes = protocol.attributes
|
this.protocol.attributes = protocol.attributes
|
||||||
|
this.refreshProtocolStatus();
|
||||||
},
|
},
|
||||||
addStep(position) {
|
addStep(position) {
|
||||||
$.post(this.urls.add_step_url, {position: position}, (result) => {
|
$.post(this.urls.add_step_url, {position: position}, (result) => {
|
||||||
|
@ -257,8 +273,8 @@
|
||||||
if(position === this.steps.length - 1) {
|
if(position === this.steps.length - 1) {
|
||||||
this.$nextTick(() => this.scrollToBottom());
|
this.$nextTick(() => this.scrollToBottom());
|
||||||
}
|
}
|
||||||
|
this.refreshProtocolStatus();
|
||||||
})
|
})
|
||||||
this.refreshProtocolStatus();
|
|
||||||
},
|
},
|
||||||
updateStepsPosition(step, action = 'add') {
|
updateStepsPosition(step, action = 'add') {
|
||||||
let position = step.attributes.position;
|
let position = step.attributes.position;
|
||||||
|
|
|
@ -86,7 +86,9 @@ export default {
|
||||||
});
|
});
|
||||||
filesUploadedCntr += 1;
|
filesUploadedCntr += 1;
|
||||||
if (filesUploadedCntr === filesToUploadCntr) {
|
if (filesUploadedCntr === filesToUploadCntr) {
|
||||||
this.$emit('stepUpdated');
|
setTimeout(() => {
|
||||||
|
this.$emit('stepUpdated');
|
||||||
|
}, 1000);
|
||||||
resolve('done');
|
resolve('done');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,6 +419,7 @@
|
||||||
$.post(this.urls[`create_${elementType}_url`], (result) => {
|
$.post(this.urls[`create_${elementType}_url`], (result) => {
|
||||||
result.data.isNew = true;
|
result.data.isNew = true;
|
||||||
this.elements.push(result.data)
|
this.elements.push(result.data)
|
||||||
|
this.$emit('stepUpdated')
|
||||||
}).error(() => {
|
}).error(() => {
|
||||||
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
HelperModule.flashAlertMsg(this.i18n.t('errors.general'), 'danger');
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository,
|
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository,
|
||||||
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code,
|
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code,
|
||||||
:published, :version_comment, :archived
|
:published, :version_comment, :archived, :linked
|
||||||
|
|
||||||
def updated_at
|
def updated_at
|
||||||
object.updated_at.to_i
|
object.updated_at.to_i
|
||||||
|
@ -84,6 +84,10 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
!object.in_module?
|
!object.in_module?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def linked
|
||||||
|
object.linked?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_from_repo_url
|
def load_from_repo_url
|
||||||
|
|
Loading…
Add table
Reference in a new issue