mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 03:46:39 +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 modalMessage = modal.find('.modal-body .message');
|
||||
var updateBtn = modal.find(".modal-footer [data-action='submit']");
|
||||
$("[data-action='unlink'], [data-action='revert'], [data-action='update-parent'], [data-action='update-self']")
|
||||
.on('ajax:success', function(e, data) {
|
||||
$('.protocol-options-dropdown')
|
||||
.on('ajax:success', "[data-action='unlink'], [data-action='revert'], [data-action='update-parent'],"
|
||||
+ "[data-action='update-self']", function(e, data) {
|
||||
modalTitle.html(data.title);
|
||||
modalMessage.html(data.message);
|
||||
updateBtn.text(data.btn_text);
|
||||
|
|
|
@ -189,6 +189,9 @@
|
|||
inRepository() {
|
||||
return this.protocol.attributes.in_repository
|
||||
},
|
||||
linked() {
|
||||
return this.protocol.attributes.linked;
|
||||
},
|
||||
urls() {
|
||||
return this.protocol.attributes.urls || {}
|
||||
}
|
||||
|
@ -232,21 +235,34 @@
|
|||
if (this.inRepository) return
|
||||
// legacy method from app/assets/javascripts/my_modules/protocols.js
|
||||
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) {
|
||||
this.protocol.attributes = attributes
|
||||
},
|
||||
updateName(newName) {
|
||||
this.protocol.attributes.name = newName;
|
||||
this.refreshProtocolStatus();
|
||||
$.ajax({
|
||||
type: 'PATCH',
|
||||
url: this.urls.update_protocol_name_url,
|
||||
data: { protocol: { name: newName } }
|
||||
data: { protocol: { name: newName } },
|
||||
success: () => {
|
||||
this.refreshProtocolStatus();
|
||||
}
|
||||
});
|
||||
},
|
||||
updateDescription(protocol) {
|
||||
this.protocol.attributes = protocol.attributes
|
||||
this.refreshProtocolStatus();
|
||||
},
|
||||
addStep(position) {
|
||||
$.post(this.urls.add_step_url, {position: position}, (result) => {
|
||||
|
@ -257,8 +273,8 @@
|
|||
if(position === this.steps.length - 1) {
|
||||
this.$nextTick(() => this.scrollToBottom());
|
||||
}
|
||||
this.refreshProtocolStatus();
|
||||
})
|
||||
this.refreshProtocolStatus();
|
||||
},
|
||||
updateStepsPosition(step, action = 'add') {
|
||||
let position = step.attributes.position;
|
||||
|
|
|
@ -86,7 +86,9 @@ export default {
|
|||
});
|
||||
filesUploadedCntr += 1;
|
||||
if (filesUploadedCntr === filesToUploadCntr) {
|
||||
this.$emit('stepUpdated');
|
||||
setTimeout(() => {
|
||||
this.$emit('stepUpdated');
|
||||
}, 1000);
|
||||
resolve('done');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,6 +419,7 @@
|
|||
$.post(this.urls[`create_${elementType}_url`], (result) => {
|
||||
result.data.isNew = true;
|
||||
this.elements.push(result.data)
|
||||
this.$emit('stepUpdated')
|
||||
}).error(() => {
|
||||
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,
|
||||
:created_at_formatted, :updated_at_formatted, :added_by, :authors, :keywords, :version, :code,
|
||||
:published, :version_comment, :archived
|
||||
:published, :version_comment, :archived, :linked
|
||||
|
||||
def updated_at
|
||||
object.updated_at.to_i
|
||||
|
@ -84,6 +84,10 @@ class ProtocolSerializer < ActiveModel::Serializer
|
|||
!object.in_module?
|
||||
end
|
||||
|
||||
def linked
|
||||
object.linked?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_from_repo_url
|
||||
|
|
Loading…
Add table
Reference in a new issue