def get_display(my): if not my.preprocessed: my.preprocess() if my.is_refresh: top = Widget() else: top = DivWdg() top.add_class("spt_work_hours_top") hidden = HiddenWdg('workhour_data') hidden.add_class('spt_workhour_data') header_data = {'start_date': str(my.start_date)} header_data = jsondumps(header_data).replace('"', """) hidden.set_value(header_data, set_form_value=False) top.add(hidden) days = [] for date in my.dates: days.append(date.strftime("%Y_%m_%d")) today = my.today.strftime("%Y_%m_%d") task = my.get_current_sobject() if not my.is_refresh: my.set_as_panel(top) entries = my.entries.get(task.get_code()) if isinstance(task, Task): parent = task.get_parent() if not parent: disabled = True else: disabled = False else: disabled = False if not entries: entries = {} table = Table() top.add(table) if my.use_straight_time: row_list = [my.ST_ROW] if my.show_overtime: row_list.append(my.OT_ROW) prefix_list = ['', 'ot'] else: row_list = [my.STT_ROW, my.ENT_ROW] prefix_list = ['stt', 'ent'] text = HiddenWdg(my.get_name()) text.add_class("spt_data") table.add_color("color", "color") table.add_styles("width: %spx; float: left" % my.table_width) for row_to_draw in row_list: tr = table.add_row() tr.add_style('line-height', '8px') td = table.add_blank_cell() offset_width = my.MONTH_WIDTH + my.LEFT_WIDTH + 8 td.add_style("min-width: %spx" % offset_width) td.add(text) # go through each day and draw an input for overtime total_hours_st = 0 total_hours_ot = 0 search_key = task.get_search_key() # Add a label to indicate if the row is straight time or overtime time_prefix = '' if row_to_draw == my.OT_ROW: time_prefix = 'ot' div = DivWdg() div.add("OT") div.add_styles('text-align: right; margin-right: 4px') td.add(div) elif row_to_draw == my.STT_ROW: time_prefix = 'stt' div = DivWdg() div.add("ST") div.add_styles('text-align: right; margin: 0 4px 4px 0') td.add(div) elif row_to_draw == my.ENT_ROW: time_prefix = 'ent' div = DivWdg() div.add("ET") div.add_styles('text-align: right; margin: 0 4px 4px 0') td.add(div) for idx, day in enumerate(days): day_wdg = DivWdg() day_wdg.add(day) td = table.add_cell() td.add_style("width: %spx" % my.day_width) text = TextWdg('%sday_%s' % (time_prefix, day)) if disabled: text.set_option('read_only', 'true') text.set_attr('disabled', 'disabled') td.add(text) text.add_class('spt_day%s' % (time_prefix)) text.add_styles( "width: %spx;text-align: right;padding-left: 2px" % (my.day_width - 2)) #text.add_styles("width: 100%;text-align: right;padding-left: 2px") if day == today: text.add_style("border: solid 1px black") week_day = my.weekday_dict[idx] if week_day in ['Sat', 'Sun']: # MAIN: Overtime, weekend if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[-15, 0, 5]) else: text.add_color("background", "background2", modifier=[0, 15, 20]) if row_to_draw == my.OT_ROW: text.add_attr('input_field_type', 'ot') else: text.add_attr('input_field_type', 'st') if my.kwargs.get('show_all_users') == 'false': pass else: text.set_option('read_only', 'true') #TODO: while we may have multiple entries per task, we will only use the latest one here # for now, making the UI cleaner # if a corresponding entry exists, display its value entry_list_dict = entries.get(day) daily_sum = 0 value = 0 entry_list = [] if entry_list_dict: row_key = my.ROW_DICT.get(row_to_draw) entry_list = entry_list_dict.get(row_key) if entry_list: for entry in entry_list: # Check if there is something in the category column. category = entry.get_value("category") if row_to_draw == my.OT_ROW: # Skip if the category field does not have a 'ot' indicated. if not category: print "Warning this work_hour entry has no category [%s]" % entry.get_code( ) continue # Check if there exist a value in the straight_time column value, delta = my.get_time_value(entry, row_to_draw) if value: text.set_value(value) text.add_attr('orig_input_value', value) if row_to_draw == my.OT_ROW: total_hours_ot += float(delta) else: total_hours_st += float(delta) daily_sum += delta # we only use value instead of the sum "daily_sum" for now if row_to_draw == my.OT_ROW: my.summary_ot[idx].update({search_key: daily_sum}) else: my.summary_st[idx].update({search_key: daily_sum}) script = ''' var orig_value = bvr.src_el.getAttribute("orig_input_value"); var input_field_type = bvr.src_el.getAttribute("input_field_type"); bvr.src_el.value = bvr.src_el.value.strip(); if (bvr.src_el.value == '') { if (orig_value) { bvr.src_el.value = 0; } else { return; } } else if (bvr.src_el.value == orig_value) { return; } bvr.prefix_list.splice( bvr.prefix_list.indexOf(bvr.time_prefix),1) var other_time_prefix = bvr.prefix_list[0]; spt.work_hour.update_total(bvr, '.spt_day' + bvr.time_prefix); // register this as changed item var all_top_el = bvr.src_el.getParent(".spt_work_hours_top"); var values1 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ bvr.time_prefix, false); var values2 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ other_time_prefix, false); // Merge values from straight time and overtime fields in values variable. for (var attr in values2) { values1[attr] = values2[attr]; } for (val in values1) { if (values1[val] && isNaN(values1[val])) { spt.error('You have non-numeric values in your work hours. Please correct it: ' + values[val]); return; } } delete values1.data; var value_wdg = all_top_el.getElement(".spt_data"); var value = JSON.stringify(values1); value_wdg.value = value; var layout = bvr.src_el.getParent(".spt_layout"); var version = layout.getAttribute("spt_version"); if (version == "2") { spt.table.set_layout(layout); spt.table.accept_edit(all_top_el, value, false); } else { var cached_data = {}; spt.dg_table.edit.widget = all_top_el; spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data ); } ''' # accept on pressing Enter behavior = { 'type': 'keydown', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' if (evt.key=='enter') { %s } ''' % script } text.add_behavior(behavior) behavior = { 'type': 'blur', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' %s ''' % script } text.add_behavior(behavior) text = TextWdg("total") td = table.add_cell(text) td.add_style("width: 35px") text.add_attr('spt_total', '.spt_total%s' % (time_prefix)) text.add_class('spt_total%s' % (time_prefix)) text.add_styles( "width: %spx; text-align: right; padding-right: 3px" % my.day_width) text.set_attr("readonly", "readonly") # MAIN: Overtime, total. if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[5, -15, 0]) if total_hours_ot: text.set_value("%0.1f" % total_hours_ot) my.summary_ot[7].update({search_key: total_hours_ot}) else: text.add_color("background", "background2", modifier=[20, 0, 15]) if total_hours_st: text.set_value("%0.1f" % total_hours_st) my.summary_st[7].update({search_key: total_hours_st}) td = table.add_blank_cell() td.add_style('width: 100%') return top
def handle_dir_or_item(my, item_div, dirname, basename): spath = "%s/%s" % (dirname, basename) fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename)) md5 = my.md5s.get(fspath) changed = False context = None error_msg = None snapshot = None file_obj = my.checked_in_paths.get(fspath) if not file_obj: if fspath.startswith(my.base_dir): rel = fspath.replace("%s/" % my.base_dir, "") file_obj = my.checked_in_paths.get(rel) if file_obj != None: snapshot_code = file_obj.get_value("snapshot_code") snapshot = my.snapshots_dict.get(snapshot_code) if not snapshot: # last resort snapshot = file_obj.get_parent() if snapshot: context = snapshot.get_value("context") item_div.add_attr("spt_snapshot_code", snapshot.get_code()) snapshot_md5 = file_obj.get_value("md5") item_div.add_attr("spt_md5", snapshot_md5) item_div.add_attr("title", "Checked-in as: %s" % file_obj.get_value("file_name")) if md5 and md5 != snapshot_md5: item_div.add_class("spt_changed") changed = True else: error_msg = 'snapshot not found' status = None if file_obj != None: if changed: check = IconWdg( "Checked-In", IconWdg.ERROR, width=12 ) status = "changed" else: check = IconWdg( "Checked-In", IconWdg.CHECK, width=12 ) status = "same" item_div.add_color("color", "color", [0, 0, 50]) else: check = None item_div.add_style("opacity: 0.8") status = "unversioned" if check: item_div.add(check) check.add_style("float: left") check.add_style("margin-left: -16px") check.add_style("margin-top: 4px") # add the file name filename_div = DivWdg() item_div.add(filename_div) filename_div.add(basename) file_info_div = None if snapshot and status != 'unversioned': file_info_div = SpanWdg() filename_div.add(file_info_div) if error_msg: filename_div.add(' (%s)'%error_msg) filename_div.add_style("float: left") filename_div.add_style("overflow: hidden") filename_div.add_style("width: 65%") # DEPRECATED from pyasm.widget import CheckboxWdg, TextWdg, SelectWdg, HiddenWdg checkbox = CheckboxWdg("check") checkbox.add_style("display: none") checkbox.add_class("spt_select") checkbox.add_style("float: right") checkbox.add_style("margin-top: 1px") item_div.add(checkbox) subcontext_val = '' cat_input = None is_select = True if my.context_options: context_sel = SelectWdg("context") context_sel.add_attr('title', 'context') context_sel.set_option("show_missing", False) context_sel.set_option("values", my.context_options) item_div.add_attr("spt_context", my.context_options[0]) cat_input = context_sel input_cls = 'spt_context' else: if my.subcontext_options in [['(main)'], ['(auto)'] , []]: is_select = False #subcontext = TextWdg("subcontext") subcontext = HiddenWdg("subcontext") subcontext.add_class("spt_subcontext") elif my.subcontext_options == ['(text)']: is_select = False subcontext = TextWdg("subcontext") subcontext.add_class("spt_subcontext") else: is_select = True subcontext = SelectWdg("subcontext") subcontext.set_option("show_missing", False) subcontext.set_option("values", my.subcontext_options) #subcontext.add_empty_option("----") cat_input = subcontext input_cls = 'spt_subcontext' if my.subcontext_options == ['(main)'] or my.subcontext_options == ['(auto)']: subcontext_val = my.subcontext_options[0] subcontext.set_value(subcontext_val) item_div.add_attr("spt_subcontext", subcontext_val) elif context: parts = context.split("/") if len(parts) > 1: # get the actual subcontext value subcontext_val = "/".join(parts[1:]) # identify a previous "auto" check-in and preselect the item in the select if is_select and subcontext_val not in my.subcontext_options: subcontext_val = '(auto)' elif isinstance(cat_input, HiddenWdg): subcontext_val = '' # the Text field will adopt the subcontext value of the last check-in subcontext.set_value(subcontext_val) item_div.add_attr("spt_subcontext", subcontext_val) else: if is_select: if my.subcontext_options: subcontext_val = my.subcontext_options[0] #subcontext_val = '(auto)' cat_input.set_value(subcontext_val) else: subcontext_val = '' item_div.add_attr("spt_subcontext", subcontext_val) item_div.add(cat_input) cat_input.add_behavior( { 'type': 'click_up', 'propagate_evt': False, 'cbjs_action': ''' bvr.src_el.focus(); ''' } ) cat_input.add_style("display: none") cat_input.add_class("spt_subcontext") cat_input.add_style("float: right") cat_input.add_style("width: 50px") cat_input.add_style("margin-top: -1px") cat_input.add_style("font-size: 10px") cat_input.add_style("height: 16px") # we depend on the attribute cuz sometimes we go by the initialized value # since they are not drawn cat_input.add_behavior( { 'type': 'change', 'cbjs_action': ''' var el = bvr.src_el.getParent('.spt_dir_list_item'); el.setAttribute("%s", bvr.src_el.value); ''' %input_cls } ) if file_info_div: if subcontext_val in ['(auto)','(main)', '']: file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s)</i>" % snapshot.get_value("version") ) else: file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s - %s)</i>" % (snapshot.get_value("version"), subcontext_val) )
def get_display(my): if not my.preprocessed: my.preprocess() if my.is_refresh: top = Widget() else: top = DivWdg() top.add_class("spt_work_hours_top") hidden = HiddenWdg('workhour_data') hidden.add_class('spt_workhour_data') header_data = {'start_date': str(my.start_date)} header_data = jsondumps(header_data).replace('"', """) hidden.set_value(header_data, set_form_value=False ) top.add(hidden) days = [] for date in my.dates: days.append( date.strftime("%Y_%m_%d") ) today = my.today.strftime("%Y_%m_%d") task = my.get_current_sobject() if not my.is_refresh: my.set_as_panel(top) entries = my.entries.get(task.get_code()) if isinstance(task, Task): parent = task.get_parent() if not parent: disabled = True else: disabled = False else: disabled = False if not entries: entries = {} table = Table() top.add(table) if my.use_straight_time: row_list = [my.ST_ROW] if my.show_overtime: row_list.append(my.OT_ROW) prefix_list = ['','ot'] else: row_list = [my.STT_ROW, my.ENT_ROW] prefix_list = ['stt','ent'] text = HiddenWdg(my.get_name() ) text.add_class("spt_data") table.add_color("color", "color") table.add_styles("width: %spx; float: left"%my.table_width) for row_to_draw in row_list: tr = table.add_row() tr.add_style('line-height','8px') td = table.add_blank_cell() offset_width = my.MONTH_WIDTH + my.LEFT_WIDTH+8 td.add_style("min-width: %spx" % offset_width) td.add(text) # go through each day and draw an input for overtime total_hours_st = 0 total_hours_ot = 0 search_key = task.get_search_key() # Add a label to indicate if the row is straight time or overtime time_prefix = '' if row_to_draw == my.OT_ROW: time_prefix = 'ot' div = DivWdg() div.add("OT") div.add_styles('text-align: right; margin-right: 4px') td.add(div) elif row_to_draw == my.STT_ROW: time_prefix = 'stt' div = DivWdg() div.add("ST") div.add_styles('text-align: right; margin: 0 4px 4px 0') td.add(div) elif row_to_draw == my.ENT_ROW: time_prefix = 'ent' div = DivWdg() div.add("ET") div.add_styles('text-align: right; margin: 0 4px 4px 0') td.add(div) for idx, day in enumerate(days): day_wdg = DivWdg() day_wdg.add(day) td = table.add_cell() td.add_style("width: %spx" % my.day_width) text = TextWdg('%sday_%s' % (time_prefix, day)) if disabled: text.set_option('read_only','true') text.set_attr('disabled','disabled') td.add(text) text.add_class('spt_day%s' % (time_prefix)) text.add_styles("width: %spx;text-align: right;padding-left: 2px" %(my.day_width-2)) #text.add_styles("width: 100%;text-align: right;padding-left: 2px") if day == today: text.add_style("border: solid 1px black") else: text.add_border() week_day = my.weekday_dict[idx] if week_day in ['Sat','Sun']: # MAIN: Overtime, weekend if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[-15,0,5]) else: text.add_color("background", "background2", modifier= [0,15,20]) text.add_style("margin: 0px 1px") if row_to_draw == my.OT_ROW: text.add_attr('input_field_type', 'ot') else: text.add_attr('input_field_type', 'st') if my.kwargs.get('show_all_users')=='true': text.set_option('read_only','true') #TODO: while we may have multiple entries per task, we will only use the latest one here # for now, making the UI cleaner # if a corresponding entry exists, display its value entry_list_dict = entries.get(day) daily_sum = 0 value = 0 entry_list = [] if entry_list_dict: row_key = my.ROW_DICT.get(row_to_draw) entry_list = entry_list_dict.get(row_key) if entry_list: for entry in entry_list: # Check if there is something in the category column. category = entry.get_value("category") if row_to_draw == my.OT_ROW: # Skip if the category field does not have a 'ot' indicated. if not category: print "Warning this work_hour entry has no category [%s]" % entry.get_code() continue # Check if there exist a value in the straight_time column value, delta = my.get_time_value(entry, row_to_draw) if value: text.set_value(value) text.add_attr('orig_input_value', value) if row_to_draw == my.OT_ROW: total_hours_ot += float(delta) else: total_hours_st += float(delta) daily_sum += delta # we only use value instead of the sum "daily_sum" for now if row_to_draw == my.OT_ROW: my.summary_ot[idx].update({search_key: daily_sum}) else: my.summary_st[idx].update({search_key: daily_sum}) script = ''' var orig_value = bvr.src_el.getAttribute("orig_input_value"); var input_field_type = bvr.src_el.getAttribute("input_field_type"); bvr.src_el.value = bvr.src_el.value.strip(); if (bvr.src_el.value == '') { if (orig_value) { bvr.src_el.value = 0; } else { return; } } else if (bvr.src_el.value == orig_value) { return; } bvr.prefix_list.splice( bvr.prefix_list.indexOf(bvr.time_prefix),1) var other_time_prefix = bvr.prefix_list[0]; spt.work_hour.update_total(bvr, '.spt_day' + bvr.time_prefix); // register this as changed item var all_top_el = bvr.src_el.getParent(".spt_work_hours_top"); var values1 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ bvr.time_prefix, false); var values2 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ other_time_prefix, false); // Merge values from straight time and overtime fields in values variable. for (var attr in values2) { values1[attr] = values2[attr]; } for (val in values1) { if (values1[val] && isNaN(values1[val])) { spt.error('You have non-numeric values in your work hours. Please correct it: ' + values[val]); return; } } delete values1.data; var value_wdg = all_top_el.getElement(".spt_data"); var value = JSON.stringify(values1); value_wdg.value = value; var layout = bvr.src_el.getParent(".spt_layout"); var version = layout.getAttribute("spt_version"); if (version == "2") { spt.table.set_layout(layout); spt.table.accept_edit(all_top_el, value, false); } else { var cached_data = {}; spt.dg_table.edit.widget = all_top_el; spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data ); } ''' # accept on pressing Enter behavior = { 'type': 'keydown', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' if (evt.key=='enter') { %s } '''%script} text.add_behavior(behavior) behavior = { 'type': 'blur', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' %s '''%script} text.add_behavior(behavior) text = TextWdg("total") td = table.add_cell(text) td.add_style("width: 35px") text.add_border() text.add_attr('spt_total', '.spt_total%s' % (time_prefix)) text.add_class('spt_total%s' % (time_prefix)) text.add_styles("width: %spx; text-align: right; padding-right: 3px"%my.day_width) text.set_attr("readonly", "readonly") # MAIN: Overtime, total. if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[5,-15,0]) if total_hours_ot: text.set_value("%0.1f" % total_hours_ot) my.summary_ot[7].update({search_key: total_hours_ot}) else: text.add_color("background", "background2", modifier=[20,0,15]) if total_hours_st: text.set_value("%0.1f" % total_hours_st) my.summary_st[7].update({search_key: total_hours_st}) td = table.add_blank_cell() td.add_style('width: 100%') return top
def get_display(my): current = my.get_current_sobject() if current.is_insert(): widget = Widget() parent_key = my.get_option('parent_key') if parent_key: parent = SearchKey.get_by_search_key(parent_key) if parent: widget.add(SpanWdg(parent.get_code())) else: # use the project as the parent parent = Project.get() widget.add(SpanWdg("Project: %s" % parent.get_code())) #raise TacticException('Task creation aborted since parent is undetermined. Please check the configuration that generates this table.') text = HiddenWdg(my.get_input_name()) text.set_option('size', '40') text.set_value(parent_key) widget.add(text) return widget else: search_type = current.get_value('search_type') if not search_type: return "No parent type" widget = Widget() parent = current.get_parent() if parent: widget.add(parent.get_code()) return widget # What is this look up code for? text = TextWdg(my.get_input_name()) behavior = { 'type': 'keyboard', 'kbd_handler_name': 'DgTableMultiLineTextEdit' } text.add_behavior(behavior) widget.add(text) icon = IconButtonWdg("Look up", IconWdg.ZOOM) icon.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var options = { title: '%s', class_name: 'tactic.ui.panel.ViewPanelWdg' }; var args = { search_type: '%s', view: 'list' }; spt.popup.get_widget( {}, {options: options, args: args} ); ''' % (search_type, search_type) }) widget.add(icon) return widget
def handle_dir_or_item(self, item_div, dirname, basename): spath = "%s/%s" % (dirname, basename) #fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename)) fspath = "%s/%s" % (dirname, basename) md5 = self.md5s.get(fspath) changed = False context = None error_msg = None snapshot = None file_obj = self.checked_in_paths.get(fspath) if not file_obj: if fspath.startswith(self.base_dir): rel = fspath.replace("%s/" % self.base_dir, "") file_obj = self.checked_in_paths.get(rel) if file_obj != None: snapshot_code = file_obj.get_value("snapshot_code") snapshot = self.snapshots_dict.get(snapshot_code) if not snapshot: # last resort snapshot = file_obj.get_parent() if snapshot: context = snapshot.get_value("context") item_div.add_attr("spt_snapshot_code", snapshot.get_code()) snapshot_md5 = file_obj.get_value("md5") item_div.add_attr("spt_md5", snapshot_md5) item_div.add_attr( "title", "Checked-in as: %s" % file_obj.get_value("file_name")) if md5 and md5 != snapshot_md5: item_div.add_class("spt_changed") changed = True else: error_msg = 'snapshot not found' status = None if file_obj != None: if changed: check = IconWdg("Checked-In", IconWdg.ERROR, width=12) status = "changed" else: check = IconWdg("Checked-In", IconWdg.CHECK, width=12) status = "same" item_div.add_color("color", "color", [0, 0, 50]) else: check = None item_div.add_style("opacity: 0.8") status = "unversioned" if check: item_div.add(check) check.add_style("float: left") check.add_style("margin-left: -16px") check.add_style("margin-top: 4px") # add the file name filename_div = DivWdg() item_div.add(filename_div) filename_div.add(basename) file_info_div = None if snapshot and status != 'unversioned': file_info_div = SpanWdg() filename_div.add(file_info_div) if error_msg: filename_div.add(' (%s)' % error_msg) filename_div.add_style("float: left") filename_div.add_style("overflow: hidden") filename_div.add_style("width: 65%") # DEPRECATED """ checkbox = CheckboxWdg("check") checkbox.add_style("display: none") checkbox.add_class("spt_select") checkbox.add_style("float: right") checkbox.add_style("margin-top: 1px") item_div.add(checkbox) """ subcontext_val = '' cat_input = None is_select = True if self.context_options: context_sel = SelectWdg("context") context_sel.add_attr('title', 'context') context_sel.set_option("show_missing", False) context_sel.set_option("values", self.context_options) item_div.add_attr("spt_context", self.context_options[0]) cat_input = context_sel input_cls = 'spt_context' else: if self.subcontext_options in [['(main)'], ['(auto)'], []]: is_select = False #subcontext = TextWdg("subcontext") subcontext = HiddenWdg("subcontext") subcontext.add_class("spt_subcontext") elif self.subcontext_options == ['(text)']: is_select = False subcontext = TextWdg("subcontext") subcontext.add_class("spt_subcontext") else: is_select = True subcontext = SelectWdg("subcontext", bs=False) subcontext.set_option("show_missing", False) subcontext.set_option("values", self.subcontext_options) #subcontext.add_empty_option("----") cat_input = subcontext input_cls = 'spt_subcontext' if self.subcontext_options == [ '(main)' ] or self.subcontext_options == ['(auto)']: subcontext_val = self.subcontext_options[0] subcontext.set_value(subcontext_val) item_div.add_attr("spt_subcontext", subcontext_val) elif context: parts = context.split("/") if len(parts) > 1: # get the actual subcontext value subcontext_val = "/".join(parts[1:]) # identify a previous "auto" check-in and preselect the item in the select if is_select and subcontext_val not in self.subcontext_options: subcontext_val = '(auto)' elif isinstance(cat_input, HiddenWdg): subcontext_val = '' # the Text field will adopt the subcontext value of the last check-in subcontext.set_value(subcontext_val) item_div.add_attr("spt_subcontext", subcontext_val) elif self.subcontext_options: # handles file which may have previous strict checkin subcontext_val = self.subcontext_options[0] item_div.add_attr("spt_subcontext", subcontext_val) else: if is_select: if self.subcontext_options: subcontext_val = self.subcontext_options[0] #subcontext_val = '(auto)' cat_input.set_value(subcontext_val) else: subcontext_val = '' item_div.add_attr("spt_subcontext", subcontext_val) item_div.add(cat_input) cat_input.add_behavior({ 'type': 'click_up', 'propagate_evt': False, 'cbjs_action': ''' bvr.src_el.focus(); ''' }) # on selecting in the UI, it will be visible again cat_input.add_style("display: none") cat_input.add_class("spt_subcontext") cat_input.add_style("float: right") cat_input.add_style("width: 70px") cat_input.add_style("margin-top: -1px") cat_input.add_style("font-size: 10px") # it needs to be 18px at least for selected value visible cat_input.add_style("height: 18px") # we depend on the attribute cuz sometimes we go by the initialized value # since they are not drawn cat_input.add_behavior({ 'type': 'change', 'cbjs_action': ''' var el = bvr.src_el.getParent('.spt_dir_list_item'); el.setAttribute("%s", bvr.src_el.value); ''' % input_cls }) if file_info_div: if subcontext_val in ['(auto)', '(main)', '']: file_info_div.add( " <i style='font-size: 9px; opacity: 0.6'>(v%s)</i>" % snapshot.get_value("version")) else: file_info_div.add( " <i style='font-size: 9px; opacity: 0.6'>(v%s - %s)</i>" % (snapshot.get_value("version"), subcontext_val))
def get_display(self): current = self.get_current_sobject() if current.is_insert(): widget = Widget() parent_key = self.get_option('parent_key') if parent_key: parent = SearchKey.get_by_search_key(parent_key) if parent: widget.add(SpanWdg(parent.get_code())) else: # use the project as the parent parent = Project.get() widget.add(SpanWdg("Project: %s" % parent.get_code())) #raise TacticException('Task creation aborted since parent is undetermined. Please check the configuration that generates this table.') text = HiddenWdg(self.get_input_name()) text.set_option('size','40') text.set_value(parent_key) widget.add(text) return widget else: search_type = current.get_value('search_type') if not search_type: return "No parent type" widget = Widget() parent = current.get_parent() if parent: widget.add(parent.get_code()) return widget # What is this look up code for? text = TextWdg(self.get_input_name()) behavior = { 'type': 'keyboard', 'kbd_handler_name': 'DgTableMultiLineTextEdit' } text.add_behavior(behavior) widget.add(text) icon = IconButtonWdg("Look up", IconWdg.ZOOM) icon.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var options = { title: '%s', class_name: 'tactic.ui.panel.ViewPanelWdg' }; var args = { search_type: '%s', view: 'list' }; spt.popup.get_widget( {}, {options: options, args: args} ); ''' % (search_type, search_type) } ) widget.add(icon) return widget