Statistics
| Revision:

root / hci / trunk / eneraptor-web-app / grails-app / taglib / com / eneraptor / hci / ErptrTagLib.groovy @ 11

History | View | Annotate | Download (3.97 KB)

1
package com.eneraptor.hci
2

    
3
class ErptrTagLib { 
4

    
5
        static namespace = 'erptr'
6
        def mainMenuService
7
        
8
        def menu = { attrs ->
9
        
10
                List menuItems = mainMenuService.getMainMenu()
11
                
12
                menuItems.each {
13
                        out << "<li"
14
                        if(attrs.chosen == it.name) {
15
                                out << " class='current'"
16
                        }
17
                        out << "><a href='"
18
                        out << g.createLink(controller: "${it.name}", action: "${it.url}")
19
                        out << "'>${it.label}</a></li>"
20
                }
21
                
22
                out << "<li style='float:right;'><a href='"
23
                out << g.createLink(controller: 'login', action: 'logout')
24
                out << "'>Log out</a></li>"
25
                        
26
        }
27
        
28
        def subMenu = { attrs ->
29
                
30
                List subMenuItems = mainMenuService.getSubMenu(attrs.menu)
31
                if(subMenuItems == null) {
32
                        out << "<p>This sub-menu is not configured yet.</p>"
33
                } else {
34
                        subMenuItems.each {
35
                                out << "<li><a href='"
36
                                out << g.createLink(controller: "${it.name}", action: "${it.url}")
37
                                out << "' class='"
38
                                out << "${it.name}-${it.url}"
39
                                out << "'>"
40
                                if(attrs.chosen == it.url) out << "<u>"
41
                                out << it.label
42
                                if(attrs.chosen == it.url) out << "</u>"
43
                                out << "</a></li>"
44
                        }
45
                }
46
                
47
        }
48
        
49
        def box = { attrs, body ->
50
        
51
                out << "<div class='box'>"
52
                out << "<h3>${attrs['title']}</h3>"
53
                out << "<div class='boxContents'>"
54
                out << body()
55
                out << "</div>"
56
                out << "</div>"
57
                out << "<br />"
58
                        
59
        }
60
        
61
        def helpImg = {
62
                out << "<img style='position: relative; top: 3px;' src='" + g.resource(dir: 'img/icons/', file:'help.png') + "' />"
63
        }
64
        
65
        def helpBox = {
66
                out << "<div id='helpBox'>"
67
                out << "</div><br />"
68
        }
69
        
70
        def confirmBox = { attrs, body ->
71
                out << "<div id='confirmBox'>"
72
                out << "<div class='confirmBoxContent'>"
73
                out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'tick.png') + "' />"
74
                out << body()
75
                out << "</div>"
76
                out << "</div><br />"
77
        }
78
        
79
        def errorBox = { attrs, body ->
80
                out << "<div id='errorBox'>"
81
                out << "<div class='errorBoxContent'>"
82
                out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'cross.png') + "' />"
83
                out << body()
84
                out << "</div>"
85
                out << "</div><br />"
86
        }
87
        
88
        def warningBox = { attrs, body ->
89
                out << "<div id='warningBox'>"
90
                out << "<div class='warningBoxContent'>"
91
                out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'error.png') + "' />"
92
                out << body()
93
                out << "</div>"
94
                out << "</div><br />"
95
        }
96
        
97
        def logEntryOptions = { attrs ->
98
                out << "<a href='"
99
                out << g.createLink(action: 'detail', id: attrs.for)
100
                out << "'>"
101
                out << "<img src='"
102
                out << g.resource(dir: 'img/icons/', file: 'information.png')
103
                out << "' />"
104
                out << "</a>"
105
                out << "<a href='"
106
                out << g.createLink(action: 'deleteEntry', id: attrs.for)
107
                out << "'>"
108
                out << "<img src='"
109
                out << g.resource(dir: 'img/icons/', file: 'delete.png')
110
                out << "' />"
111
                out << "</a>"
112
        }
113
        
114
        def changeDeleteOptions = { attrs ->
115
                out << "<a href='"
116
                out << g.createLink(action: 'change' + attrs.table + 'Entry', id: attrs.for)
117
                out << "'>"
118
                out << "<img src='"
119
                out << g.resource(dir: 'img/icons/', file: 'wrench_orange.png')
120
                out << "' />"
121
                out << "</a>"
122
                out << "<a href='"
123
                out << g.createLink(action: 'delete' + attrs.table + 'Entry', id: attrs.for)
124
                out << "'>"
125
                out << "<img src='"
126
                out << g.resource(dir: 'img/icons/', file: 'delete.png')
127
                out << "' />"
128
                out << "</a>"
129
        }
130
        
131
        def icon = { attrs ->
132
                out << "<img style='float:left;position:relative;bottom:2px;' src='"
133
                out << g.resource(dir: "img/icons/", file: attrs.w + ".png")
134
                out << "' />"
135
        }
136
        
137
        def helpLink = { attrs ->
138
                
139
                out << g.remoteLink(action:"getHelp", params: [what: attrs.for], update: "helpBox", after: "\$('helpBox').pulsate({pulses: 2, duration: 0.5, from: 0.5})", erptr.helpImg())
140
                
141
        }
142
        
143
        def rawInfoBox = { attrs, body ->
144
                out << "<div class='rawInfoBox'>"
145
                out << body()
146
                out << "</div>"
147
        }
148
        
149
}