Skip to content

Commit

Permalink
Fixed redraw of QR Code light-box
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jan 3, 2025
1 parent 5d2f0a6 commit 47510e6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 24 deletions.
2 changes: 1 addition & 1 deletion logicaldoc-core/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<unzip src="@{webroot}/WEB-INF/lib/${pom.artifactId}-${pom.version}-plugin.jar.skip" dest="@{webroot}/WEB-INF/lib/tmp" />
<delete>
<fileset dir="@{webroot}/WEB-INF/lib/tmp">
<include name="com/logicaldoc/core/security/dao/HibernateTenant*" />
<include name="com/logicaldoc/core/security/HibernateTenant*" />
<include name="com/logicaldoc/core/security/authentication/AuthenticationChain*" />
</fileset>
</delete>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void scrollGrid(ListGrid listGrid, EndScrollListener listener) {
/*
* With a timer we scroll the grid in order to fetch all the data
*/
final Timer timer = new Timer() {
new Timer() {
public void run() {
Integer[] visibleRows = listGrid.getVisibleRows();
if (visibleRows[1] >= listGrid.getTotalRows() - 1) {
Expand All @@ -59,8 +59,7 @@ public void run() {
schedule(100);
}
}
};
timer.schedule(100);
}.schedule(100);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.logicaldoc.gui.common.client.widgets;

import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Window;

/**
* A window with utility method to force a delayed redraw of the content
*
* @author Marco Meschieri - LogicalDOC
* @since 9.1.1
*/
public abstract class DelayedRedrawWindow extends Window {

/**
* Forces the redraw after waiting some milliseconds
*/
protected void delayedRedraw() {
new Timer() {
public void run() {
redraw();
}
}.schedule(200);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.smartgwt.client.types.ImageStyle;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;

Expand All @@ -19,10 +18,10 @@
*
* @author Marco Meschieri - LogicalDOC
* @since 9.1.1
*
*/
public class QRLightbox extends Window {
public class QRLightbox extends DelayedRedrawWindow {
private static final String QRCODE = "qrcode";

private static final int QR_SIZE = 150;

public QRLightbox(String content) {
Expand Down Expand Up @@ -70,6 +69,8 @@ public QRLightbox(String content) {
form.setTitleOrientation(TitleOrientation.LEFT);
form.setItems(qr1Item, qr2Item);
addItem(form);

delayedRedraw();
});
} else {
// We are accessing from the declared server.url so just display the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
import com.logicaldoc.gui.common.client.i18n.I18N;
import com.smartgwt.client.types.HeaderControls;
import com.smartgwt.client.widgets.HeaderControl;
import com.smartgwt.client.widgets.Window;

public abstract class StickyWindow extends Window {
/**
* A Window that remembers its dimensions
*
* @author Marco Meschieri - LogicalDOC
* @since 8.8
*/
public abstract class StickyWindow extends DelayedRedrawWindow {

/**
* The key is a class name while the value is it's descriptor
Expand Down Expand Up @@ -70,7 +75,7 @@ protected WindowStatus getWindowStatus() {
}

protected void restoreCurrentStatus() {
if(mustCenter())
if (mustCenter())
centerInPage();
WindowStatus status = getWindowStatus();
if (status != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.logicaldoc.gui.common.client.i18n.I18N;
import com.logicaldoc.gui.common.client.util.ItemFactory;
import com.logicaldoc.gui.common.client.util.Util;
import com.logicaldoc.gui.common.client.widgets.DelayedRedrawWindow;
import com.smartgwt.client.types.HeaderControls;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;

Expand All @@ -18,7 +18,7 @@
* @author Marco Meschieri - LogicalDOC
* @since 9.1.1
*/
public class PermaLinkDisplay extends Window {
public class PermaLinkDisplay extends DelayedRedrawWindow {

private static final int QR_SIZE = 100;

Expand All @@ -35,25 +35,25 @@ public PermaLinkDisplay(long docId) {
if (!urlBase.endsWith("/"))
urlBase += "/";

String downloadUrl = Util.downloadURL(docId);
String downloadUrl1 = Util.downloadURL(docId);
String downloadUrl2 = urlBase + "download?docId=" + docId;

String displayUrl = Util.displayURL(docId, null);
String displayUrl1 = Util.displayURL(docId, null);
String displayUrl2 = urlBase + "display?docId=" + docId;

ImageLoader.loadImages(new String[] { Util.qrURL(downloadUrl, QR_SIZE), Util.qrURL(downloadUrl2, QR_SIZE),
Util.qrURL(displayUrl, QR_SIZE), Util.qrURL(displayUrl2, QR_SIZE) }, imageElements -> {
StaticTextItem downloadUrlItem = prepareBarcodeAndLink("download1", "download", downloadUrl);
ImageLoader.loadImages(new String[] { Util.qrURL(downloadUrl1, QR_SIZE), Util.qrURL(downloadUrl2, QR_SIZE),
Util.qrURL(displayUrl1, QR_SIZE), Util.qrURL(displayUrl2, QR_SIZE) }, imageElements -> {
StaticTextItem downloadUrlItem = prepareBarcodeAndLink("download1", "download", downloadUrl1);
downloadUrlItem.setShowTitle(true);
StaticTextItem downloadUrlItem2 = prepareBarcodeAndLink("download2", "download", downloadUrl2);
downloadUrlItem2.setShowTitle(false);
downloadUrlItem2.setVisible(!downloadUrl.equals(downloadUrl2));
downloadUrlItem2.setVisible(!downloadUrl1.equals(downloadUrl2));

StaticTextItem displayUrlItem = prepareBarcodeAndLink("displayUrl1", "details", displayUrl);
StaticTextItem displayUrlItem = prepareBarcodeAndLink("displayUrl1", "details", displayUrl1);
displayUrlItem.setShowTitle(true);
StaticTextItem displayUrlItem2 = prepareBarcodeAndLink("displayUrl2", "details", displayUrl2);
displayUrlItem2.setShowTitle(false);
displayUrlItem2.setVisible(!displayUrl.equals(displayUrl2));
displayUrlItem2.setVisible(!displayUrl1.equals(displayUrl2));

DynamicForm form = new DynamicForm();
form.setNumCols(1);
Expand All @@ -62,6 +62,11 @@ public PermaLinkDisplay(long docId) {
form.setItems(downloadUrlItem, downloadUrlItem2, displayUrlItem, displayUrlItem2);

addItem(form);

/*
* With a timer we force the redraw
*/
delayedRedraw();
});
}

Expand Down
7 changes: 3 additions & 4 deletions logicaldoc-gui/war/header.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,19 @@ body {
let windowContent = '<!DOCTYPE html> ';
windowContent += '<html> ';
windowContent += '<head><title>' + title + '</title> ';
windowContent += '<head><title>' + title + '</title> ';
windowContent += '\u003Cstyle> ';
windowContent += '.cell, .cellDarkAltCol, .cellDark{white-space: nowrap;} ';
windowContent += '.printHeader{white-space: nowrap; font-weight: bold; border:0px solid white;} ';
windowContent += '\u003C/style> ';
windowContent += "<link REL='STYLESHEET' HREF='<%=MODULE%>/sc/skins/<%=SKIN%>/style.css' TYPE='text/css' /> ";
windowContent += "\u003Cscript type='text/javascript'> ";
windowContent += " function printPage(){document.getElementById('printPanel').style.display='none'; window.print(); window.close();} ";
windowContent += "\u003C/script> ";
windowContent += '</head> ';
windowContent += '<body> ';
windowContent += "<div id='printPanel' class='printPanel default'><ul><li><a href='javascript:printPage();' id='printButton'> ";
Expand Down

0 comments on commit 47510e6

Please sign in to comment.