Skip to content

Commit 2ab3a22

Browse files
committed
update
1 parent 467d78d commit 2ab3a22

File tree

9 files changed

+89
-84
lines changed

9 files changed

+89
-84
lines changed

common/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func TmplDir(style string) (tmplDir string) {
158158
return
159159
}
160160

161-
// CreateUrl creates the complete url of the desired widget template
162-
func CreateUrl(widget string) string {
161+
// LookupPath creates the complete path of the desired widget template
162+
func LookupPath(widget string) string {
163163
if !FileSystem.IsEmpty() {
164164
fp, err := FileSystem.Open(widget)
165165
if err != nil {

fieldset.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"strings"
2626

2727
"github.com/coscms/forms/common"
28-
conf "github.com/coscms/forms/config"
28+
"github.com/coscms/forms/config"
2929
"github.com/coscms/forms/fields"
3030
)
3131

@@ -93,7 +93,7 @@ func (f *FieldSetType) render() string {
9393
var err error
9494
tpl, ok := common.CachedTemplate(tpf)
9595
if !ok {
96-
tpl, err = common.ParseFiles(common.CreateUrl(tpf))
96+
tpl, err = common.ParseFiles(common.LookupPath(tpf))
9797
if err != nil {
9898
return err.Error()
9999
}
@@ -123,7 +123,7 @@ func (f *FieldSetType) Lang() string {
123123
return f.Language
124124
}
125125

126-
func (f *FieldSetType) Clone() conf.FormElement {
126+
func (f *FieldSetType) Clone() config.FormElement {
127127
fc := *f
128128
return &fc
129129
}
@@ -175,7 +175,7 @@ func (f *FieldSetType) SortAll(sortList ...string) *FieldSetType {
175175
}
176176

177177
// Elements adds the provided elements to the fieldset.
178-
func (f *FieldSetType) Elements(elems ...conf.FormElement) *FieldSetType {
178+
func (f *FieldSetType) Elements(elems ...config.FormElement) *FieldSetType {
179179
for _, e := range elems {
180180
switch v := e.(type) {
181181
case fields.FieldInterface:

forms.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"strings"
3434

3535
"github.com/coscms/forms/common"
36-
conf "github.com/coscms/forms/config"
36+
"github.com/coscms/forms/config"
3737
"github.com/coscms/forms/fields"
3838
"github.com/webx-top/validation"
3939
)
@@ -44,7 +44,7 @@ const (
4444
GET = "GET"
4545
)
4646

47-
func NewWithConfig(c *conf.Config, args ...interface{}) *Form {
47+
func NewWithConfig(c *config.Config, args ...interface{}) *Form {
4848
form := New()
4949
form.Init(c, args...)
5050
return form
@@ -60,7 +60,7 @@ func NewWithConfigFile(m interface{}, configJSONFile string) *Form {
6060

6161
func New() *Form {
6262
return &Form{
63-
FieldList: []conf.FormElement{},
63+
FieldList: []config.FormElement{},
6464
FieldMap: make(map[string]int),
6565
ContainerMap: make(map[string]string),
6666
Style: common.BASE,
@@ -77,7 +77,7 @@ func New() *Form {
7777
}
7878
}
7979

80-
func NewFromModel(m interface{}, c *conf.Config) *Form {
80+
func NewFromModel(m interface{}, c *config.Config) *Form {
8181
form := NewWithConfig(c, m)
8282
form.SetModel(m)
8383
form.ParseModel(m)
@@ -90,7 +90,7 @@ type Form struct {
9090
Model interface{}
9191
IngoreValid []string
9292

93-
FieldList []conf.FormElement
93+
FieldList []config.FormElement
9494
FieldMap map[string]int
9595
ContainerMap map[string]string
9696
Style string
@@ -104,7 +104,7 @@ type Form struct {
104104
valid *validation.Validation
105105
labelFn func(string) string
106106
validTagFn func(string, fields.FieldInterface)
107-
config *conf.Config
107+
config *config.Config
108108
beforeRender []func()
109109
debug bool
110110
OmitOrMustFieldsValue map[string]bool //true:omit; false:must
@@ -192,9 +192,9 @@ func (f *Form) ValidTagFunc() func(string, fields.FieldInterface) {
192192
return f.validTagFn
193193
}
194194

195-
func (f *Form) Init(c *conf.Config, model ...interface{}) *Form {
195+
func (f *Form) Init(c *config.Config, model ...interface{}) *Form {
196196
if c == nil {
197-
c = &conf.Config{}
197+
c = &config.Config{}
198198
}
199199
f.config = c
200200
if len(c.Theme) == 0 {
@@ -209,7 +209,7 @@ func (f *Form) Init(c *conf.Config, model ...interface{}) *Form {
209209
tmpl, ok := common.CachedTemplate(tpf)
210210
if !ok {
211211
var err error
212-
tmpl, err = common.ParseFiles(common.CreateUrl(c.Template))
212+
tmpl, err = common.ParseFiles(common.LookupPath(c.Template))
213213
if err != nil {
214214
log.Println(err)
215215
}
@@ -304,7 +304,7 @@ func (f *Form) ParseModel(model ...interface{}) *Form {
304304
}
305305
flist, fsort := f.unWindStructure(m, ``)
306306
for _, v := range flist {
307-
f.Elements(v.(conf.FormElement))
307+
f.Elements(v.(config.FormElement))
308308
}
309309
if len(fsort) > 0 {
310310
f.Sort(fsort)
@@ -613,7 +613,7 @@ func (f *Form) String() string {
613613
}
614614

615615
// Elements adds the provided elements to the form.
616-
func (f *Form) Elements(elems ...conf.FormElement) {
616+
func (f *Form) Elements(elems ...config.FormElement) {
617617
for _, e := range elems {
618618
switch v := e.(type) {
619619
case fields.FieldInterface:
@@ -739,7 +739,7 @@ func (f *Form) Field(name string) fields.FieldInterface {
739739
}
740740

741741
// Fields returns all field
742-
func (f *Form) Fields() []conf.FormElement {
742+
func (f *Form) Fields() []config.FormElement {
743743
return f.FieldList
744744
}
745745

@@ -757,7 +757,7 @@ func (f *Form) LangSet(name string) *LangSetType {
757757
}
758758
}
759759

760-
func (f *Form) NewLangSet(name string, langs []*conf.Language) *LangSetType {
760+
func (f *Form) NewLangSet(name string, langs []*config.Language) *LangSetType {
761761
return LangSet(name, f.Style, langs...)
762762
}
763763

@@ -785,7 +785,7 @@ func (f *Form) NewFieldSet(name string, label string, elems ...fields.FieldInter
785785
func (f *Form) SortAll(sortList ...string) *Form {
786786
elem := f.FieldList
787787
size := len(elem)
788-
f.FieldList = make([]conf.FormElement, size)
788+
f.FieldList = make([]config.FormElement, size)
789789
var sortSlice []string
790790
if len(sortList) == 1 {
791791
sortSlice = strings.Split(sortList[0], ",")
@@ -857,8 +857,8 @@ func (f *Form) Sort2Last(fieldsName ...string) *Form {
857857

858858
func (f *Form) sortFields(index, oldIndex, endIdx, size int) {
859859

860-
var newFields []conf.FormElement
861-
oldFields := make([]conf.FormElement, size)
860+
var newFields []config.FormElement
861+
oldFields := make([]config.FormElement, size)
862862
copy(oldFields, f.FieldList)
863863
var min, max int
864864
if index > oldIndex {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/francoispqt/gojay v1.2.13 // indirect
77
github.com/goccy/go-json v0.5.1 // indirect
88
github.com/json-iterator/go v1.1.11 // indirect
9-
github.com/stretchr/testify v1.7.0 // indirect
9+
github.com/stretchr/testify v1.7.0
1010
github.com/webx-top/com v0.2.0
1111
github.com/webx-top/tagfast v0.0.0-20161020041435-9a2065ce3dd2
1212
github.com/webx-top/validation v0.0.1

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE
172172
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
173173
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
174174
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
175+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
175176
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
176177
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
177178
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)