def get_display(self): ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.ClipboardAddCbk") progress = ajax.generate_div() progress.add_style('display', 'inline') search_type = self.sobject.get_search_type() search_id = self.sobject.get_id() ajax.set_option("search_type", search_type) ajax.set_option("search_id", search_id) search_key = self.sobject.get_search_key() span = SpanWdg() span.set_id("clipboard_%s" % search_key) span.add_style("display: none") checkbox = CheckboxWdg() checkbox.add_style("vertical-align: top") checkbox.add_style("width: 7px") checkbox.add_event("onclick", "%s" % ajax.get_on_script(show_progress=False)) #checkbox.add_event("onmouseover", "this.style.width=15") #checkbox.add_event("onmouseout", "this.style.width=7") # FIXME :DEPRECATED """ event = WebContainer.get_event_container() caller = event.get_event_caller(ClipboardWdg.EVENT_ID) from file_wdg import ThumbWdg post_script = [caller] if self.thumbnail_mode: post_script.append( ThumbWdg.get_refresh_script(\ self.sobject, self.icon_size, show_progress=False) ) progress.set_post_ajax_script(';'.join(post_script)) if Clipboard.is_selected(self.sobject): checkbox.set_option("checked", "1") """ span.add(checkbox) span.add(progress) return span
def get_display(self): ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.ClipboardAddCbk") progress = ajax.generate_div() progress.add_style('display', 'inline') search_type = self.sobject.get_search_type() search_id = self.sobject.get_id() ajax.set_option("search_type", search_type) ajax.set_option("search_id", search_id) search_key = self.sobject.get_search_key() span = SpanWdg() span.set_id("clipboard_%s" % search_key) span.add_style("display: none") checkbox = CheckboxWdg() checkbox.add_style("vertical-align: top") checkbox.add_style("width: 7px") checkbox.add_event("onclick", "%s" % ajax.get_on_script(show_progress=False) ) #checkbox.add_event("onmouseover", "this.style.width=15") #checkbox.add_event("onmouseout", "this.style.width=7") # FIXME :DEPRECATED """ event = WebContainer.get_event_container() caller = event.get_event_caller(ClipboardWdg.EVENT_ID) from file_wdg import ThumbWdg post_script = [caller] if self.thumbnail_mode: post_script.append( ThumbWdg.get_refresh_script(\ self.sobject, self.icon_size, show_progress=False) ) progress.set_post_ajax_script(';'.join(post_script)) if Clipboard.is_selected(self.sobject): checkbox.set_option("checked", "1") """ span.add(checkbox) span.add(progress) return span
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)" )) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create #widget.add(create) return widget
def get_create_view_wdg(my, search_type): # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2)) create_popup.add( CheckboxWdg('auto_create_edit', label='Auto Create Edit View')) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", search_type) ajax.set_option("project", Project.get_project_code()) div = ajax.generate_div() div.set_post_ajax_script('document.form.submit()') create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')")) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) widget.add(create) widget.add(div) return widget
def get_preview_wdg(self): widget = Widget() web = WebContainer.get_web() csv_parser = CsvParser(self.file_path) csv_parser.parse() csv_titles = csv_parser.get_titles() csv_data = csv_parser.get_data() ajax = AjaxCmd() ajax.set_option("search_type", self.search_type) ajax.set_option("file_path", self.file_path) ajax.add_element_name("has_title") event = WebContainer.get_event_container() caller = event.get_event_caller(SiteMenuWdg.EVENT_ID) div = ajax.generate_div() div.set_post_ajax_script(caller) widget.add(div) columns = [] num_columns = len(csv_titles) ajax.set_option("num_columns", num_columns) for i in range(0, num_columns): column = web.get_form_value("column_%s" % i) if column: column = csv_titles[i] else: column = web.get_form_value("column_new_%s" % i) columns.append(column) ajax.add_element_name("column_%s" % i) ajax.add_element_name("new_column_%s" % i) ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd") import_button = IconButtonWdg("Import", IconWdg.REFRESH, True) import_button.add_event("onclick", ajax.get_on_script(show_progress=False)) import_button.add_style("float: right") widget.add(import_button) preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True) preview_submit.add_style("float: right") widget.add(preview_submit) sobject_title = self.search_type_obj.get_title() widget.add("<p>4. Import</p>") widget.add(HtmlElement.br()) widget.add( "<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title) table = Table(css="table") table.add_style("width: 100%") table.add_row() for i, title in enumerate(columns): if not title: title = "<b style='color:red'>*</b>" table.add_header(title) for i, row in enumerate(csv_data): if i > 100: break table.add_row() for j, cell in enumerate(row): table.add_cell(cell) widget.add(table) return widget
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) # create_popup.add( HtmlElement.br(2) ) # create_popup.add( "Copy from template: " ) # template_select = SelectWdg("copy_from_template") # template_select.add_empty_option("-- None --") # template_select.set_option("values", "list|summary|task") # create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg("Create") ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)"), ) cancel_icon = ProdIconButtonWdg("Cancel") cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create # widget.add(create) return widget
def get_create_view_wdg(my, search_type): # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) # create_popup.add( HtmlElement.br(2) ) # create_popup.add( "Copy from template: " ) # template_select = SelectWdg("copy_from_template") # template_select.add_empty_option("-- None --") # template_select.set_option("values", "list|summary|task") # create_popup.add( template_select ) create_popup.add(HtmlElement.br(2)) create_popup.add(CheckboxWdg("auto_create_edit", label="Auto Create Edit View")) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg("Create") ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", search_type) ajax.set_option("project", Project.get_project_code()) div = ajax.generate_div() div.set_post_ajax_script("document.form.submit()") create_icon.add_event("onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')")) cancel_icon = ProdIconButtonWdg("Cancel") cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) widget.add(create) widget.add(div) return widget
def get_preview_wdg(my): widget = Widget() web = WebContainer.get_web() csv_parser = CsvParser(my.file_path) csv_parser.parse() csv_titles = csv_parser.get_titles() csv_data = csv_parser.get_data() ajax = AjaxCmd() ajax.set_option("search_type", my.search_type) ajax.set_option("file_path", my.file_path) ajax.add_element_name("has_title") event = WebContainer.get_event_container() caller = event.get_event_caller(SiteMenuWdg.EVENT_ID) div = ajax.generate_div() div.set_post_ajax_script(caller) widget.add(div) columns = [] num_columns = len(csv_titles) ajax.set_option("num_columns", num_columns) for i in range(0, num_columns): column = web.get_form_value("column_%s" % i) if column: column = csv_titles[i] else: column = web.get_form_value("column_new_%s" % i) columns.append(column) ajax.add_element_name("column_%s" % i) ajax.add_element_name("new_column_%s" % i) ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd") import_button = IconButtonWdg("Import", IconWdg.REFRESH, True) import_button.add_event("onclick", ajax.get_on_script(show_progress=False)) import_button.add_style("float: right") widget.add( import_button ) preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True) preview_submit.add_style("float: right") widget.add(preview_submit) sobject_title = my.search_type_obj.get_title() widget.add("<p>4. Import</p>") widget.add(HtmlElement.br()) widget.add("<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title) table = Table(css="table") table.add_style("width: 100%") table.add_row() for i, title in enumerate(columns): if not title: title = "<b style='color:red'>*</b>" table.add_header(title) for i, row in enumerate(csv_data): if i > 100: break table.add_row() for j, cell in enumerate(row): table.add_cell(cell) widget.add(table) return widget
def add_publish_wdg(my, sobject, publish_msg): code = sobject.get_value('code') button = IconButtonWdg("publish", IconWdg.PUBLISH) # FIXME: HOW TO HANDLE THIS with new event mechanism? # set up event event_name = "%s_%s" %(sobject.get_search_key(), FlashActionWdg.PUBLISH_ACTION) event = WebContainer.get_event_container() function = event.get_event_caller(event_name) # escape the single quotes for function button.add_event("onclick", "comment_bubble.show(event, '%s', '%s')" \ % (code, Common.escape_quote(function))) # get the ajax load from pyasm.web import AjaxCmd ajax = AjaxCmd("publish_%s" % sobject.get_id() ) ajax.register_cmd("pyasm.flash.FlashAssetPublishCmd") ajax.add_element_name("upload_description") ajax.add_element_name("upload_files") ajax.set_option("search_type", sobject.get_search_type() ) ajax.set_option("search_id", sobject.get_id() ) div = ajax.generate_div() my.div.add(div) on_script = ajax.get_on_script(show_progress=False) thumb_script = ThumbWdg.get_refresh_script(sobject) post_publish_script = [thumb_script] post_publish_script.append(my.load_wdg.get_refresh_script(show_progress=False)) caller = event.get_event_caller(SiteMenuWdg.EVENT_ID) # update the SiteMenuWdg post_publish_script.append(caller) div.set_post_ajax_script(';'.join(post_publish_script)) #event.add_listener(event_name, "if(pyflash.publish('%s','%s')==false) return;%s" \ # % (code, publish_msg.get_id(), on_script ) ) behavior = { 'type': 'listen', 'event_name': event_name, 'cbjs_action': "if(pyflash.publish('%s','%s')==false) return;%s" \ % (code, publish_msg.get_id(), on_script ) } my.div.add_behavior(behavior) my.div.add(button) my.div.add(publish_msg) my.div.add(HtmlElement.br())