def get_display(my): widget = DivWdg() table = Table() table.add_attr('class','my_preferences_wdg') prefs = my.login_obj.get('twog_preferences').split(',') for pref in prefs: if pref not in [None,'']: kv = pref.split('=') key = kv[0] val = kv[1] table.add_row() desc = table.add_cell(my.key_dict[key]) desc.add_attr('nowrap','nowrap') this_sel = SelectWdg(key) this_sel.add_attr('id',key) this_sel.add_style('width: 100px;') this_sel.append_option('True','true') this_sel.append_option('False','false') this_sel.set_value(val) table.add_cell(this_sel) table.add_row() t2 = Table() t2.add_row() t2.add_cell() tc = t2.add_cell('<input type="button" name="Save My Preferences" value="Save My Preferences"/>') tc.add_attr('width', '50px') tc.add_behavior(my.get_save_preferences()) t2.add_cell() table.add_cell(t2) widget.add(table) return widget
def get_sel(my, id_name, arr, default, alpha_sort): this_sel = SelectWdg(id_name) this_sel.add_attr('id',id_name) if default not in arr and default not in [None,'']: arr.append(default) if alpha_sort: arr.sort() arr2 = [] for a in arr: arr2.append(a) this_sel.append_option('--Select--','') for a in arr2: this_sel.append_option(a,a) this_sel.set_value(default) return this_sel
def get_display(my): return '' search_types = 'MMS/discipline.MMS/product_type'.split(".") top = DivWdg() parents = None for search_type in search_types: if not parents: search = Search(search_type) sobjects = search.get_sobjects() columns = search.get_columns() column = columns[1] select = SelectWdg(search_type) select.set_option("values", [x.get_id() for x in sobjects] ) select.set_option("labels", [x.get_value(column) for x in sobjects] ) top.add(select) else: for parent in parents: search = Search(search_type) search.add_relationship_filter(parent) sobjects = search.get_sobjects() if not sobjects: continue columns = search.get_columns() column = columns[1] values = [x.get_id() for x in sobjects] labels = [x.get_value(column) for x in sobjects] select = SelectWdg(search_type) select.add_attr("spt_input_key", parent.get_id() ) select.set_option("values", values ) select.set_option("labels", labels ) top.add(select) parents = sobjects return top
def get_display(self): return '' search_types = 'MMS/discipline.MMS/product_type'.split(".") top = DivWdg() parents = None for search_type in search_types: if not parents: search = Search(search_type) sobjects = search.get_sobjects() columns = search.get_columns() column = columns[1] select = SelectWdg(search_type) select.set_option("values", [x.get_id() for x in sobjects] ) select.set_option("labels", [x.get_value(column) for x in sobjects] ) top.add(select) else: for parent in parents: search = Search(search_type) search.add_relationship_filter(parent) sobjects = search.get_sobjects() if not sobjects: continue columns = search.get_columns() column = columns[1] values = [x.get_id() for x in sobjects] labels = [x.get_value(column) for x in sobjects] select = SelectWdg(search_type) select.add_attr("spt_input_key", parent.get_id() ) select.set_option("values", values ) select.set_option("labels", labels ) top.add(select) parents = sobjects return top
def get_statuses_select_from_task_pipe(self, status, pipe_code, search_type, task_sk, user_is_scheduler): # gets the processes from the sobject's pipeline statuses = ['Pending', 'Ready', 'On Hold', 'Client Response', 'Fix Needed', 'Rejected', 'In Progress', 'DR In Progress', 'Amberfin01 In Progress', 'Amberfin02 In Progress', 'BATON In Progress', 'Export In Progress', 'Need Buddy Check', 'Buddy Check In Progress', 'Completed'] task_select = SelectWdg('task_stat_select') task_select.add_attr('old_status', status) task_select.add_attr('id', 'status_{0}'.format(task_sk)) if len(statuses) > 0: task_select.append_option('--Select--', '') task_select.set_value(status) for stat in statuses: if stat == 'On Hold' and user_is_scheduler: task_select.append_option(stat, stat) if stat == 'Approved': task_select.append_option('Rejected', 'Rejected') task_select.append_option(stat, stat) if stat == 'Approved': task_select.append_option('Completed', 'Completed') return task_select
def get_display(my): top = DivWdg() top.add_class("spt_element_top") prefix = my.kwargs.get('prefix') # this should be name to be consistent with the BaseInputWdg interface widget_name = my.kwargs.get('name') if not widget_name: widget_name = 'data_type' display_options = my.kwargs.get('display_options') if not display_options: display_options = {} option = my.kwargs.get('option') if not option: option = {} # get the current value option_name = option.get('name') widget_type = display_options.get(option_name) select = SelectWdg(widget_name) top.add(select) default = option.get('default') if default: select.set_value(default) else: select.add_empty_option('-- Select --') values = option.get('values') if not values: values = 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode', select.set_option('values', values) if widget_type: select.set_value(widget_type) select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var value = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_element_top"); var selects = top.getElements(".spt_format"); for (var i = 0; i < selects.length; i++) { var type = selects[i].getAttribute("spt_type"); if (value == type) { selects[i].setStyle("display", ""); selects[i].removeAttribute("disabled"); } else { selects[i].setStyle("display", "none"); selects[i].setAttribute("disabled", "disabled"); selects[i].value = ''; } } ''' } ) selects_values = { '': [], 'integer': ['-1234', '-1,234'], 'float': ['-1234.12', '-1,234.12'], 'percent': ['-13%', '-12.95%'], 'currency': ['-$1,234', '-$1,234.00', '-$1,234.--', '-1,234.00 CAD', '($1,234.00)', ], 'date': ['31/12/99', 'December 31, 1999', '31/12/1999', 'Dec 31, 99', 'Dec 31, 1999', '31 Dec, 1999', '31 December 1999', 'Fri, Dec 31, 99', 'Fri 31/Dec 99', 'Fri, December 31, 1999', 'Friday, December 31, 1999', '12-31', '99-12-31', '1999-12-31', '12-31-1999', '12/99', '31/Dec', 'December', '52', 'DATE'], 'time': ['13:37', '13:37:46', '01:37 PM', '01:37:46 PM', '31/12/99 13:37', '31/12/99 13:37:46', 'DATETIME'], 'scientific': ['-1.23E+03', '-1.234E+03'], 'boolean': ['true|false', 'True|False', 'Checkbox'], 'timecode': ['MM:SS.FF', 'MM:SS:FF', 'MM:SS', 'HH:MM:SS.FF', 'HH:MM:SS:FF', 'HH:MM:SS'], } for key, select_values in selects_values.items(): # skip the empty key if not key: continue # options for each if prefix: select = SelectWdg("%s|format" % prefix, for_display=False) else: select = SelectWdg("format", for_display=False) select.add_class("spt_format") select.add_attr("spt_type", key) value = display_options.get('format') if key == '': select.add_style("display", "none") elif widget_type == key: select.set_value(value) else: select.add_style("display", "none") select.add_attr("disabled", "disabled") select.set_option("values", select_values) select.add_empty_option("-- Format --") top.add(select) if key == 'timecode': if prefix: select = SelectWdg("%s|fps" % prefix, for_display=False) else: select = SelectWdg("fps", for_display=False) select.add_class("spt_format") select.add_attr("spt_type", key) value = display_options.get('fps') if widget_type == key: select.set_value(value) else: select.add_style("display", "none") select.set_option("values", "12|24|25|30|60") select.set_option("labels", "12 fps|24 fps|25 fps|30 fps|60 fps") select.add_empty_option("-- fps --") top.add(select) return top
def get_display(my): from tactic_client_lib import TacticServerStub work_order_code = '' user = '' sources = '' platform = '' colors = {'0': '#828282', '1': '#b8b8b8'} types = ['Internal','Client','Platform'] if 'work_order_code' in my.kwargs.keys(): work_order_code = str(my.kwargs.get('work_order_code')) if 'user' in my.kwargs.keys(): user = str(my.kwargs.get('user')) if 'sources' in my.kwargs.keys(): sources = my.kwargs.get('sources') if 'platform' in my.kwargs.keys(): platform = my.kwargs.get('platform') delim1 = 'ZXuO#' delim2 = '|||' sources_arr = sources.split(delim1) widget = DivWdg() table = Table() table.add_attr('class','alert_popup_%s' % work_order_code) color_count = 0 for source in sources_arr: entry_tbl = Table() if source != 'MISSING SOURCE': source_code, barcode, location = source.split(delim2); else: source_code = 'MISSING SOURCE' barcode = 'MISSING SOURCE' location = 'UNKNOWN' row00 = entry_tbl.add_row() nw00 = entry_tbl.add_cell('<b>Issue Type for <u>%s</u>:</b> ' % barcode) nw00.add_attr('nowrap','nowrap') type_sel = SelectWdg('report_type_%s' % work_order_code) for t in types: type_sel.append_option(t,t) type_sel.add_attr('code', source_code) type_sel.add_attr('name', barcode) nw0 = entry_tbl.add_cell(type_sel) nw0.add_attr('align','left') nw0.add_attr('width','100%s' % '%') row1 = entry_tbl.add_row() nw1 = entry_tbl.add_cell('<b>File Path for <u>%s</u> (if applicable)</b>' % barcode) nw1.add_attr('nowrap','nowrap') row2 = entry_tbl.add_row() nw11 = entry_tbl.add_cell('<textarea cols="45" rows="2" class="report_file_%s" code="%s" name="%s">%s</textarea>' % (work_order_code, source_code, barcode, location)) row3 = entry_tbl.add_row() nw2 = entry_tbl.add_cell('<b>Description of Issue for <u>%s</u></b>' % barcode) nw2.add_attr('nowrap','nowrap') row4 = entry_tbl.add_row() nw21 = entry_tbl.add_cell('<textarea cols="45" rows="10" class="report_operator_description_%s" code="%s" name="%s"></textarea>' % (work_order_code, source_code, barcode)) row1.add_style('background-color: %s;' % colors[str(color_count % 2)]) row2.add_style('background-color: %s;' % colors[str(color_count % 2)]) row3.add_style('background-color: %s;' % colors[str(color_count % 2)]) row4.add_style('background-color: %s;' % colors[str(color_count % 2)]) row00.add_style('background-color: %s;' % colors[str(color_count % 2)]) nw1.add_attr('colspan','2') nw11.add_attr('colspan','2') nw2.add_attr('colspan','2') nw21.add_attr('colspan','2') color_count = color_count + 1 table.add_row() table.add_cell(entry_tbl) table.add_row() submit_cell = table.add_cell('<input type="button" value="Submit Alert(s)"/>') submit_cell.add_attr('align','center') submit_cell.add_behavior(my.alert_problems(work_order_code, user, platform)) widget.add(table) return widget
def get_display(my): table = Table() tbl_id = "manual_proj_adder_top_%s" % my.order_sk table.add_attr("id", tbl_id) table.add_attr("search_type", "twog/proj") table.add_attr("order_sk", my.order_sk) table.add_attr("parent_sk", my.parent_sk) table.add_attr("title_code", my.title_code) table.add_attr("user_name", Environment.get_user_name()) ctbl = Table() ctbl.add_row() c1 = ctbl.add_cell("Project Names (Comma Delimited)") c1.add_attr("nowrap", "nowrap") ctbl.add_row() ctbl.add_cell('<textarea cols="100" rows="5" id="comma_names" order_sk="%s"></textarea>' % my.order_sk) table.add_row() table.add_cell(ctbl) table.add_row() mid = table.add_cell("-- OR --") mid.add_attr("align", "center") ntbl = Table() ntbl.add_row() ntbl.add_cell("Name: ") ntbl.add_cell('<input type="text" id="primary_name" style="width: 200px;"/>') n1 = ntbl.add_cell(" From Number: ") n1.add_attr("nowrap", "nowrap") ntbl.add_cell('<input type="text" id="from_number" style="width: 50px;"/>') n2 = ntbl.add_cell(" To Number: ") n2.add_attr("nowrap", "nowrap") ntbl.add_cell('<input type="text" id="to_number" style="width: 50px;"/>') table.add_row() table.add_cell(ntbl) ptbl = Table() start_date = CalendarInputWdg("start_date") start_date.set_option("show_time", "true") start_date.set_option("show_activator", "true") start_date.set_option("display_format", "MM/DD/YYYY HH:MM") start_date.set_option("time_input_default", "5:00 PM") ptbl.add_row() ptbl.add_cell("Start Date: ") ptbl.add_cell(start_date) due_date = CalendarInputWdg("due_date") due_date.set_option("show_time", "true") due_date.set_option("show_activator", "true") due_date.set_option("display_format", "MM/DD/YYYY HH:MM") due_date.set_option("time_input_default", "5:00 PM") ptbl.add_row() ptbl.add_cell("Due Date: ") ptbl.add_cell(due_date) btbl = Table() etbl = Table() platform_search = Search("twog/platform") platform_search.add_order_by("name desc") platforms = platform_search.get_sobjects() plat_sel = SelectWdg("platform") plat_sel.add_attr("id", "platform") plat_sel.append_option("--Select--", "") for p in platforms: plat_sel.append_option(p.get_value("name"), p.get_value("name")) ptbl.add_row() ptbl.add_cell("Priority: ") ptbl.add_cell('<input type="text" id="priority" style="width: 50px;"/>') ptbl.add_row() ptbl.add_cell("Platform: ") ptbl.add_cell(plat_sel) proj_search = Search("twog/proj") proj_search.add_filter("title_code", my.parent_code) proj_search.add_order_by("order_in_pipe") projs = proj_search.get_sobjects() btbl.add_row() p1 = btbl.add_cell("<u>First Proj Comes After</u>") p1.add_attr("nowrap", "nowrap") p2 = btbl.add_cell("<u>Last Proj Leads To</u>") p2.add_attr("nowrap", "nowrap") fromtbl = Table() for p in projs: fromtbl.add_row() checker = CustomCheckboxWdg( name="from_check", value_field=p.get_value("code"), id=p.get_value("code"), checked="false", dom_class="from_check", code=p.get_value("code"), ) fromtbl.add_cell(checker) fromtbl.add_cell("%s (%s)" % (p.get_value("process"), p.get_value("code"))) totbl = Table() for p in projs: totbl.add_row() checker = CustomCheckboxWdg( name="to_check", value_field=p.get_value("code"), checked="false", id=p.get_value("code"), dom_class="to_check", code=p.get_value("code"), ) totbl.add_cell(checker) totbl.add_cell("%s (%s)" % (p.get_value("process"), p.get_value("code"))) btbl.add_row() btbl.add_cell(fromtbl) btbl.add_cell(totbl) table.add_row() table.add_cell(ptbl) table.add_row() table.add_cell(btbl) table.add_row() table.add_cell(etbl) table.add_row() stbl = Table() stbl.add_row() s1 = stbl.add_cell(" ") s1.add_attr("width", "40%") saction = stbl.add_cell('<input type="button" value="Create Projects"/>') saction.add_behavior(my.get_save()) s2 = stbl.add_cell(" ") s2.add_attr("width", "40%") ss = table.add_cell(stbl) ss.add_attr("colspan", "2") ss.add_attr("align", "center") widget = DivWdg() widget.add(table) return widget
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): widget = DivWdg() table = Table() table.add_attr('class','client_deliverable_wdg') table.add_row() table2 = Table() table2.add_style('border-spacing: 5px;') table2.add_style('border-collapse: separate;') table2.add_row() c1 = table2.add_cell('Order Code:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('order_code') tb1.add_attr('id','order_code') tb1.add_attr('disabled','disabled') tb1.set_value(my.sob['order_code']) table2.add_cell(tb1) c1 = table2.add_cell('PO Number:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('po_number') tb1.add_attr('id','po_number') tb1.add_attr('disabled','disabled') tb1.set_value(my.sob['po_number']) table2.add_cell(tb1) c1 = table2.add_cell('Title Code:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('title_code') tb1.add_attr('id','title_code') tb1.add_attr('disabled','disabled') tb1.set_value(my.sob['title_code']) table2.add_cell(tb1) c1 = table2.add_cell('Platform:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('platform') tb1.add_attr('id','platform') tb1.add_attr('disabled','disabled') tb1.set_value(my.sob['platform']) table2.add_cell(tb1) c1 = table2.add_cell('Client:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('client_name') tb1.add_attr('id','client_name') tb1.add_attr('disabled','disabled') tb1.set_value(my.sob['client_name']) table2.add_cell(tb1) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Title Source(s):') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('original_source_code') tb1.add_attr('id','original_source_code') tb1.add_attr('disabled','disabled') tb1.add_style('width','200px') tb1.set_value(my.sob['original_source_code']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','2') c1 = table2.add_cell('Title Source Barcodes(s):') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('original_source_barcode') tb1.add_attr('id','original_source_barcode') tb1.add_attr('disabled','disabled') tb1.add_style('width','200px') tb1.set_value(my.sob['original_source_barcode']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','2') c1 = table2.add_cell('Ancestors:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('ancestors') tb1.add_attr('id','ancestors') tb1.add_attr('disabled','disabled') tb1.add_style('width','300px') tb1.set_value(my.sob['ancestors']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','3') table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Destination:') c1.add_attr('nowrap','nowrap') destination_sel = SelectWdg('destination') destination_sel.add_attr('id','destination') destination_sel.append_option('--Select--','') for c in my.all_clients: destination_sel.append_option(c.get('name'),c.get('name')) if my.sob.get('destination') == None: my.sob['destination'] = '' destination_sel.set_value(my.sob.get('destination')) table2.add_cell(destination_sel) if my.sob.get('record_id') in [None,'']: next_id_sob = my.server.eval("@SOBJECT(twog/global_resource['name','sony_next_unique_id'])")[0] next_id = int(next_id_sob.get('description')) my.sob['record_id'] = next_id my.server.update(next_id_sob.get('__search_key__'), {'description': next_id + 1}, triggers=False) c1 = table2.add_cell('Record ID:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('record_id') tb1.add_attr('id','record_id') tb1.set_value(my.sob['record_id']) table2.add_cell(tb1) c1 = table2.add_cell('Alpha ID:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('alpha_id') tb1.add_attr('id','alpha_id') tb1.set_value(my.sob['alpha_id']) table2.add_cell(tb1) c1 = table2.add_cell('Client Barcode:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('client_barcode') tb1.add_attr('id','client_barcode') tb1.set_value(my.sob['client_barcode']) table2.add_cell(tb1) c1 = table2.add_cell('Release Number:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('release_number') tb1.add_attr('id','release_number') tb1.set_value(my.sob['release_number']) table2.add_cell(tb1) table2.add_row() c1 = table2.add_cell('Title ID:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('title_id') tb1.add_attr('id','title_id') tb1.set_value(my.sob['title_id']) table2.add_cell(tb1) c1 = table2.add_cell('Title Name:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('title_name') tb1.add_attr('id','title_name') tb1.set_value(my.sob['title_name']) table2.add_cell(tb1) c1 = table2.add_cell('Title Type:') c1.add_attr('nowrap','nowrap') title_type_sel = SelectWdg('title_type') title_type_sel.add_attr('id','title_type') title_type_sel.append_option('--Select--','') for type in my.title_types: title_type_sel.append_option(type,type) if my.sob.get('title_type') == None: my.sob['title_type'] = '' title_type_sel.set_value(my.sob.get('title_type')) table2.add_cell(title_type_sel) c1 = table2.add_cell('Title Comment:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('title_comment') tb1.add_attr('id','title_comment') tb1.add_style('width','300px') tb1.set_value(my.sob['title_comment']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','3') table2.add_row() c1 = table2.add_cell('Clip Id:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('clip_id') tb1.add_attr('id','clip_id') tb1.set_value(my.sob['clip_id']) table2.add_cell(tb1) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Trailer Number:') c1.add_attr('nowrap','nowrap') trailer_number_sel = SelectWdg('trailer_number') trailer_number_sel.add_attr('id','trailer_number') trailer_number_sel.append_option('--Select--','') for number in my.trailer_numbers: trailer_number_sel.append_option(number,number) if my.sob.get('trailer_number') == None: my.sob['trailer_number'] = '' trailer_number_sel.set_value(my.sob.get('trailer_number')) table2.add_cell(trailer_number_sel) c1 = table2.add_cell('Trailer Rev Number:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('trailer_rev_number') tb1.add_attr('id','trailer_rev_number') tb1.set_value(my.sob['trailer_rev_number']) table2.add_cell(tb1) c1 = table2.add_cell('Trailer Type:') c1.add_attr('nowrap','nowrap') trailer_type_sel = SelectWdg('trailer_type') trailer_type_sel.add_attr('id','trailer_type') trailer_type_sel.append_option('--Select--','') for type in my.trailer_types: trailer_type_sel.append_option(type,type) if my.sob.get('trailer_type') == None: my.sob['trailer_type'] = '' trailer_type_sel.set_value(my.sob.get('trailer_type')) table2.add_cell(trailer_type_sel) c1 = table2.add_cell('Trailer Version:') c1.add_attr('nowrap','nowrap') trailer_version_sel = SelectWdg('trailer_version') trailer_version_sel.add_attr('id','trailer_version') trailer_version_sel.append_option('--Select--','') for version in my.trailer_versions: trailer_version_sel.append_option(version,version) if my.sob.get('trailer_version') == None: my.sob['trailer_version'] = '' trailer_version_sel.set_value(my.sob.get('trailer_version')) table2.add_cell(trailer_version_sel) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Language Audio:') c1.add_attr('nowrap','nowrap') language_audio_sel = SelectWdg('language_audio') language_audio_sel.append_option('--Select--','') for language in my.audio_languages: language_audio_sel.append_option(language,language) if my.sob.get('language_audio') == None: my.sob['language_audio'] = '' language_audio_sel.set_value(my.sob.get('language_audio')) table2.add_cell(language_audio_sel) c1 = table2.add_cell('Language Subtitled:') c1.add_attr('nowrap','nowrap') language_subtitled_sel = SelectWdg('language_subtitled') language_subtitled_sel.add_attr('id','language_subtitled') language_subtitled_sel.append_option('--Select--','') for language in my.subtitle_languages: language_subtitled_sel.append_option(language,language) if my.sob.get('language_subtitled') == None: my.sob['language_subtitled'] = '' language_subtitled_sel.set_value(my.sob.get('language_subtitled')) table2.add_cell(language_subtitled_sel) c1 = table2.add_cell('Language Text:') c1.add_attr('nowrap','nowrap') language_text_sel = SelectWdg('language_text') language_text_sel.add_attr('id','language_text') language_text_sel.append_option('--Select--','') for language in my.text_languages: language_text_sel.append_option(language,language) if my.sob.get('language_text') == None: my.sob['language_text'] = '' language_text_sel.set_value(my.sob.get('language_text')) table2.add_cell(language_text_sel) c1 = table2.add_cell('Original Language:') c1.add_attr('nowrap','nowrap') original_language_sel = SelectWdg('original_language') original_language_sel.add_attr('id','original_language') original_language_sel.append_option('--Select--','') for language in my.original_languages: original_language_sel.append_option(language,language) if my.sob.get('original_language') == None: my.sob['original_language'] = '' original_language_sel.set_value(my.sob.get('original_language')) table2.add_cell(original_language_sel) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Source:') c1.add_attr('nowrap','nowrap') source_sel = SelectWdg('source') source_sel.add_attr('id','source') source_sel.append_option('--Select--','') for s in my.sources: source_sel.append_option(s,s) if my.sob.get('source') == None: my.sob['source'] = '' source_sel.set_value(my.sob.get('source')) table2.add_cell(source_sel) c1 = table2.add_cell('Audio Config:') c1.add_attr('nowrap','nowrap') audio_config_sel = SelectWdg('audio_config') audio_config_sel.add_attr('id','audio_config') audio_config_sel.append_option('--Select--','') for a in my.audio_configs: audio_config_sel.append_option(a,a) if my.sob.get('audio_config') == None: my.sob['audio_config'] = '' audio_config_sel.set_value(my.sob.get('audio_config')) table2.add_cell(audio_config_sel) c1 = table2.add_cell('Master Audio Config:') c1.add_attr('nowrap','nowrap') master_audio_config_sel = SelectWdg('master_audio_config') master_audio_config_sel.add_attr('id','master_audio_config') master_audio_config_sel.append_option('--Select--','') for a in my.audio_configs: master_audio_config_sel.append_option(a,a) if my.sob.get('master_audio_config') == None: my.sob['master_audio_config'] = '' master_audio_config_sel.set_value(my.sob.get('master_audio_config')) table2.add_cell(master_audio_config_sel) c1 = table2.add_cell('Run Time Calc:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('run_time_calc') tb1.add_attr('id','run_time_calc') tb1.set_value(my.sob['run_time_calc']) #Might want to add the : timestamp js here -- from qc reports table2.add_cell(tb1) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Narrative:') c1.add_attr('nowrap','nowrap') narrative_sel = SelectWdg('narrative') narrative_sel.add_attr('id','narrative') narrative_sel.append_option('--Select--','') for n in my.narratives: narrative_sel.append_option(n,n) if my.sob.get('narrative') == None: my.sob['narrative'] = '' narrative_sel.set_value(my.sob.get('narrative')) table2.add_cell(narrative_sel) c1 = table2.add_cell('Texted/Textless:') c1.add_attr('nowrap','nowrap') tt_sel = SelectWdg('texted_textless') tt_sel.add_attr('id','texted_textless') tt_sel.append_option('--Select--','') for t in my.texted_textless: tt_sel.append_option(t,t) if my.sob.get('texted_textless') == None: my.sob['texted_textless'] = '' tt_sel.set_value(my.sob.get('texted_textless')) table2.add_cell(tt_sel) c1 = table2.add_cell('Aspect Ratio:') c1.add_attr('nowrap','nowrap') aspect_ratio_sel = SelectWdg('aspect_ratio') aspect_ratio_sel.add_attr('id','aspect_ratio') aspect_ratio_sel.append_option('--Select--','') for a in my.aspect_ratios: aspect_ratio_sel.append_option(a,a) if my.sob.get('aspect_ratio') == None: my.sob['aspect_ratio'] = '' aspect_ratio_sel.set_value(my.sob.get('aspect_ratio')) table2.add_cell(aspect_ratio_sel) c1 = table2.add_cell('Standard:') c1.add_attr('nowrap','nowrap') standard_sel = SelectWdg('standard') standard_sel.add_attr('id','standard') standard_sel.append_option('--Select--','') for s in my.standards: standard_sel.append_option(s,s) if my.sob.get('standard') == None: my.sob['standard'] = '' standard_sel.set_value(my.sob.get('standard')) table2.add_cell(standard_sel) table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('HD:') c1.add_attr('nowrap','nowrap') hd_sel = SelectWdg('hd') hd_sel.add_attr('id','hd') hd_sel.append_option('--Select--','') for s in my.hd: hd_sel.append_option(s,s) if my.sob.get('hd') == None: my.sob['hd'] = '' hd_sel.set_value(my.sob.get('hd')) table2.add_cell(hd_sel) # c1 = table2.add_cell('Genre:') # c1.add_attr('nowrap','nowrap') # tb1 = TextWdg('genre') # tb1.add_attr('id','genre') # tb1.set_value(my.sob['genre']) # table2.add_cell(tb1) c1 = table2.add_cell('MPAA:') c1.add_attr('nowrap','nowrap') mpaa_sel = SelectWdg('mpaa') mpaa_sel.add_attr('id','mpaa') mpaa_sel.append_option('--Select--','') for s in my.mpaa: mpaa_sel.append_option(s,s) if my.sob.get('mpaa') == None: my.sob['mpaa'] = '' mpaa_sel.set_value(my.sob.get('mpaa')) table2.add_cell(mpaa_sel) c1 = table2.add_cell('MPAA Ratings:') c1.add_attr('nowrap','nowrap') mpaa_ratings_sel = SelectWdg('mpaa_ratings') mpaa_ratings_sel.add_attr('id','mpaa_ratings') mpaa_ratings_sel.append_option('--Select--','') for s in my.mpaa_ratings: mpaa_ratings_sel.append_option(s,s) if my.sob.get('mpaa_ratings') == None: my.sob['mpaa_ratings'] = '' mpaa_ratings_sel.set_value(my.sob.get('mpaa_ratings')) table2.add_cell(mpaa_ratings_sel) table2.add_row() table2.add_cell(table2.hr()) # table2.add_row() # # c1 = table2.add_cell('UK Ratings:') # c1.add_attr('nowrap','nowrap') # uk_ratings_sel = SelectWdg('uk_ratings') # uk_ratings_sel.add_attr('id','uk_ratings') # uk_ratings_sel.append_option('--Select--','') # for s in my.uk_ratings: # uk_ratings_sel.append_option(s,s) # if my.sob.get('uk_ratings') == None: # my.sob['uk_ratings'] = '' # uk_ratings_sel.set_value(my.sob.get('uk_ratings')) # table2.add_cell(uk_ratings_sel) # # c1 = table2.add_cell('Australia Ratings:') # c1.add_attr('nowrap','nowrap') # australia_ratings_sel = SelectWdg('australia_ratings') # australia_ratings_sel.add_attr('id','australia_ratings') # australia_ratings_sel.append_option('--Select--','') # for s in my.australia_ratings: # australia_ratings_sel.append_option(s,s) # if my.sob.get('australia_ratings') == None: # my.sob['australia_ratings'] = '' # australia_ratings_sel.set_value(my.sob.get('australia_ratings')) # table2.add_cell(australia_ratings_sel) # # c1 = table2.add_cell('Germany Ratings:') # c1.add_attr('nowrap','nowrap') # germany_ratings_sel = SelectWdg('germany_ratings') # germany_ratings_sel.add_attr('id','germany_ratings') # germany_ratings_sel.append_option('--Select--','') # for s in my.germany_ratings: # germany_ratings_sel.append_option(s,s) # if my.sob.get('germany_ratings') == None: # my.sob['germany_ratings'] = '' # germany_ratings_sel.set_value(my.sob.get('germany_ratings')) # table2.add_cell(germany_ratings_sel) # # table2.add_row() # table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('Legal Rights:') c1.add_attr('nowrap','nowrap') legal_rights_sel = SelectWdg('legal_right') legal_rights_sel.add_attr('id','legal_right') legal_rights_sel.append_option('--Select--','') for s in my.legal_rights: legal_rights_sel.append_option(s,s) if my.sob.get('legal_right') == None: my.sob['legal_right'] = '' legal_rights_sel.set_value(my.sob.get('legal_right')) table2.add_cell(legal_rights_sel) from tactic.ui.widget import CalendarInputWdg, ActionButtonWdg ld = table2.add_cell('Legal Date: ') ld.add_attr('nowrap','nowrap') legal_date = CalendarInputWdg("legal_date") if my.sob.get('legal_date') not in [None,'']: legal_date.set_option('default', my.fix_date(my.sob.get('legal_date'))) legal_date.set_option('show_activator', True) legal_date.set_option('show_confirm', False) #legal_date.set_option('show_text', True) legal_date.set_option('show_today', False) #legal_date.set_option('read_only', False) legal_date.add_attr('id','legal_date') table2.add_cell(legal_date) c1 = table2.add_cell('Legal Comment:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('legal_comment') tb1.add_attr('id','legal_comment') tb1.add_style('width','300px') tb1.set_value(my.sob['legal_comment']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','3') table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('HE Creative Comment:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('he_creative_comment') tb1.add_attr('id','he_creative_comment') tb1.add_style('width','300px') tb1.set_value(my.sob['he_creative_comment']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','3') table2.add_row() table2.add_cell(table2.hr()) table2.add_row() c1 = table2.add_cell('URL:') c1.add_attr('nowrap','nowrap') tb1 = TextWdg('url') tb1.add_attr('id','url') tb1.add_style('width','300px') tb1.set_value(my.sob['url']) c2 = table2.add_cell(tb1) c2.add_attr('colspan','3') table2.add_row() table2.add_cell(table2.hr()) table2.add_row() #ta1 = table2.add_cell('Cast Info:') #table2.add_row() #ta1 = table2.add_cell('<textarea cols="90" rows="10" class="spt_input" name="cast_info" id="cast_info">%s</textarea>' % my.sob.get('cast_info')) #table2.add_row() submit = table2.add_cell('<input type="button" value="Submit"/>') sk = '' if not my.is_insert: sk = my.sob.get('__search_key__') submit.add_behavior(my.get_submit(sk)) if not my.is_insert: xml = table2.add_cell('<input type="button" value="Generate XML"/>') xml.add_behavior(my.get_xml(sk)) table.add_cell(table2) widget.add(table) return widget
def get_display(my): top = DivWdg() top.add_class("spt_element_top") prefix = my.kwargs.get('prefix') # this should be name to be consistent with the BaseInputWdg interface widget_name = my.kwargs.get('name') if not widget_name: widget_name = 'data_type' display_options = my.kwargs.get('display_options') if not display_options: display_options = {} option = my.kwargs.get('option') if not option: option = {} # get the current value option_name = option.get('name') widget_type = display_options.get(option_name) select = SelectWdg(widget_name) top.add(select) default = option.get('default') if default: select.set_value(default) else: select.add_empty_option('-- Select --') values = option.get('values') if not values: values = 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode', select.set_option('values', values) if widget_type: select.set_value(widget_type) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var value = bvr.src_el.value; var top = bvr.src_el.getParent(".spt_element_top"); var selects = top.getElements(".spt_format"); for (var i = 0; i < selects.length; i++) { var type = selects[i].getAttribute("spt_type"); if (value == type) { selects[i].setStyle("display", ""); selects[i].removeAttribute("disabled"); } else { selects[i].setStyle("display", "none"); selects[i].setAttribute("disabled", "disabled"); selects[i].value = ''; } } ''' }) selects_values = { '': [], 'integer': ['-1234', '-1,234'], 'float': ['-1234.12', '-1,234.12'], 'percent': ['-13%', '-12.95%'], 'currency': ['-$1,234', '-$1,234.00', '-$1,234.--', '-1,234.00 CAD'], 'date': [ '31/12/99', 'December 31, 1999', '31/12/1999', 'Dec 31, 99', 'Dec 31, 1999', '31 Dec, 1999', '31 December 1999', 'Fri, Dec 31, 99', 'Fri 31/Dec 99', 'Fri, December 31, 1999', 'Friday, December 31, 1999', '12-31', '99-12-31', '1999-12-31', '12-31-1999', '12/99', '31/Dec', 'December', '52', 'DATE' ], 'time': [ '13:37', '13:37:46', '01:37 PM', '01:37:46 PM', '31/12/99 13:37', '31/12/99 13:37:46', 'DATETIME' ], 'scientific': ['-1.23E+03', '-1.234E+03'], 'boolean': ['true|false', 'True|False', 'Checkbox'], 'timecode': [ 'MM:SS.FF', 'MM:SS:FF', 'MM:SS', 'HH:MM:SS.FF', 'HH:MM:SS:FF', 'HH:MM:SS' ], } for key, select_values in selects_values.items(): # skip the empty key if not key: continue # options for each if prefix: select = SelectWdg("%s|format" % prefix, for_display=False) else: select = SelectWdg("format", for_display=False) select.add_class("spt_format") select.add_attr("spt_type", key) value = display_options.get('format') if key == '': select.add_style("display", "none") elif widget_type == key: select.set_value(value) else: select.add_style("display", "none") select.add_attr("disabled", "disabled") select.set_option("values", select_values) select.add_empty_option("-- Format --") top.add(select) if key == 'timecode': if prefix: select = SelectWdg("%s|fps" % prefix, for_display=False) else: select = SelectWdg("fps", for_display=False) select.add_class("spt_format") select.add_attr("spt_type", key) value = display_options.get('fps') if widget_type == key: select.set_value(value) else: select.add_style("display", "none") select.set_option("values", "12|24|25|30|60") select.set_option("labels", "12 fps|24 fps|25 fps|30 fps|60 fps") select.add_empty_option("-- fps --") top.add(select) return top
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(my): table = Table() tbl_id = 'manual_wo_adder_top_%s' % my.order_sk table.add_attr("id", tbl_id) table.add_attr('search_type', 'twog/work_order') table.add_attr('order_sk', my.order_sk) table.add_attr('parent_sk', my.parent_sk) table.add_attr('title_code', my.title_code) table.add_attr('user_name', Environment.get_user_name()) ctbl = Table() ctbl.add_row() c1 = ctbl.add_cell('Work Order Names (Comma Delimited)') c1.add_attr('nowrap', 'nowrap') ctbl.add_row() ctbl.add_cell('<textarea cols="100" rows="5" id="comma_names" order_sk="%s"></textarea>' % my.order_sk) table.add_row() table.add_cell(ctbl) table.add_row() mid = table.add_cell('-- OR --') mid.add_attr('align', 'center') ntbl = Table() ntbl.add_row() ntbl.add_cell('Name: ') ntbl.add_cell('<input type="text" id="primary_name" style="width: 200px;"/>') n1 = ntbl.add_cell(' From Number: ') n1.add_attr('nowrap', 'nowrap') ntbl.add_cell('<input type="text" id="from_number" style="width: 50px;"/>') n2 = ntbl.add_cell(' To Number: ') n2.add_attr('nowrap', 'nowrap') ntbl.add_cell('<input type="text" id="to_number" style="width: 50px;"/>') table.add_row() table.add_cell(ntbl) ptbl = Table() start_date = CalendarInputWdg('start_date') start_date.set_option('show_time', 'true') start_date.set_option('show_activator', 'true') start_date.set_option('display_format', 'MM/DD/YYYY HH:MM') start_date.set_option('time_input_default', '5:00 PM') ptbl.add_row() ptbl.add_cell("Start Date: ") ptbl.add_cell(start_date) due_date = CalendarInputWdg('due_date') due_date.set_option('show_time', 'true') due_date.set_option('show_activator', 'true') due_date.set_option('display_format', 'MM/DD/YYYY HH:MM') due_date.set_option('time_input_default', '5:00 PM') ptbl.add_row() ptbl.add_cell("Due Date: ") ptbl.add_cell(due_date) btbl = Table() etbl = Table() g_search = Search("sthpw/login_group") g_search.add_where("\"login_group\" not in ('user','client')") g_search.add_order_by('login_group') groups = g_search.get_sobjects() group_sel = SelectWdg('assigned_login_group') group_sel.add_attr('id', 'assigned_login_group') group_sel.append_option('--Select--', '') for group in groups: group_sel.append_option(group.get_value('login_group'), group.get_value('login_group')) user_search = Search("sthpw/login") user_search.add_filter('location', 'internal') user_search.add_filter('license_type', 'user') user_search.add_order_by('login') users = user_search.get_sobjects() user_sel = SelectWdg("assigned") user_sel.add_attr('id', 'assigned') user_sel.append_option('--Select--', '') for u in users: user_sel.append_option(u.get_value('login'), u.get_value('login')) ptbl.add_row() p1 = ptbl.add_cell('Work Group: ') p1.add_attr('nowrap', 'nowrap') ptbl.add_cell(group_sel) ptbl.add_row() ptbl.add_cell('Assigned: ') ptbl.add_cell(user_sel) ptbl.add_row() p2 = ptbl.add_cell('Title Id Number: ') p2.add_attr('nowrap', 'nowrap') ptbl.add_cell('<input type="text" id="title_id_num" style="width: 200px;"/>') ptbl.add_row() p3 = ptbl.add_cell('Estimated Work Hours: ') p3.add_attr('nowrap', 'nowrap') ptbl.add_cell('<input type="text" id="estimated_work_hours" style="width: 50px;"/>') ptbl.add_row() p4 = ptbl.add_cell('Instructions: ') p4.add_attr('valign', 'top') ptbl.add_cell('<textarea cols="100" rows="20" id="instructions"></textarea>') wo_search = Search("twog/work_order") wo_search.add_filter('proj_code', my.parent_code) wo_search.add_order_by('order_in_pipe') wos = wo_search.get_sobjects() btbl.add_row() p5 = btbl.add_cell('<u>First WO Comes After</u>') p5.add_attr('nowrap', 'nowrap') p6 = btbl.add_cell('<u>Last WO Leads To</u>') p6.add_attr('nowrap', 'nowrap') fromtbl = Table() for p in wos: fromtbl.add_row() checker = CustomCheckboxWdg(name='from_check', value_field=p.get_value('code'), id=p.get_value('code'), checked='false', dom_class='from_check', code=p.get_value('code')) fromtbl.add_cell(checker) f1 = fromtbl.add_cell("%s (%s)" % (p.get_value('process'), p.get_value('code'))) f1.add_attr('nowrap', 'nowrap') totbl = Table() for p in wos: totbl.add_row() checker = CustomCheckboxWdg(name='to_check', value_field=p.get_value('code'), checked='false', id=p.get_value('code'), dom_class='to_check', code=p.get_value('code')) totbl.add_cell(checker) t1 = totbl.add_cell("%s (%s)" % (p.get_value('process'), p.get_value('code'))) t1.add_attr('nowrap', 'nowrap') btbl.add_row() btbl.add_cell(fromtbl) btbl.add_cell(totbl) table.add_row() table.add_cell(ptbl) table.add_row() table.add_cell(btbl) table.add_row() table.add_cell(etbl) table.add_row() stbl = Table() stbl.add_row() s1 = stbl.add_cell(' ') s1.add_attr('width', '40%') saction = stbl.add_cell('<input type="button" value="Create Work Orders"/>') saction.add_behavior(my.get_save()) s2 = stbl.add_cell(' ') s2.add_attr('width', '40%') ss = table.add_cell(stbl) ss.add_attr('colspan', '2') ss.add_attr('align', 'center') widget = DivWdg() widget.add(table) return widget
def get_display(self): top = DivWdg() element_name = self.kwargs.get('element_name') config_view = self.kwargs.get("config_view") display_class = config_view.get_display_handler(element_name) display_options = config_view.get_display_options(element_name) element_attr = config_view.get_element_attributes(element_name) name = element_attr.get('name') edit = element_attr.get('edit') title = element_attr.get('title') width = element_attr.get('width') # add the name from pyasm.web import Table table = Table() top.add(table) table.add_row() td = table.add_cell("Name: ") td.add_style("padding: 5px") name_text = SpanWdg(name) name_text.add_style('font-weight: bold') name_text.add_attr("size", "50") table.add_cell(name_text) table.add_row_cell("<br/>Element Attributes:<br/>") # add the title table.add_row() td = table.add_cell("Title: ") td.add_style("padding: 5px") title_text = TextWdg("title") title_text.add_attr("size", "50") if title: title_text.set_value(title) table.add_cell(title_text) # add the width table.add_row() td = table.add_cell("Width: ") td.add_style("padding: 5px") width_text = TextWdg("width") if width: width_text.set_value(width) width_text.add_attr("size", "50") table.add_cell(width_text) # add the editable table.add_row() td = table.add_cell("Editable: ") td.add_style("padding: 5px") editable_text = CheckboxWdg("editable") editable_text.add_attr("size", "50") table.add_cell(editable_text) table.add_row_cell("<br/>Display:<br/>") # add the widget table.add_row() td = table.add_cell("Widget: ") td.add_style("padding: 5px") widget_select = SelectWdg("widget") options = ['Expression'] widget_select.set_option("values", options) widget_select.add_empty_option("-- Select --") #widget_select.set_value(display_class) table.add_cell(widget_select) table.add_row_cell(" - or -") # add the class table.add_row() td = table.add_cell("Class Name: ") td.add_style("padding: 5px") class_text = TextWdg("class_name") class_text.set_value(display_class) class_text.add_attr("size", "50") table.add_cell(class_text) # introspect the widget if not display_class: display_class = "pyasm.widget.SimpleTableElementWdg" #display_class = "tactic.ui.panel.ViewPanelWdg" from pyasm.common import Common import_stmt = Common.get_import_from_class_path(display_class) if import_stmt: exec(import_stmt) else: exec("from pyasm.widget import %s" % display_class) try: options = eval("%s.get_args_options()" % display_class) except AttributeError: try: info = eval("%s.get_args_keys()" % display_class) except AttributeError: return top options = [] for key, description in info.items(): option = { 'name': key, 'type': 'TextWdg', 'description': description } options.append(option) ''' options = [ { 'name': 'expression', 'type': 'TextWdg', 'size': '50' }, ] ''' if options: top.add("<br/>Widget Options:<br/>") table = Table() top.add(table) for option in options: table.add_row() name = option.get('name') title = name type = option.get('type') td = table.add_cell("%s: " % title) td.add_style("padding: 5px") value = display_options.get(name) if type == 'SelectWdg': edit_wdg = SelectWdg("%s|value" % name) edit_wdg.add_style("width: 250px") edit_wdg.add_empty_option('-- Select --') values = option.get('values') edit_wdg.set_option('values', values) if value: edit_wdg.set_value(value) elif type == 'TextAreaWdg': edit_wdg = TextAreaWdg("%s|value" % name) if value: edit_wdg.set_value(value) edit_wdg.add_attr("cols", "60") edit_wdg.add_attr("rows", "3") else: edit_wdg = TextWdg("%s|value" % name) if value: edit_wdg.set_value(value) edit_wdg.add_style("width: 250px") table.add_cell(edit_wdg) return top
def get_display(my): person_code = '' person = None person_exists = False has_login = '******' is_disabled = 'false' is_employee = 'false' login_obj = None password = '' existing_login_name = '' if 'person_code' in my.kwargs.keys(): person_code = my.kwargs.get('person_code') person_s = Search("twog/person") person_s.add_filter('code',person_code) person = person_s.get_sobject() if person: person_exists = True login_name = person.get_value('login_name') if login_name not in [None,'']: login_s = Search("sthpw/login") login_s.add_filter('login',login_name) login_obj = login_s.get_sobject() if login_obj: has_login = '******' license_type = login_obj.get_value('license_type') password = login_obj.get_value('password') existing_login_name = login_obj.get_value('login') if license_type == 'disabled': is_disabled = 'true' if login_obj.get_value('location') == 'internal': is_employee = 'true' first_name = '' last_name = '' company_code = '' title = '' email = '' alternate_email = '' main_phone = '' work_phone = '' cell_phone = '' home_phone = '' fax = '' country = '' state = '' city = '' zip = '' street_address = '' suite = '' if person_exists: first_name = person.get_value('first_name') last_name = person.get_value('last_name') company_code = person.get_value('company_code') title = person.get_value('title') email = person.get_value('email') alternate_email = person.get_value('alternate_email') main_phone = person.get_value('main_phone') work_phone = person.get_value('work_phone') cell_phone = person.get_value('cell_phone') home_phone = person.get_value('home_phone') fax = person.get_value('fax') country = person.get_value('country') state = person.get_value('state') city = person.get_value('city') zip = person.get_value('zip') street_address = person.get_value('street_address') suite = person.get_value('suite') people_s = Search("twog/person") people_s.add_order_by('last_name') people_s.add_order_by('first_name') people = people_s.get_sobjects() peep_sel = SelectWdg("person_selector") peep_sel.add_attr('id','person_selector') peep_sel.append_option('--Create New Login--','NEW') for peep in people: peep_sel.append_option('%s, %s' % (peep.get_value('last_name'), peep.get_value('first_name')), peep.get_code()) if person_exists: peep_sel.set_value(person_code) peep_sel.add_behavior(my.switch_person()) company_s = Search("twog/company") company_s.add_order_by('name') companies = company_s.get_sobjects() comp_sel = SelectWdg('company_code') comp_sel.add_attr('id','company_code') comp_sel.append_option('--Select--','') for company in companies: comp_sel.append_option(company.get_value('name'), company.get_code()) if person_exists: comp_sel.set_value(company_code) country_sel = SelectWdg('country') country_sel.add_attr('id','country') country_sel.append_option('--Select--','') for country in my.countries: country_sel.append_option(country,country) if person_exists: my_country = person.get_value('country') if my_country in [None,'']: my_country = '' country_sel.set_value(my_country) state_sel = SelectWdg('state') state_sel.add_attr('id','state') state_sel.append_option('--Select--','') for state in my.states: state_sel.append_option(state,state) if person_exists: my_state = person.get_value('state') if my_state in [None,'']: my_state = '' state_sel.set_value(my_state) group_tbl = Table() group_tbl.add_row() group_tbl.add_cell("<b><u>GROUPS:</u></b>") login_gs = Search('sthpw/login_group') login_gs.add_order_by('login_group') login_groups = login_gs.get_sobjects() lgs = [] if has_login == 'true': my_lg_s = Search('sthpw/login_in_group') my_lg_s.add_filter('login',login_obj.get_value('login')) my_lgs = my_lg_s.get_sobjects() for ml in my_lgs: lgs.append(ml.get_value('login_group')) group_tbl.add_row() lcount = 0 for lg in login_groups: if lg.get_value('login_group') not in ['client','user','default']: if lcount % 7 == 0: group_tbl.add_row() this_group = 'false' if lg.get_value('login_group') in lgs: this_group = 'true' chk = CustomCheckboxWdg(name='group_check_%s' % lcount,value_field=lg.get_value('login_group'),id='group_check_%s' % lcount,checked=this_group,dom_class='group_check',text='%s:' % lg.get_value('login_group').upper(),text_spot='right',text_align='left',nowrap='nowrap',extra1=this_group) group_tbl.add_cell(chk) lcount = lcount + 1 group_tbl.add_row() group_tbl.add_cell(' ') widget = DivWdg() table = Table() table.add_attr('class','login_manager_wdg') lt = Table() ltop = Table() red_row = ltop.add_row() red_row.add_attr('id','red_row') red_row.add_style('background-color: #FF0000;') if 'login_name' in my.kwargs.keys(): ltop.add_cell("<b>Login Name: %s, Password: %s</b>" % (my.kwargs.get('login_name'), my.kwargs.get('login_pass'))) else: red_row.add_style('display: none;') ltop.add_row() emp_checker = CustomCheckboxWdg(name='is_employee',value_field='is_employee',id='is_employee',checked=is_employee,dom_class='is_employee',additional_js=my.switch_has_login(),extra1=is_employee) ltop.add_cell(emp_checker) ltop.add_cell('Is Employee?') ltop.add_cell(' ') login_checker = CustomCheckboxWdg(name='has_login',value_field='has_login',id='has_login',checked=has_login,dom_class='has_login',extra1=has_login,extra2=existing_login_name) ltop.add_cell(login_checker) ltop.add_cell('Enable Login?') ltop.add_cell(' ') disabled_checker = CustomCheckboxWdg(name='account_disabled',value_field='account_disabled',id='account_disabled',checked=is_disabled,dom_class='account_disabled',extra1=is_disabled) ltop.add_cell(disabled_checker) ltop.add_cell('Account Disabled?') group_row = ltop.add_row() group_row.add_attr('id','group_row') if is_employee != 'true': group_row.add_style('display: none;') gcell = ltop.add_cell(group_tbl) gcell.add_attr('colspan','7') lt.add_row() ltt = lt.add_cell(ltop) ltt.add_attr('colspan','2') lt.add_row() lt.add_cell('First Name: ') lt.add_cell(my.txtbox('first_name',first_name)) lt.add_row() lt.add_cell('Last Name: ') lt.add_cell(my.txtbox('last_name',last_name)) lt.add_row() lt.add_cell('Company: ') side_tbl = Table() side_tbl.add_row() side_tbl.add_cell(comp_sel) side_tbl.add_cell(" ") add_comp = side_tbl.add_cell('<input type="button" value="Add New Company"/>') add_comp.add_behavior(my.add_company()) lt.add_cell(side_tbl) lt.add_row() lt.add_cell('Title: ') lt.add_cell(my.txtbox('title',title)) lt.add_row() lt.add_cell('Email: ') lt.add_cell(my.txtbox('email',email)) lt.add_row() lt.add_cell('Alt Email: ') lt.add_cell(my.txtbox('alternate_email',alternate_email)) lt.add_row() lt.add_cell('Main Phone: ') lt.add_cell(my.txtbox('main_phone',main_phone)) lt.add_row() lt.add_cell('Work Phone: ') lt.add_cell(my.txtbox('work_phone',work_phone)) lt.add_row() lt.add_cell('Cell Phone: ') lt.add_cell(my.txtbox('cell_phone',cell_phone)) lt.add_row() lt.add_cell('Home Phone: ') lt.add_cell(my.txtbox('home_phone',home_phone)) lt.add_row() lt.add_cell('Fax: ') lt.add_cell(my.txtbox('fax',fax)) lt.add_row() lt.add_cell('Country: ') lt.add_cell(country_sel) lt.add_row() lt.add_cell('State: ') lt.add_cell(state_sel) lt.add_row() lt.add_cell('City: ') lt.add_cell(my.txtbox('city',city)) lt.add_row() lt.add_cell('Zip: ') lt.add_cell(my.txtbox('zip',zip)) lt.add_row() lt.add_cell('Street Address: ') lt.add_cell(my.txtbox('street_address',street_address)) lt.add_row() lt.add_cell('Suite: ') lt.add_cell(my.txtbox('suite',suite)) img = my.get_snapshot(person, login_obj) rt = Table() rt.add_attr('width','300px') rt.add_style('background-color: #ba4e33;') rt.add_style('height: 400px;') rt.add_row() img_cell = rt.add_cell(img) img_cell.add_attr('valign','top') img_cell.add_attr('align','center') selector_row = table.add_row() selector_row.add_attr('id','selector_row') select_tbl = Table() select_tbl.add_row() select_tbl.add_cell('Person: ') select_tbl.add_cell(peep_sel) select_cell = table.add_cell(select_tbl) select_cell.add_attr('colspan','3') select_cell.add_attr('align','center') table.add_row() top1 = table.add_cell(lt) top1.add_attr('valign','top') table.add_cell(' ') top2 = table.add_cell(rt) top2.add_attr('valign','top') table.add_row() save_butt = table.add_cell('<input type="button" value="Save/Create" />') save_butt.add_attr('colspan','3') save_butt.add_attr('align','center') save_butt.add_behavior(my.get_save()) widget.add(table) return widget
def get_display(my): user_name = my.kwargs.get('user') code = my.kwargs.get('code') sk = my.kwargs.get('sk') t_search = Search("twog/title") t_search.add_filter('order_code',code) titles = t_search.get_sobjects() widget = DivWdg() table = Table() table.add_attr('class','clone_titles_selector') # Select all or none toggle_behavior = {'css_class': 'clickme', 'type': 'click_up', 'cbjs_action': ''' try{ var checked_img = '<img src="/context/icons/custom/custom_checked.png"/>' var not_checked_img = '<img src="/context/icons/custom/custom_unchecked.png"/>' var top_el = spt.api.get_parent(bvr.src_el, '.clone_titles_selector'); inputs = top_el.getElementsByClassName('title_selector'); var curr_val = bvr.src_el.getAttribute('checked'); image = ''; if(curr_val == 'false'){ curr_val = false; image = not_checked_img; }else if(curr_val == 'true'){ curr_val = true; image = checked_img; } for(var r = 0; r < inputs.length; r++){ inputs[r].setAttribute('checked',curr_val); inputs[r].innerHTML = image; } } catch(err){ spt.app_busy.hide(); spt.alert(spt.exception.handler(err)); } '''} # Here need textbox for either an order code to clone to, or if the order code is invalid then create a new order with what is in the textbox as its name table2 = Table() table2.add_row() uto = table2.add_cell('<input type="button" value="Clone to Same Order"/>') uto.add_behavior(my.get_clone_here(code)) table2.add_row() # User can enter a new name, which will create a new order with that name and place the clones inside # Or user can provide an exiting order code, so the cloned titles will go into that one t22 = table2.add_cell('Order Code or New Name:') t22.add_attr('nowrap','nowrap') namer = table2.add_cell('<input type="text" id="clone_order_name"/>') charge_sel = SelectWdg("charge_sel") charge_sel.add_style('width: 120px;') charge_sel.add_attr('id','charge_sel') charges = ['New','Redo','Redo - No Charge'] # Allow the user to tell us whether this is a normal order, a redo, or a redo with no charge for ch in charges: charge_sel.append_option(ch,ch) table2.add_cell(' Type: ') table2.add_cell(charge_sel) table2.add_cell('Count: ') table2.add_cell('<input type="text" value="1" id="clone_order_count"/>') yn = SelectWdg('duplicate_order_vals') yn.add_style('width: 100px;') yn.append_option('No','No') yn.append_option('Yes','Yes') tac = table2.add_cell('Duplicate Order Values? ') tac.add_attr('nowrap','nowrap') table2.add_cell(yn) table.add_row() ncell = table.add_cell(table2) t2b = Table() t2b.add_attr('id','t2b') # Put the toggler in if there are more than 1 titles if len(titles) > 1: t2b.add_row() toggler = CustomCheckboxWdg(name='chk_clone_toggler',additional_js=toggle_behavior,value_field='toggler',id='selection_toggler',checked='false') t2b.add_row() t2b.add_cell(toggler) t2b.add_cell('<b><- Select/Deselect ALL</b>') table.add_row() table.add_cell(t2b) t3b = Table() t3b.add_attr('id','t3b') # Display list of titles to choose from for title in titles: t3b.add_row() t3b.add_row() tname = title.get_value('title') if title.get_value('episode') not in [None,'']: tname = '%s: %s' % (tname, title.get_value('episode')) checkbox = CustomCheckboxWdg(name='clone_title_%s' % title.get_code(),value_field=title.get_code(),checked='false',text=tname,text_spot='right',text_align='left',nowrap='nowrap',dom_class='title_selector') ck = t3b.add_cell(checkbox) cter = t3b.add_cell(' --- Count: ') # This is how many clones you want to add of each title inser = t3b.add_cell('<input type="text" value="1" id="clone_count_%s" style="width: 40px;"/>' % title.get_code()) table.add_row() table.add_cell(t3b) if len(titles) < 1: table.add_row() table.add_cell('There are no titles in this Order') table.add_row() go_butt = '' if len(titles) > 0: go_butt = table.add_cell('<input type="button" class="clone_titles" value="Clone"/>') go_butt.add_attr('sk',sk) go_butt.add_attr('search_type','twog/order') go_butt.add_attr('user',user_name) behavior = {'css_class': 'clickme', 'type': 'click_up', 'cbjs_action': ''' try{ var my_sk = '%s'; var my_user = '******'; var my_code = my_sk.split('code=')[1]; if(confirm("Do You Really Want To Clone These Titles?")){ var server = TacticServerStub.get(); current_order = server.eval("@SOBJECT(twog/order['code','" + my_code + "'])")[0]; var top_el = spt.api.get_parent(bvr.src_el, '.clone_titles_selector'); oname_input = top_el.getElementById('clone_order_name'); oname = oname_input.value; charge_type_el = top_el.getElementById('charge_sel'); charge_type = charge_type_el.value; redo = false; no_charge = false; if(charge_type.indexOf('Redo') != -1){ redo = true; if(charge_type.indexOf('No Charge') != -1){ no_charge = true; } } clone_order_count = top_el.getElementById('clone_order_count').value; if(isNaN(clone_order_count)){ alert("'" + clone_order_count + "' is not a number. Proceeding as if you entered '1' for the number of orders to create."); clone_order_count = 1; }else{ clone_order_count = Number(clone_order_count); } proceed = true; clone_type = ''; that_order = null; new_order = false; new_order_codes = ''; duplicate = false; if(oname == '' || oname == null){ //Just an alert to remind them they have to tell us where the title clones should go alert("You must enter an existing order code or a new order name to put the cloned titles in"); proceed = false; //}else if(oname.indexOf('ORDER') != -1){ }else if(/^ORDER([0-9]{5,})$/.test(oname)){ //If "ORDER" is in the name, assume that it is actually an order code if(clone_order_count != 1){ alert("You have indicated that you want these clones to go into " + clone_order_count + " new orders. However, we can't do that if you are specifying an order as well (" + oname + "). Please fix this and then try again."); proceed = false; } that_order = server.eval("@SOBJECT(twog/order['code','" + oname + "'])"); if(that_order.length == 1 && proceed){ that_order = that_order[0]; new_order_codes = that_order.code; proceed = true; clone_type = that_order.name + ' (' + that_order.code + ')'; alert("Cloning the selected titles to " + that_order.name + "(" + that_order.code + ")"); }else{ //Only proceed if we could find the order they wanted to attach the title clones to proceed = false; alert("Could not find the Order with code '" + oname + "'"); } }else if(proceed){ yes_no_els = top_el.getElementsByTagName('select'); for(var xp = 0; xp < yes_no_els.length; xp++){ if(yes_no_els[xp].getAttribute('name') == 'duplicate_order_vals'){ if(yes_no_els[xp].value == 'Yes'){ duplicate = true; } } } packet = {'client_code': current_order.client_code, 'client_name': current_order.client_name, 'classification': 'Bid', 'no_charge': no_charge, 'redo': redo, 'login': my_user}; if(duplicate){ packet['sap_po'] = current_order.sap_po; packet['sales_rep'] = current_order.sales_rep; packet['platform'] = current_order.platform; packet['client_rep'] = current_order.client_rep; packet['sales_rep'] = current_order.sales_rep; packet['start_date'] = current_order.start_date; packet['due_date'] = current_order.due_date; packet['expected_delivery_date'] = current_order.expected_delivery_date; packet['expected_price'] = current_order.expected_price; } for(var dr = 1; dr < clone_order_count + 1; dr++){ new_name = oname + ' ' + dr; clone_type = 'New Order: ' + oname; if(clone_order_count == 1){ new_name = oname; clone_type = 'New Orders (' + clone_order_count + '): ' + oname; } packet['name'] = new_name; that_order = server.insert('twog/order', packet); proceed = true; new_order = true; if(new_order_codes == ''){ new_order_codes = that_order.code; }else{ new_order_codes = new_order_codes + ',' + that_order.code; } } } if(proceed){ //Good to go... clone_titles = []; checks = top_el.getElementsByClassName('title_selector'); for(var r = 0; r < checks.length; r++){ //see which titles will be cloned, and which ones will not title_code = checks[r].getAttribute('value_field'); if(checks[r].getAttribute('checked') == 'true'){ clone_titles.push(title_code) } } //Get number of times per selected title that we want to clone each title counters = {}; for(var r = 0; r < clone_titles.length; r++){ this_count_el = top_el.getElementById('clone_count_' + clone_titles[r]); ccount = this_count_el.value; if(!isNaN(ccount)){ //If it is a number, give it that number counters[clone_titles[r]] = this_count_el.value; }else{ //If it isn't a number, just assume the user wants to clone it once counters[clone_titles[r]] = '1'; alert(clone_titles[r] + "'s " + ccount + " is not a number. Will clone only once."); } } if(confirm("Are You Sure You Want To Clone These " + clone_titles.length + " Titles to " + clone_type + "?")){ title_str = ''; //Create string like "TITLE12345[10],TITLE23456[2]" to pass to the TitleClonerCmd //Bracketed items are the number of times to clone the title for(var r = 0; r < clone_titles.length; r++){ title_code = clone_titles[r]; if(title_str == ''){ title_str = title_code + '[' + counters[title_code] + ']'; }else{ title_str = title_str + ',' + title_code + '[' + counters[title_code] + ']'; } } spt.app_busy.show("Creating Clones..."); //Here send the order and title info to the cloner wdg copy_attributes = 'false' if(duplicate){ copy_attributes = 'true'; } kwargs = {'order_code': new_order_codes, 'titles': title_str, 'user_name': my_user, 'no_charge': no_charge, 'redo': redo, 'copy_attributes': copy_attributes}; //now send to the cloning process thing = server.execute_cmd('manual_updaters.TitleClonerCmd', kwargs); if(clone_order_count == 1){ //Here load a new tab with the order getting the clones var class_name = 'order_builder.order_builder.OrderBuilder'; kwargs = { 'sk': that_order.__search_key__, 'user': my_user }; spt.tab.add_new('order_builder_' + that_order.code, 'Order Builder For ' + that_order.name, class_name, kwargs); }else{ alert("Please reload your list of orders in the order view. You will see your " + clone_order_count + " new cloned orders there."); } spt.popup.close(spt.popup.get_popup(bvr.src_el)); spt.app_busy.hide(); }else{ if(new_order && clone_order_count == 1){ server.retire_sobject(that_order.__search_key__); }else if(clone_order_count > 1){ code_split = new_order_codes.split(','); for(var ww = 0; ww < code_split.length; ww++){ server.retire_sobject(server.build_search_key('twog/order', code_split[ww])); } } } } } } catch(err){ spt.app_busy.hide(); spt.alert(spt.exception.handler(err)); //alert(err); } ''' % (sk, user_name)} #Add the clone behavior go_butt.add_behavior(behavior) widget.add(table) return widget
def get_display(my): top = DivWdg() element_name = my.kwargs.get('element_name') config_view = my.kwargs.get("config_view") display_class = config_view.get_display_handler(element_name) display_options = config_view.get_display_options(element_name) element_attr = config_view.get_element_attributes(element_name) name = element_attr.get('name') edit = element_attr.get('edit') title = element_attr.get('title') width = element_attr.get('width') # add the name from pyasm.web import Table table = Table() top.add(table) table.add_row() td = table.add_cell("Name: ") td.add_style("padding: 5px") name_text = SpanWdg(name) name_text.add_style('font-weight: bold') name_text.add_attr("size", "50") table.add_cell(name_text) table.add_row_cell("<br/>Element Attributes:<br/>") # add the title table.add_row() td = table.add_cell("Title: ") td.add_style("padding: 5px") title_text = TextWdg("title") title_text.add_attr("size", "50") if title: title_text.set_value(title) table.add_cell(title_text) # add the width table.add_row() td = table.add_cell("Width: ") td.add_style("padding: 5px") width_text = TextWdg("width") if width: width_text.set_value(width) width_text.add_attr("size", "50") table.add_cell(width_text) # add the editable table.add_row() td = table.add_cell("Editable: ") td.add_style("padding: 5px") editable_text = CheckboxWdg("editable") editable_text.add_attr("size", "50") table.add_cell(editable_text) table.add_row_cell("<br/>Display:<br/>") # add the widget table.add_row() td = table.add_cell("Widget: ") td.add_style("padding: 5px") widget_select = SelectWdg("widget") options = ['Expression'] widget_select.set_option("values", options) widget_select.add_empty_option("-- Select --") #widget_select.set_value(display_class) table.add_cell(widget_select) table.add_row_cell(" - or -") # add the class table.add_row() td = table.add_cell("Class Name: ") td.add_style("padding: 5px") class_text = TextWdg("class_name") class_text.set_value(display_class) class_text.add_attr("size", "50") table.add_cell(class_text) # introspect the widget if not display_class: display_class = "pyasm.widget.SimpleTableElementWdg" #display_class = "tactic.ui.panel.ViewPanelWdg" from pyasm.common import Common import_stmt = Common.get_import_from_class_path(display_class) if import_stmt: exec(import_stmt) else: exec("from pyasm.widget import %s" % display_class) try: options = eval("%s.get_args_options()" % display_class) except AttributeError: try: info = eval("%s.get_args_keys()" % display_class) except AttributeError: return top options = [] for key, description in info.items(): option = { 'name': key, 'type': 'TextWdg', 'description': description } options.append(option) ''' options = [ { 'name': 'expression', 'type': 'TextWdg', 'size': '50' }, ] ''' if options: top.add("<br/>Widget Options:<br/>") table = Table() top.add(table) for option in options: table.add_row() name = option.get('name') title = name type = option.get('type') td = table.add_cell( "%s: " % title ) td.add_style("padding: 5px") value = display_options.get(name) if type == 'SelectWdg': edit_wdg = SelectWdg("%s|value" % name) edit_wdg.add_style("width: 250px") edit_wdg.add_empty_option('-- Select --') values = option.get('values') edit_wdg.set_option('values', values) if value: edit_wdg.set_value(value) elif type == 'TextAreaWdg': edit_wdg = TextAreaWdg("%s|value" % name) if value: edit_wdg.set_value(value) edit_wdg.add_attr("cols", "60") edit_wdg.add_attr("rows", "3") else: edit_wdg = TextWdg("%s|value" % name) if value: edit_wdg.set_value(value) edit_wdg.add_style("width: 250px") table.add_cell(edit_wdg) return top