github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/client/controllers/shared.go (about)

     1  package controllers
     2  
     3  import (
     4  	rd "github.com/benoitkugler/goACVE/server/core/rawdata"
     5  )
     6  
     7  const (
     8  	ButtonActivated = EtatSideButton(2)
     9  	ButtonPresent   = EtatSideButton(1)
    10  )
    11  
    12  // EtatSideButton vaut 0 pour absent, 1 pour désactivé, 2 pour activé
    13  type EtatSideButton int
    14  
    15  // Stat représente une statistique d'une table
    16  type Stat struct {
    17  	Label, Value string
    18  }
    19  
    20  type baseOnglet interface {
    21  	IsActif() bool
    22  	UpdateToolbar()
    23  	Render()
    24  	GrabFocus()
    25  }
    26  
    27  func HasId(l rd.Table, id rd.IId) bool {
    28  	for _, item := range l {
    29  		if item.Id == id {
    30  			return true
    31  		}
    32  	}
    33  	return false
    34  }
    35  
    36  func RemoveItem(l rd.Table, index int) rd.Table {
    37  	return append(l[:index], l[index+1:]...)
    38  }
    39  
    40  func ToIds(l rd.Table) rd.Ids {
    41  	out := make(rd.Ids, len(l))
    42  	for i, item := range l {
    43  		out[i] = item.Id.Int64()
    44  	}
    45  	return out
    46  }