views

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootStrap

func BootStrap()

BootStrap makes the necessary updates to view definitions. In particular: - sets the type of the view from the arch root. - extracts embedded views - populates the fields map from the views arch.

func LoadFromEtree

func LoadFromEtree(element *etree.Element)

LoadFromEtree reads the view given etree.Element, creates or updates the view and adds it to the view registry if it not already.

Types

type Collection

type Collection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A Collection is a view collection

var Registry *Collection

Registry is the views collection of the application

func NewCollection

func NewCollection() *Collection

NewCollection returns a pointer to a new Collection instance

func (*Collection) Add

func (vc *Collection) Add(v *View)

Add adds the given view to our Collection

func (*Collection) GetAll

func (vc *Collection) GetAll() []*View

GetAll returns a list of all views of this Collection. Views are returned in an arbitrary order

func (*Collection) GetAllViewsForModel

func (vc *Collection) GetAllViewsForModel(model string) []*View

GetAllViewsForModel returns a list with all views for the given model

func (*Collection) GetByID

func (vc *Collection) GetByID(id string) *View

GetByID returns the View with the given id

func (*Collection) GetFirstViewForModel

func (vc *Collection) GetFirstViewForModel(model string, viewType ViewType) *View

GetFirstViewForModel returns the first view of type viewType for the given model

func (*Collection) LoadFromEtree

func (vc *Collection) LoadFromEtree(element *etree.Element)

LoadFromEtree loads the given view given as Element into this collection.

type SubViews

type SubViews map[ViewType]*View

A SubViews is a holder for embedded views of a field

type TranslatableAttribute

type TranslatableAttribute struct {
	Attribute string
	Value     string
}

A TranslatableAttribute is a reference to an attribute in a XML view definition that can be translated.

type View

type View struct {
	ID       string
	Name     string
	Model    string
	Type     ViewType
	Priority uint8

	FieldParent string
	Fields      []string
	SubViews    map[string]SubViews
	// contains filtered or unexported fields
}

View is the internal definition of a view in the application

func (*View) AddOnchanges

func (v *View) AddOnchanges(fInfos map[string]*models.FieldInfo)

AddOnchanges adds onchange=1 for each field in the view which has an OnChange method defined

func (*View) Arch

func (v *View) Arch(lang string) *etree.Document

Arch returns the arch XML string of this view for the given language. Call with empty string to get the default language's arch

func (*View) SanitizeSearchView

func (v *View) SanitizeSearchView()

SanitizeSearchView adds the missing domain attribute if it does not exist

func (*View) TranslatableStrings

func (v *View) TranslatableStrings() []TranslatableAttribute

TranslatableStrings returns the list of all the strings in the view arch that must be translated.

type ViewRef

type ViewRef [2]string

ViewRef is an array of two strings representing a view: - The first one is the ID of the view - The second one is the name of the view

func MakeViewRef

func MakeViewRef(id string) ViewRef

MakeViewRef creates a ViewRef from a view id

func (ViewRef) ID

func (vr ViewRef) ID() string

ID returns the ID of the current view reference

func (ViewRef) IsNull

func (vr ViewRef) IsNull() bool

IsNull returns true if this ViewRef references no view

func (ViewRef) MarshalJSON

func (vr ViewRef) MarshalJSON() ([]byte, error)

MarshalJSON is the JSON marshalling method of ViewRef. It marshals empty ViewRef into null instead of ["", ""].

func (ViewRef) Name

func (vr ViewRef) Name() string

Name returns the name of the current view reference

func (*ViewRef) Scan

func (vr *ViewRef) Scan(src interface{}) error

Scan fetches the name of our view from the ID stored in the database to fill the ViewRef.

func (*ViewRef) UnmarshalJSON

func (vr *ViewRef) UnmarshalJSON(data []byte) error

UnmarshalJSON is the JSON unmarshalling method of ViewRef. It unmarshals null into an empty ViewRef.

func (*ViewRef) UnmarshalXMLAttr

func (vr *ViewRef) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr is the XML unmarshalling method of ViewRef. It unmarshals null into an empty ViewRef.

func (ViewRef) Value

func (vr ViewRef) Value() (driver.Value, error)

Value extracts ID of our ViewRef for storing in the database.

type ViewTuple

type ViewTuple struct {
	ID   string   `xml:"id,attr"`
	Type ViewType `xml:"type,attr"`
}

ViewTuple is an array of two strings representing a view: - The first one is the ID of the view - The second one is the view type corresponding to the view ID

func (ViewTuple) MarshalJSON

func (vt ViewTuple) MarshalJSON() ([]byte, error)

MarshalJSON is the JSON marshalling method of ViewTuple. It marshals ViewTuple into a list [id, type].

func (*ViewTuple) UnmarshalJSON

func (vt *ViewTuple) UnmarshalJSON(data []byte) error

UnmarshalJSON method for ViewTuple

type ViewType

type ViewType string

A ViewType defines the type of a view

const (
	ViewTypeTree     ViewType = "tree"
	ViewTypeList     ViewType = "list"
	ViewTypeForm     ViewType = "form"
	ViewTypeGraph    ViewType = "graph"
	ViewTypeCalendar ViewType = "calendar"
	ViewTypeDiagram  ViewType = "diagram"
	ViewTypeGantt    ViewType = "gantt"
	ViewTypeKanban   ViewType = "kanban"
	ViewTypeSearch   ViewType = "search"
	ViewTypeQWeb     ViewType = "qweb"
)

View types

type ViewXML

type ViewXML struct {
	ID          string `xml:"id,attr"`
	Name        string `xml:"name,attr"`
	Model       string `xml:"model,attr"`
	Priority    uint8  `xml:"priority,attr"`
	Arch        string `xml:",innerxml"`
	InheritID   string `xml:"inherit_id,attr"`
	FieldParent string `xml:"field_parent,attr"`
}

ViewXML is used to unmarshal the XML definition of a View

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL