Page 1 of 1

Next / Prev. Navigation in DV

Posted: 2021-02-01 17:20
by skoch
Hello,

since the last update of Appgini version 5.94 the new feature "Next / Prev navigation in DV" has been added. It shows the Next / Prev buttons with icon and text in the detail view.
When used in conjunction with the AppGini Helper (Compact Layout) plug-in, is there a way to suppress the text from the button system-wide.

Ahmed sent me a script for the hooks / footer-extras.php, which deletes the button text, but not for the first record, where it is still displayed.
Below is the script:

Code: Select all

<script>
$j(function() { 
   var btnText = $j('.next-record').text().trim();
   var btnHtml = $j('.next-record').html();
   $j('.next-record').html(btnHtml.replace(btnText, ''));

   btnText = $j('.previous-record').text().trim();
   btnHtml = $j('.previous-record').html();
   $j('.previous-record').html(btnHtml.replace(btnText, ''));
})
</script>
Is there a solution?

Stefan

Re: Next / Prev. Navigation in DV

Posted: 2021-02-02 07:09
by jsetzer
Thank you for reporting this issue. I am going to fix it with the next release.

For now you can use the following javascript code in your hooks/TABLENAME-dv.js file:

Code: Select all

$j("button[name=nextRecordDV],button[name=previousRecordDV]").each(function(){var n=$j(this).text(),a=$j(this).find("i.glyphicon");span=$j("<span/>").append(n).addClass("visible-xs"),$j(this).html("").append(a).append(span)});
chrome_hqEBBwLAno.png
chrome_hqEBBwLAno.png (727 Bytes) Viewed 8300 times

SOLVED: Next / Prev. Navigation in DV

Posted: 2021-02-02 07:22
by jsetzer
I have looked at the source code. These two new buttons are dynamically loaded. They are not yet present when the script is executed on detail view load.

So, instead of ...

Code: Select all

var dv = AppGiniHelper.dv;
dv.compact();
...just write...

Code: Select all

var dv = AppGiniHelper.dv;
dv.ready(function () {
    dv.compact();
});

Re: Next / Prev. Navigation in DV

Posted: 2021-02-04 10:36
by skoch
Hello,

with these adjustments it works great - thank you very much :D

Stefan

SOLVED: Next / Prev. Navigation in DV

Posted: 2021-02-04 10:45
by jsetzer
Great, glad to hear that!

Re: SOLVED: Next / Prev. Navigation in DV

Posted: 2021-07-17 16:54
by ddelpiano
jsetzer wrote:
2021-02-02 07:22
I have looked at the source code. These two new buttons are dynamically loaded. They are not yet present when the script is executed on detail view load.
[...]
Hello!
I've applied your suggestions and added the following code to all *-dv.js files:

// file: hooks/anagrafica-dv.js
var dv = AppGiniHelper.DV;
// Compact View
$j("button[name=nextRecordDV],button[name=previousRecordDV]").each(function(){var n=$j(this).text(),a=$j(this).find("i.glyphicon");span=$j("<span/>").append(n).addClass("visible-xs"),$j(this).html("").append(a).append(span)});// file: hooks/patenti-dv.js
dv.ready(function () {
dv.compact();
});
AppGiniHelper.DV.compact(true, true, true);

It works! But...
Is there a more elegant/efficient way to put some of it once, say in header-extras.js?
Please help me with syntax, because I'm not much of a programmer (my job was network management).
Thank you

Dario Delpiano

Re: Next / Prev. Navigation in DV

Posted: 2021-07-23 14:34
by jsetzer
Did you already try putting the code into header-extras?

(not tested)

Code: Select all

<!-- file: hooks/header-extras.php -->
<script>
jQuery(document).ready(function(){
  $j("button[name=nextRecordDV],button[name=previousRecordDV]").each(function(){var n=$j(this).text(),a=$j(this).find("i.glyphicon");span=$j("<span/>").append(n).addClass("visible-xs");$j(this).html("").append(a).append(span)});
});
</script>

Re: Next / Prev. Navigation in DV

Posted: 2021-07-27 13:56
by ddelpiano
I've moved the code to hooks/header-extras.php and it seems to work.
But... not always! For some mysterious reasons, sometimes label are shown, random.
I've cleared browser cache, restarted Apache. Problem persists. Any ideas?
Thank you
Dario Delpiano

Re: Next / Prev. Navigation in DV

Posted: 2021-07-27 18:05
by jsetzer
Maybe the lazy loaded elements are not yet loaded at the moment you execute your code

Re: Next / Prev. Navigation in DV

Posted: 2021-07-29 18:02
by ddelpiano
jsetzer wrote:
2021-07-27 18:05
Maybe the lazy loaded elements are not yet loaded at the moment you execute your code
Could you please explain? Is that due to code, to slow test server (WAMP) or to browser?
Thank you

Dario Delpiano

Re: Next / Prev. Navigation in DV

Posted: 2021-07-29 19:55
by jsetzer
Explanation;
When loading a webpage dozens to hundreds of single resources are loaded. Due to internet architecture there is no guarantee for a certain order of loading nor can be guaranteed that specific lazy loaded resources are available when the main page has been downloaded completely.
Before accessing an element for manipulation you should check availability of the element.

Waiting for document.ready should be fine in many cases. But I cannot see your complete code nor can I see any errors nor do I know your network performance. So, it's impossible for me to do remote debugging. If my 1st solution is working fine but the 2nd solution is not, I'd recommend you should go with the 1st solution.

Re: Next / Prev. Navigation in DV

Posted: 2021-08-20 13:35
by ddelpiano
Hello again!
I had applied your code, and it works. But...
in AppGiniHelper library there is an ActionButton function that seems to do the same, only in a cleaner and ordinate manner.
I removed all previous code from hooks/*-dv.js and added in each [tablename]-dv.js the following code:

Code: Select all

var actionbuttons = dv.actionbuttons;
AppGiniHelper.DV.ActionButtons()
    .hideText();
It doesn't work! What I'm doing wrong?
Thank you

Re: Next / Prev. Navigation in DV

Posted: 2021-08-20 22:15
by jsetzer
As far as I can see AppGiniHelper.DV.ActionButtons()
.hideText(); has nothing to do with hiding prev/next buttons

Re: Next / Prev. Navigation in DV

Posted: 2021-08-22 16:52
by ddelpiano
Thank you

Re: Next / Prev. Navigation in DV

Posted: 2021-11-24 07:47
by jsetzer
I have had a closer look at hideText()-method of DV-ActionButtons.

Status

At least in latest version it seems to work even for Prev / Next buttons:

Default Prev / Next buttons
chrome_E7ngsKlgpb.png
chrome_E7ngsKlgpb.png (1.63 KiB) Viewed 7178 times

Call hideText()-method in console
chrome_v96UKHNmgX.png
chrome_v96UKHNmgX.png (1.55 KiB) Viewed 7178 times

After execution of hideText()-method
chrome_aoQKrIbp2n.png
chrome_aoQKrIbp2n.png (1.5 KiB) Viewed 7178 times

Problem

The problem is related to lazy loading of Prev / Next buttons (explanation for lazy-load: see above). This means before executing the hideText() methods you will have to wait for the buttons to exist.

Solution

Perhaps the easiest solution: try this

Code: Select all

// file: hooks/TABLENAME-dv.js
var dv = AppGiniHelper.dv;
dv.ready(function () {
    dv.getActionButtons().hideText();
});
This works for me.