Browse Source

Tiny aesthetic fixes

Dmitry Yu Okunev 5 years ago
parent
commit
61797b964e
2 changed files with 17 additions and 1 deletions
  1. 13 1
      formular.go
  2. 4 0
      person.go

+ 13 - 1
formular.go

@@ -8,6 +8,7 @@ import (
 	"github.com/revel/revel"
 	"github.com/xaionaro-go/extime"
 	"html/template"
+	"strings"
 )
 
 //reform:formular
@@ -58,6 +59,13 @@ type Formular struct {
 	//ExtraVacDays       *int    `reform:"ExtraVacDays"`
 }
 
+func (f *Formular) AfterFind() error {
+	if f.UnitShortName != nil {
+		*f.UnitShortName = strings.Trim(*f.UnitShortName, " ")
+	}
+	return nil
+}
+
 func (sql Formular) ActiveOnly() *FormularScope {
 	return sql.Scope().ActiveOnly()
 }
@@ -142,7 +150,7 @@ func (f *Formular) PrepareIsActive() *Formular {
 
 func (f Formular) IsActive() bool {
 	if !f.isActiveReady {
-		panic("formular is not ready for method IsActive: it's required to call PrepareIsReady method, first")
+		panic("formular is not ready for method IsActive: it's required to call PrepareIsActive method, first")
 	}
 	return f.isActive
 }
@@ -183,6 +191,10 @@ func (formulars Formulars) GetEmpGUIDs() (empGUIDs []int) {
 func (formulars Formulars) PreparePeople() Formulars {
 	ids := formulars.GetEmpGUIDs()
 
+	if len(ids) == 0 {
+		return formulars
+	}
+
 	people, err := PersonSQL.Select("EmpGUID IN (?)", ids)
 	if err != nil && err != sql.ErrNoRows {
 		panic(err)

+ 4 - 0
person.go

@@ -108,6 +108,10 @@ func (person Person) GetFormularsPtr() *Formulars {
 func (people People) PrepareFormulars() People {
 	ids := people.GetEmpGUIDs()
 
+	if len(ids) == 0 {
+		return people
+	}
+
 	formulars, err := FormularSQL.Select("EmpGUID IN (?)", ids)
 	if err != nil && err != sql.ErrNoRows {
 		panic(err)