Commit b96b6980 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Continue WebTree implementation. Replace 'ShowHeader' and 'ShowRowNumber' by a...

Continue WebTree implementation. Replace 'ShowHeader' and 'ShowRowNumber' by a 'Header' property in WebTable.

[GB.WEB.GUI]
* NEW: WebTable: Replace the 'ShowHeader' and 'ShowRowNumber' properties by a 'Header' property.
* NEW: WebTable: Draw the vertical header the same way as the horizontal header, and make it sticky.
* NEW: WebTable: Replace the 'DblClick' event by the 'Activate' event.
* NEW: WebTree: Implement the 'Activate' event.
* BUG: WebTree: The "select all" checkbox now works as expected.
*
parent 423b02fc
Pipeline #364405519 passed with stage
in 26 minutes and 13 seconds
......@@ -3,15 +3,17 @@
Export
Inherits WebControl
Public Const _Properties As String = "*,Border=True,Mode{Select.*}=None,ShowCheck=True,ShowHeader=True,ShowRowNumber,Sortable"
Public Const _Properties As String = "*,Border=True,Mode{Select.*}=None,ShowCheck=True,Header{WebTable.None;Horizontal;Vertical;Both}=Horizontal,ShowRow,Sortable"
Public Const _Group As String = "View"
Public Const _DrawWith As String = "GridView"
Public Const _DefaultSize As String = "24,24"
Public Const _DefaultEvent As String = "Data"
Public Enum None, Horizontal, Vertical, Both
Event Data(Row As Integer, Column As Integer, Data As WebTableData)
Event Select
Event DblClick
Event Activate
Event Sort
Property Read Columns As _WebTableColumns
......@@ -25,8 +27,8 @@ Property Step As Integer
Property ScrollX As Integer
Property ScrollY As Integer
Property ShowCheck As Boolean
Property Header As Integer
Property ShowHeader As Boolean
Property ShowRowNumber As Boolean
Property Sortable As Boolean
Property SortColumn As Integer
Property SortOrder As Integer
......@@ -44,12 +46,11 @@ Private $iScrollX As Integer
Private $iScrollY As Integer
Private $bNoScrolling As Boolean
Private $bNoCheck As Boolean
Private $bNoHeader As Boolean
Private $iEnsureVisible As Integer = -1
Private $bSortable As Boolean
Private $iSortColumn As Integer = -1
Private $bSortDescent As Boolean
Private $bShowRowNumber As Boolean
Private $iHeader As Integer = Horizontal
Public Sub _new()
......@@ -72,8 +73,11 @@ Private Sub PrintRow(iRow As Integer)
Dim hData As WebTableData
Dim sStyle As String
Dim NX As Integer
Dim bNoHeader As Boolean
bNoHeader = ($iHeader And Horizontal) = 0
If $bShowRowNumber Then
If $iHeader And Vertical Then
Print "<td class=\"gw-table-index\">"; iRow + 1; "</td>";
Endif
......@@ -94,7 +98,7 @@ Private Sub PrintRow(iRow As Integer)
Print "</td>";
Endif
If $bNoHeader Then
If bNoHeader Then
For iCol = 0 To $hColumns.Count - 1
If $hColumns[iCol].Expand Then Inc NX
Next
......@@ -111,7 +115,7 @@ Private Sub PrintRow(iRow As Integer)
Print "<td";
hCol._PrintAlignment()
sStyle = ""
If $bNoHeader And If iRow = 0 Then
If bNoHeader And If iRow = 0 Then
If hCol.Expand Then
Print " width=\""; 100 \ NX; "%\"";
Else If hCol.Width Then
......@@ -156,7 +160,7 @@ Private Sub PrintBody(iStart As Integer, iEnd As Integer)
If $iMode <> Select.Single Then Print ",event";
Print ");\"";
Print Me._GetEventJS("ondblclick", "DblClick");
Print Me._GetEventJS("ondblclick", "Activate");
Endif
Print ">";
......@@ -186,7 +190,7 @@ Public Sub _Render()
Print "<table id=\""; Me.Name; ":table\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">"
'Endif
If Not $bNoHeader Then $hColumns._Render()
If $iHeader And Horizontal Then $hColumns._Render()
If $iDisplay < 0 Then
iCount = $iCount
......@@ -532,14 +536,14 @@ End
Private Function ShowHeader_Read() As Boolean
Return Not $bNoHeader
Return $iHeader <> 0
End
Private Sub ShowHeader_Write(Value As Boolean)
$bNoHeader = Not Value
Me.Refresh
If Value = ShowHeader_Read() Then Return
Header_Write(Horizontal)
End
......@@ -615,16 +619,18 @@ Private Sub SortOrder_Write(Value As Integer)
End
Private Function ShowRowNumber_Read() As Boolean
Return $bShowRowNumber
Private Function Header_Read() As Integer
Return $iHeader
End
Private Sub ShowRowNumber_Write(Value As Boolean)
Private Sub Header_Write(Value As Integer)
If $bShowRowNumber = Value Then Return
$bShowRowNumber = Value
Value = Value And 3
If $iHeader = Value Then Return
$iHeader = Value
Me.Refresh
End
......@@ -56,15 +56,15 @@ Public Sub _Render()
Print "<thead><tr>";
If hTable.ShowRowNumber Then Print "<th></th>";
If hTable.Header And WebTable.Vertical Then Print "<th class=\"gw-table-index\"></th>";
iMode = hTable.Mode
If iMode And If hTable.ShowCheck Then
If iMode = Select.Multiple Then
Print "<th class=\"gw-table-check\">";
Print "<input type=\"checkbox\"";
Print GetTable()._GetUpdateJS("onchange", "!!", "this.checked");
If GetTable()._IsEverythingSelected() Then Print " checked";
Print hTable._GetUpdateJS("onchange", "!!", "this.checked");
If hTable._IsEverythingSelected() Then Print " checked";
Print "></th>"
Else
Print "<th></th>"
......
......@@ -256,3 +256,9 @@ Public Sub WebSpinBox1_Change()
lblSpinBox.Text = "-> " & CStr(WebSpinBox1.Value)
End
Public Sub WebTree1_Activate()
Message(WebTree1.Item.Text)
End
......@@ -149,7 +149,7 @@
#MoveScaled(1,15,133.75,40)
Expand = True
Mode = Select.Multiple
ShowRowNumber = True
Header = WebTable.Both
Sortable = True
}
Index = 1
......@@ -218,13 +218,13 @@
{ WebTree1 WebTree
#MoveScaled(1,1,133.75,49)
Expand = True
ShowCheck = True
ShowHeader = True
}
Index = 0
}
{ WebTimer1 WebTimer
#MoveScaled(65,75)
Enabled = True
}
{ WebAudio1 WebAudio
#MoveScaled(78,77)
......
......@@ -200,7 +200,6 @@ End
Public Sub Remove((Key) As String)
Dim iRow As Integer
Dim hItem As _WebTreeItem
'If $hRenameBox Then Cancel()
......@@ -211,17 +210,7 @@ Public Sub Remove((Key) As String)
If Not hItem Then Error.Raise("Unknown item: " & Key)
_SaveSelection
iRow = _ItemToRow(hItem)
RemoveRec(Key)
_AddCount(0)
'If iRow >= 0 Then UpdateRowHeight(Null, iRow, -1)
_RestoreSelection
_RefreshView
End
......@@ -745,22 +734,23 @@ End
Public Sub SelectAll()
If $iMode <> Select.Multiple Then Return
$hSelection.SelectAll()
If $hSelection.SelectAll() Then Return
Raise Select
Me.Refresh
End
Public Sub UnselectAll()
If $iMode = Select.Multiple Then
$hSelection.UnSelectAll()
If $hSelection.UnSelectAll() Then Return
Raise Select
Else If $iMode = Select.Single Then
If $sKey Then
$sKey = ""
Raise Select
Endif
If Not $sKey Then Return
$sKey = ""
Raise Select
Endif
Me.Refresh
End
......@@ -1174,7 +1164,7 @@ Private Sub PrintItem(hItem As _WebTreeItem, iLevel As Integer, bVisible As Bool
If $iMode <> Select.Single Then Print ",event";
Print ");\"";
Print Me._GetEventJS("ondblclick", "DblClick");
Print Me._GetUpdateJS("ondblclick", "%" & JS(sKeyBase64));
Endif
If Not bVisible Then Print " style=\"display:none;\"";
......@@ -1198,17 +1188,17 @@ Private Sub PrintItem(hItem As _WebTreeItem, iLevel As Integer, bVisible As Bool
'Print "<td onmousedown=\"gw.table.check("; JS(Me.Name); ","; CStr(iRow);
'If $iMode <> Select.Single Then Print ",event";
'Print ")\">";
Print "<div class=\"gw-tree-check\">";
'Print "<div class=\"gw-tree-check\">";
If $iMode = Select.Single Then
Print "<input type=\"radio\" name=\""; Me.Name; "\"";
Else
Print "<input type=\"checkbox\"";
Endif
Print " id=\""; Me.Name & ":" & Base64(sKey); "\"";
Print " id=\""; Me.Name & ":" & Base64(sKey); "\" class=\"gw-tree-check\"";
'Print Me._GetUpdateJS("onchange", "!" & CStr(iRow), "this.checked");
If _IsSelected(sKey) Then Print " checked";
Print ">";
Print "</div>";
'Print "</div>";
Endif
If hItem.Image Then
......@@ -1306,6 +1296,7 @@ Public Sub _UpdateProperty(sProp As String, vValue As Variant)
Dim aProp As String[]
Dim hItem As _WebTreeItem
Dim sKey As String
Dim sCursor As String
If sProp Begins "^" Then
......@@ -1341,6 +1332,13 @@ Public Sub _UpdateProperty(sProp As String, vValue As Variant)
_SetSelected(sKey, True)
Endif
Dec Me._NoRefresh
Else If sProp Begins "%" Then
sCursor = $sCursor
$sCursor = FromBase64(Mid$(sProp, 2))
Raise Activate
$sCursor = sCursor
Else If sProp = "#scroll" Then
......
......@@ -31,22 +31,6 @@ Private Sub GetParent() As WebTree
End
Public Sub Select(iStart As Integer, Optional iLength As Integer = 1)
Dim hParent As WebTree = GetParent()
Dim I As Integer
Dim hItem As _WebTreeItem
For I = iStart To iStart + iLength - 1
hItem = hParent._RowToItem(I)
If Not hItem Then Break
Keys[hItem.Key] = True
Next
End
Public Sub SelectItem(sKey As String, bSelected As Boolean)
If bSelected Then
......@@ -57,33 +41,19 @@ Public Sub SelectItem(sKey As String, bSelected As Boolean)
End
Public Sub UnSelect(iStart As Integer, Optional iLength As Integer = 1)
Dim hParent As WebTree = GetParent()
Dim I As Integer
Dim hItem As _WebTreeItem
For I = iStart To iStart + iLength - 1
hItem = hParent._RowToItem(I)
If Not hItem Then Break
Keys.Remove(hItem.Key)
Next
End
Public Sub UnSelectAll()
Public Sub UnSelectAll() As Boolean
If Keys.Count = 0 Then Return True
Keys.Clear
'Dump
End
Public Sub SelectAll()
Public Sub SelectAll() As Boolean
Dim sKey As String
If IsEverythingSelected() Then Return True
Keys.Clear
For Each sKey In GetParent().Keys
Keys[sKey] = True
......
......@@ -74,24 +74,26 @@ Public Sub _Render()
If sStyle Then Print " style=\""; sStyle; "\"";
Print ">";
If I = 0 And If iMode And If hTree.ShowCheck Then
If iMode = Select.Multiple Then
Print "<input type=\"checkbox\"";
If I = 0 Then
If iMode = Select.Multiple And If hTree.ShowCheck Then
Print "<input class=\"gw-tree-check\" type=\"checkbox\"";
Print hTree._GetUpdateJS("onchange", "!!", "this.checked");
If hTree._IsEverythingSelected() Then Print " checked";
Print ">";
Endif
Print "<div class=\"gw-tree-header\">"; Html(hCol.Text); "</div>";
Else
If hCol.Text Then
Print "<div";
hCol._PrintAlignment()
Print ">";
Print Html(hCol.Text);
Print "</div>";
Else
Print "&nbsp;";
Endif
Endif
If hCol.Text Then
Print "<div";
hCol._PrintAlignment()
Print ">";
Print Html(hCol.Text);
Print "</div>";
Else
Print "&nbsp;";
Endif
Print "</th>"
Next
......
......@@ -695,9 +695,19 @@ P:first-child,UL:first-child,OL:first-child {
.gw-table-index {
text-align: right;
border-right: solid 1px #F0F0F0;
border-right: solid 1px #C0C0C0;
font-size: smaller;
font-weight: bold;
background-color: #E0E0E0;
padding: 0.25em 0.5em;
position: sticky;
left: 0;
z-index: 1;
box-sizing: border-box;
}
TH.gw-table-index {
z-index: 2 !important;
}
/*.gw-table > DIV > TABLE > TBODY > TR > TD:last-child {
......@@ -985,6 +995,12 @@ TABLE.gw-calendar > TBODY > TR > TD.gw-date-current {
.gw-tree-item {
position: relative;
display: flex;
align-items: center;
}
.gw-tree-header {
display: inline;
vertical-align: top;
}
.gw-tree-arrow {
......@@ -1026,11 +1042,6 @@ TABLE.gw-calendar > TBODY > TR > TD.gw-date-current {
box-sizing: border-box;
}
TH.gw-tree-check {
padding: 0 0.5em;
vertical-align: middle;
}
.gw-tree > DIV > TABLE > THEAD > TR > TH:last-child {
border-right: none;
}
......@@ -1049,3 +1060,8 @@ TD.gw-table-check {
.gw-tree > DIV > TABLE > TBODY > TR:hover {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAFUlEQVQYlWNkYGDgYcADmPBJDh8FABV4ABwe4TuyAAAAAElFTkSuQmCC');
}
.gw-tree-check {
margin: 0;
margin-right: 0.25em;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment