[GB.WEB.FORM]

* NEW: WebForm.Download() is a new static method that triggers a file download on the client side.
* BUG: WebTextBox: The default event is "Change" now.
* BUG: Allows quotes in automatic completion items.


git-svn-id: svn://localhost/gambas/trunk@7935 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2016-10-25 02:37:16 +00:00
parent 8b09edbe72
commit a39a89c6f1
9 changed files with 72 additions and 14 deletions

View file

@ -1,6 +1,6 @@
[Component] [Component]
Key=gb.web.form Key=gb.web.form
Version=3.8.90 Version=3.9.90
State=1 State=1
Authors=Benoît Minisini Authors=Benoît Minisini
Requires=gb.web,gb.util.web,gb.util Requires=gb.web,gb.util.web,gb.util

View file

@ -1059,6 +1059,10 @@ HandleRequest
M M
_init
M
Main Main
M M
@ -1159,6 +1163,10 @@ AddJavascriptFile
m m
(sFile)s (sFile)s
Download
M
(Path)s[(ContentType)s(Remove)b]
#WebHBox #WebHBox
WebContainer WebContainer
C C
@ -1834,6 +1842,10 @@ _DefaultSize
C C
s s
"24,4" "24,4"
_DefaultEvent
C
s
"Change"
:Change :Change
: :

View file

@ -2,6 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: gb.web.form 3.8.90\n" "Project-Id-Version: gb.web.form 3.8.90\n"
"POT-Creation-Date: 2016-10-25 02:03 UTC\n"
"PO-Revision-Date: 2016-06-25 00:29 UTC\n" "PO-Revision-Date: 2016-06-25 00:29 UTC\n"
"Last-Translator: Benoît Minisini <gambas@users.sourceforge.net>\n" "Last-Translator: Benoît Minisini <gambas@users.sourceforge.net>\n"
"Language: fr\n" "Language: fr\n"
@ -18,7 +19,10 @@ msgid "This is a very important message"
msgstr "" msgstr ""
#: FHello.webform:18 #: FHello.webform:18
msgid "<h1>Welcome to the <tt>gb.web.form</tt> component!</h1>\n<p>This component aims at making web application as easy as making desktop applications.</p>\n<p>This goal is difficult to achieve, but I hope to succeed!</p>" msgid ""
"<h1>Welcome to the <tt>gb.web.form</tt> component!</h1>\n"
"<p>This component aims at making web application as easy as making desktop applications.</p>\n"
"<p>This goal is difficult to achieve, but I hope to succeed!</p>"
msgstr "" msgstr ""
#: FHello.webform:34 FMessage.webform:50 #: FHello.webform:34 FMessage.webform:50
@ -260,4 +264,3 @@ msgstr ""
#: Webform6.webform:24 #: Webform6.webform:24
msgid "Logout" msgid "Logout"
msgstr "" msgstr ""

View file

@ -1,8 +1,8 @@
# Gambas Project File 3.0 # Gambas Project File 3.0
# Compiled with Gambas 3.8.90 # Compiled with Gambas 3.9.90
Startup=Webform6 Startup=Webform6
UseHttpServer=1 UseHttpServer=1
Version=3.8.90 Version=3.9.90
VersionFile=1 VersionFile=1
Component=gb.util Component=gb.util
Component=gb.util.web Component=gb.util.web

View file

@ -20,6 +20,8 @@ Static Private $aJavascript As New String[]
Static Private $aRefresh As New String[] Static Private $aRefresh As New String[]
Static Private $cLibrary As New Collection Static Private $cLibrary As New Collection
Static Private $iDownload As Integer
'Static Private $aPreload As String[] 'Static Private $aPreload As String[]
Event Open Event Open
@ -55,6 +57,13 @@ Static Public Sub HandleRequest()
End End
Static Public Sub _init()
System.Language = Request.Language
End
Static Public Sub Main() Static Public Sub Main()
Dim sPath As String Dim sPath As String
@ -70,8 +79,6 @@ Static Public Sub Main()
Me.HandleRequest Me.HandleRequest
If Response.Done Then Return If Response.Done Then Return
System.Language = Request.Language
sPath = Mid$(Request.Path, 2) sPath = Mid$(Request.Path, 2)
If Not sPath Then If Not sPath Then
@ -99,6 +106,11 @@ Static Public Sub Main()
If Not Error Then Response.SendFile(sPath) If Not Error Then Response.SendFile(sPath)
Return Return
Else If sPath Begins "download:" Then
If DownloadFile(Mid$(sPath, 10)) Then Goto NOT_FOUND
Return
Else If sPath = "~dump" Then Else If sPath = "~dump" Then
If Session.Id Then If Session.Id Then
@ -725,3 +737,35 @@ Public Sub AddJavascriptFile(sFile As String)
$aJavascriptFiles.Add(sFile) $aJavascriptFiles.Add(sFile)
End End
Static Public Sub Download(Path As String, Optional ContentType As String, Optional Remove As Boolean)
Dim cDownload As Collection
'' TODO: Move file to /tmp/gambas.XXXX/download if it is a temp file
cDownload = Session["download"]
If Not cDownload Then cDownload = New Collection
Inc $iDownload
cDownload[$iDownload] = [Path, ContentType, Remove]
Session["download"] = cDownload
_AddJavascript("window.open(" & JS("/" &/ Application.Root &/ "download:" & CStr($iDownload) &/ File.Name(Path)) & ", '_blank');")
End
Static Private Sub DownloadFile(sKey As String) As Boolean
Dim aDownload As String[]
Dim iPos As Integer
iPos = InStr(sKey, "/")
If iPos Then sKey = Left(sKey, iPos - 1)
Try aDownload = Session["download"][sKey]
If Error Then Return True
Response.AddHeader("Content-Disposition", "attachment")
Response.SendFile(aDownload[0], aDownload[1])
If aDownload[2] Then Try Kill aDownload[0]
End

View file

@ -6,6 +6,7 @@ Inherits WebControl
Public Const _Properties As String = "*,Border=True,ReadOnly,PlaceHolder,Text" Public Const _Properties As String = "*,Border=True,ReadOnly,PlaceHolder,Text"
Public Const _DrawWith As String = "TextBox" Public Const _DrawWith As String = "TextBox"
Public Const _DefaultSize As String = "24,4" Public Const _DefaultSize As String = "24,4"
Public Const _DefaultEvent As String = "Change"
Event Change Event Change
Event Completion(Text As String) Event Completion(Text As String)

View file

@ -2,7 +2,7 @@ Webform6
0 0
0 0
3.8.90 3.9.90
gb.util gb.util
gb.util.web gb.util.web

View file

@ -41,7 +41,7 @@ var AutoComplete = (function(){
// escape special characters // escape special characters
search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
return '<div class="gw-ac-suggestion" data-val="' + item + '">' + item.replace(re, "<b>$1</b>") + '</div>'; return '<div class="gw-ac-suggestion" data-val="' + item.replace(/"/g, '&quot;') + '">' + item.replace(re, "<b>$1</b>") + '</div>';
}, },
onSelect: function(e, term, item){} onSelect: function(e, term, item){}
}; };

View file

@ -1095,11 +1095,6 @@ gw = {
new AutoComplete({ new AutoComplete({
selector: $(id), selector: $(id),
cache: false, cache: false,
/*source: function(term, response)
{
gw.raise(id, 'completion', [term]);
response($(id).gw_completion);
}*/
source: function(term, response) { source: function(term, response) {
var xhr = $(id).gw_xhr; var xhr = $(id).gw_xhr;
if (xhr) if (xhr)
@ -1119,6 +1114,9 @@ gw = {
} }
}; };
xhr.send(); xhr.send();
},
onSelect: function(e, term, item) {
gw.update(id, 'text', $(id).value);
} }
}); });
}, },