@@ -3,6 +3,7 @@ package main
33import (
44 "database/sql"
55 "edm/pkg/accs"
6+ "edm/pkg/memdb"
67 "encoding/json"
78 "fmt"
89 "log"
@@ -265,7 +266,7 @@ type CompanyPage struct {
265266 Message string
266267 Editable bool
267268 New bool
268- UserList []UserListElem
269+ UserList []memdb. ObjHasID
269270}
270271
271272func (bs * BaseStruct ) companyHandler (w http.ResponseWriter , r * http.Request ) {
@@ -290,7 +291,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
290291 New : false ,
291292 }
292293
293- user := bs .team .getByID (Page .LoggedinID )
294+ user := unmarshalToProfile ( bs .team .GetByID (Page .LoggedinID ) )
294295 Page .UserConfig = user .UserConfig
295296 if user .UserRole == 1 {
296297 Page .Editable = true
@@ -333,7 +334,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
333334 if r .FormValue ("createButton" ) != "" {
334335 c .ID , created = c .create (bs .db , bs .dbt )
335336 if created > 0 {
336- bs . team . constructCorpList (bs .db , bs .dbt )
337+ constructCorpList (bs .db , bs .dbt , bs . team )
337338 if Page .UserConfig .ReturnAfterCreation {
338339 http .Redirect (w , r , "/companies/" , http .StatusSeeOther )
339340 } else {
@@ -348,8 +349,8 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
348349 if r .FormValue ("updateButton" ) != "" {
349350 updated = c .update (bs .db , bs .dbt )
350351 if updated > 0 {
351- bs . team . constructCorpList (bs .db , bs .dbt )
352- bs . team . constructUnitList (bs .db , bs .dbt )
352+ constructCorpList (bs .db , bs .dbt , bs . team )
353+ constructUnitList (bs .db , bs .dbt , bs . team )
353354 Page .Message = "dataWritten"
354355 } else {
355356 Page .Message = "dataNotWritten"
@@ -382,7 +383,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
382383 unitaff = u .update (bs .db , bs .dbt )
383384 }
384385 if unitaff > 0 {
385- bs . team . constructUnitList (bs .db , bs .dbt )
386+ constructUnitList (bs .db , bs .dbt , bs . team )
386387 Page .Message = "dataWritten"
387388 } else {
388389 Page .Message = "dataNotWritten"
@@ -398,15 +399,15 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
398399 UnitIntID , _ := strconv .Atoi (r .FormValue ("unitID" ))
399400 unitaff := sqla .DeleteObjects (bs .db , bs .dbt , "units" , "ID" , []int {UnitIntID })
400401 if unitaff > 0 {
401- bs . team . constructUnitList (bs .db , bs .dbt )
402+ constructUnitList (bs .db , bs .dbt , bs . team )
402403 Page .Message = "dataWritten"
403404 } else {
404405 Page .Message = "dataNotWritten"
405406 }
406407 }
407408
408409 // Loading code ============================================
409- Page .UserList = bs .team .returnUserList ( )
410+ Page .UserList = bs .team .GetObjectArr ( "UserList" )
410411 if TextID == "new" {
411412 Page .New = true
412413 Page .PageTitle = bs .text .NewCompany
0 commit comments