mirror of https://github.com/anoshenko/rui.git
Bug fixing
This commit is contained in:
parent
f239af2324
commit
7ac196c549
|
@ -1,3 +1,6 @@
|
||||||
|
# v0.18.0
|
||||||
|
Added SetParams method to View interface
|
||||||
|
|
||||||
# v0.17.0
|
# v0.17.0
|
||||||
* Added "mod", "rem", "round", "round-up", "round-down", and "round-to-zero" SizeFunc functions
|
* Added "mod", "rem", "round", "round-up", "round-down", and "round-to-zero" SizeFunc functions
|
||||||
* Added ModSize, RemSize, RoundSize, RoundUpSize, RoundDownSize, and RoundToZeroSize functions
|
* Added ModSize, RemSize, RoundSize, RoundUpSize, RoundDownSize, and RoundToZeroSize functions
|
||||||
|
|
|
@ -251,22 +251,22 @@ function activateTab(layoutId, tabNumber) {
|
||||||
if (element) {
|
if (element) {
|
||||||
const currentNumber = element.getAttribute("data-current");
|
const currentNumber = element.getAttribute("data-current");
|
||||||
if (currentNumber != tabNumber) {
|
if (currentNumber != tabNumber) {
|
||||||
function setTab(number, styleProperty, display) {
|
function setTab(number, styleProperty, visibility) {
|
||||||
const tab = document.getElementById(layoutId + '-' + number);
|
const tab = document.getElementById(layoutId + '-' + number);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
tab.className = element.getAttribute(styleProperty);
|
tab.className = element.getAttribute(styleProperty);
|
||||||
const page = document.getElementById(tab.getAttribute("data-view"));
|
const page = document.getElementById(tab.getAttribute("data-view"));
|
||||||
if (page) {
|
if (page) {
|
||||||
page.style.display = display;
|
page.style.visibility = visibility
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const page = document.getElementById(layoutId + "-page" + number);
|
const page = document.getElementById(layoutId + "-page" + number);
|
||||||
if (page) {
|
if (page) {
|
||||||
page.style.display = display;
|
page.style.visibility = visibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTab(currentNumber, "data-inactiveTabStyle", "none")
|
setTab(currentNumber, "data-inactiveTabStyle", "hidden")
|
||||||
setTab(tabNumber, "data-activeTabStyle", "");
|
setTab(tabNumber, "data-activeTabStyle", "");
|
||||||
element.setAttribute("data-current", tabNumber);
|
element.setAttribute("data-current", tabNumber);
|
||||||
scanElementsSize()
|
scanElementsSize()
|
||||||
|
|
|
@ -83,6 +83,10 @@ func (customView *CustomViewData) SetAnimated(tag string, value any, animation A
|
||||||
return customView.superView.SetAnimated(tag, value, animation)
|
return customView.superView.SetAnimated(tag, value, animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (customView *CustomViewData) SetParams(params Params) bool {
|
||||||
|
return customView.superView.SetParams(params)
|
||||||
|
}
|
||||||
|
|
||||||
// SetChangeListener set the function to track the change of the View property
|
// SetChangeListener set the function to track the change of the View property
|
||||||
func (customView *CustomViewData) SetChangeListener(tag string, listener func(View, string)) {
|
func (customView *CustomViewData) SetChangeListener(tag string, listener func(View, string)) {
|
||||||
customView.superView.SetChangeListener(tag, listener)
|
customView.superView.SetChangeListener(tag, listener)
|
||||||
|
|
|
@ -38,8 +38,8 @@ const (
|
||||||
// TabCloseButton is the constant for "tab-close-button" property tag.
|
// TabCloseButton is the constant for "tab-close-button" property tag.
|
||||||
//
|
//
|
||||||
// Used by `TabsLayout`.
|
// Used by `TabsLayout`.
|
||||||
// Controls whether to add close button to a tab(s). This property can be set separately for each child view or for tabs
|
// Controls whether to add close button to a tab(s). This property can be set separately for each child view or for tabs
|
||||||
// layout itself. Property set for child view takes precedence over the value set for tabs layout. Default value is
|
// layout itself. Property set for child view takes precedence over the value set for tabs layout. Default value is
|
||||||
// `false`.
|
// `false`.
|
||||||
//
|
//
|
||||||
// Supported types: `bool`, `int`, `string`.
|
// Supported types: `bool`, `int`, `string`.
|
||||||
|
@ -103,7 +103,7 @@ const (
|
||||||
// CurrentTabStyle is the constant for "current-tab-style" property tag.
|
// CurrentTabStyle is the constant for "current-tab-style" property tag.
|
||||||
//
|
//
|
||||||
// Used by `TabsLayout`.
|
// Used by `TabsLayout`.
|
||||||
// Set the style for the display of the current(selected) tab. The default value is "ruiCurrentTab" or
|
// Set the style for the display of the current(selected) tab. The default value is "ruiCurrentTab" or
|
||||||
// "ruiCurrentVerticalTab".
|
// "ruiCurrentVerticalTab".
|
||||||
//
|
//
|
||||||
// Supported types: `string`.
|
// Supported types: `string`.
|
||||||
|
@ -925,24 +925,24 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde
|
||||||
buffer.WriteString(`-page`)
|
buffer.WriteString(`-page`)
|
||||||
buffer.WriteString(strconv.Itoa(n))
|
buffer.WriteString(strconv.Itoa(n))
|
||||||
|
|
||||||
|
if current != n {
|
||||||
|
buffer.WriteString(`" style="display: grid; align-items: stretch; justify-items: stretch; visibility: hidden; `)
|
||||||
|
} else {
|
||||||
|
buffer.WriteString(`" style="display: grid; align-items: stretch; justify-items: stretch; `)
|
||||||
|
}
|
||||||
|
|
||||||
switch location {
|
switch location {
|
||||||
case LeftTabs, LeftListTabs:
|
case LeftTabs, LeftListTabs:
|
||||||
buffer.WriteString(`" style="position: relative; grid-row-start: 1; grid-row-end: 2; grid-column-start: 2; grid-column-end: 3;`)
|
buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 2; grid-column-end: 3;">`)
|
||||||
|
|
||||||
case TopTabs:
|
case TopTabs:
|
||||||
buffer.WriteString(`" style="position: relative; grid-row-start: 2; grid-row-end: 3; grid-column-start: 1; grid-column-end: 2;`)
|
buffer.WriteString(`grid-row-start: 2; grid-row-end: 3; grid-column-start: 1; grid-column-end: 2;">`)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
buffer.WriteString(`" style="position: relative; grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;`)
|
buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;">`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if current != n {
|
viewHTML(view, buffer)
|
||||||
buffer.WriteString(` display: none;`)
|
|
||||||
}
|
|
||||||
buffer.WriteString(`">`)
|
|
||||||
|
|
||||||
view.addToCSSStyle(map[string]string{`position`: `absolute`, `left`: `0`, `right`: `0`, `top`: `0`, `bottom`: `0`})
|
|
||||||
viewHTML(tabsLayout.views[n], buffer)
|
|
||||||
buffer.WriteString(`</div>`)
|
buffer.WriteString(`</div>`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
view.go
23
view.go
|
@ -54,6 +54,11 @@ type View interface {
|
||||||
// Scroll returns the location size of the scrollable view in pixels
|
// Scroll returns the location size of the scrollable view in pixels
|
||||||
Scroll() Frame
|
Scroll() Frame
|
||||||
|
|
||||||
|
// SetParams sets properties with name "tag" of the "rootView" subview. Result:
|
||||||
|
// * true - all properties were set successful,
|
||||||
|
// * false - error (incompatible type or invalid format of a string value, see AppLog).
|
||||||
|
SetParams(params Params) bool
|
||||||
|
|
||||||
// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
|
// SetAnimated sets the value (second argument) of the property with name defined by the first argument.
|
||||||
// Return "true" if the value has been set, in the opposite case "false" are returned and
|
// Return "true" if the value has been set, in the opposite case "false" are returned and
|
||||||
// a description of the error is written to the log
|
// a description of the error is written to the log
|
||||||
|
@ -423,6 +428,24 @@ func (view *viewData) set(tag string, value any) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (view *viewData) SetParams(params Params) bool {
|
||||||
|
if params == nil {
|
||||||
|
errorLog("Argument of function SetParams is nil")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
session := view.Session()
|
||||||
|
session.startUpdateScript(view.htmlID())
|
||||||
|
result := true
|
||||||
|
for _, tag := range params.AllTags() {
|
||||||
|
if value, ok := params[tag]; ok {
|
||||||
|
result = view.Set(tag, value) && result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.finishUpdateScript(view.htmlID())
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func viewPropertyChanged(view *viewData, tag string) {
|
func viewPropertyChanged(view *viewData, tag string) {
|
||||||
if view.updateTransformProperty(tag) {
|
if view.updateTransformProperty(tag) {
|
||||||
return
|
return
|
||||||
|
|
10
viewUtils.go
10
viewUtils.go
|
@ -57,9 +57,15 @@ func SetParams(rootView View, viewID string, params Params) bool {
|
||||||
session := rootView.Session()
|
session := rootView.Session()
|
||||||
session.startUpdateScript(rootView.htmlID())
|
session.startUpdateScript(rootView.htmlID())
|
||||||
result := true
|
result := true
|
||||||
for tag, value := range params {
|
//for tag, value := range params {
|
||||||
result = rootView.Set(tag, value) && result
|
// result = rootView.Set(tag, value) && result
|
||||||
|
//}
|
||||||
|
for _, tag := range params.AllTags() {
|
||||||
|
if value, ok := params[tag]; ok {
|
||||||
|
result = rootView.Set(tag, value) && result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.finishUpdateScript(rootView.htmlID())
|
session.finishUpdateScript(rootView.htmlID())
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue