File size: 10,813 Bytes
530729e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
// Copyright 2019 GoAdmin Core Team. All rights reserved.
// Use of this source code is governed by a Apache-2.0 style
// license that can be found in the LICENSE file.

package types

import (
	"html/template"

	"github.com/GoAdminGroup/go-admin/modules/menu"
	"github.com/GoAdminGroup/go-admin/plugins/admin/modules"
	"github.com/GoAdminGroup/go-admin/template/types/form"
)

type FormAttribute interface {
	SetHeader(value template.HTML) FormAttribute
	SetContent(value FormFields) FormAttribute
	SetTabContents(value []FormFields) FormAttribute
	SetTabHeaders(value []string) FormAttribute
	SetFooter(value template.HTML) FormAttribute
	SetPrefix(value string) FormAttribute
	SetUrl(value string) FormAttribute
	SetPrimaryKey(value string) FormAttribute
	SetHorizontal(value bool) FormAttribute
	SetId(id string) FormAttribute
	SetAjax(successJS, errorJS template.JS) FormAttribute
	SetHiddenFields(fields map[string]string) FormAttribute
	SetFieldsHTML(html template.HTML) FormAttribute
	SetMethod(value string) FormAttribute
	SetHeadWidth(width int) FormAttribute
	SetInputWidth(width int) FormAttribute
	SetTitle(value template.HTML) FormAttribute
	SetLayout(layout form.Layout) FormAttribute
	SetOperationFooter(value template.HTML) FormAttribute
	GetDefaultBoxHeader(hideBack bool) template.HTML
	GetDetailBoxHeader(editUrl, deleteUrl string) template.HTML
	GetBoxHeaderNoButton() template.HTML
	GetContent() template.HTML
}

type BoxAttribute interface {
	SetHeader(value template.HTML) BoxAttribute
	SetBody(value template.HTML) BoxAttribute
	SetNoPadding() BoxAttribute
	SetFooter(value template.HTML) BoxAttribute
	SetTitle(value template.HTML) BoxAttribute
	WithHeadBorder() BoxAttribute
	SetIframeStyle(iframe bool) BoxAttribute
	SetAttr(attr template.HTMLAttr) BoxAttribute
	SetStyle(value template.HTMLAttr) BoxAttribute
	SetHeadColor(value string) BoxAttribute
	SetClass(value string) BoxAttribute
	SetTheme(value string) BoxAttribute
	SetSecondHeader(value template.HTML) BoxAttribute
	SetSecondHeadColor(value string) BoxAttribute
	WithSecondHeadBorder() BoxAttribute
	SetSecondHeaderClass(value string) BoxAttribute
	GetContent() template.HTML
}

type ColAttribute interface {
	SetSize(value S) ColAttribute
	SetContent(value template.HTML) ColAttribute
	AddContent(value template.HTML) ColAttribute
	GetContent() template.HTML
}

type ImgAttribute interface {
	SetWidth(value string) ImgAttribute
	SetHeight(value string) ImgAttribute
	WithModal() ImgAttribute
	SetSrc(value template.HTML) ImgAttribute
	GetContent() template.HTML
}

type LabelAttribute interface {
	SetContent(value template.HTML) LabelAttribute
	SetColor(value template.HTML) LabelAttribute
	SetType(value string) LabelAttribute
	GetContent() template.HTML
}

type RowAttribute interface {
	SetContent(value template.HTML) RowAttribute
	AddContent(value template.HTML) RowAttribute
	GetContent() template.HTML
}

type ButtonAttribute interface {
	SetContent(value template.HTML) ButtonAttribute
	SetOrientationRight() ButtonAttribute
	SetOrientationLeft() ButtonAttribute
	SetMarginLeft(int) ButtonAttribute
	SetMarginRight(int) ButtonAttribute
	SetThemePrimary() ButtonAttribute
	SetSmallSize() ButtonAttribute
	AddClass(class string) ButtonAttribute
	SetID(id string) ButtonAttribute
	SetMiddleSize() ButtonAttribute
	SetHref(string) ButtonAttribute
	SetThemeWarning() ButtonAttribute
	SetTheme(value string) ButtonAttribute
	SetLoadingText(value template.HTML) ButtonAttribute
	SetThemeDefault() ButtonAttribute
	SetType(string) ButtonAttribute
	GetContent() template.HTML
}

type TableAttribute interface {
	SetThead(value Thead) TableAttribute
	SetInfoList(value []map[string]InfoItem) TableAttribute
	SetType(value string) TableAttribute
	SetName(name string) TableAttribute
	SetMinWidth(value string) TableAttribute
	SetHideThead() TableAttribute
	SetSticky(sticky bool) TableAttribute
	SetLayout(value string) TableAttribute
	SetStyle(style string) TableAttribute
	GetContent() template.HTML
}

type DataTableAttribute interface {
	GetDataTableHeader() template.HTML
	SetThead(value Thead) DataTableAttribute
	SetInfoList(value []map[string]InfoItem) DataTableAttribute
	SetEditUrl(value string) DataTableAttribute
	SetDeleteUrl(value string) DataTableAttribute
	SetNewUrl(value string) DataTableAttribute
	SetPrimaryKey(value string) DataTableAttribute
	SetStyle(style string) DataTableAttribute
	SetAction(action template.HTML) DataTableAttribute
	SetIsTab(value bool) DataTableAttribute
	SetActionFold(fold bool) DataTableAttribute
	SetHideThead() DataTableAttribute
	SetLayout(value string) DataTableAttribute
	SetButtons(btns template.HTML) DataTableAttribute
	SetSticky(sticky bool) DataTableAttribute
	SetHideFilterArea(value bool) DataTableAttribute
	SetHideRowSelector(value bool) DataTableAttribute
	SetActionJs(aj template.JS) DataTableAttribute
	SetNoAction() DataTableAttribute
	SetInfoUrl(value string) DataTableAttribute
	SetDetailUrl(value string) DataTableAttribute
	SetHasFilter(hasFilter bool) DataTableAttribute
	SetSortUrl(value string) DataTableAttribute
	SetExportUrl(value string) DataTableAttribute
	SetUpdateUrl(value string) DataTableAttribute
	GetContent() template.HTML
}

type TreeAttribute interface {
	SetTree(value []menu.Item) TreeAttribute
	SetEditUrl(value string) TreeAttribute
	SetOrderUrl(value string) TreeAttribute
	SetUrlPrefix(value string) TreeAttribute
	SetDeleteUrl(value string) TreeAttribute
	GetContent() template.HTML
	GetTreeHeader() template.HTML
}

type TreeViewAttribute interface {
	SetTree(value TreeViewData) TreeViewAttribute
	SetUrlPrefix(value string) TreeViewAttribute
	SetID(id string) TreeViewAttribute
	GetContent() template.HTML
}

type PaginatorAttribute interface {
	SetCurPageStartIndex(value string) PaginatorAttribute
	SetCurPageEndIndex(value string) PaginatorAttribute
	SetTotal(value string) PaginatorAttribute
	SetPreviousClass(value string) PaginatorAttribute
	SetPreviousUrl(value string) PaginatorAttribute
	SetPages(value []map[string]string) PaginatorAttribute
	SetPageSizeList(value []string) PaginatorAttribute
	SetNextClass(value string) PaginatorAttribute
	SetNextUrl(value string) PaginatorAttribute
	SetOption(value map[string]template.HTML) PaginatorAttribute
	SetUrl(value string) PaginatorAttribute
	SetExtraInfo(value template.HTML) PaginatorAttribute
	SetEntriesInfo(value template.HTML) PaginatorAttribute
	GetContent() template.HTML
}

type TabsAttribute interface {
	SetData(value []map[string]template.HTML) TabsAttribute
	GetContent() template.HTML
}

type AlertAttribute interface {
	SetTheme(value string) AlertAttribute
	SetTitle(value template.HTML) AlertAttribute
	SetContent(value template.HTML) AlertAttribute
	Warning(msg string) template.HTML
	GetContent() template.HTML
}

type LinkAttribute interface {
	OpenInNewTab() LinkAttribute
	SetURL(value string) LinkAttribute
	SetAttributes(attr template.HTMLAttr) LinkAttribute
	SetClass(class template.HTML) LinkAttribute
	NoPjax() LinkAttribute
	SetTabTitle(value template.HTML) LinkAttribute
	SetContent(value template.HTML) LinkAttribute
	GetContent() template.HTML
}

type PopupAttribute interface {
	SetID(value string) PopupAttribute
	SetTitle(value template.HTML) PopupAttribute
	SetDraggable() PopupAttribute
	SetHideFooter() PopupAttribute
	SetWidth(width string) PopupAttribute
	SetHeight(height string) PopupAttribute
	SetFooter(value template.HTML) PopupAttribute
	SetFooterHTML(value template.HTML) PopupAttribute
	SetBody(value template.HTML) PopupAttribute
	SetSize(value string) PopupAttribute
	GetContent() template.HTML
}

type PanelInfo struct {
	Thead    Thead    `json:"thead"`
	InfoList InfoList `json:"info_list"`
}

type Thead []TheadItem

type TheadItem struct {
	Head       string       `json:"head"`
	Sortable   bool         `json:"sortable"`
	Field      string       `json:"field"`
	Hide       bool         `json:"hide"`
	Editable   bool         `json:"editable"`
	EditType   string       `json:"edit_type"`
	EditOption FieldOptions `json:"edit_option"`
	Width      string       `json:"width"`
}

func (t Thead) GroupBy(group [][]string) []Thead {
	var res = make([]Thead, len(group))

	for key, value := range group {
		var newThead = make(Thead, 0)

		for _, info := range t {
			if modules.InArray(value, info.Field) {
				newThead = append(newThead, info)
			}
		}

		res[key] = newThead
	}

	return res
}

type TreeViewData struct {
	Data              TreeViewItems `json:"data,omitempty"`
	Levels            int           `json:"levels,omitempty"`
	BackColor         string        `json:"backColor,omitempty"`
	BorderColor       string        `json:"borderColor,omitempty"`
	CheckedIcon       string        `json:"checkedIcon,omitempty"`
	CollapseIcon      string        `json:"collapseIcon,omitempty"`
	Color             string        `json:"color,omitempty"`
	EmptyIcon         string        `json:"emptyIcon,omitempty"`
	EnableLinks       bool          `json:"enableLinks,omitempty"`
	ExpandIcon        string        `json:"expandIcon,omitempty"`
	MultiSelect       bool          `json:"multiSelect,omitempty"`
	NodeIcon          string        `json:"nodeIcon,omitempty"`
	OnhoverColor      string        `json:"onhoverColor,omitempty"`
	SelectedIcon      string        `json:"selectedIcon,omitempty"`
	SearchResultColor string        `json:"searchResultColor,omitempty"`
	SelectedBackColor string        `json:"selectedBackColor,omitempty"`
	SelectedColor     string        `json:"selectedColor,omitempty"`
	ShowBorder        bool          `json:"showBorder,omitempty"`
	ShowCheckbox      bool          `json:"showCheckbox,omitempty"`
	ShowIcon          bool          `json:"showIcon,omitempty"`
	ShowTags          bool          `json:"showTags,omitempty"`
	UncheckedIcon     string        `json:"uncheckedIcon,omitempty"`

	SearchResultBackColor  string `json:"searchResultBackColor,omitempty"`
	HighlightSearchResults bool   `json:"highlightSearchResults,omitempty"`
}

type TreeViewItems []TreeViewItem

type TreeViewItemState struct {
	Checked  bool `json:"checked,omitempty"`
	Disabled bool `json:"disabled,omitempty"`
	Expanded bool `json:"expanded,omitempty"`
	Selected bool `json:"selected,omitempty"`
}

type TreeViewItem struct {
	Text         string            `json:"text,omitempty"`
	Icon         string            `json:"icon,omitempty"`
	SelectedIcon string            `json:"selected_icon,omitempty"`
	Color        string            `json:"color,omitempty"`
	BackColor    string            `json:"backColor,omitempty"`
	Href         string            `json:"href,omitempty"`
	Selectable   bool              `json:"selectable,omitempty"`
	State        TreeViewItemState `json:"state,omitempty"`
	Tags         []string          `json:"tags,omitempty"`
	Nodes        TreeViewItems     `json:"nodes,omitempty"`
}