chg: [UI] Go directly to edit mode after clicking to "Edit report" button

pull/6788/head
Jakub Onderka 2020-12-21 22:45:29 +01:00
parent 8403bdee44
commit df5f65da25
2 changed files with 15 additions and 7 deletions

View File

@ -98,7 +98,7 @@
</li>
</ul>
<?php elseif($canEdit && !empty($editRedirect)): ?>
<a id="saveMarkdownButton" type="button" class="btn btn-primary" href="<?= h($editRedirect) ?>" target="_blank">
<a type="button" class="btn btn-primary" href="<?= h($editRedirect) ?>#splitscreen" target="_blank">
<i class="<?= $this->FontAwesome->getClass('edit') ?>"></i>
<?= __('Edit report') ?>
</a>
@ -221,4 +221,4 @@
if (!empty($additionalMarkdownElements)) {
echo $this->element($additionalMarkdownElements['path'], $additionalMarkdownElements['variables']);
}
?>
?>

View File

@ -40,7 +40,15 @@ $(document).ready(function() {
initCodeMirror()
toggleSaveButton(false)
}
setMode(defaultMode)
var mode = defaultMode;
if (window.location.hash) {
// Switch to mode by using #[mode_name] in URL
var anchor = window.location.hash.substr(1);
if ((canEdit && (anchor === 'editor' || anchor === 'splitscreen')) || anchor === 'viewer' || anchor === 'raw') {
mode = anchor;
}
}
setMode(mode)
if (canEdit) {
setEditorData(originalRaw);
@ -337,20 +345,20 @@ function setMode(mode) {
$mardownViewerToolbar.find('button[data-togglemode="' + mode + '"]').addClass('btn-inverse')
hideAll()
$editorContainer.css('width', '');
if (mode == 'raw') {
if (mode === 'raw') {
$rawContainer.show()
}
if (mode == 'splitscreen') {
if (mode === 'splitscreen') {
$resizableHandle.show()
$splitContainer.addClass('split-actif')
} else {
$resizableHandle.hide()
$splitContainer.removeClass('split-actif')
}
if (mode == 'viewer' || mode == 'splitscreen') {
if (mode === 'viewer' || mode === 'splitscreen') {
$viewerContainer.show()
}
if (mode == 'editor' || mode == 'splitscreen') {
if (mode === 'editor' || mode === 'splitscreen') {
$editorContainer.show({
duration: 0,
complete: function() {