-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction_bar_wdg.py_prep_Python
More file actions
262 lines (202 loc) · 10.7 KB
/
action_bar_wdg.py_prep_Python
File metadata and controls
262 lines (202 loc) · 10.7 KB
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
###########################################################
#
# Copyright (c) 2009, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#
__all__ = ["ActionBarWdg"]
from pyasm.web import *
from pyasm.common import Environment
from tactic.ui.common import BaseRefreshWdg
from tactic.ui.container import PopupWdg
from tactic.ui.activator import ButtonForDropdownMenuWdg
from pyasm.widget import ButtonWdg
class ActionBarWdg(BaseRefreshWdg):
'''Set of menus making different sets of tools available in one place'''
def init(my):
pass
def get_args_keys(my):
return {
'table_id': 'id of the table that this action operates on'
}
def get_display(my):
my.table_id = my.kwargs.get('table_id')
if not my.table_id:
my.table_id = 'main_body_table'
action_bar_top_div = DivWdg()
action_bar_top_div.set_id("ActionBarWdg")
inner_div = DivWdg()
inner_div.set_style("background: #2f2f2f; color: #000000; border: 1px solid #000000; padding: 2px;")
# Fill out content div here!
btn_info_list = [
# {'id': 'ActionBar_FileMenu_Btn', 'title': 'File', 'menus': [ my.get_file_menu() ], 'match_w': False},
{'id': 'ActionBar_ViewMenu_Btn', 'title': 'View', 'menus': [ my.get_view_menu() ], 'match_w': False},
# {'id': 'ActionBar_EditMenu_Btn', 'title': 'Edit', 'menus': [ my.get_edit_menu() ], 'match_w': False},
# {'id': 'ActionBar_ItemsMenu_Btn', 'title': 'Items', 'menus': [ my.get_items_menu() ], 'match_w': False},
{'id': 'ActionBar_ToolsMenu_Btn', 'title': 'Tools', 'menus': [ my.get_tools_menu() ], 'match_w': False}
#{'id': 'ActionBar_ProjectMenu_Btn', 'title': 'Project', 'menus': [ my.get_project_menu() ], 'match_w': False},
]
table = Table()
table.add_row()
for btn_info in btn_info_list:
dd_button = ButtonForDropdownMenuWdg( id = btn_info['id'],
title = btn_info['title'],
menus = btn_info['menus'],
width = 120,
match_width = btn_info['match_w'],
nudge_menu_horiz = 0 )
td = table.add_cell()
td.add( dd_button )
# -- example of how to set this widget up as a tear_off (leaving here for reference for now)
# --
# tear_off = SpanWdg()
# tear_off.add( "[tear-off]" )
# tear_off.add_class( "SPT_TEAR_OFF_ACTIVATOR" )
# tear_off.add_styles( "cursor: pointer;" )
# tear_off.add_behavior( { 'type': 'click_up',
# 'cbjs_action': 'spt.popup.tear_off_el( $("%s"), "%s", %s, "%s" );' %
# (action_bar_id, popup_title, 'spt.popup.remove_el_by_class', 'SPT_TEAR_OFF_ACTIVATOR')
# } )
# td = table.add_cell()
# td.add( tear_off )
inner_div.add( table )
# Finished generating tools for Action Bar ...
action_bar_top_div.add(inner_div)
aux_div = DivWdg()
aux_div.set_id("ActionBar_Aux")
aux_div.add_class("SPT_AUX")
aux_div.add_styles("display: none;")
aux_div_title = DivWdg()
aux_div_title.add_looks("popup fnt_text") # look shouldn't be "popup" here!
aux_div_title.set_id("ActionBar_Aux_Title")
aux_div_content = DivWdg()
aux_div_content.set_id("ActionBar_Aux_Content")
aux_div.add( "<div> </div>" )
aux_div.add( aux_div_title )
# add spacing
aux_div.add(HtmlElement.br(2))
aux_div.add( aux_div_content )
aux_div.add( "<div> </div>" )
action_bar_top_div.add(aux_div)
return action_bar_top_div
def get_view_menu(my):
is_admin = False
security = Environment.get_security()
if security.check_access("builtin", "view_site_admin", "allow"):
is_admin = True
menu_items = [
{ "type": "action", "label": "Save Current View",
"bvr_cb": {'cbjs_action': "spt.dg_table.view_action_cbk('save','%s', bvr);" % my.table_id,
'is_admin': is_admin} },
{ "type": "action", "label": "Save My View As...",
"bvr_cb": {'cbjs_action': "spt.dg_table.view_action_cbk('add_my_view','%s', bvr);" % my.table_id} },
]
if is_admin:
menu_items.insert(2, { "type": "action", "label": "Save Project View As ...", "bvr_cb": {'cbjs_action': "spt.dg_table.view_action_cbk('save_project_view','%s', bvr);" % my.table_id} })
return {'menu_id': 'ActionBar_ViewMenu_Main', 'width': 150, 'allow_icons': False,
'opt_spec_list': menu_items}
def get_file_menu(my):
menu_items = [
{ "type": "action", "label": "Export All...", "bvr_cb": {
'cbfn_action': "spt.dg_table_action.set_actionbar_aux_content",
'class_name': 'tactic.ui.widget.CsvExportWdg',
'args': {"table_id": "%s" %my.table_id, \
"is_export_all": "true"}}},
{ "type": "action", "label": "Export Selected", "bvr_cb": {
'cbfn_action': "spt.dg_table_action.set_actionbar_aux_content",
'class_name': 'tactic.ui.widget.CsvExportWdg',
'args': {"table_id": "%s" %my.table_id}}},
{ "type": "separator" },
{ "type": "action", "label": "Sign Out", "bvr_cb": {'cbjs_action': "alert('File->Sign Out');"} }
]
security = Environment.get_security()
if security.check_access("builtin", "view_site_admin", "allow"):
menu_items.insert(0, { "type": "action", "label": "Import CSV", "bvr_cb": {
'cbfn_action': "spt.dg_table_action.set_actionbar_aux_content",
'class_name': 'tactic.ui.widget.CsvImportWdg',
'args': {"table_id": "%s" %my.table_id} }})
return {'menu_id': 'ActionBar_FileMenu_Main', 'width': 150, 'allow_icons': False,
'opt_spec_list': menu_items}
def get_edit_menu(my):
return {
'menu_id': 'ActionBar_EditMenu_Main', 'width': 200, 'allow_icons': False,
'opt_spec_list': [
{ "type": "action", "label": "Show Server Transaction Log",
"bvr_cb": {
'cbjs_action': "spt.popup.get_widget(evt, bvr)",
'options': {
'class_name': 'tactic.ui.popups.TransactionPopupWdg',
'title': 'Transaction Log',
'popup_id': 'TransactionLog_popup'
}
}
},
{ "type": "separator" },
{ "type": "action", "label": "Undo Last Server Transaction",
"bvr_cb": {'cbjs_action': "spt.undo();"} },
{ "type": "action", "label": "Redo Last Server Transaction",
"bvr_cb": {'cbjs_action': "spt.redo();"} },
# FIXME: can't do this yet because the Action bar is not
# specific to the view.
#{ "type": "action", "label": "Add Columns",
# "bvr_cb": {
# 'cbfn_action': 'spt.dg_table_action.get_popup_wdg',
# 'class_name': 'tactic.ui.panel.AddPredefinedColumnWdg',
# 'args': { 'search_type': my.search_type },
# 'element_id': 'predefined_column_wdg',
# }
#},
#'''
#{ "type": "action", "label": "Search Type Manager",
# "bvr_cb": {'cbjs_action': "spt.panel.load('main_body','tactic.ui.panel.SearchTypeManagerWdg')"} },
]
}
def get_items_menu(my):
return {
'menu_id': 'ActionBar_ItemsMenu_Main', 'width': 140, 'allow_icons': False,
'opt_spec_list': [
#{ "type": "action", "label": "Add New Item",
# NOTE: this only works for main_body!!
# "bvr_cb": {'cbjs_action': "spt.dg_table.add_item_cbk('main_body_table');"} },
#{ "type": "separator" },
{ "type": "action", "label": "Retire Selected Items",
"bvr_cb": {'cbjs_action': "spt.dg_table.retire_selected('%s');" % my.table_id} },
{ "type": "action", "label": "Delete Selected Items",
"bvr_cb": {'cbjs_action': "spt.dg_table.delete_selected('%s');" % my.table_id} },
]
}
def get_tools_menu(my):
menu_items = [
#{ "type": "action", "label": "Search Types Manager",
# "bvr_cb": {'cbjs_action': "spt.panel.load('main_body','tactic.ui.panel.SearchTypeManagerWdg')"} },
#{ "type": "separator" },
{ "type": "action", "label": "Web Client Output Log",
"bvr_cb": {'cbjs_action': "spt.js_log.show(false);"} },
{ "type": "action", "label": "TACTIC Script Editor",
"bvr_cb": {'cbjs_action': 'spt.panel.load_popup("TACTIC Script Editor",\
"tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} );'} }
]
security = Environment.get_security()
if security.check_access("builtin", "view_site_admin", "allow"):
menu_items.insert(0, {"type": "action", "label": "Create New Project",
"bvr_cb": { 'cbjs_action': "spt.popup.open('create_project_wizard'); Effects.fade_in($('create_project_wizard'), 200);"}})
menu_items.insert(1, { "type": "separator" })
return {
'menu_id': 'ActionBar_ToolsMenu_Main', 'width': 140, 'allow_icons': False,
'opt_spec_list': menu_items
}
def get_project_menu(my):
return {
'menu_id': 'ActionBar_ProjectMenu_Main', 'width': 200, 'allow_icons': False,
'opt_spec_list': [
{
"type": "action",
"label": "Create New Project",
"bvr_cb": { 'cbjs_action': "spt.popup.open('create_project_wizard');" }
} ]
}