def init(my): my.item_cls = my.kwargs.get('left_search_type') my.container_cls = my.kwargs.get('right_search_type') my.grouping_cls = my.kwargs.get('search_type') my.item_sobj = my.container_sobj = None # List the items search = Search(my.item_cls) my._order_search(search) items = search.get_sobjects() if items: my.item_sobj = items[0] #select = MultiSelectWdg("item_ids") #select.set_search_for_options(search,"login", "get_full_name()") user_span = SpanWdg(css='med') user_table = Table(css='table') user_table.add_style("margin-left: 6px") user_table.set_max_width() user_table.add_col(css='small') user_table.add_col() user_table.add_style("min-width: 14em") user_table.add_row_cell(search.get_search_type_obj()\ .get_description(), "heading") for item in items: user_table.add_row() checkbox = CheckboxWdg("item_ids") checkbox.set_option("value", item.get_primary_key_value() ) user_table.add_cell( checkbox ) project_code = item.get_value("project_code", no_exception=True) if project_code: user_table.add_cell( "[ %s ]" % project_code ) else: user_table.add_cell( "[ * ]" ) user_table.add_cell( item.get_description() ) user_span.add(user_table) # control widget in the middle control_div = DivWdg() control_div.add_style('padding: 100px 10px 0 10px') button = IconSubmitWdg(my.ADD_LABEL, "stock_insert-slide.png", True) button.add_style('padding: 2px 30px 4px 30px') control_div.add(button) main_table = Table(css='collapse') main_table.set_max_width() main_table.add_row(css='plain_bg') main_table.add_cell(user_span, 'valign_top') td = main_table.add_cell(control_div, 'valign_top') td.add_style('width','12em') main_table.add_cell(my._get_target_span(), 'valign_top') my.add(main_table) # register command here if my.item_sobj and my.container_sobj: marshaller = WebContainer.register_cmd("pyasm.widget.SObjectGroupCmd") marshaller.set_option("grouping_search_type", my.grouping_cls) marshaller.set_option("item_foreign_key", my.item_sobj.get_foreign_key()) marshaller.set_option("container_foreign_key", my.container_sobj.get_foreign_key())
def init(self): # List the items search = Search(self.item_cls.SEARCH_TYPE) self._order_search(search) items = search.get_sobjects() if items: self.item_sobj = items[0] #select = MultiSelectWdg("item_ids") #select.set_search_for_options(search,"login", "get_full_name()") user_span = SpanWdg(css='med') user_table = Table(css='table') user_table.add_style("margin-left: 6px") user_table.set_max_width() user_table.add_col(css='small') user_table.add_col() user_table.add_style("min-width: 14em") user_table.add_row_cell(search.get_search_type_obj()\ .get_description(), "heading") for item in items: user_table.add_row() checkbox = CheckboxWdg("item_ids") checkbox.set_option("value", item.get_primary_key_value()) user_table.add_cell(checkbox) project_code = item.get_value("project_code", no_exception=True) if project_code: user_table.add_cell("[ %s ]" % project_code) else: user_table.add_cell("[ * ]") user_table.add_cell(item.get_description()) user_span.add(user_table) # control widget in the middle control_div = DivWdg() control_div.add_style('padding: 100px 10px 0 10px') button = IconSubmitWdg(self.ADD_LABEL, IconWdg.INSERT, True) button.add_style('padding: 2px 30px 4px 30px') control_div.add(button) main_table = Table(css='collapse') main_table.set_max_width() main_table.add_row(css='plain_bg') main_table.add_cell(user_span, 'valign_top') td = main_table.add_cell(control_div, 'valign_top') td.add_style('width', '12em') main_table.add_cell(self._get_target_span(), 'valign_top') self.add(main_table) # register command here if self.item_sobj and self.container_sobj: marshaller = WebContainer.register_cmd( "pyasm.widget.SObjectGroupCmd") marshaller.set_option("grouping_search_type", self.grouping_cls.SEARCH_TYPE) marshaller.set_option("item_foreign_key", self.item_sobj.get_foreign_key()) marshaller.set_option("container_foreign_key", self.container_sobj.get_foreign_key())
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_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