def get_out_files_list(task_data_code, task_sobject_search_key): out_files_list = get_task_data_out_files(task_data_code) div_wdg = DivWdg() if out_files_list: out_files_unordered_html_list = HtmlElement.ul() for out_file in out_files_list: file_li = HtmlElement.li() file_li.add('{0} ({1})'.format( out_file.get('file_path'), out_file.get('classification').title())) file_edit_button = ButtonNewWdg(title='Edit File', icon='EDIT') file_edit_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Edit File', 'widgets.EditFileWdg', out_file.get_search_key(), 'Task', 'widgets.TaskInspectWdg', task_sobject_search_key)) file_edit_button.add_style('display', 'inline-block') file_li.add(file_edit_button) out_files_unordered_html_list.add(file_li) div_wdg.add(out_files_unordered_html_list) else: div_wdg.add('No output files exist for this task') return div_wdg
def get_next_tasks_div(task_sobject): div_wdg = DivWdg() div_wdg.add(HtmlElement.h4('Next Tasks')) pipeline_code = task_sobject.get_parent().get('pipeline_code') pipeline_xml = get_pipeline_xml(pipeline_code) next_task_processes = get_next_tasks_processes_from_xml( pipeline_xml, task_sobject.get('process')) if next_task_processes: for process in next_task_processes: div_wdg.add(process) next_task_sobject = get_task_sobject_from_xml_and_process( pipeline_xml, process, task_sobject.get('search_code')) if next_task_sobject: task_load_button = ButtonNewWdg(title='Load Order', icon='WORK') task_load_button.add_behavior( obu.get_load_new_tab_behavior( 'task_{0}'.format(next_task_sobject.get_code()), process, 'widgets.TaskInspectWdg', next_task_sobject.get_search_key())) task_load_button.add_style('display', 'inline-block') div_wdg.add(task_load_button) else: div_wdg.add('None') return div_wdg
def get_display(self): instructions_template_div = DivWdg() instructions_template_div.set_id('instructions_template') instructions_template_div.add_style('display', 'inline-block') instructions_template_name_div = DivWdg() instructions_template_name_div.add_style('text-decoration', 'underline') instructions_template_name_div.add_style('font-size', '24px') instructions_template_name_div.add(self.instructions_template_sobject.get('name')) instructions_template_div.add(instructions_template_name_div) instructions_template_div.add(self.get_selected_department_instructions_section()) outer_div = DivWdg() outer_div.set_id('instructions_template_builder') outer_div.add(instructions_template_div) create_new_instructions_document_button = ButtonNewWdg( title='Create an Instructions Document from this Template', icon='ADD') create_new_instructions_document_button.add_behavior( get_load_popup_widget_behavior( 'Create an Instructions Document', 'widgets.CreateInstructionsDocumentFromTemplateWdg', self.instructions_template_sobject.get_search_key() ) ) outer_div.add(create_new_instructions_document_button) return outer_div
def get_buttons_row(self): outer_div = DivWdg() download_attached_files_button = ButtonNewWdg(title='Download Attached Files', icon='DOWNLOAD') download_attached_files_button.add_behavior(obu.get_download_attached_files_behavior( self.task_sobject.get_search_key() )) download_attached_files_button.add_style('display', 'inline-block') note_button = ButtonNewWdg(title='Add Note', icon='NOTE') note_button.add_behavior(obu.get_add_notes_behavior(self.task_sobject.get_search_key())) note_button.add_style('display', 'inline-block') outer_div.add(download_attached_files_button) outer_div.add(note_button) return outer_div
def get_display(self): task_search_key = self.get_current_sobject().get_search_key() task_inspect_button = ButtonNewWdg( title='Inspect Task'.format(task_search_key), icon='WORK' ) task_inspect_button.add_behavior(self.get_launch_behavior(task_search_key)) return task_inspect_button
def get_display(self): instructions_template_search_key = self.get_current_sobject().get_search_key() instructions_template_button = ButtonNewWdg( title='Instructions Template'.format(instructions_template_search_key), icon='WORK' ) instructions_template_button.add_behavior(self.get_launch_behavior(instructions_template_search_key)) return instructions_template_button
def get_display(self): order = self.get_current_sobject() order_builder_button = ButtonNewWdg( title='Order Builder for {0}'.format(order.get_code()), icon='WORK') order_builder_button.add_behavior( self.get_launch_behavior(order.get_search_key())) return order_builder_button
def get_display(self): prequal_eval_code = self.get_current_sobject().get_code() prequal_eval_button = ButtonNewWdg( title='PreQual Evaluation for {0}'.format(prequal_eval_code), icon='WORK') prequal_eval_button.add_behavior( self.get_launch_behavior(prequal_eval_code)) return prequal_eval_button
def get_display(self): department_request = self.get_current_sobject() response_button = ButtonNewWdg(title='Response for {0}'.format( department_request.get_code()), icon='WORK') response_button.add_behavior( self.get_launch_behavior(department_request.get_search_key())) return response_button
def get_save_as_new_version_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_as_new_version_button = ButtonNewWdg(title='Save As New Version', icon='INSERT') save_as_new_version_button.add_class('save_as_new_version_button') save_as_new_version_button.add_behavior(self.get_save_as_new_version_behavior()) section_span.add(save_as_new_version_button) return section_span
def get_save_new_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_new_button = ButtonNewWdg(title='Save', icon='NEW') save_new_button.add_class('save_due_date') save_new_button.add_behavior(self.get_save_new_behavior()) section_span.add(save_new_button) return section_span
def get_export_to_pdf_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_as_new_button = ButtonNewWdg(title='Export to PDF', icon='ARROW_DOWN') save_as_new_button.add_class('save_as_new_button') save_as_new_button.add_behavior(self.get_export_to_pdf_behavior(self.prequal_eval_sobject.get_code())) section_span.add(save_as_new_button) return section_span
def get_save_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_button = ButtonNewWdg(title='Save', icon='SAVE') save_button.add_class('save_button') save_button.add_behavior(self.get_save_behavior(self.prequal_eval_sobject.get_code())) section_span.add(save_button) return section_span
def get_add_row_button(self): span_wdg = SpanWdg() add_row_button = ButtonNewWdg(title='Add Row', icon='ADD') add_row_button.add_class('add_row_button') add_row_button.add_style('display', 'inline-block') add_row_button.add_behavior(self.get_add_row_behavior()) span_wdg.add(add_row_button) return span_wdg
def get_row_checked_button(self, row_code): span_wdg = SpanWdg() checked_row_button = ButtonNewWdg(title='Checked Row', icon='CHECK') checked_row_button.add_style('display', 'inline-block') checked_row_button.add_behavior( self.get_checked_row_behavior(row_code)) span_wdg.add(checked_row_button) return span_wdg
def get_remove_row_button(self, row_code): span_wdg = SpanWdg() remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE') remove_row_button.add_class('subtract_row_button') remove_row_button.add_style('display', 'inline-block') remove_row_button.add_behavior(self.get_remove_row_behavior(row_code)) span_wdg.add(remove_row_button) return span_wdg
def get_remove_row_button(self, line_code): section_span = SpanWdg() section_span.add_style('display', 'inline-block') remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE') remove_row_button.add_class('remove_row_button') remove_row_button.add_behavior( get_remove_audio_configuration_line_behavior( self.element_evaluation_code, line_code)) section_span.add(remove_row_button) return section_span
def get_add_row_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') add_row_button = ButtonNewWdg(title='Add Row', icon='ADD') add_row_button.add_class('add_row_button') add_row_button.add_behavior( get_add_audio_configuration_line_behavior( self.element_evaluation_code)) section_span.add(add_row_button) return section_span
def get_add_multiple_rows_button(self): span_wdg = SpanWdg() # TODO: Find a better icon for this add_row_button = ButtonNewWdg(title='Add Multiple Row', icon='PLUS_ADD') add_row_button.add_class('add_row_button') add_row_button.add_style('display', 'inline-block') add_row_button.add_behavior(self.get_add_multiple_rows_behavior()) span_wdg.add(add_row_button) return span_wdg
def get_buttons_row(self): outer_div = DivWdg() edit_all_statuses_button = ButtonNewWdg(title='Edit All Statuses', icon='EDIT') edit_all_statuses_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Change Statuses', 'widgets.ChangeMultipleFileStatusesOnPackageWdg', self.package_sobject.get_search_key(), 'Package', 'widgets.PackageInspectWdg', self.package_sobject.get_search_key())) edit_all_statuses_button.add_style('display', 'inline-block') note_button = ButtonNewWdg(title='Add Note', icon='NOTE') note_button.add_behavior( obu.get_add_notes_behavior(self.package_sobject.get_search_key())) note_button.add_style('display', 'inline-block') outer_div.add(edit_all_statuses_button) outer_div.add(note_button) return outer_div
def get_export_to_pdf_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') export_to_pdf_button = ButtonNewWdg(title='Export to PDF', icon='ARROW_DOWN') export_to_pdf_button.add_class('export_to_pdf_button') export_to_pdf_button.add_behavior( self.get_export_to_pdf_behavior( self.metadata_report_sobject.get_code())) section_span.add(export_to_pdf_button) return section_span
def setup_html_list_for_file_flows_in_order(self, width=600): file_flows_list = HtmlElement.ul() file_flows_list.add_style('list-style-type', 'none') file_flows_list.add_style('margin-left', '10px') file_flows_list.add_style('padding-left', '0px') component_sobjects = get_component_sobjects_from_order_code(self.order_sobject.get_code())\ # Only do the searching and rendering if components exist for the Order if component_sobjects: component_sobjects_string = ','.join([ "'{0}'".format(component.get_code()) for component in component_sobjects ]) file_flow_search = Search('twog/file_flow') file_flow_search.add_where('\"component_code\" in ({0})'.format( component_sobjects_string)) file_flows = file_flow_search.get_sobjects() for file_flow in file_flows: file_flow_div = DivWdg() file_flow_div.add_style('background-color', '#d9edf7') file_flow_div.add_style('padding', '10px') file_flow_div.add_style('border-radius', '10px') file_flow_div.add(file_flow.get('name')) file_flow_div.add_style('display', 'block') change_component_button = ButtonNewWdg( title='Change Component', icon='PIPELINE') change_component_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Change Component', 'widgets.ChangeComponentForFileFlowWdg', file_flow.get_search_key(), 'Order Builder', 'order_builder.OrderBuilderWdg', self.order_sobject.get_search_key())) change_component_button.add_style('display', 'inline-block') file_flow_div.add(change_component_button) li = HtmlElement.li() li.add(file_flow_div) file_flows_list.add(li) return file_flows_list
def get_display(self): outer_div = DivWdg() outer_div.set_id('package_inspect_{0}'.format( self.package_sobject.get_code())) outer_div.add(get_page_header(self.package_sobject.get('name'))) outer_div.add( HtmlElement.h4('Code: {0}'.format( self.package_sobject.get_code()))) task_sobject = self.package_sobject.get_all_children('sthpw/task')[0] change_status_button = ButtonNewWdg(title='Change Status', icon='EDIT') change_status_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Change Status', 'widgets.ChangeStatusWdg', task_sobject.get_search_key(), 'Package', 'widgets.PackageInspectWdg', self.package_sobject.get_search_key())) change_status_button.add_style('display', 'inline-block') outer_div.add( HtmlElement.h4('Status: {0}'.format(task_sobject.get('status')))) outer_div.add(change_status_button) outer_div.add(HtmlElement.h4('<u>Files</u>')) outer_div.add(self.get_files_list()) outer_div.add(HtmlElement.h4('<u>Instructions</u>')) instructions = self.package_sobject.get('delivery_instructions') if not instructions: instructions = 'Sorry, instructions have not been added yet.' outer_div.add(instructions.encode('utf-8')) outer_div.add(self.get_buttons_row()) return outer_div
def get_files_list(self): outer_div = DivWdg() file_in_package_sobjects = get_file_in_package_sobjects_by_package_code( self.package_sobject.get_code()) file_sobjects = get_file_sobjects_from_file_in_package_sobjects( file_in_package_sobjects) files_unordered_html_list = HtmlElement.ul() for file_sobject, file_in_package_sobject in zip( file_sobjects, file_in_package_sobjects): task_sobject = file_in_package_sobject.get_all_children( 'sthpw/task')[0] file_li = HtmlElement.li() file_li.add( file_sobject.get('file_path') + ' - ' + task_sobject.get('status')) change_status_button = ButtonNewWdg(title='Change Status', icon='EDIT') change_status_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Change Status', 'widgets.ChangeStatusWdg', task_sobject.get_search_key(), 'Package', 'widgets.PackageInspectWdg', self.package_sobject.get_search_key())) change_status_button.add_style('display', 'inline-block') file_li.add(change_status_button) files_unordered_html_list.add(file_li) outer_div.add(files_unordered_html_list) return outer_div
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add(my.get_copyright_wdg()) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add( '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n' ) head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add( '<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>' ) # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n") else: head.add("<title>%s%s</title>\n" % (project_title, is_admin)) # add the javascript libraries head.add(JavascriptImportWdg()) # add the body body = my.body html.add(body) body.add_event('onload', 'spt.onload_startup(this)') top = my.top # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer top.add(""" <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % (IconWdg.get_icon_path("ERROR"))) # add the content content_div = DivWdg() top.add(content_div) Container.put("TopWdg::content", content_div) # add a dummy button for global behaviors from tactic.ui.widget import ButtonNewWdg, IconButtonWdg ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM) IconButtonWdg(title="DUMMY", icon=IconWdg.FILM) # NOTE: it does not need to be in the DOM. Just needs to be # instantiated #content_div.add(button) if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) content_div.add(content_wdg) # add a calendar wdg from tactic.ui.widget import CalendarWdg cal_wdg = CalendarWdg(css_class='spt_calendar_template_top') cal_wdg.top.add_style('display: none') content_div.add(cal_wdg) if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) top.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access( "builtin", "view_site_admin", "allow"): div = DivWdg() top.add(div) top.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.G_CLOSE) icon_div.add(icon_button) icon_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(parent); ''' }) div.add("<b>ADMIN >></b>") div.add_behavior({ 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(bvr.src_el); ''' }) div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' }) div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' }) project_code = Project.get_project_code() div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/admin/link/_startup"; window.open(url); ''' % project_code }) # Add the script editor listener load_div = DivWdg() top.add(load_div) load_div.add_behavior({ 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } ''' }) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%" % key, "like") search.add_filter("url", "/%s" % key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key)) top.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir, client_asset_dir)) top.add(script) # add a global container for commonly used widgets div = DivWdg() top.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class("SPT_PUW") busy_div.add_styles( "display: none; position: absolute; z-index: 1000") busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id", "app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add(AppBusyWdg()) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template", destroy_on_close=True) popup_div.add(popup) div.add(popup_div) inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(self): div_wdg = DivWdg() div_wdg.set_id('task_inspect_{0}'.format(self.task_sobject.get_code())) div_wdg.add(get_page_header(self.task_sobject.get('process'))) div_wdg.add(HtmlElement.h4('Code: {0}'.format(self.task_sobject.get_code()))) div_wdg.add(HtmlElement.h4('Package: {0} ({1})'.format(self.parent_component.get('name'), self.parent_component.get_code()))) # Get the order that contains the parent component and display its information order_sobject = get_order_sobject_from_component_sobject(self.parent_component) div_wdg.add(HtmlElement.h4('Order: {0} ({1})'.format(order_sobject.get('name'), order_sobject.get_code()))) div_wdg.add(HtmlElement.h4('<u>Status</u>')) div_wdg.add(get_task_status_select_wdg(self.task_sobject)) div_wdg.add(HtmlElement.h4('<u>Estimated Hours: {0}</u>'.format(self.task_data.get('estimated_hours')))) change_estimated_hours_button = ButtonNewWdg(title='Change Estimated Hours', icon='TIME') change_estimated_hours_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Change Estimated Hours', 'widgets.ChangeEstimatedHoursForTaskWdg', self.task_sobject.get_search_key(), 'Task', 'widgets.TaskInspectWdg', self.task_sobject.get_search_key() ) ) change_estimated_hours_button.add_style('display', 'inline-block') div_wdg.add(change_estimated_hours_button) add_input_file_button = ButtonNewWdg(title='Add Input Files', icon='INSERT_MULTI') add_input_file_button.add_behavior( obu.get_load_popup_widget_behavior('Add Input Files from Order', 'widgets.AddInputFilesToTaskWdg', self.task_sobject.get_search_key()) ) add_input_file_button.add_style('display', 'inline-block') div_wdg.add(add_input_file_button) create_input_file_button = ButtonNewWdg(title='Create a new Input File', icon='ADD') create_input_file_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Create a new Input File', 'widgets.CreateNewInputFileForTaskWdg', self.task_sobject.get_search_key(), 'Task', 'widgets.TaskInspectWdg', self.task_sobject.get_search_key() ) ) create_input_file_button.add_style('display', 'inline-block') div_wdg.add(create_input_file_button) move_input_file_to_output_button = ButtonNewWdg(title='Move Input File to Output', icon='RIGHT') move_input_file_to_output_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior( 'Move Input File to Output', 'widgets.MoveInputFileToOutputWdg', self.task_sobject.get_search_key(), 'Task', 'widgets.TaskInspectWdg', self.task_sobject.get_search_key() ) ) move_input_file_to_output_button.add_style('display', 'inline-block') div_wdg.add(move_input_file_to_output_button) add_equipment_button = ButtonNewWdg(title='Add Equipment', icon='INSERT_MULTI') add_equipment_button.add_behavior( obu.get_load_popup_widget_with_reload_behavior('Add Equipment', 'widgets.EquipmentInTaskWdg', self.task_sobject.get_search_key(), 'Task', 'widgets.TaskInspectWdg', self.task_sobject.get_search_key()) ) add_equipment_button.add_style('display', 'inline-block') div_wdg.add(add_equipment_button) if self.parent_component.get_search_type() == u'twog/component?project=twog': div_wdg.add(HtmlElement.h4('<u>Instructions</u>')) instructions_code = self.parent_component.get('instructions_code') instructions = get_task_instructions_text_from_instructions_code(instructions_code, self.task_sobject.get('process')) if not instructions: instructions = 'Sorry, instructions have not been added yet.' div_wdg.add(self.parse_instruction_text(instructions.encode('utf-8'))) elif self.parent_component.get_search_type() == u'twog/package?project=twog': div_wdg.add(HtmlElement.h4('<u>Instructions</u>')) instructions = self.parent_component.get('delivery_instructions') if not instructions: instructions = 'Sorry, instructions have not been added yet.' div_wdg.add(self.parse_instruction_text(instructions.encode('utf-8'))) div_wdg.add(self.get_buttons_row()) submit_button = SubmitWdg('Submit Changes') submit_button.add_behavior(self.submit_button_behavior()) submit_button.add_style('display', 'block') div_wdg.add(submit_button) return div_wdg
def get_buttons(my): button_div = DivWdg() button_row = ButtonRowWdg() button_div.add(button_row) button_row.add_style("float: right") button_row.add_style("padding-top: 5px") button_row.add_style("padding-bottom: 3px") button_row.add_style("padding-right: 5px") button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_row.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Refreshing"); var top = bvr.src_el.getParent(".spt_undo_log_top"); spt.panel.refresh(top) spt.app_busy.hide(); ''' } ) button = ButtonNewWdg(title="Undo the last transaction", icon=IconWdg.UNDO) button_row.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.undo_cbk(evt, bvr); spt.panel.refresh('UndoLogWdg'); ''' } ) button = ButtonNewWdg(title="Redo the last transaction", icon=IconWdg.REDO) button_row.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.redo_cbk(evt, bvr); spt.panel.refresh('UndoLogWdg'); ''' } ) # concept of a work session, which holds transaction codes session = {} # how should this session be stored? Timestamp based? now = datetime.datetime.now() today = now.strftime("%Y-%m-%d") now = now.strftime("%Y-%m-%d %H:%M:%S") location = Config.get_value("install", "server") login = Environment.get_user_name() project_code = Project.get_project_code() """ button = ButtonNewWdg(title="Save Selected Transactions", icon=IconWdg.SAVE) button_row.add(button) button.add_behavior( { 'type': 'click_up', 'login': login, 'project_code': project_code, 'session': session, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_undo_log_top"); var table = top.getElement(".spt_table"); var search_keys = spt.dg_table.get_selected_search_keys(table); if (search_keys.length == 0) { spt.error("No transactions selected"); return; } spt.app_busy.show("Saving Selected Transactions") bvr.session['search_keys'] = search_keys.join("|"); var server = TacticServerStub.get(); var kwargs = { login: bvr.login, project_code: bvr.project_code, session: bvr.session } var class_name = 'tactic.command.TransactionPluginCreateCmd'; server.execute_cmd(class_name, kwargs); spt.panel.refresh('UndoLogWdg'); spt.app_busy.hide(); ''' } ) #button.add_arrow_behavior( { # 'type': 'click_up', # 'cbjs_action': '''alert('cow')''' #} ) button.set_show_arrow_menu(True) from tactic.ui.container import SmartMenu, Menu, MenuItem menu = Menu(width=180) menu_item = MenuItem(type='title', label='Actions') menu.add(menu_item) menu_item = MenuItem(type='action', label='Save Today\'s Transactions') menu.add(menu_item) session['start_time'] = "%s 00:00:00" % today session['end_time'] = now menu_item.add_behavior( { 'type': 'click_up', 'login': login, 'project_code': project_code, 'session': session, 'cbjs_action': ''' spt.app_busy.show("Saving Today's Transactions") var server = TacticServerStub.get(); var kwargs = { login: bvr.login, project_code: bvr.project_code, session: bvr.session } var class_name = 'tactic.command.TransactionPluginCreateCmd'; server.execute_cmd(class_name, kwargs); spt.panel.refresh('UndoLogWdg'); spt.app_busy.hide(); ''' } ) SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } ) SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True ) button = ButtonNewWdg(title="Upload Transaction Session", icon=IconWdg.UPLOAD) button_row.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Select Transaction File"); var applet = spt.Applet.get(); var files = applet.open_file_browser(); if (files.length == 0) { spt.alert("No files selected"); spt.app_busy.hide(); return; } var path = files[0]; spt.app_busy.show("Installing Transaction File"); var server = TacticServerStub.get(); server.upload_file(path); var class_name = 'tactic.command.TransactionPluginInstallCmd'; var kwargs = { path: path } try { var info = server.execute_cmd(class_name, kwargs); } catch(e) { spt.alert(e); } spt.panel.refresh('UndoLogWdg'); spt.app_busy.hide(); ''' } ) """ return button_div
def get_display(my): my.search_key = my.kwargs.get("search_key") my.process = my.kwargs.get("process") my.sobject = Search.get_by_search_key(my.search_key) my.pipeline_code = my.kwargs.get("pipeline_code") top = DivWdg() top.add_class("spt_file_selector") top.add_style("position: relative") hidden = HiddenWdg("mode") #hidden = TextWdg("mode") hidden.add_class("spt_mode") top.add(hidden) top.add_style("padding: 5px") top.add_style("min-width: 500px") top.add_style("min-height: 400px") top.add_color("background", "background") top.add_color("color", "color") #top.add_border() logo_wdg = DivWdg() logo = HtmlElement.img(src="/context/icons/logo/perforce_logo.gif") logo_wdg.add(logo) top.add(logo_wdg) logo_wdg.add_style("opacity: 0.2") logo_wdg.add_style("position: absolute") logo_wdg.add_style("bottom: 0px") logo_wdg.add_style("right: 5px") # get some info from the config file """ client_env_var = Config.get_value("perforce", "client_env_var") if not client_env_var: client_env_var = "P4Client" port_env_var = Config.get_value("perforce", "port_env_var") if not port_env_var: port_env_var = "P4Port" user_env_var = Config.get_value("perforce", "user_env_var") if not user_env_var: user_env_var = "P4User" password_env_var = Config.get_value("perforce", "password_env_var") if not password_env_var: password_env_var = "P4Passwd" """ # {GET(sthpw/login)}_user host = "" client = "" user = "" password = "" port = "" project = my.sobject.get_project() depot = project.get_value("location", no_exception=True) if not depot: depot = "" top.add_behavior({ 'type': 'load', #'client_env_var': client_env_var, #'port_env_var': port_env_var, #'user_env_var': user_env_var, #'password_env_var': password_env_var, 'client': client, 'user': user, 'password': password, 'host': host, 'port': port, 'depot': depot, 'cbjs_action': get_onload_js() }) list_wdg = DivWdg() top.add(list_wdg) list_wdg.add_style("height: 32px") from tactic.ui.widget import SingleButtonWdg, ButtonNewWdg, ButtonRowWdg button_row = ButtonRowWdg() list_wdg.add(button_row) button_row.add_style("float: left") button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH, long=False) button_row.add(button) button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Reading file system ...") var top = bvr.src_el.getParent(".spt_checkin_top"); spt.panel.refresh(top); spt.app_busy.hide(); ''' }) button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT, long=False) button_row.add(button) my.sandbox_dir = my.kwargs.get("sandbox_dir") # what are we trying to do here??? #my.root_sandbox_dir = Environment.get_sandbox_dir() #project = my.sobject.get_project() #my.root_sandbox_dir = "%s/%s" % (my.root_sandbox_dir, project.get_code()) #repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "") #repo_dir = "%s/%s" % (project.get_code(), repo_dir) # checkout command requires either starting with //<depot>/ or just # the relative path to the root. The following removes # the root of the sandbox folder assuming that this is mapped # to the base of the depot my.root_sandbox_dir = Environment.get_sandbox_dir() repo_dir = my.sandbox_dir repo_dir = my.sandbox_dir.replace("%s/" % my.root_sandbox_dir, "") #button.add_style("padding-right: 14px") button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'repo_dir': repo_dir, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_top"); spt.app_busy.show("Reading file system ...") var data = spt.scm.checkout(bvr.repo_dir) spt.panel.refresh(top); spt.app_busy.hide(); ''' }) button = ButtonNewWdg(title="Perforce Actions", icon=IconWdg.PERFORCE, show_arrow=True) #button.set_show_arrow_menu(True) button_row.add(button) menu = Menu(width=220) menu_item = MenuItem(type='title', label='Perforce') menu.add(menu_item) menu_item = MenuItem(type='action', label='Show Workspaces') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var activator = spt.smenu.get_activator(bvr); var class_name = 'tactic.ui.checkin.WorkspaceWdg'; var top = activator.getParent(".spt_checkin_top"); var content = top.getElement(".spt_checkin_content"); var el = top.getElement(".spt_mode"); el.value = "workspace"; var kwargs = {}; spt.panel.load(content, class_name, kwargs); ''' }) menu_item = MenuItem(type='action', label='Show Changelists') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var activator = spt.smenu.get_activator(bvr); var class_name = 'tactic.ui.checkin.ChangelistWdg'; var top = activator.getParent(".spt_checkin_top"); var content = top.getElement(".spt_checkin_content"); var el = top.getElement(".spt_mode"); el.value = "changelist"; var kwargs = {}; spt.panel.load(content, class_name, kwargs); ''' }) menu_item = MenuItem(type='action', label='Show Branches') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var activator = spt.smenu.get_activator(bvr); var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg'; var top = activator.getParent(".spt_checkin_top"); var content = top.getElement(".spt_checkin_content"); var el = top.getElement(".spt_mode"); el.value = "branch"; var kwargs = {}; spt.panel.load(content, class_name, kwargs); ''' }) menu_item = MenuItem(type='title', label='Actions') menu.add(menu_item) menu_item = MenuItem(type='action', label='Add New Changelist') menu.add(menu_item) menu_item.add_behavior({ 'type': 'load', 'cbjs_action': ''' var activator = spt.smenu.get_activator(bvr); spt.scm.run("add_changelist", ["New Changelist"]); var class_name = 'tactic.ui.checkin.ChangelistWdg'; var top = activator.getParent(".spt_checkin_top"); var content = top.getElement(".spt_checkin_content"); spt.panel.load(content, class_name); ''' }) menu_item = MenuItem(type='separator') menu.add(menu_item) menu_item = MenuItem(type='action', label='Sign Out of Perforce') menu.add(menu_item) menu_item.add_behavior({ 'type': 'load', 'cbjs_action': ''' if (!confirm("Are you sure you wish to sign out of Perforce?")) { return; } spt.scm.signout_user(); var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_checkin_top"); spt.panel.refresh(top); ''' }) #SmartMenu.add_smart_menu_set( button.get_arrow_wdg(), { 'BUTTON_MENU': menu } ) #SmartMenu.assign_as_local_activator( button.get_arrow_wdg(), "BUTTON_MENU", True ) SmartMenu.add_smart_menu_set(button.get_button_wdg(), {'BUTTON_MENU': menu}) SmartMenu.assign_as_local_activator(button.get_button_wdg(), "BUTTON_MENU", True) # Perforce script editor. (nice because it should run as the user # in the appopriate environment """ button = ButtonNewWdg(title="P4 Script Editor", icon=IconWdg.CREATE, show_arrow=True) #button_row.add(button) button.add_style("padding-right: 14px") button.add_style("float: left") """ button = ButtonNewWdg(title="Changelists Counter", icon=IconWdg.CHECK_OUT_SM, show_arrow=True) #button_row.add(button) #button.add_style("padding-right: 14px") button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' // find any changelists that were missed var changelists = spt.scm.run("get_changelists", []); for (var i = 0; i < changelists.length; i++) { var changelist = changelists[i]; var info = spt.scm.run("get_changelist_info",[changelist.change]); console.log(info); } ''' }) # Hiding this for now button = ButtonNewWdg(title="Create", icon=IconWdg.NEW, show_arrow=True) #button_row.add(button) button.add_style("padding-right: 14px") button.add_style("float: left") menu = Menu(width=220) menu_item = MenuItem(type='title', label='New ...') menu.add(menu_item) menu_item = MenuItem(type='action', label='Text File') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'sandbox_dir': my.sandbox_dir, 'cbjs_action': ''' var path = bvr.sandbox_dir + "/" + "new_text_file.txt"; var env = spt.Environment.get(); var url = env.get_server_url() + "/context/VERSION_API"; var applet = spt.Applet.get(); applet.download_file(url, path); var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_checkin_top"); spt.panel.refresh(top); ''' }) #create_sobj = SObject.create("sthpw/virtual") #create_sobj.set_value("title", "Maya Project") #create_sobj.set_value("script_path", "create/maya_project") script_path = 'create/maya_project' menu_item = MenuItem(type='action', label='Maya Project') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'sandbox_dir': my.sandbox_dir, 'process': my.process, 'script_path': script_path, 'cbjs_action': ''' var script = spt.CustomProject.get_script_by_path(bvr.script_path); var options = {}; options.script = script; // add some data to options options.sandbox_dir = bvr.sandbox_dir; options.process = bvr.process; spt.CustomProject.exec_custom_script({}, options); var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_checkin_top"); spt.panel.refresh(top); ''' }) template_path = '/context/template/maya_project.zip' menu_item = MenuItem(type='action', label='Zipped Template') menu.add(menu_item) menu_item.add_behavior({ 'type': 'click_up', 'sandbox_dir': my.sandbox_dir, 'template_path': template_path, 'cbjs_action': ''' var path = bvr.sandbox_dir + "/" + "_template.zip"; var env = spt.Environment.get(); var url = env.get_server_url() + bvr.template_path; var applet = spt.Applet.get(); applet.download_file(url, path); applet.unzip_file(path, bvr.sandbox_dir); applet.rmtree(path); var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_checkin_top"); spt.panel.refresh(top); ''' }) SmartMenu.add_smart_menu_set(button, {'BUTTON_MENU': menu}) SmartMenu.assign_as_local_activator(button, "BUTTON_MENU", True) # Browse button for browsing files and dirs directly """ browse_div = DivWdg() list_wdg.add(browse_div) browse_div.add_style("float: left") button = ActionButtonWdg(title="Browse", tip="Select Files or Folder to Check-In") browse_div.add(button) behavior = { 'type': 'click_up', 'base_dir': my.sandbox_dir, 'cbjs_action': ''' var current_dir = bvr.base_dir; var is_sandbox = false; spt.checkin.browse_folder(current_dir, is_sandbox); ''' } button.add_behavior( behavior ) """ from tactic.ui.widget import SandboxButtonWdg, CheckoutButtonWdg, ExploreButtonWdg, GearMenuButtonWdg button_row = ButtonRowWdg() list_wdg.add(button_row) button_row.add_style("float: right") #button = SandboxButtonWdg(base_dir=my.sandbox_dir, process=my.process) #button_row.add(button) #button = CheckoutButtonWdg(base_dir=my.sandbox_dir, sobject=my.sobject, proces=my.process) #button_row.add(button) button = ExploreButtonWdg(base_dir=my.sandbox_dir) button_row.add(button) button = GearMenuButtonWdg(base_dir=my.sandbox_dir, process=my.process, pipeline_code=my.pipeline_code) button_row.add(button) list_wdg.add("<br clear='all'/>") top.add("<hr/>") content_div = DivWdg() top.add(content_div) content_div.add_class("spt_checkin_content") content = my.get_content_wdg() content_div.add(content) return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkout_top") top.add_color("background", "background") top.add_style("width: 800px") inner = DivWdg() top.add(inner) snapshot_codes = my.kwargs.get("snapshot_codes") search_keys = my.kwargs.get("search_keys") if snapshot_codes: if isinstance(snapshot_codes, basestring): snapshots_codes = eval(snapshot_codes) search = Search("sthpw/snapshot") search.add_filters("code", snapshot_codes) snapshots = search.get_sobjects() elif search_keys: if isinstance(search_keys, basestring): search_keys = eval(search_keys) sobjects = Search.get_by_search_keys(search_keys) snapshots = [] for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish") if snapshot: snapshots.append(snapshot) snapshot_codes = [] for snapshot in snapshots: snapshot_codes.append(snapshot.get("code")) if not snapshot_codes: no_snapshots_div = DivWdg() no_snapshots_div.add("No files in selection") inner.add(no_snapshots_div) return top sandbox_dir = Environment.get_sandbox_dir("default") project_code = Project.get_project_code() sandbox_dir = "%s/%s" % (sandbox_dir, project_code) base_dir = my.kwargs.get("base_dir") if base_dir: title_div = DivWdg() inner.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("padding", "15px") title_div.add_style("font-weight: bold") title_div.add("Path: %s" % base_dir) inner.add("Check-out to: %s" % sandbox_dir) button_div = ButtonRowWdg() inner.add(button_div) button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); spt.panel.refresh(top) ''' }) web = WebContainer.get_web() if web.use_applet(): button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'snapshot_codes': snapshot_codes, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); var progress = top.getElement(".spt_checkout_progress"); var message = top.getElement(".spt_checkout_message"); var snapshot_codes = bvr.snapshot_codes; var num_snapshots = snapshot_codes.length; var server = TacticServerStub.get(); for (var i = 0; i < snapshot_codes.length; i++) { var snapshot_code = snapshot_codes[i]; var percent = parseInt( (i+1) / (num_snapshots-1) * 100); var desc = "Checking out: "+(i+1)+" of "+num_snapshots+": "+snapshot_code; progress.setStyle("width", percent + "%"); message.innerHTML = desc; server.checkout_snapshot(snapshot_code, null, {file_types: ['main'], filename_mode: 'source'}); } progress.setStyle("width", "100%"); progress.setStyle("background", "#0F0"); message.innerHTML = "" ''' }) button = ButtonNewWdg(title="Sandbox", icon=IconWdg.FOLDER_GO) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'sandbox_dir': sandbox_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); applet.open_explorer(bvr.sandbox_dir); ''' }) msg_div = DivWdg() inner.add(msg_div) msg_div.add_class("spt_checkout_message") msg_div.add(" ") progress_div = DivWdg() inner.add(progress_div) progress_div.add_style("width: auto") progress_div.add_style("height: 15px") progress_div.add_style("margin: 0px 10px 10px 10px") progress_div.add_border() progress = DivWdg() progress.add_class("spt_checkout_progress") progress_div.add(progress) progress.add_style("background", "#F00") progress.add_style("width", "0%") progress.add(" ") snapshot_div = DivWdg() inner.add(snapshot_div) layout = ViewPanelWdg( search_type="sthpw/snapshot", show_shelf=False, edit=False, width="100%", element_names=[ 'preview', 'file', 'context', 'version', 'timestamp', 'description' ], ) snapshot_div.add(layout) layout.set_sobjects(snapshots[:50]) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_action_wdg(self): div = DivWdg() div.add_gradient("background", "background", -5) div.add_border() div.add_style("padding: 3px") button_row = ButtonRowWdg() div.add(button_row) button_row.add_style("float: left") div.add("<br clear='all'/>") button = ButtonNewWdg(title='Save Layout', icon=IconWdg.SAVE) button_row.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Saving ..."); var top = bvr.src_el.getParent(".spt_freeform_top"); var canvas_top = top.getElement(".spt_freeform_canvas_top"); var canvas = canvas_top.getElement(".spt_freeform_canvas"); spt.freeform.init(canvas); var xml = spt.freeform.export(); var search_type = canvas.getAttribute("spt_search_type"); var view = canvas.getAttribute("spt_view"); if (!search_type || !view) { alert("Cannot find search type or view"); return; } var server = TacticServerStub.get(); var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} ); server.update(sobject, {config: xml} ); spt.app_busy.hide(); ''' }) button = ButtonNewWdg(title='Add', icon=IconWdg.ADD, show_arrow=True) button_row.add(button) from tactic.ui.container import SmartMenu smenu_set = SmartMenu.add_smart_menu_set( button.get_button_wdg(), {'BUTTON_MENU': self.get_add_menu()}) SmartMenu.assign_as_local_activator(button.get_button_wdg(), "BUTTON_MENU", True) button = ButtonNewWdg(title='Remove', icon=IconWdg.DELETE) button_row.add(button) button = ButtonNewWdg(title='Clear', icon=IconWdg.KILL) button_row.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_freeform_top"); var canvas_top = top.getElement(".spt_freeform_canvas_top"); var canvas = canvas_top.getElement(".spt_freeform_canvas"); spt.freeform.init(canvas); if ( !confirm("Are you sure you wish to clear the canvas?") ) { return; } spt.freeform.clear_canvas(); ''' }) return div