From a8b73814fb37f1fc9d7243ab661f9592810dc553 Mon Sep 17 00:00:00 2001 From: Torsten Oppermann <torsten@sgalinski.de> Date: Mon, 13 Nov 2017 15:52:46 +0100 Subject: [PATCH] [TASK] Completing backend js functionality --- Resources/Private/Partials/SelectRoot.html | 2 +- .../Private/Templates/Backend/Index.html | 4 +- Resources/Public/Scripts/Backend.js | 68 ++++++++++++++++++- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/Resources/Private/Partials/SelectRoot.html b/Resources/Private/Partials/SelectRoot.html index 6ee2968b..d49dd6cd 100644 --- a/Resources/Private/Partials/SelectRoot.html +++ b/Resources/Private/Partials/SelectRoot.html @@ -10,7 +10,7 @@ <f:for each="{pages}" as="page"> <tr data-uid="{page.uid}"> <td nowrap="nowrap" class="col-title"> - <a href="#" onclick="sgRouteGoToPage({page.uid}, '{page.path}'); return false;"> + <a href="#" onclick="sgJobsGoToPage({page.uid}, '{page.path}'); return false;"> <f:format.raw> <sg:backend.icon table="pages" row="{page}" clickMenu="0" /> {page._thePathFull} </f:format.raw> diff --git a/Resources/Private/Templates/Backend/Index.html b/Resources/Private/Templates/Backend/Index.html index 06993847..aae8e10c 100644 --- a/Resources/Private/Templates/Backend/Index.html +++ b/Resources/Private/Templates/Backend/Index.html @@ -1,3 +1,5 @@ +{namespace sg=SGalinski\SgJobs\ViewHelpers} + <f:layout name="Default" /> <f:section name="iconButtons"> @@ -9,7 +11,7 @@ <f:debug>{_all}</f:debug> <f:if condition="{rootPageUid}"> <f:then> - <h1>test</h1> + <h1>{rootPageUid}</h1> </f:then> <f:else> diff --git a/Resources/Public/Scripts/Backend.js b/Resources/Public/Scripts/Backend.js index 977424a1..2b75e509 100644 --- a/Resources/Public/Scripts/Backend.js +++ b/Resources/Public/Scripts/Backend.js @@ -1,3 +1,19 @@ +(function($) { + function deleteAllListener(_event) { + _event.preventDefault(); + + var confirm = SG.lang.SgRoutes['backend.delete_all']; + if (window.confirm(confirm)) { + window.location = $(_event.currentTarget).attr('href'); + } + } + + $(document).ready(function() { + $('.btn-delete-all').on('click', deleteAllListener); + $.get(TYPO3.settings.ajaxUrls['sg_routes::ajaxPing']); + }); +})(TYPO3.jQuery); + // functions for backend docheader functionality function jumpExt(URL, anchor) { // var anc = anchor ? anchor : ""; @@ -21,4 +37,54 @@ function setHighlight(id) { // if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { top.content.nav_frame.refresh_nav(); } -} \ No newline at end of file +} + +/** + * Switches to the spefied page in the BE + * + * @param {number} uid + * @param {string} path + */ +function sgJobsGoToPage(uid, path) { + if (top.nav) { + top.nav.invokePageId(uid,gotToPageCallback); + } else { + var tree = top.Ext.getCmp('typo3-pagetree'); + if (tree) { + tree.activeTree.selectPath(path); + } + var separator = '?'; + if (top.currentSubScript.indexOf('?') !== -1) { + separator = '&'; + } + top.TYPO3.Backend.ContentContainer.setUrl( + top.currentSubScript + separator + 'id=' + uid + ); + } +} + + +/** + * Callback for page selection in the pagetree + */ +function gotToPageCallback(path){ + var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); + callback.apply(this, arguments); + var node = top.nav.getSelected(); + if (node) { + top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree); + } +} + +/** + * opens the selected category edit form + * + * @return {boolean} + */ +function editSelectedCategory(){ + var selected = TYPO3.jQuery('#filter-categories').val(); + if(selected && CategoryEditLinks[selected[0]]) { + jumpToUrl(CategoryEditLinks[selected[0]] + '&returnUrl=' + T3_THIS_LOCATION); + } + return false; +} -- GitLab