Merge pull request #413 from trheyi/main
[add] form & table loadFieSync & fix props bug
This commit is contained in:
commit
fada1277e6
5 changed files with 28 additions and 3 deletions
|
|
@ -112,7 +112,14 @@ func (cProp CloudPropsDSL) replaceAny(data interface{}, root string, replace fun
|
|||
|
||||
func (cProp CloudPropsDSL) replaceMap(data map[string]interface{}, root string, replace func(cProp CloudPropsDSL) interface{}) error {
|
||||
xpath := fmt.Sprintf(".%s.$%s", cProp.Xpath, cProp.Name)
|
||||
|
||||
// get keys
|
||||
keys := []string{}
|
||||
for key := range data {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
|
||||
for _, key := range keys {
|
||||
path := fmt.Sprintf("%s.%s", root, key)
|
||||
if !strings.HasPrefix(xpath, path) {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/yaoapp/gou/application"
|
||||
|
|
@ -51,6 +52,7 @@ import (
|
|||
|
||||
// Forms the loaded form widgets
|
||||
var Forms map[string]*DSL = map[string]*DSL{}
|
||||
var lock sync.Mutex
|
||||
|
||||
// New create a new DSL
|
||||
func New(id string) *DSL {
|
||||
|
|
@ -94,7 +96,14 @@ func Load(cfg config.Config) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// LoadFile load table dsl by file
|
||||
// LoadFileSync load form dsl by file
|
||||
func LoadFileSync(root string, file string) error {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
return LoadFile(root, file)
|
||||
}
|
||||
|
||||
// LoadFile load form dsl by file
|
||||
func LoadFile(root string, file string) error {
|
||||
|
||||
id := share.ID(root, file)
|
||||
|
|
|
|||
|
|
@ -191,5 +191,5 @@ func processLoad(process *gouProcess.Process) interface{} {
|
|||
}
|
||||
|
||||
file = strings.TrimPrefix(file, string(os.PathSeparator))
|
||||
return LoadFile("forms", file)
|
||||
return LoadFileSync("forms", file)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,5 +318,5 @@ func processLoad(process *gouProcess.Process) interface{} {
|
|||
}
|
||||
|
||||
file = strings.TrimPrefix(file, string(os.PathSeparator))
|
||||
return LoadFile("tables", file)
|
||||
return LoadFileSync("tables", file)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/yaoapp/gou/application"
|
||||
|
|
@ -81,6 +82,7 @@ import (
|
|||
|
||||
// Tables the loaded table widgets
|
||||
var Tables map[string]*DSL = map[string]*DSL{}
|
||||
var lock sync.Mutex
|
||||
|
||||
// New create a new DSL
|
||||
func New(id string) *DSL {
|
||||
|
|
@ -144,6 +146,13 @@ func LoadID(id string, root string) error {
|
|||
return fmt.Errorf("table %s not found", id)
|
||||
}
|
||||
|
||||
// LoadFileSync load table dsl by file
|
||||
func LoadFileSync(root string, file string) error {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
return LoadFile(root, file)
|
||||
}
|
||||
|
||||
// LoadFile load table dsl by file
|
||||
func LoadFile(root string, file string) error {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue