* add return confirm dialog.
This commit is contained in:
@@ -178,3 +178,9 @@
|
||||
border-width: 16px 0 16px 10px;
|
||||
border-color: transparent transparent transparent #2e7eff;
|
||||
}
|
||||
|
||||
#returnConfirmModal .footer
|
||||
{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
(function () {
|
||||
const form = document.querySelector('#mainForm');
|
||||
if (form) {
|
||||
form.addEventListener('input', function () {
|
||||
isPromptDesignDirty = true;
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -21,7 +21,8 @@ $lang->ai->nextStep = 'Next';
|
||||
$lang->ai->goTesting = 'Go testing';
|
||||
|
||||
$lang->ai->validate = new stdclass();
|
||||
$lang->ai->validate->noEmpty = '%s cannot be empty.';
|
||||
$lang->ai->validate->noEmpty = '%s cannot be empty.';
|
||||
$lang->ai->validate->dirtyForm = 'The design step of %s has changed. Do you want to save and return it?';
|
||||
|
||||
$lang->ai->prompts = new stdclass();
|
||||
$lang->ai->prompts->common = 'Prompt';
|
||||
|
||||
@@ -21,7 +21,8 @@ $lang->ai->nextStep = '下一步';
|
||||
$lang->ai->goTesting = '去调试';
|
||||
|
||||
$lang->ai->validate = new stdclass();
|
||||
$lang->ai->validate->noEmpty = '%s不能为空。';
|
||||
$lang->ai->validate->noEmpty = '%s不能为空。';
|
||||
$lang->ai->validate->dirtyForm = '%s的参数配置已变动,是否保存并返回?';
|
||||
|
||||
$lang->ai->prompts = new stdclass();
|
||||
$lang->ai->prompts->common = '提词';
|
||||
|
||||
@@ -57,7 +57,27 @@
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" form="mainForm"><i class="icon icon-save icon-sm"></i> <?php echo $lang->save ?></button>
|
||||
<button id="saveButton" type="submit" class="btn btn-primary" form="mainForm"><i class="icon icon-save icon-sm"></i> <?php echo $lang->save ?></button>
|
||||
<div class="modal fade" id="returnConfirmModal">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<p><?php echo sprintf($lang->ai->validate->dirtyForm, $lang->ai->designStepNav[$step])?></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="footer">
|
||||
<div>
|
||||
<?php echo html::a(inlink("prompts"), html::commonButton("<i class='icon icon-back icon-sm'></i> $lang->goback", '', 'btn btn-info'));?>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $lang->cancel?></button>
|
||||
<button type="button" class="btn btn-primary"><?php echo $lang->save?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function()
|
||||
{
|
||||
@@ -101,12 +121,35 @@
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
const submitButton = document.getElementById('submit');
|
||||
const submitButton = document.getElementById('saveButton');
|
||||
if(!submitButton) return;
|
||||
submitButton.click();
|
||||
})
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
let isPromptDesignDirty = false;
|
||||
(function()
|
||||
{
|
||||
const backButton = document.querySelector('.design-steps button:first-child');
|
||||
if(!backButton) return;
|
||||
backButton.addEventListener('click', function(e)
|
||||
{
|
||||
if(!isPromptDesignDirty) return;
|
||||
$('#returnConfirmModal').modal('show', 'fit');
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
const modalSaveButton = document.querySelector('#returnConfirmModal .btn-primary');
|
||||
if(!modalSaveButton) return;
|
||||
modalSaveButton.addEventListener('click', function()
|
||||
{
|
||||
const submitButton = document.getElementById('saveButton');
|
||||
if(!submitButton) return;
|
||||
submitButton.click();
|
||||
location.href = createLink('ai', 'prompts');
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user