github.com/kotovmak/go-admin@v1.1.1/template/components/alert.go (about)

     1  package components
     2  
     3  import (
     4  	"html/template"
     5  
     6  	"github.com/kotovmak/go-admin/modules/errors"
     7  	"github.com/kotovmak/go-admin/modules/language"
     8  	"github.com/kotovmak/go-admin/template/types"
     9  )
    10  
    11  type AlertAttribute struct {
    12  	Name    string
    13  	Theme   string
    14  	Title   template.HTML
    15  	Content template.HTML
    16  	types.Attribute
    17  }
    18  
    19  func (compo *AlertAttribute) SetTheme(value string) types.AlertAttribute {
    20  	compo.Theme = value
    21  	return compo
    22  }
    23  
    24  func (compo *AlertAttribute) SetTitle(value template.HTML) types.AlertAttribute {
    25  	compo.Title = value
    26  	return compo
    27  }
    28  
    29  func (compo *AlertAttribute) SetContent(value template.HTML) types.AlertAttribute {
    30  	compo.Content = value
    31  	return compo
    32  }
    33  
    34  func (compo *AlertAttribute) Warning(msg string) template.HTML {
    35  	return compo.SetTitle(errors.MsgWithIcon).
    36  		SetTheme("warning").
    37  		SetContent(language.GetFromHtml(template.HTML(msg))).
    38  		GetContent()
    39  }
    40  
    41  func (compo *AlertAttribute) GetContent() template.HTML {
    42  	return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "alert")
    43  }