Просмотр исходного кода

go fmt, added "Formulars.PrepareIsActive()"

Dmitry Yu Okunev лет назад: 6
Родитель
Сommit
1af42a3958
4 измененных файлов с 21 добавлено и 13 удалено
  1. 9 1
      formular.go
  2. 1 1
      person.go
  3. 2 2
      timesheet_row.go
  4. 9 9
      unit.go

+ 9 - 1
formular.go

@@ -158,6 +158,14 @@ func (f Formular) IsActive() bool {
 
 type Formulars []Formular
 
+func (formulars Formulars) PrepareIsActive() Formulars {
+	for idx, _ := range formulars {
+		formulars[idx].PrepareIsActive()
+	}
+
+	return formulars
+}
+
 func (formulars Formulars) ToMap() map[int]*Formular {
 	formularMap := map[int]*Formular{}
 
@@ -182,7 +190,7 @@ func (formulars Formulars) GetEmpGUIDs() (empGUIDs []int) {
 	for _, formular := range formulars {
 		empGUIDMap[formular.EmpGUID] = true
 	}
-	for empGUID, _ := range empGUIDMap {
+	for empGUID := range empGUIDMap {
 		empGUIDs = append(empGUIDs, empGUID)
 	}
 

+ 1 - 1
person.go

@@ -123,7 +123,7 @@ func (people People) PrepareFormulars() People {
 		(*personMap[formular.EmpGUID]).formulars = append((*personMap[formular.EmpGUID]).formulars, formular)
 	}
 
-	for idx, _ := range people {
+	for idx := range people {
 		people[idx].formularsReady = true
 	}
 

+ 2 - 2
timesheet_row.go

@@ -109,7 +109,7 @@ func (timesheetRows TimesheetRows) GetEmpGUIDs() (empGUIDs []int) {
 	for _, timesheetRow := range timesheetRows {
 		empGUIDMap[timesheetRow.EmpGUID] = true
 	}
-	for empGUID, _ := range empGUIDMap {
+	for empGUID := range empGUIDMap {
 		empGUIDs = append(empGUIDs, empGUID)
 	}
 
@@ -134,7 +134,7 @@ func (timesheetRows TimesheetRows) PrepareFormulars(activeOnly bool) TimesheetRo
 		panic("Not implemented, yet")
 	}
 
-	for idx, _ := range timesheetRows {
+	for idx := range timesheetRows {
 		timesheetRows[idx].formularReady = true
 	}
 

+ 9 - 9
unit.go

@@ -129,7 +129,7 @@ func (units Units) ToMap() map[int]*Unit {
 func (units Units) calculateTree(strict bool) {
 	unitMap := units.ToMap()
 
-	for idx, _ := range units {
+	for idx := range units {
 		unit := &units[idx]
 
 		if unit.ParentId == nil {
@@ -148,7 +148,7 @@ func (units Units) calculateTree(strict bool) {
 		parent.children = append(parent.children, unit)
 	}
 
-	for idx, _ := range units {
+	for idx := range units {
 		units[idx].childrenReady = true
 	}
 }
@@ -193,7 +193,7 @@ func (u *Unit) PrepareFormulars() *Unit {
 		u.formulars, err = FormularSQL.Select(Formular{UnitId: u.Id})
 	} else {
 		u.formulars, err = FormularSQL.Select(Formular{PersNumber: u.PersNumber})
-		for idx, _ := range u.formulars {
+		for idx := range u.formulars {
 			u.formulars[idx].UnitId = u.Id
 		}
 	}
@@ -239,9 +239,9 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
 	}
 
 	if len(nums) > 0 {
-		scope  = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
+		scope = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
 	} else {
-		scope  = scope.Where("OrgDiv IN (?)", ids)
+		scope = scope.Where("OrgDiv IN (?)", ids)
 	}
 
 	formulars, err := scope.Select()
@@ -262,7 +262,7 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
 		(*unitPtr).formulars = append((*unitPtr).formulars, formular)
 	}
 
-	for idx, _ := range units {
+	for idx := range units {
 		units[idx].formularsReady = true
 	}
 
@@ -319,7 +319,7 @@ func (u *Unit) prepareChildrenTree(recursive bool) *Unit {
 		panic(err)
 	}
 
-	for idx, _ := range children {
+	for idx := range children {
 		child := &children[idx]
 		if recursive {
 			child.PrepareChildrenTree()
@@ -340,14 +340,14 @@ func (u *Unit) PrepareChildren() *Unit {
 }
 
 func (units Units) PrepareChildrenTree() Units {
-	for idx, _ := range units {
+	for idx := range units {
 		units[idx].PrepareChildrenTree()
 	}
 
 	return units
 }
 func (units Units) PrepareChildren() Units {
-	for idx, _ := range units {
+	for idx := range units {
 		units[idx].PrepareChildren()
 	}