mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +08:00
Enable result comment button after canceling result edit [SCI-6537] (#3894)
* Enable result comment button after cancelling edit button [SCI-6537]
This commit is contained in:
parent
3df030b29e
commit
493c7d64eb
3 changed files with 13 additions and 11 deletions
|
@ -35,18 +35,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyEditResultAssetCallback() {
|
function applyEditResultAssetCallback() {
|
||||||
$('.edit-result-asset').on('ajax:success', function(e, data) {
|
$('.edit-result-asset').off('ajax:success ajax:error').on('ajax:success', function(e, data) {
|
||||||
var $result = $(this).closest('.result');
|
var $result = $(this).closest('.result');
|
||||||
var $form = $(data.html);
|
var $form = $(data.html);
|
||||||
var $prevResult = $result;
|
var $prevResult = $result;
|
||||||
$result.after($form);
|
$result.after($form);
|
||||||
$result.remove();
|
$prevResult.hide();
|
||||||
|
|
||||||
_formAjaxResultAsset($form);
|
_formAjaxResultAsset($form, $prevResult);
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
$form.find('.cancel-edit').click(function () {
|
$form.find('.cancel-edit').click(function () {
|
||||||
$form.after($prevResult);
|
$prevResult.show();
|
||||||
$form.remove();
|
$form.remove();
|
||||||
applyEditResultAssetCallback();
|
applyEditResultAssetCallback();
|
||||||
Results.toggleResultEditButtons(true);
|
Results.toggleResultEditButtons(true);
|
||||||
|
@ -60,8 +60,9 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function _formAjaxResultAsset($form) {
|
function _formAjaxResultAsset($form, $prevResult) {
|
||||||
$form.on('ajax:success', function(e, data) {
|
$form.on('ajax:success', function(e, data) {
|
||||||
|
if ($prevResult) $prevResult.remove();
|
||||||
$form.after(data.html);
|
$form.after(data.html);
|
||||||
var $newResult = $form.next();
|
var $newResult = $form.next();
|
||||||
initFormSubmitLinks($newResult);
|
initFormSubmitLinks($newResult);
|
||||||
|
|
|
@ -41,9 +41,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply ajax callback to form
|
// Apply ajax callback to form
|
||||||
function _formAjaxResultTable($form) {
|
function _formAjaxResultTable($form, $prevResult) {
|
||||||
$form.on('ajax:success', function(e, data) {
|
$form.on('ajax:success', function(e, data) {
|
||||||
var $result;
|
var $result;
|
||||||
|
if ($prevResult) $prevResult.remove();
|
||||||
$form.after(data.html);
|
$form.after(data.html);
|
||||||
$result = $(this).next();
|
$result = $(this).next();
|
||||||
initFormSubmitLinks($result);
|
initFormSubmitLinks($result);
|
||||||
|
@ -64,20 +65,20 @@
|
||||||
|
|
||||||
// Edit result table button behaviour
|
// Edit result table button behaviour
|
||||||
function applyEditResultTableCallback() {
|
function applyEditResultTableCallback() {
|
||||||
$('.edit-result-table').on('ajax:success', function(e, data) {
|
$('.edit-result-table').off('ajax:success ajax:error').on('ajax:success', function(e, data) {
|
||||||
var $result = $(this).closest('.result');
|
var $result = $(this).closest('.result');
|
||||||
var $form = $(data.html);
|
var $form = $(data.html);
|
||||||
var $prevResult = $result;
|
var $prevResult = $result;
|
||||||
$result.after($form);
|
$result.after($form);
|
||||||
$result.remove();
|
$prevResult.hide();
|
||||||
|
|
||||||
_formAjaxResultTable($form);
|
_formAjaxResultTable($form, $prevResult);
|
||||||
_initEditableHandsOnTable($form);
|
_initEditableHandsOnTable($form);
|
||||||
_onSubmitExtractTable($form);
|
_onSubmitExtractTable($form);
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
$form.find('.cancel-edit').click(function () {
|
$form.find('.cancel-edit').click(function () {
|
||||||
$form.after($prevResult);
|
$prevResult.show();
|
||||||
$form.remove();
|
$form.remove();
|
||||||
applyEditResultTableCallback();
|
applyEditResultTableCallback();
|
||||||
Results.toggleResultEditButtons(true);
|
Results.toggleResultEditButtons(true);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
// Edit result text button behaviour
|
// Edit result text button behaviour
|
||||||
function applyEditResultTextCallback() {
|
function applyEditResultTextCallback() {
|
||||||
$('.edit-result-text').off().on('ajax:success', function(e, data) {
|
$('.edit-result-text').off('ajax:success ajax:error').on('ajax:success', function(e, data) {
|
||||||
var $result = $(this).closest('.result');
|
var $result = $(this).closest('.result');
|
||||||
var $form = $(data.html);
|
var $form = $(data.html);
|
||||||
var $prevResult = $result;
|
var $prevResult = $result;
|
||||||
|
|
Loading…
Reference in a new issue