def get_display(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior( { 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' } ) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior( { 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' } ) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior( { 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' } ) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>"*2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): top = my.top top.add_class("spt_changelist_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior({'type': 'load', 'cbjs_action': scm_get_onload_js()}) sync_dir = Environment.get_sandbox_dir() # HARD CODED project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot changelist = my.kwargs.get("changelist") if not changelist: changelist = WidgetSettings.get_value_by_key("current_changelist") else: WidgetSettings.set_value_by_key("current_changelist", changelist) if not changelist: changelist = 'default' changelists = my.kwargs.get("changelists") if not changelists: changelists = [] elif isinstance(changelists, basestring): changelists = changelists.replace("'", '"') changelists = jsonloads(changelists) top.add_behavior({ 'type': 'load', 'sync_dir': sync_dir, 'depot': depot, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' }) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_color("background", "background", -3) table.add_row() th = table.add_header("") th = table.add_header("Changelist") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("Status") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Delete") th.add_style("text-align: left") #table.set_unique_id() #table.add_smart_styles("spt_changelist_item", { # 'text-align: right' # } )) bgcolor = table.get_color("background", -8) table.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_changelist_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' }) table.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_changelist_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' }) table.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': "spt_changelist_radio", 'cbjs_action': ''' var changelist = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", changelist); spt.app_busy.show("Loading Changelists Information"); spt.changelist.load(bvr.src_el, changelist); spt.app_busy.hide(); ''' }) for c in changelists: num_items = len(c.get("info")) name = c.get("change") tr = table.add_row() tr.add_class("spt_changelist_item") radio = RadioWdg("changelist") radio.add_class("spt_changelist_radio") table.add_cell(radio) radio.set_option("value", name) if name == changelist: radio.set_checked() table.add_cell(name) table.add_cell(c.get("desc")) table.add_cell(num_items) table.add_cell(c.get("status")) if num_items: icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM) icon.add_behavior({ 'type': 'click_up', 'changelist': c.get("change"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_changelist_content"); top.setAttribute("spt_changelist", bvr.changelist); spt.app_busy.show("Loading Changelist"); spt.changelist.load(bvr.src_el, bvr.changelist); spt.app_busy.hide(); ''' }) else: icon = '' table.add_cell(icon) if not num_items and name != 'default': icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE) else: icon = "" table.add_cell(icon) inner.add("<hr/>") files = my.kwargs.get("files") if isinstance(files, basestring): files = files.replace("'", '"') files = jsonloads(files) if files == None: inner.add_behavior({ 'type': 'load', 'location': location, 'changelist': changelist, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.changelist = {} spt.changelist.load = function(el, changelist) { var applet = spt.Applet.get(); var changelists = spt.scm.run("get_changelists_by_user",[]); var dflt = { 'change': 'default', 'status': 'pending' } changelists.push(dflt); changelists = changelists.reverse(); for (var i = 0; i < changelists.length; i++) { var info = spt.scm.run("get_changelist_files",[changelists[i].change]); changelists[i]['info'] = info; } // get the current chnage list var files = spt.scm.run("get_changelist_files",[changelist]); var path_info = {}; var sizes = []; for ( var i = 0; i < files.length; i++) { // FIXME: perforce specific var path = files[i].depotFile; path = path.replace(bvr.location, bvr.sync_dir); files[i].path = path; var size; if (applet.exists(path)) { var info = applet.get_path_info(path); size = info.size; } else { size = 0; } sizes.push(size); path_info[path] = 'editable'; } //var ret_val = spt.scm.status(bvr.sync_dir); //console.log(ret_val); var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg'; var kwargs = { files: files, sizes: sizes, changelist: changelist, changelists: changelists, path_info: path_info, } var top = el.getParent(".spt_changelist_content"); spt.panel.load(top, class_name, kwargs); } spt.changelist.load(bvr.src_el, bvr.changelist); ''' }) content = DivWdg() inner.add(content) content.add_class("spt_changelist_content") if files == None: loading_wdg = DivWdg() content.add(loading_wdg) loading_wdg.add("<b>Loading ...</b>") loading_wdg.add_style("padding: 30px") elif files: title_wdg = DivWdg() title_wdg.add_style("height: 15px") title_wdg.add("Changelist: [%s]" % changelist) content.add(title_wdg) title_wdg.add_gradient("background", "background", -5) title_wdg.add_style("padding: 5px") title_wdg.add_border() #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD) #content.add(button) content.add("<br/>") paths = [x.get("path") for x in files] sizes = my.kwargs.get("sizes") path_info = my.kwargs.get("path_info") from scm_dir_list_wdg import ScmDirListWdg # dummy search_key search_key = "sthpw/virtual?code=xx001" dir_list_wdg = ScmDirListWdg( base_dir=sync_dir, paths=paths, sizes=sizes, path_info=path_info, all_open=True, #search_key=search_key ) content.add(dir_list_wdg) else: content.add("Changelist: [%s]" % changelist) content.add("<br/>" * 2) no_files_wdg = DivWdg() content.add(no_files_wdg) no_files_wdg.add_style("padding: 20px") no_files_wdg.add_border() no_files_wdg.add("No files in changelist") no_files_wdg.add_color("color", "color3") no_files_wdg.add_color("background", "background3") no_files_wdg.add_style("font-weight: bold") no_files_wdg.add_style("text-align: center") return top
def get_display(my): top = my.top top.add_class("spt_branch_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") #top.add_border() #top.add_style("padding", "10px") top.add_style("min-width: 600px") top.add_style("min-height: 400px") top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot branch = my.kwargs.get("branch") if not branch: branch = WidgetSettings.get_value_by_key("current_branch") else: WidgetSettings.set_value_by_key("current_branch", branch) if not branch: branch = 'main' branches = my.kwargs.get("branches") if not branches: branches = [] elif isinstance(branches, basestring): branches = branches.replace("'", '"') branches = jsonloads(branches) top.add_behavior( { 'type': 'load', 'depot': depot, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_row() th = table.add_header("") th = table.add_header("Branches") th.add_style("text-align: left") th = table.add_header("Options") th.add_style("text-align: left") th = table.add_header("Owner") th.add_style("text-align: left") th = table.add_header("Check-out") th.add_style("text-align: left") bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_branch_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_branch_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_branch_radio", 'cbjs_action': ''' var value = bvr.src_el.value; spt.app_busy.show("Setting current branch to " + value); var server = TacticServerStub.get(); server.set_widget_setting("current_branch", value); var top = bvr.src_el.getParent(".spt_checkin_top"); top.removeAttribute("spt_sandbox_dir"); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) for c in branches: name = c.get("branch") tr = table.add_row() tr.add_class("spt_branch_item") radio = RadioWdg("branch") radio.add_class("spt_branch_radio") table.add_cell(radio) radio.set_option("value", name) if name == branch: radio.set_checked() table.add_cell(name) table.add_cell(c.get("Options")) table.add_cell(c.get("Owner")) icon = IconButtonWdg(title="Check-out", icon=IconWdg.CHECK_OUT_SM) table.add_cell(icon) icon.add_behavior( { 'type': 'click_up', 'branch': c.get("branch"), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_branch_content"); top.setAttribute("spt_brange", bvr.branch); spt.app_busy.show("Checking out branch ["+bvr.branch+"]"); spt.scm.checkout("new_project/"+bvr.branch); spt.app_busy.hide(); ''' } ) inner.add("<hr/>") if my.kwargs.get("branches") == None: inner.add_behavior( { 'type': 'load', 'location': location, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.branch = {} spt.branch.load = function(el) { var branches = spt.scm.run("get_branches",[]); var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg'; var kwargs = { branches: branches, } var top = el.getParent(".spt_branch_content"); spt.panel.load(top, class_name, kwargs); } spt.branch.load(bvr.src_el); ''' } ) return top
def get_display(self): web = WebContainer.get_web() show_multi_project = web.get_form_value('show_multi_project') project = Project.get() search_type_objs = project.get_search_types( include_multi_project=show_multi_project) top = self.top top.add_class("spt_panel_stype_list_top") #top.add_style("min-width: 400px") #top.add_style("max-width: 1000px") #top.add_style("width: 100%") top.center() button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED) top.add(button) button.add_style("float: right") button.add_style("margin-top: 0px") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' }) button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon="BS_PLUS") top.add(button) button.add_style("display: inline-block") button.add_style("vertical-align: middle") button.add_style("margin-top: 0px") button.add_style("margin-right: 15px") button.add_style("margin-left: 5px") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.SearchTypeCreatorWdg'; var kwargs = { }; var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_stype_list_top"); popup.on_register_cbk = function() { spt.panel.refresh(top); } ''' }) cb = CheckboxWdg('show_multi_project', label=' show multi-project') if show_multi_project: cb.set_checked() cb.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var panel = bvr.src_el.getParent('.spt_panel_stype_list_top') spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked}); ''' }) span = SpanWdg(css='small') top.add(span) top.add(cb) top.add("<br clear='all'/>") top.add("<br clear='all'/>") #search_type_objs = [] if not search_type_objs: arrow_div = DivWdg() top.add(arrow_div) icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32) icon.add_style("margin-top: -20") icon.add_style("margin-left: -15") icon.add_style("position: absolute") arrow_div.add(icon) arrow_div.add(" " * 5) arrow_div.add("<b>Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: 5px") arrow_div.add_style("margin-left: 20px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 25px") arrow_div.set_box_shadow("0px 5px 20px") arrow_div.set_round_corners(30) arrow_div.add_color("background", "background") div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("width: 600px") div.add_style("margin: 30px auto") div.add_style("padding: 20px") div.add_color("background", "background3") icon = IconWdg("WARNING", IconWdg.WARNING) div.add(icon) div.add("<b>No Searchable Types have been created</b>") div.add("<br/><br/>") div.add( "Searchables Types contain lists of items that are managed in this project. Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours." ) div.add("<br/>" * 2) div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias="main") div.add(help) div.add("<br/>") div.add( "Click on the 'Add' button above to start adding new types.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") table = Table() div.add(table) table.add_style("margin-top: 14px") table.set_max_width() # group mouse over table.add_relay_behavior({ 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" }) table.add_relay_behavior({ 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" }) border_color = table.get_color("border") tr = table.add_row() tr.add_color("color", "color") tr.add_color("background", "background", -3) tr.add_style("border-bottom: solid 1px %s" % border_color) th = table.add_header("") th.add_style("text-align: left") th = table.add_header("Title") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Add") th.add_style("text-align: left") th = table.add_header("Import") th.add_style("text-align: left") th = table.add_header("Custom Columns") th.add_style("text-align: left") th = table.add_header("Workflow") th.add_style("text-align: left") th = table.add_header("Notifications") th.add_style("text-align: left") th = table.add_header("Triggers") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") #th = table.add_header("Security") #th.add_style("text-align: left") for i, search_type_obj in enumerate(search_type_objs): tr = table.add_row() tr.add_class("spt_row") if not i or not i % 2: tr.add_color("background", "background") else: tr.add_color("background", "background", -2) thumb = ThumbWdg() thumb.set_sobject(search_type_obj) thumb.set_icon_size(30) td = table.add_cell(thumb) search_type = search_type_obj.get_value("search_type") title = search_type_obj.get_title() table.add_cell(title) try: search = Search(search_type) count = search.get_count() if count: table.add_cell("%s item/s" % count) else: table.add_cell(" ") except: td = table.add_cell("< No table >") td.add_style("font-style: italic") td.add_style("color: #F00") continue #search = Search(search_type) #search.add_interval_filter("timestamp", "today") #created_today = search.get_count() #table.add_cell(created_today) td = table.add_cell() button = IconButtonWdg(title="View", icon=IconWdg.ZOOM) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) button.add_style("float: left") arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN) arrow_button.add_style("margin-left: 20px") td.add(arrow_button) cbk = ''' var activator = spt.smenu.get_activator(bvr); var class_name = bvr.class_name; var layout = bvr.layout; var kwargs = { search_type: bvr.search_type, layout: layout, view: bvr.view, simple_search_view: 'simple_search', element_names: bvr.element_names, }; // use tab var top = activator.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new('%s', '%s', class_name, kwargs); ''' % (title, title) from tactic.ui.panel import SwitchLayoutMenu SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False) td = table.add_cell() button = IconButtonWdg(title="Add", icon=IconWdg.ADD) td.add(button) button.add_behavior({ 'type': 'listen', 'search_type': search_type, 'event_name': 'startup_save:' + search_type_obj.get_title(), 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' }) button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: bvr.search_type, view: "insert", save_event: "startup_save:" + bvr.title } spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' }) """ td = table.add_cell() button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'checkin', element_names: ['preview','code','name','description','history','general_checkin','notes'] }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'title': "Import Data", 'cbjs_action': ''' var class_name = 'tactic.ui.widget.CsvImportWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_type': search_type, 'title': "Add Custom Columns", 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ColumnEditWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE) button.add_style("float: left") td.add(button) search = Search("sthpw/pipeline") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg("Has Items", IconWdg.CHECK, width=8) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior({ 'type': 'click_up', 'title': 'Workflow', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.PipelineEditWdg'; var kwargs = { search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL) button.add_style("float: left") td.add(button) search = Search("sthpw/notification") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg("Has Items", IconWdg.CHECK, width=8) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior({ 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT) td.add(button) button.add_style("float: left") search = Search("config/trigger") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg("Has Items", IconWdg.CHECK, width=8) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior({ 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_type_obj.get_search_key(), 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/sobject", view: "edit_startup", search_key: bvr.search_key } spt.panel.load_popup("Edit Searchable Type", class_name, kwargs); ''' }) """ td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' alert("security"); ''' } ) """ columns_wdg = DivWdg() top.add(columns_wdg) return top
class ResizableTableWdg(BaseRefreshWdg): def __init__(self, **kwargs): self.table = Table() self.table.add_style("border-collapse: collapse") self.table.add_style("padding: 0px") self.table.set_attr("cellpadding", "0px") self.table.set_attr("cellspacing", "0px") self.is_first_row = True self.hilight = self.table.get_color("background", -40) super(ResizableTableWdg, self).__init__(**kwargs) def set_style(self, name, value=None): self.table.set_style(name, value) def set_max_width(self): self.table.set_max_width() def add_class(self, name): self.table.add_class(name) def get_display(self): top = self.top self.table.add_class("spt_resizable_table_top") self.table.add_behavior( { 'type': 'load', 'cbjs_action': self.get_onload_js() } ) self.table.add_behavior( { 'type': 'load', 'cbjs_action': ''' var resizable_cells = bvr.src_el.getElements(".spt_resizable_cell"); for (var i = 0; i < resizable_cells.length; i++) { var resizable_el = resizable_cells[i].getElement(".spt_resizable"); if (!resizable_el) { continue; } var size = resizable_cells[i].getSize(); resizable_el.setStyle("width", size.x); resizable_el.setAttribute("width", size.x); } ''' } ) top.add(self.table) return top def set_keep_table_size(self): self.table.add_class("spt_resizable_keep_size") def add_color(self, color, modifier=0): self.table.add_color(color, modifier) def add_border(self, modifier=0): self.table.add_border(modifier=modifier) def add_style(self, name, value=None): self.table.add_style(name, value=value) def add_row(self, resize=True): # add resize row if not self.is_first_row and resize == True: tr, td = self.table.add_row_cell() td.add_style("height: 3px") td.add_style("min-height: 3px") td.add_style("cursor: n-resize") tr.add_behavior( { 'type': 'drag', 'cb_set_prefix': 'spt.resizable_table.row_drag' } ) tr.add_behavior( { 'type': 'hover', 'hilight': self.hilight, 'cbjs_action_over': ''' var color = bvr.src_el.getStyle("background-color"); bvr.src_el.setStyle("background-color", bvr.hilight); bvr.src_el.setAttribute("spt_last_background", color); ''', 'cbjs_action_out': ''' var color = bvr.src_el.getAttribute("spt_last_background"); bvr.src_el.setStyle("background-color", color); ''' } ) icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL) td.add(icon) td.add_style("text-align: center") content_tr = self.table.add_row() self.is_first_row = False return content_tr def add_resize_row(self): tr, td = self.table.add_row_cell() td.add_style("height: 3px") td.add_style("min-height: 3px") td.add_style("cursor: n-resize") tr.add_behavior( { 'type': 'drag', 'cb_set_prefix': 'spt.resizable_table.row_drag' } ) tr.add_behavior( { 'type': 'hover', 'hilight': self.hilight, 'cbjs_action_over': ''' var color = bvr.src_el.getStyle("background-color"); bvr.src_el.setStyle("background-color", bvr.hilight); bvr.src_el.setAttribute("spt_last_background", color); ''', 'cbjs_action_out': ''' var color = bvr.src_el.getAttribute("spt_last_background"); bvr.src_el.setStyle("background-color", color); ''' } ) icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL) td.add(icon) return tr, td def add_cell(self, widget=None, resize=True, rowspan=1, colspan=1): td_content = self.table.add_cell() td_content.add_style("vertical-align: top") td_content.add_class("spt_resizable_cell") if rowspan > 1: td_content.add_attr("rowspan", rowspan+1) if colspan > 1: td_content.add_attr("colspan", colspan+1) if not resize: return td_content # add resize cell td = self.table.add_cell() td.add_style("width: 4px") td.add_style("min-width: 4px") td.add_style("cursor: e-resize") icon_div = DivWdg() icon_div.add_style("width: 4px") icon_div.add_style("overflow: hidden") icon = IconWdg("Drag to Resize", IconWdg.RESIZE_HORIZ) icon_div.add(icon) td.add(icon_div) td.add_style("vertical-align: middle") td.add_behavior( { 'type': 'drag', 'cb_set_prefix': 'spt.resizable_table.cell_drag' } ) td.add_behavior( { 'type': 'hover', 'hilight': self.hilight, 'cbjs_action_over': ''' var color = bvr.src_el.getStyle("background-color"); bvr.src_el.setStyle("background-color", bvr.hilight); bvr.src_el.setAttribute("spt_last_background", color); ''', 'cbjs_action_out': ''' var color = bvr.src_el.getAttribute("spt_last_background"); bvr.src_el.setStyle("background-color", color); ''' } ) if rowspan > 1: td.add_attr("rowspan", rowspan+1) if colspan > 1: td.add_attr("colspan", colspan+1) if widget: td_content.add(widget) return td_content def get_onload_js(self): return r'''
def get_display(my): top = my.top top.add_class("spt_workspace_content") my.set_as_panel(top) top.add_color("color", "color") top.add_color("background", "background") top.add_style("min-width: 600px") top.add_style("min-height: 400px") # NOTE: is there ever a time when this is not loaded already? top.add_behavior( { 'type': 'load', 'cbjs_action': scm_get_onload_js() } ) sync_dir = Environment.get_sandbox_dir() project = Project.get() depot = project.get_value("location", no_exception=True) if not depot: depot = project.get_code() location = '//%s' % depot workspace = my.kwargs.get("workspace") if not workspace: workspace = WidgetSettings.get_value_by_key("current_workspace") else: WidgetSettings.set_value_by_key("current_workspace", workspace) if not workspace: workspace = 'main' workspaces = my.kwargs.get("workspaces") if not workspaces: workspaces = [] elif isinstance(workspaces, basestring): workspaces = workspaces.replace("'", '"') workspaces = jsonloads(workspaces) top.add_behavior( { 'type': 'load', 'depot': depot, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.scm.sync_dir = bvr.sync_dir; spt.scm.depot = bvr.depot; ''' } ) inner = DivWdg() top.add(inner) table = Table() inner.add(table) table.add_style("width: 100%") table.add_row() th = table.add_header("") th = table.add_header("Workspaces") th.add_style("text-align: left") th = table.add_header("Description") th.add_style("text-align: left") th = table.add_header("Owner") th.add_style("text-align: left") th = table.add_header("Root") th.add_style("text-align: left") bgcolor = table.get_color("background", -8) table.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_workspace_item', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); ''' } ) table.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_workspace_item', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ''); ''' } ) table.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': "spt_workspace_radio", 'cbjs_action': ''' var value = bvr.src_el.value; spt.app_busy.show("Setting current workspace to " + value); var server = TacticServerStub.get(); server.set_widget_setting("current_workspace", value); var top = bvr.src_el.getParent(".spt_checkin_top"); top.removeAttribute("spt_sandbox_dir"); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) for c in workspaces: name = c.get("client") tr = table.add_row() tr.add_class("spt_workspace_item") radio = RadioWdg("workspace") radio.add_class("spt_workspace_radio") table.add_cell(radio) radio.set_option("value", name) if name == workspace: radio.set_checked() table.add_cell(name) table.add_cell(c.get("Description")) table.add_cell(c.get("Owner")) table.add_cell(c.get("Root")) if not workspaces: ws_div = DivWdg() table.add_row() table.add_cell(ws_div) ws_div.add_style("height: 60px") ws_div.add_style("width: 300px") ws_div.add("<b>No workspaces defined</b>") ws_div.add_color("color", "color3") ws_div.add_color("background", "background3") ws_div.add_border() ws_div.add_style("margin-top: 30px") ws_div.add_style("margin-bottom: 30px") ws_div.add_style("margin-left: auto") ws_div.add_style("margin-right: auto") ws_div.add_style("padding-top: 30px") ws_div.add_style("text-align: center") inner.add("<hr/>") if my.kwargs.get("workspaces") == None: inner.add_behavior( { 'type': 'load', 'location': location, 'sync_dir': sync_dir, 'cbjs_action': ''' spt.workspace = {} spt.workspace.load = function(el) { var workspaces = spt.scm.run("get_workspaces",[]); console.log(workspaces); var class_name = 'tactic.ui.checkin.workspace_wdg.WorkspaceWdg'; var kwargs = { workspaces: workspaces, } var top = el.getParent(".spt_workspace_content"); spt.panel.load(top, class_name, kwargs); } spt.workspace.load(bvr.src_el); ''' } ) return top