예제 #1
0
 def get_display(my):
     widget = DivWdg()
     table = Table()
     table.add_attr('class','scraper')
     table.add_row()
     tb = TextWdg('title_box')
     tb.add_attr('id','title_box')
     multiple_titles = None
     print "MY.TITLE_OF_SHOW = %s" % my.title_of_show
     if my.title_of_show not in [None,'']:
         tb.set_value(my.title_of_show)
         #poster_url_text = my.get_poster_url(my.title_of_show)
         #poster_url = poster_url_text.split('=')[1]
         multiple_titles = my.get_multiple_title_info(my.title_of_show)
     print "MULTIPLE_TITLES = %s" % multiple_titles
     tb.add_behavior(my.get_search())
     table.add_cell(tb)
     if multiple_titles not in [None,''] and len(multiple_titles) > 0:
         for m in multiple_titles:
             table.add_row()
             table.add_cell('<img src="%s"/>' % m['TopLevel']['poster'])
             mkeys = m.keys()
             for k in mkeys: 
                 table.add_row()
                 table.add_cell('<b><u>%s</u></b>' % k)
                 dudes = m[k]
                 dkeys = dudes.keys()
                 for d in dkeys:
                     table.add_row()
                     table.add_cell('%s: %s' % (d, dudes[d])) 
     widget.add(table)
     return widget
예제 #2
0
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id() )
      
        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);'''%(key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);'''%script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 
                'cbjs_action': script})

            select.set_option("values",options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 
                'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)
     
        return div
예제 #3
0
    def get_info_wdg(my):

        div = DivWdg()

        div.add("<b>Create a share</b>")
        div.add("<br/>" * 2)

        table = Table()
        div.add(table)
        table.add_style("margin-left: 15px")

        table.add_row()
        td = table.add_cell("Share Code: ")
        td.add_style("vertical-align: top")
        text = TextWdg("code")
        table.add_cell(text)
        text.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            var value = bvr.src_el.value;
            if (!value) {
                return;
            }
            var server = TacticServerStub.get();
            var expr = "@SOBJECT(sthpw/sync_server['code','"+value+"'])";
            var test = server.eval(expr);
            if (test.length > 0) {
                spt.alert("Share ["+value+"] already exists.");
                bvr.src_el.value = "";
                bvr.src_el.focus();
            }
            '''
        })
        tr, td = table.add_row_cell()
        msg_div = DivWdg()
        td.add(msg_div)
        msg_div.add(
            "The share code is used as a prefix for all transactions and allows TACTIC to separate transactions from each location.  By convention, these codes should be a short initial (ie: ABC)."
        )
        msg_div.add_style("margin: 10px 20px 20px 20px")

        table.add_row()
        table.add_row_cell("&nbsp;")

        table.add_row()
        td = table.add_cell("Description: ")
        td.add_style("vertical-align: top")
        text = TextAreaWdg("description")
        td = table.add_cell(text)

        #table.add_row()
        #table.add_cell("Auth Ticket: ")
        #text = TextWdg("ticket")
        #table.add_cell(text)

        return div
예제 #4
0
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id())

        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);''' % (key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);''' % script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 'cbjs_action': script})

            select.set_option("values", options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)

        return div
 def txtbox(my, name, val, code, old_val, width='200px', js='no'):
     txt = TextWdg(name)
     txt.add_attr('id', name)
     txt.add_attr('code', code)
     txt.add_attr('old_val', old_val)
     txt.add_style('width: %s;' % width)
     txt.set_value(val)
     if js == 'yes':
         txt.add_behavior(my.get_nums_only())
     return txt
 def txtbox(my, name, val, code, old_val, width='200px', js='no'):
     txt = TextWdg(name)
     txt.add_attr('id', name)
     txt.add_attr('code', code)
     txt.add_attr('old_val', old_val)
     txt.add_style('width: %s;' % width)
     txt.set_value(val)
     if js == 'yes':
         txt.add_behavior(my.get_nums_only())
     return txt
예제 #7
0
 def get_display(my):
     from pyasm.search import Search
     #from tactic_client_lib import TacticServerStub
     barcode = ''
     sources = []
     bad_sources = []
     if 'barcode' in my.kwargs.keys():
         barcode = my.kwargs.get('barcode')
         tracker_s = Search("twog/location_tracker")
         tracker_s.add_filter('location_barcode',barcode)
         trackers = tracker_s.get_sobjects()
         #print "BARCODE = %s" % barcode
         #print "LEN TRACKERS = %s" % len(trackers)
         for t in trackers:
             tdate = t.get('timestamp')
             source_barcode = t.get('source_barcode')
             other_tracks = Search("twog/location_tracker")
             other_tracks.add_filter('source_barcode',source_barcode)
             other_tracks.add_filter('timestamp',tdate, op=">")
             others = other_tracks.get_sobjects()
             if len(others) == 0:
                 source_s = Search("twog/source")
                 source_s.add_filter('barcode',source_barcode)
                 source = source_s.get_sobject()
                 if source:
                     if source.get_value('in_house') in [True,'true','True',1,'1']:
                         sources.append(source)
                 else:
                     bad_sources.append({'barcode': source_barcode, 'title': 'UNKNOWN SOURCE'})
     
     table = Table()
     table.add_attr('class','location_inventory_wdg')
     table.add_row()
     bc = TextWdg('nextbc')
     bc.add_attr('id', 'location_inventory_txtbox')
     bc.add_behavior(my.get_entry_bvr())
     bc.set_value(barcode)
     table.add_cell(bc)
     #print "LEN SOURCES = %s" % len(sources)
     if len(sources) > 0:
         table.add_row()
         table.add_cell("<b>TOTAL: %s (UNKNOWN: %s)</b>" % (len(sources), len(bad_sources)))
     for source in sources:
         table.add_row()
         table.add_cell('Barcode: %s, Code: %s, Name: %s: %s' % (source.get_value('barcode'), source.get_code(), source.get_value('title'), source.get_value('episode')))
     if len(bad_sources) > 0:
         table.add_row()
         table.add_cell("<b>UNKNOWN SOURCES</b>")
         for b in bad_sources:
             table.add_row()
             table.add_cell('Barcode: %s, Name: %s' % (b.get('barcode'), b.get('title')))
     widget = DivWdg()
     widget.add(table)
     return widget
예제 #8
0
    def get_display(my):

        raise Exception("tactic.widget.ColorInputWdg is deprecated")

        color_div = DivWdg()
        color_div.add_style("z-index: 1000")
        # color_div.add_style("float: left")
        import random

        number = random.randint(1, 1000)
        rainbow_id = "rainbow_%s" % number

        color_div.add(
            """
        <img id="%s" src="/context/spt_js/mooRainbow/rainbow.png" alt="[r]" width="16" height="16" />
        """
            % rainbow_id
        )
        # <input id="myInput" name="myInput" type="text" size="13" />

        text = TextWdg(my.get_name())
        text.set_id("myInput")
        behavior = {"type": "keyboard", "kbd_handler_name": "DgTableMultiLineTextEdit"}
        text.add_behavior(behavior)
        color_div.add(text)

        color_div.add_behavior(
            {
                "type": "load",
                "cbjs_action": """
            var r = new MooRainbow('%s', {
                startColor: [58, 142, 246],
                imgPath:    '/context/spt_js/mooRainbow/images/',
                onComplete: function(color) { $(myInput).value=color.hex; }
            });
            """
                % rainbow_id,
            }
        )

        return color_div
예제 #9
0
    def get_display(self):

        raise Exception("tactic.widget.ColorInputWdg is deprecated")

        color_div = DivWdg()
        color_div.add_style("z-index: 1000")
        #color_div.add_style("float: left")
        import random
        number = random.randint(1, 1000)
        rainbow_id = "rainbow_%s" % number

        color_div.add('''
        <img id="%s" src="/context/spt_js/mooRainbow/rainbow.png" alt="[r]" width="16" height="16" />
        ''' % rainbow_id)
        #<input id="selfInput" name="selfInput" type="text" size="13" />

        text = TextWdg(self.get_name())
        text.set_id("selfInput")
        behavior = {
            'type': 'keyboard',
            'kbd_handler_name': 'DgTableMultiLineTextEdit'
        }
        text.add_behavior(behavior)
        color_div.add(text)


        color_div.add_behavior( { 
            "type": "load",
            "cbjs_action": '''
            var r = new MooRainbow('%s', {
                startColor: [58, 142, 246],
                imgPath:    '/context/spt_js/mooRainbow/images/',
                onComplete: function(color) { $(myInput).value=color.hex; }
            });
            ''' % rainbow_id
        } )



        return color_div
예제 #10
0
    def get_display(my):   
        table = Table()
        my.movement_code = my.kwargs.get('movement_code')
        table.add_attr('class', 'movement_add_source')
        table.add_attr('movement_id','')
        table.add_attr('movement_sk','')
        table.add_attr('movement_code','')
        top_row = table.add_row()
        top_row.add_style('background-color: #eaeaea;')
        if my.movement_code not in ['',None]:
            ms = MovementScripts(movement_code=my.movement_code)
            barcode_text_wdg = TextWdg('source_barcode_insert')
            barcode_text_wdg.add_attr('id','source_barcode_insert')
            barcode_text_wdg.add_behavior(ms.get_barcode_insert_behavior())
            table.add_cell('Barcode: ')
            table.add_cell(barcode_text_wdg)

        widget = DivWdg()
        widget.add(table)
        if my.movement_code not in ['',None]:
            widget.add_behavior(my.get_on_load_js())
        return widget
예제 #11
0
    def get_display(self):

        search_type = self.kwargs.get("search_type")
        view = self.kwargs.get("view")
        assert search_type
        assert view

        #self.handle_search()

        config_xml = self.kwargs.get("config_xml")
        if not config_xml:
            config_xml = "<config/>"

        # extraneous variables inherited from TableLayoutWdg
        self.edit_permission = False

        top = DivWdg()
        top.add_class("spt_freeform_layout_top")
        self.set_as_panel(top)
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("height: 100%")
        top.add_style("width: 100%")
        border_color = top.get_color("border")
        top.add_style("border: dashed 1px %s" % border_color)

        is_refresh = self.kwargs.get("is_refresh")

        config = WidgetConfig.get(view=view, xml=config_xml)

        # define canvas
        canvas = top
        canvas.add_class("spt_freeform_canvas")
        canvas.add_style("position: relative")

        self.kwargs['view'] = view

        element_names = config.get_element_names()
        view_attrs = config.get_view_attributes()

        canvas_height = view_attrs.get("height")
        if not canvas_height:
            canvas_height = '400px'
        canvas.add_style("height: %s" % canvas_height)

        canvas_width = view_attrs.get("width")
        if not canvas_width:
            width = '600px'
        canvas.add_style("width: %s" % canvas_width)

        if not self.sobjects:
            search = Search(search_type)
            sobject = search.get_sobject()
        else:
            sobject = self.sobjects[0]

        dialog_id = self.kwargs.get("dialog_id")

        canvas.add_behavior({
            'type':
            'smart_click_up',
            'search_type':
            search_type,
            'view':
            view,
            'bvr_match_class':
            'SPT_ELEMENT_SELECT',
            'cbjs_action':
            '''
        var element = bvr.src_el;
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var attr = top.getElement(".spt_freeform_attr_top");

        var element_id = element.getAttribute("spt_element_id");
        var attrs = element.attrs;
        if (!attrs) {
            attrs = {};
        }

        var class_name = 'tactic.ui.tools.freeform_layout_wdg.FreeFormAttrWdg';
        var kwargs = {
            element_id: element_id,
            element_name: element.getAttribute("spt_element_name"),
            display_handler: element.getAttribute("spt_display_handler"),
            display_options: attrs
        }
        spt.panel.load(attr, class_name, kwargs);

        var dialog_id = '%s';
        spt.show( $(dialog_id) );

        ''' % dialog_id
        })

        canvas.add_behavior({
            'type': 'load',
            'cbjs_action': self.get_onload_js()
        })

        canvas.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
        var top = bvr.src_el;
        spt.freeform.init(top);
        '''
        })

        for element_name in element_names:

            widget_div = DivWdg()
            canvas.add(widget_div)
            widget_div.add_style("position: absolute")
            widget_div.add_style("vertical-align: top")

            widget_div.add_class("SPT_ELEMENT_SELECT")

            widget_div.add_behavior({
                'type':
                'load',
                'cbjs_action':
                '''
                bvr.src_el.makeDraggable()
                '''
            })

            el_attrs = config.get_element_attributes(element_name)
            height = el_attrs.get("height")
            if height:
                widget_div.add_style("height: %s" % height)

            width = el_attrs.get("width")
            if width:
                widget_div.add_style("width: %s" % width)

            display_handler = config.get_display_handler(element_name)
            display_options = config.get_display_options(element_name)

            widget_div.add_attr("spt_display_handler", display_handler)

            widget_div.add_behavior({
                'type':
                'load',
                'display_options':
                display_options,
                'cbjs_action':
                '''
            bvr.src_el.attrs = bvr.display_options;
            '''
            })

            try:
                widget = config.get_display_widget(element_name)
            except:
                continue

            widget.set_sobject(sobject)
            widget_div.add_attr("spt_element_name", element_name)
            widget_div.add_class("spt_element")

            content = DivWdg()
            widget_div.add(content)
            content.add_class("spt_element_content")
            content.add(widget)

            try:
                is_resizable = widget.is_resizable()
            except:
                is_resizable = False

            number = random.randint(0, 10000)
            element_id = "element%s" % number
            widget_div.set_attr("spt_element_id", element_id)

            # HACK for action button widget.  This widget takes over the
            # mouse hover very strongly, so need some padding to have
            # the widget_div trigger first
            if isinstance(widget, ActionButtonWdg):
                widget_div.add_style("padding: 2px")
                widget_div.add_style("height: 30px")

            # right now, the hover behavior has to be put on each element
            widget_div.add_behavior({
                'type':
                'hover',
                'cbjs_action_over':
                '''
            var size = bvr.src_el.getSize();
            var buttons = bvr.src_el.getElement(".spt_freeform_button_top");
            var buttons_size = buttons.getSize();
            spt.show(buttons);
            if (size.y < 32) {
                size.y = 32;
            }
            buttons.setStyle("width", size.x + 20);
            buttons.setStyle("height", size.y );
            buttons.setStyle("border", "solid 1px blue");
            ''',
                'cbjs_action_out':
                '''
            var buttons = bvr.src_el.getElement(".spt_freeform_button_top");
            spt.hide(buttons);
            buttons.setStyle("width", "100%")
            buttons.setStyle("height", "100%")
            '''
            })

            dummy = TextWdg("foo")
            widget_div.add(dummy)
            dummy.add_class("spt_foo")
            dummy.add_style("position: absolute")
            dummy.add_style("left: -100000")
            widget_div.add_behavior({
                'type':
                'mouseover',
                'cbjs_action':
                '''
            var foo = bvr.src_el.getElement(".spt_foo");
            foo.focus();
            '''
            })
            widget_div.add_behavior({
                'type':
                'mouseleave',
                'cbjs_action':
                '''
            var foo = bvr.src_el.getElement(".spt_foo");
            foo.blur();
            '''
            })

            dummy.add_behavior({
                'type':
                'keyup',
                'cbjs_action':
                '''
            var keys = ['tab','enter','delete','left','right','up','down'];
            var key = evt.key;
            //console.log(key);
            if (keys.indexOf(key) > -1) evt.stop();

            var element = bvr.src_el.getParent(".SPT_ELEMENT_SELECT");
            var canvas = bvr.src_el.getParent(".spt_freeform_canvas");
            var pos = element.getPosition();
            var cpos = canvas.getPosition();
            pos = { x: pos.x - cpos.x -1, y: pos.y - cpos.y -1 };

            if (key == 'delete') {
                element.destroy()
            }

            var step = 1;
            if (evt.shift == true) {
                step = 10;
            }

            if (key == 'left') {
                pos.x = pos.x - step;
            }
            else if (key == 'right') {
                pos.x = pos.x + step;
            }
            else if (key == 'up') {
                pos.y = pos.y - step;
            }
            else if (key == 'down') {
                pos.y = pos.y + step;
            }

            element.position(pos);

            '''
            })

            xpos = el_attrs.get("xpos")
            if not xpos:
                xpos = '100px'
            widget_div.add_style("left: %s" % xpos)

            ypos = el_attrs.get("ypos")
            if not ypos:
                ypos = '100px'
            widget_div.add_style("top: %s" % ypos)

            buttons_div = DivWdg()
            widget_div.add(buttons_div)
            buttons_div.add_class("spt_freeform_button_top")
            buttons_div.add_style("display: none")
            buttons_div.add_style("position: absolute")
            buttons_div.add_style("top: 0px")
            buttons_div.add_style("left: -10px")
            buttons_div.add_style("height: 100%")
            buttons_div.add_style("width: 105%")
            buttons_div.add_class("hand")

            buttons_div.add_border()

            #icon = IconWdg('Move', icon=IconWdg.ADD)
            #buttons_div.add(icon)
            #icon.add_class("move")

            is_resizable = True
            if is_resizable:
                icon_div = DivWdg()
                icon_div.add_style("cursor: move")
                buttons_div.add(icon_div)
                icon_div.add_style("position: absolute")
                icon_div.add_style("bottom: 0px")
                icon_div.add_style("right: 0px")
                icon = IconWdg('Scale', icon=IconWdg.RESIZE_CORNER)
                icon_div.add(icon)
                icon_div.add_behavior({
                    'type':
                    'drag',
                    "drag_el":
                    '@',
                    "cb_set_prefix":
                    'spt.freeform.resize_element_drag'
                })

                #icon.add_class("spt_resize_element")

        # for TableLayoutWdg??
        top.add_class("spt_table_top")
        class_name = Common.get_full_class_name(self)
        top.add_attr("spt_class_name", class_name)

        top.add("<br clear='all'/>")

        icon_div = DivWdg()
        top.add(icon_div)

        icon_div.add_class("spt_resize_canvas")
        icon_div.add_style("cursor: nw-resize")
        icon_div.add_style("z-index: 1000")
        icon_div.add_class("spt_popup_resize")
        icon_div.add_style("top: %s" % canvas_height)
        icon_div.add_style("left: %s" % canvas_width)
        icon_div.add_style("margin-left: -15px")
        icon_div.add_style("margin-top: -15px")
        icon_div.add_style("position: absolute")
        icon_div.add_behavior({
            'type': 'drag',
            "drag_el": '@',
            "cb_set_prefix": 'spt.freeform.resize_drag'
        })

        icon = IconWdg("Resize", IconWdg.RESIZE_CORNER)
        icon_div.add(icon)

        size_div = DivWdg()
        icon_div.add(size_div)
        size_div.add_class("spt_resize_title")
        size_div.add_style("display: none")
        size_div.add_style("margin-left: -60px")
        size_div.add_style("margin-top: -30px")
        size_div.add_style("width: 150px")

        return top
예제 #12
0
파일: edit_wdg.py 프로젝트: funic/TACTIC
    def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):

        from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
        if element_type in ["integer", "smallint", "bigint", "int"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableIntegerTextEdit'
            }
            input = TextWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["float"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableFloatTextEdit'
            }
            input = TextAreaWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["string", "link", "varchar", "character", "timecode"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)


        elif element_type in ["text"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextAreaWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type == "boolean":
            input = CheckboxWdg('main')
            input.set_options(display_options)
            input.add_behavior(
             {"type" : "click_up",
                    'propagate_evt': True})

        elif element_type in  ["timestamp", "date", "time", "datetime2"]:
            from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
            # FIXME: take wild guess for the time
            if element_name.endswith("_time"):
                #input = TimeInputWdg()
                behavior = {
                    'type': 'keyboard',
                    'kbd_handler_name': 'DgTableMultiLineTextEdit'
                }
                input = TextWdg('main')
                input.set_options(display_options)
                if kbd_handler:
                    input.add_behavior(behavior)

            else:
                #input = CalendarWdg()
                input = CalendarInputWdg()
                input.set_option('show_activator', False)
            #input.set_options(display_options)

        elif element_type == 'datetime':
            from tactic.ui.widget import CalendarInputWdg
            input = CalendarInputWdg()
            input.set_option('show_time', 'true')

        elif element_type == "color":
            from tactic.ui.widget import ColorInputWdg
            input = ColorInputWdg()
            input.set_options(display_options)

        elif element_type =="sqlserver_timestamp":
            # better then set it to None
            input = TextWdg()
            input.add_attr('disabled','disabled')
        else:
            # else try to instantiate it as a class
            print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
            input = TextWdg()
            input.add("No input defined")

        return input 
예제 #13
0
    def handle_item_div(my, item_div, dirname, basename):


        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")



        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")



        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg( "No Changes", IconWdg.CHECK, width=12 )
        elif status == 'added':
            check = IconWdg( "Added", IconWdg.NEW, width=16 )
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg( "Unversioned", IconWdg.HELP, width=12 )
        elif status == 'missing':
            check = IconWdg( "Missing", IconWdg.WARNING, width=12 )
        elif status == 'editable':
            check = IconWdg( "Editable", IconWdg.EDIT, width=12 )
        elif status == 'modified':
            check = IconWdg( "Modified", IconWdg.WARNING, width=12 )
        else:
            check = IconWdg( "Error (unknown status)", IconWdg.ERROR, width=12 )

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")


        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" % status)

        spath = path.replace(" ", "_")


        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')



        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")


        subcontext.add_behavior( {
            'type': 'click_up',
            'propagate_evt': False,
            'cbjs_action': '''
            bvr.src_el.focus();
            '''
        } )

        subcontext.add_style("display: none")
        item_div.add(subcontext)
예제 #14
0
    def get_display(my):
        from tactic_client_lib import TacticServerStub
        login = Environment.get_login()
        user_name = login.get_login()
        user_name = user_name.replace('.','')
        barcodes = []
        complete = False
        errors = ''
        first_loc_num1 = 5660
        last_loc_num1 = 5991
        first_loc_num2 = 6020
        last_loc_num2 = 6037
        if 'barcodes' in my.kwargs.keys():
            barcodes = my.kwargs.get('barcodes').split(',') 
        if 'complete' in my.kwargs.keys():
            complete = my.kwargs.get('complete')
        if 'errors' in my.kwargs.keys():
            errors = my.kwargs.get('errors')
        table = Table()
        table.add_attr('id','tracker_%s' % user_name) 
        table.add_attr('class','tracker_%s' % user_name) 
        if errors not in [None,'']:
            table.add_row()
            csp1 = table.add_cell(errors)
            csp1.add_attr('colspan','2')
        count = 0
        if complete:
            server = TacticServerStub.get()
            t2 = Table()
            for bc in barcodes:
                if 'EMP' in bc:
                    that_user = server.eval("@SOBJECT(sthpw/login['barcode','%s'])" % bc)
                    if that_user:
                        that_user = that_user[0]
                    else:
                        that_user = {'login': '******'}
                    t2.add_row()
                    t2.add_cell('USER: '******'login'))
                    t2.add_cell('BARCODE: %s' % bc)
            for bc in barcodes:
                bc_num = 555555555
                if '2G' in bc:
                    bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
                    bc_num = int(bc_num)
                if (bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2):
                    that_location = server.eval("@SOBJECT(twog/inhouse_locations['barcode','%s'])" % bc)
                    if that_location:
                        that_location = that_location[0]
                    else:
                        that_location = {'name': 'UNKNOWN LOCATION'}
                    t2.add_row()
                    t2.add_cell('LOCATION: ')
                    t2.add_cell(that_location.get('name'))
                    t2.add_cell('BARCODE: %s' % bc)
            for bc in barcodes:
                bc_num = 555555555
                if '2G' in bc:
                    bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
                    bc_num = int(bc_num)
                #if 'LOC' not in bc and 'EMP' not in bc:
                if not ((bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2)) and 'EMP' not in bc:
                    that_src = server.eval("@SOBJECT(twog/source['barcode','%s'])" % bc)
                    if that_src:
                        that_src = that_src[0]
                    else:
                        that_src = {'title': 'UNKNOWN SOURCE', 'episode': '', 'season': '', 'part': ''}
                    full_name = that_src.get('title')
                    if that_src.get('episode') not in [None,'']:
                        full_name = '%s EPISODE: %s' % (full_name, that_src.get('episode'))
                    if that_src.get('season') not in [None,'']:
                        full_name = '%s SEASON: %s' % (full_name, that_src.get('season'))
                    if that_src.get('part') not in [None,'']: 
                        full_name = '%s PART: %s' % (full_name, that_src.get('part'))
                    t2.add_row()
                    t2.add_cell('SOURCE: ')
                    t2.add_cell(full_name)
                    t2.add_cell('BARCODE: %s' % bc)
            table.add_row()
            csp2 = table.add_cell(t2)
            csp2.add_attr('colspan','2')
        else:                
            for bc in barcodes:
                table.add_row()
                table.add_cell('BARCODE: ')
                oldtxt = TextWdg('oldtxt')
                oldtxt.set_attr('id', 'txt_%s' % count)
                oldtxt.set_value(bc)
                table.add_cell(oldtxt)
                count = count + 1
            
        table.add_row()
        nextbc = TextWdg('nextbc')
        nextbc.add_attr('id', 'txt_%s' % count)
        nextbc.add_behavior(my.get_entry_bvr(user_name))
        table.add_cell('Barcode: ')
        table.add_cell(nextbc)

        widget = DivWdg()
        widget.add(table)
        widget.add_behavior(my.get_on_load_js(count))
        return widget
예제 #15
0
    def get_scale_wdg(my):

        show_scale = my.kwargs.get("show_scale")

        div = DivWdg()
        if show_scale in [False, 'false']:
            div.add_style("display: none")
        div.add_style("padding: 5px")
        div.add_class("spt_table_search")
        hidden = HiddenWdg("prefix", "tile_layout")
        div.add(hidden)

        div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
spt.tile_layout = {}
spt.tile_layout.layout = null;

spt.tile_layout.set_layout = function(layout) {
    if (!layout.hasClass("spt_layout")) {
        layout = layout.getParent(".spt_layout");
    }
    spt.tile_layout.layout = layout;
    return layout;
}

spt.tile_layout.get_scale = function() {
    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    var value = scale_value.value;
    value = parseInt(value);
    return value;
}


spt.tile_layout.set_scale = function(scale) {

    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    scale_value.value = scale;

    var size_x = 240*scale/100;
    var size_y = 160*scale/100;

    //var top = bvr.src_el.getParent(".spt_tile_layout_top");
    var top = spt.tile_layout.layout;
    var els = top.getElements(".spt_tile_content");
    for (var i = 0; i < els.length; i++) {
        var el = els[i];
        el.setStyle( "width",  size_x);
        el.setStyle( "height", size_y);
    }

    spt.container.set_value("tile_layout::scale", scale);

}


spt.tile_layout.drag_start_x = null;
spt.tile_layout.drag_start_value = null;

spt.tile_layout.drag_setup = function(evt, bvr, mouse_411) {
    spt.tile_layout.set_layout(bvr.src_el);
    spt.tile_layout.drag_start_x = mouse_411.curr_x;
    var src_el = spt.behavior.get_bvr_src( bvr );
    if (!src_el.value) {
        src_el.value = 0;
    }
    spt.tile_layout.drag_start_value = src_el.value;
    src_el.focus();
    src_el.select();
}
spt.tile_layout.drag_motion = function(evt, bvr, mouse_411) {
    var start_value = spt.tile_layout.drag_start_value; 
    if (isNaN(parseInt(start_value))) {
        return;
    }
    var dx = mouse_411.curr_x - spt.tile_layout.drag_start_x;
    var increment = parseInt(dx / 5);
    var multiplier;
    if (increment < 0)
        multiplier = 0.975;
    else
        multiplier = 1 / 0.975;
    increment = Math.abs(increment);
    var scale = spt.tile_layout.drag_start_value;
    for (var i = 0; i < increment; i++) {
        scale = scale * multiplier;
    }
    scale = parseInt(scale);
    spt.tile_layout.set_scale(scale);

}


        ''' } )



        div.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        spt.tile_layout.set_layout(bvr.src_el);
        var scale = spt.container.get_value("tile_layout::scale");
        if (scale) {
            spt.tile_layout.set_scale(scale);
        }
        '''
        } )


        table = Table()
        div.add(table)
        table.add_row()

        less_div = DivWdg()
        less_div.add("<input type='button' value='&lt;&lt;'/>")
        table.add_cell(less_div)

        less_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale * 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )


 
        value_wdg = TextWdg("scale")
        value_wdg.add_class("spt_scale_value")
        td = table.add_cell(value_wdg)
        td.add("&nbsp;%")
        td.add_style("padding: 3px 8px")
        if my.scale:
            value_wdg.set_value(my.scale)
        value_wdg.add_style("width: 24px")
        value_wdg.add_style("text-align: center")
        value_wdg.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )
        value_wdg.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        if (!value) {
            value = 100;
        }
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )



 
        value_wdg.add_behavior( {
            'type': 'smart_drag',
            'bvr_match_class': 'spt_scale_value',
            'ignore_default_motion' : True,
            "cbjs_setup": 'spt.tile_layout.drag_setup( evt, bvr, mouse_411 );',
            "cbjs_motion": 'spt.tile_layout.drag_motion( evt, bvr, mouse_411 );'
        } )



        more_div = DivWdg()
        more_div.add("<input type='button' value='&gt;&gt;'/>")
        table.add_cell(more_div)

        more_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale / 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )



        return div
예제 #16
0
    def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):

        from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
        if element_type in ["integer", "smallint", "bigint", "int"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableIntegerTextEdit'
            }
            input = TextWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["float"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableFloatTextEdit'
            }
            input = TextAreaWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["string", "link", "varchar", "character", "timecode"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)


        elif element_type in ["text"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextAreaWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type == "boolean":
            input = CheckboxWdg('main')
            input.set_options(display_options)
            input.add_behavior(
             {"type" : "click_up",
                    'propagate_evt': True})

        elif element_type in  ["timestamp", "date", "time", "datetime2"]:
            from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
            # FIXME: take wild guess for the time
            if element_name.endswith("_time"):
                #input = TimeInputWdg()
                behavior = {
                    'type': 'keyboard',
                    'kbd_handler_name': 'DgTableMultiLineTextEdit'
                }
                input = TextWdg('main')
                input.set_options(display_options)
                if kbd_handler:
                    input.add_behavior(behavior)

            else:
                #input = CalendarWdg()
                input = CalendarInputWdg()
                input.set_option('show_activator', False)
            #input.set_options(display_options)

        elif element_type == 'datetime':
            from tactic.ui.widget import CalendarInputWdg
            input = CalendarInputWdg()
            input.set_option('show_time', 'true')

        elif element_type == "color":
            from tactic.ui.widget import ColorInputWdg
            input = ColorInputWdg()
            input.set_options(display_options)

        elif element_type =="sqlserver_timestamp":
            # NoneType Exception is prevented in WidgetConfig already
            input = None
        else:
            # else try to instantiate it as a class
            print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
            input = TextWdg()
            input.add("No input defined")

        return input 
예제 #17
0
    def get_display(my):
        my.sk = str(my.kwargs.get('sk'))
        my.code = my.sk.split('code=')[1]
        my.parent_sk = str(my.kwargs.get('parent_sk'))
        my.order_sk = str(my.kwargs.get('order_sk'))
        order_code = my.order_sk.split('code=')[1]
        my.parent_sid = str(my.kwargs.get('parent_sid'))
        if 'user' in my.kwargs.keys():
            my.user = my.kwargs.get('user')
        else:
            my.user = Environment.get_user_name()
        if 'groups_str' in my.kwargs.keys():
            my.groups_str = my.kwargs.get('groups_str')
        if my.groups_str in [None,'']:
            user_group_names = Environment.get_group_names()
            for mg in user_group_names:
                if my.groups_str == '':
                    my.groups_str = mg
                else:
                    my.groups_str = '%s,%s' % (my.groups_str, mg)

        user_is_scheduler = False
        if 'scheduling' in my.groups_str or 'onboarding' in my.groups_str:
            user_is_scheduler = True

        if 'display_mode' in my.kwargs.keys():
            my.disp_mode = str(my.kwargs.get('display_mode'))
        if my.disp_mode == 'Small':
            my.small = True
        if 'is_master' in my.kwargs.keys():
            my.is_master_str = my.kwargs.get('is_master')
            if my.is_master_str == 'true':
                my.is_master = True
        else:
            order_search = Search("twog/order")
            order_search.add_filter('code',order_code)
            order = order_search.get_sobject()
            order_classification = order.get_value('classification')
            if order_classification in ['master', 'Master']:
                my.is_master = True
                my.is_master_str = 'true'
        open_bottom = False
        if 'open_bottom' in my.kwargs.keys():
            ob_text = my.kwargs.get('open_bottom')
            if ob_text in [True, 'true', 't', '1', 1]:
                open_bottom = True

        main_obj = None
        if 'main_obj' in my.kwargs.keys():
            main_obj = my.kwargs.get('main_obj')
        else:
            main_search = Search("twog/proj")
            main_search.add_filter('code', my.code)
            main_obj = main_search.get_sobject()
        pipe_disp = main_obj.get_value('pipeline_code')
        if pipe_disp in [None, '', 'twog/proj', 'NOTHINGXsXNOTHING']:
            pipe_disp = "Not Assigned"
            tp_search = Search("twog/title")
            tp_search.add_filter('code', main_obj.get_value('title_code'))
            titl = tp_search.get_sobject()
            title_pipe = titl.get_value('pipeline_code')
            cp_search = Search("twog/client_pipes")
            cp_search.add_filter('process_name', main_obj.get_value('process'))
            cp_search.add_filter('pipeline_code', title_pipe)
            client_pipes = cp_search.get_sobjects()
            if len(client_pipes) > 0:
                client_pipe = client_pipes[0]
                my.server.update(main_obj.get_search_key(), {'pipeline_code': client_pipe.get_value('pipe_to_assign')})
                pipe_disp = client_pipe.get_value('pipe_to_assign')
        my.search_id = main_obj.get_value('id')
        due_date = ''
        task_search = Search("sthpw/task")
        task_search.add_filter('code', main_obj.get_value('task_code'))
        task = task_search.get_sobjects()
        task_sk = ''
        status = ''
        active_status = ''
        if len(task) > 0:
            due_date = task[0].get_value('bid_end_date')
            status = task[0].get_value('status')
            task_sk = task[0].get_search_key()
            active_bool = task[0].get_value('active')
            if active_bool in [True, 'true', 't', 1, '1']:
                active_status = '<font color="#0ff000">Active</font>'
            else:
                active_status = '<font color="#ff0000">Inactive</font>'
        wo_search = Search("twog/work_order")
        wo_search.add_filter('proj_code', my.code)
        wo_search.add_order_by('order_in_pipe')
        wos = wo_search.get_sobjects()
        table = Table()
        table.add_attr('class', 'ProjRow_%s' % my.code)
        table.add_attr('id', main_obj.get_value('code'))
        table.add_attr('cellpadding', '0')
        table.add_attr('cellspacing', '0')
        table.add_style('border-collapse', 'separate')
        table.add_style('border-spacing', '25px 0px')
        table.add_style('color: #1d216a;')
        table.add_style('background-color: %s;' % my.off_color)
        table.add_style('width', '100%')
        table.add_style('border-bottom-right-radius', '10px')
        table.add_style('border-bottom-left-radius', '10px')
        table.add_style('border-top-right-radius', '10px')
        table.add_style('border-top-left-radius', '10px')
        table.add_row()
        proj_cell = table.add_cell('<b><u>Project: %s</u></b>' % main_obj.get_value('process'))
        proj_cell.add_attr('nowrap','nowrap')
        proj_cell.add_style('cursor: pointer;')
        proj_cell.add_behavior(get_panel_change_behavior('twog/proj', my.code, my.sk, my.order_sk, my.title,
                                                         main_obj.get_value('proj_templ_code'),
                                                             'builder/refresh_from_save',
                                                         main_obj.get_value('task_code'),
                                                         my.parent_sk, main_obj.get_value('process'),
                                                         user_is_scheduler))
        stat_tbl = Table()
        stat_tbl.add_row()
        stat_cell = stat_tbl.add_cell('Status: %s' % status)
        stat_cell.add_attr('nowrap','nowrap')
        if status not in [None,'']:
            stat_cell.add_style('background-color: %s;' % my.stat_colors[status])
        s2 = stat_tbl.add_cell(' ')
        s2.add_attr('width', '100%')
        table.add_cell(stat_tbl)
        due_cell = table.add_cell('Due: %s' % fix_date(due_date).split(' ')[0])
        due_cell.add_attr('nowrap', 'nowrap')
        top_buttons = Table()
        top_buttons.add_row()
        if my.small:
            select_check = CustomCheckboxWdg(name='select_%s' % my.code, value_field=my.code, checked='false',
                                             dom_class='ob_selector', parent_table="ProjRow_%s" % my.code,
                                             normal_color=my.off_color, selected_color=my.on_color, code=my.code,
                                             ntype='proj', search_key=my.sk, task_sk=task_sk,
                                             additional_js=get_selected_color_behavior(my.code, 'ProjRow',
                                                                                       my.on_color, my.off_color))
            cb = top_buttons.add_cell(select_check)
        elif user_is_scheduler or 'onboarding' in my.groups_str:
            xb = top_buttons.add_cell(my.x_butt)
            xb.add_attr('align', 'right')
            xb.add_style('cursor: pointer;')
            xb.add_behavior(get_killer_behavior(my.sk, my.parent_sk, 'TitleRow', main_obj.get_value('process'),
                                                my.order_sk, my.is_master))
        long_cell1 = table.add_cell(top_buttons)
        long_cell1.add_attr('align', 'right')
        long_cell1.add_style('width', '100%')
        table.add_row()
        code_cell = table.add_cell('Code: %s' % my.code)
        active_cell = table.add_cell(active_status)
        active_cell.add_attr('align', 'right')
        active_cell.add_attr('colspan', '3')
        active_cell.add_style('width', '100%')
        table.add_row()

        title_fullname = main_obj.get_value('title')
        if main_obj.get_value('episode') not in [None,'']:
            title_fullname = '%s: %s' % (title_fullname, main_obj.get_value('episode'))

        pipe_cell = table.add_cell('Pipeline: %s&nbsp;&nbsp;&nbsp;&nbsp;Title: %s' % (pipe_disp, title_fullname))
        pipe_cell.add_attr('nowrap', 'nowrap')
        long_cell2 = table.add_cell('Priority: ')
        long_cell2.add_attr('align', 'right')
        long_cell2.add_style('width', '100%')
        prio_wdg = TextWdg('barcode_switcher')
        prio_wdg.add_attr('old_prio',main_obj.get_value('priority'))
        prio_wdg.set_value(main_obj.get_value('priority'))
        if user_is_scheduler:
            prio_wdg.add_behavior(get_alter_prio_behavior(main_obj.get_search_key()))
        else:
            prio_wdg.add_attr('disabled', 'disabled')
            prio_wdg.add_attr('readonly', 'readonly')
        long_cell21 = table.add_cell(prio_wdg)
        long_cell21.add_attr('align', 'left')
        long_cell21.add_style('width', '100%')
        if my.small:
            proj_cell.add_style('font-size: 8px;')
            stat_cell.add_style('font-size: 8px;')
            due_cell.add_style('font-size: 8px;')
            long_cell1.add_style('font-size: 8px;')
            code_cell.add_style('font-size: 8px;')
            pipe_cell.add_style('font-size: 8px;')
            long_cell2.add_style('font-size: 8px;')
            long_cell21.add_style('font-size: 8px;')
        else:
            bottom_buttons = Table()
            bottom_buttons.add_row()
            lynk = my.get_parent_context_file_link(my.parent_sid, main_obj.get_value('process'),
                                                   'twog/title?project=twog')
            bottom_buttons.add_cell(lynk)

            if not my.is_master:
                if main_obj.get_value('creation_type') == 'hackup': # and my.user in ['admin','philip.rowe']:
                    hack_edit = ButtonSmallNewWdg(title="Edit Connections", icon=CustomIconWdg.icons.get('HACKUP'))
                    hack_edit.add_behavior(get_edit_hackup_connections(my.code, main_obj.get_value('process')))
                    he = bottom_buttons.add_cell(hack_edit)
                    he.add_attr('align', 'right')
                    he.add_attr('valign', 'bottom')
                if user_is_scheduler:
                    adder = ButtonSmallNewWdg(title="Add A Work Order", icon=CustomIconWdg.icons.get('ADD'))
                    adder.add_behavior(get_multi_add_wos_behavior(my.sk, my.order_sk))
                    add = bottom_buttons.add_cell(adder)
                    add.add_attr('align', 'right')
                    priority = ButtonSmallNewWdg(title="Change Priority", icon=CustomIconWdg.icons.get('PRIORITY'))
                    priority.add_behavior(get_change_priority_behavior(main_obj.get_value('code'),
                                                                       main_obj.get_value('process'),
                                                                       my.order_sk,
                                                                       my.is_master_str))
                    prio = bottom_buttons.add_cell(priority)
                    prio.add_attr('align', 'right')
                    duedate = ButtonSmallNewWdg(title="Change Due Date", icon=CustomIconWdg.icons.get('CALENDAR'))
                    duedate.add_behavior(get_change_due_date_behavior(main_obj.get_value('code'),
                                                                      main_obj.get_value('process'),
                                                                      my.order_sk))
                    due = bottom_buttons.add_cell(duedate)
                    due.add_attr('align', 'right')

            upload = ButtonSmallNewWdg(title="Upload", icon=CustomIconWdg.icons.get('PUBLISH'))
            upload.add_behavior(get_upload_behavior(my.sk))
            up = bottom_buttons.add_cell(upload)
            up.add_attr('align', 'right')

            note_adder = ButtonSmallNewWdg(title="Add Note", icon=CustomIconWdg.icons.get('NOTE_ADD'))
            note_adder.add_behavior(get_launch_note_behavior(my.sk, main_obj.get_value('process')))
            nadd = bottom_buttons.add_cell(note_adder)
            nadd.add_attr('align', 'right')
            nadd.add_style('cursor: pointer;')

            if user_is_scheduler or 'onboarding' in my.groups_str:
                pipe_button = ButtonSmallNewWdg(title="Assign Pipeline", icon=CustomIconWdg.icons.get('PIPELINE'))
                pipe_button.add_behavior(get_scratch_pipe_behavior('twog/proj', my.search_id, my.parent_sid,
                                                                   my.width, my.height,
                                                                   main_obj.get_value('pipeline_code'),
                                                                   main_obj.get_search_key(), 'ProjRow',
                                                                   main_obj.get_value('process'), my.order_sk))
                scratch = bottom_buttons.add_cell(pipe_button)

            if my.is_master:
                if main_obj.get_value('templ_me') == True:
                    templ_icon = CustomIconWdg.icons.get('CHECK')
                else:
                    templ_icon = CustomIconWdg.icons.get('TEMPLATE')
                templ_button = ButtonSmallNewWdg(title="Template Me", icon=templ_icon)
                if main_obj.get_value('templ_me') == False:
                    templ_button.add_behavior(get_templ_proj_behavior(main_obj.get_value('templ_me'),
                                                                      main_obj.get_value('proj_templ_code'),
                                                                      main_obj.get_search_key(),
                                                                      my.order_sk))
                templ_butt = bottom_buttons.add_cell(templ_button)
                templ_butt.add_attr('class', 'templ_butt_%s' % my.sk)

            long_cell3 = table.add_cell(bottom_buttons)
            long_cell3.add_attr('align', 'right')
            long_cell3.add_attr('valign', 'bottom')
            long_cell3.add_style('width', '100%')
        bottom = Table()
        bottom.add_attr('width', '100%')
        bottom.add_attr('cellpadding', '0')
        bottom.add_attr('cellspacing', '0')
        for wo in wos:
            wo_sk = wo.get_search_key()
            wo_row = bottom.add_row()
            wo_row.add_attr('class', 'row_%s' % wo_sk)
            wo_obj = WorkOrderRow(sk=wo_sk, parent_sk=my.sk, order_sk=my.order_sk, parent_sid=my.search_id,
                                  groups_str=my.groups_str, user=my.user, display_mode=my.disp_mode,
                                  is_master=my.is_master_str, main_obj=wo, parent_obj=main_obj)
            wo_cell = bottom.add_cell(wo_obj)
            wo_cell.add_attr('width', '100%')
            wo_cell.add_attr('sk', wo_sk)
            wo_cell.add_attr('order_sk', my.order_sk)
            wo_cell.add_attr('parent_sk', my.sk)
            wo_cell.add_attr('parent_sid', my.search_id)
            wo_cell.add_attr('display_mode', my.disp_mode)
            wo_cell.add_attr('groups_str', my.groups_str)
            wo_cell.add_attr('user', my.user)
            wo_cell.add_attr('call_me', wo.get_value('process'))
            wo_cell.add_attr('my_class', 'WorkOrderRow')
            wo_cell.add_attr('class', 'cell_%s' % wo_sk)
        tab2ret = Table()
        top_row = tab2ret.add_row()
        top_row.add_attr('class', 'top_%s' % my.sk)
        tab2ret.add_attr('width', '100%')
        tab2ret.add_cell(table)
        bot_row = tab2ret.add_row()
        bot_row.add_attr('class', 'bot_%s' % my.sk)
        if not open_bottom:
            bot_row.add_style('display: none;')
        else:
            bot_row.add_style('display: table-row;')
        bot = tab2ret.add_cell(bottom)
        bot.add_style('padding-left: 40px;')

        return tab2ret
예제 #18
0
    def get_display(my):
        my.sob_code = str(my.kwargs.get("sob_code"))
        my.sob_sk = str(my.kwargs.get("sob_sk"))
        my.sob_st = str(my.kwargs.get("sob_st"))
        my.sob_name = str(my.kwargs.get("sob_name"))
        my.pipeline = str(my.kwargs.get("pipeline"))
        my.order_sk = str(my.kwargs.get("order_sk"))
        order_code = my.order_sk.split("code=")[1]
        if "is_master" in my.kwargs.keys():
            my.is_master = my.kwargs.get("is_master")
        else:
            order_search = Search("twog/order")
            order_search.add_filter("code", order_code)
            order = order_search.get_sobject()
            order_classification = order.get_value("classification")
            if order_classification in ["master", "Master"]:
                my.is_master = True

        if my.sob_st == "twog/title":
            my.prereq_st = "twog/title_prereq"
            my.prereq_field = "title_code"
        elif my.sob_st == "twog/work_order":
            my.prereq_st = "twog/work_order_prereq"
            my.prereq_field = "work_order_code"

        user_group_names = Environment.get_group_names()
        groups_str = ""
        for mg in user_group_names:
            if groups_str == "":
                groups_str = mg
            else:
                groups_str = "%s,%s" % (groups_str, mg)
        user_is_scheduler = False
        if "scheduling" in groups_str:
            user_is_scheduler = True

        prereq_search = Search(my.prereq_st)
        prereq_search.add_filter(my.prereq_field, my.sob_code)
        prereqs = prereq_search.get_sobjects()
        overhead = Table()
        overhead.add_attr("class", "overhead_%s" % my.sob_code)
        table = Table()
        table.add_attr("class", "prereq_adder_%s" % my.sob_code)
        table.add_row()
        if my.sob_st == "twog/work_order" and user_is_scheduler:
            kill_title_pqs_btn = table.add_cell('<input type="button" value="Remove\nTitle PreReqs"/>')
            kill_title_pqs_btn.add_attr("colspan", "2")
            kill_title_pqs_btn.add_behavior(
                get_kill_wos_title_prereqs_behavior(my.sob_sk, my.order_sk, my.sob_name, my.pipeline)
            )
        else:
            table.add_cell(" ")
            table.add_cell(" ")
        table.add_cell(" ")
        table.add_cell(" ")
        sat = table.add_cell("Satisfied?")
        sat.add_attr("align", "center")
        table.add_cell(" ")
        for p in prereqs:
            table.add_row()
            if user_is_scheduler:
                killer = table.add_cell(my.x_butt)
                killer.add_style("cursor: pointer;")
                killer.add_behavior(
                    get_prereq_killer_behavior(
                        p.get_value("code"),
                        my.prereq_st,
                        my.sob_code,
                        my.sob_sk,
                        my.sob_st,
                        my.sob_name,
                        my.pipeline,
                        my.order_sk,
                    )
                )
            prereq_text = "PreReq: "
            if my.sob_st == "twog/work_order":
                if p.get_value("from_title") == True:
                    prereq_text = "Title PreReq: "
            alabel = table.add_cell(prereq_text)
            alabel.add_attr("align", "center")
            table.add_cell(
                '<input type="text" class="prereq_%s" value="%s" style="width: 500px;"/>'
                % (p.get_value("code"), p.get_value("prereq"))
            )
            save_butt = table.add_cell('<input type="button" class="save_%s" value="Save"/>' % (p.get_value("code")))
            save_butt.add_behavior(
                get_save_prereq_behavior(p.get_value("code"), my.prereq_st, my.sob_code, my.pipeline)
            )

            if p.get_value("satisfied") == True:
                check_val = "true"
            else:
                check_val = "false"
            checkbox = CustomCheckboxWdg(
                name="satisfied_%s" % p.get_value("code"),
                value_field=p.get_value("code"),
                checked=check_val,
                dom_class="prereq_selector",
                code=p.get_value("code"),
                additional_js=get_change_satisfied_behavior(
                    p.get_value("code"),
                    my.prereq_st,
                    my.sob_code,
                    p.get_value("satisfied"),
                    my.sob_sk,
                    my.sob_st,
                    my.sob_name,
                    my.pipeline,
                    my.order_sk,
                ),
            )

            ck = table.add_cell(checkbox)
            ck.add_attr("align", "center")
            if my.is_master:
                if my.sob_st == "twog/title":
                    table.add_cell(" &nbsp; ")
                    templ_search = Search("twog/pipeline_prereq")
                    templ_search.add_filter("pipeline_code", my.pipeline)
                    templ_search.add_filter("prereq", p.get_value("prereq"))
                    templ_rez = templ_search.get_sobjects()
                    templ_count = len(templ_rez)
                    if templ_count == 0:
                        template_button = ButtonSmallNewWdg(
                            title="Template This PreReq", icon=CustomIconWdg.icons.get("TEMPLATE")
                        )
                        if my.is_master and user_is_scheduler:
                            template_button.add_behavior(
                                get_template_prereq_behavior(
                                    my.sob_code, my.pipeline, my.prereq_st, p.get_value("code")
                                )
                            )
                    else:
                        template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">'
                    tb = table.add_cell(template_button)
                    tb.add_class("prereq_templ_%s" % p.get_value("code"))
                elif my.sob_st == "twog/work_order":
                    table.add_cell(" &nbsp; ")
                    wot_search = Search("twog/work_order")
                    wot_search.add_filter("code", my.sob_code)
                    wot = wot_search.get_sobject()
                    work_order_templ_code = wot.get_value("work_order_templ_code")
                    templ_search = Search("twog/work_order_prereq_templ")
                    templ_search.add_filter("work_order_templ_code", work_order_templ_code)
                    templ_search.add_filter("prereq", p.get_value("prereq"))
                    templ_rez = templ_search.get_sobjects()
                    templ_count = len(templ_rez)
                    if templ_count == 0:
                        template_button = ButtonSmallNewWdg(
                            title="Template This PreReq", icon=CustomIconWdg.icons.get("TEMPLATE")
                        )
                        if my.is_master:
                            template_button.add_behavior(
                                get_template_wo_prereq_behavior(
                                    my.sob_code, my.prereq_st, p.get_value("code"), work_order_templ_code
                                )
                            )
                    else:
                        template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">'
                    tb = table.add_cell(template_button)
                    tb.add_class("prereq_templ_%s" % p.get_value("code"))
        table.add_row()
        table.add_cell("<hr/>")
        table.add_row()
        table.add_cell(" &nbsp; ")
        if user_is_scheduler:
            label = table.add_cell("New PreReq: ")
            label.add_attr("nowrap", "nowrap")
            prereq_text_wdg = TextWdg("new_prereq")
            prereq_text_wdg.add_behavior(
                get_create_prereq_change_behavior(
                    my.sob_code, my.prereq_st, my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk
                )
            )
            table.add_cell(prereq_text_wdg)
            create_butt = table.add_cell('<input type="button" class="create_prereq" value="Create"/>')
            create_butt.add_behavior(
                get_create_prereq_behavior(
                    my.sob_code, my.prereq_st, my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk
                )
            )
        overhead.add_row()
        oh_cell = overhead.add_cell(table)
        oh_cell.add_attr("class", "prereq_adder_cell")

        return overhead
예제 #19
0
    def get_display(my):
        my.icon_string = my.get_value("icon")
        my.icon_label = my.get_value("label")

        top = DivWdg()
        top.add_class("spt_icon_chooser_top")

        # FIXME: this is being generated every time .... where to put is?
        icon_chooser = IconChooserWdg(is_popup=True)
        top.add(icon_chooser)

        icon_entry_text = TextWdg(my.get_input_name())
        icon_entry_text.set_option("size", "30")
        #icon_entry_text.set_attr("disabled", "disabled")
        icon_entry_text.add_class("SPT_ICON_ENTRY_TEXT")

        button = ActionButtonWdg(title='Choose', tip='Click to select an icon')

        icon_img = HtmlElement.img()
        icon_img.add_class("SPT_ICON_IMG")

        if my.icon_string:
            # icon_path = IconWdg.icons.get(my.icon_string)
            icon_path = IconWdg.get_icon_path(my.icon_string)
            if icon_path:
                # icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
                icon_img.set_attr("src", icon_path)
            else:
                icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

            icon_entry_text.set_value(my.icon_string)
        else:
            icon_entry_text.set_value("")
            icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

        named_event_name = "ICON_CHOOSER_SELECTION_MADE"
        icon_entry_text.add_behavior({
            'type':
            'listen',
            'event_name':
            named_event_name,
            'cbjs_action':
            '''
                var top = $("IconChooserPopup");
                var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
                //var chooser = spt.get_cousin( bvr.src_el,
                //    ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );

                var icon_name = chooser.getProperty("spt_icon_selected");
                var icon_path = chooser.getProperty("spt_icon_path");
                // bvr.src_el.innerHTML = icon_name;
                bvr.src_el.value = icon_name;
                if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
                var img_el = spt.get_cousin( bvr.src_el,
                    ".spt_icon_chooser_top", ".SPT_ICON_IMG" );
                if( icon_path ) {
                    img_el.setProperty("src", icon_path);
                } else {
                    img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
                }
           '''
        })

        top.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            'spt.popup.open( "IconChooserPopup", false);'
        })

        #top.add( my.icon_label )
        spacing = "<img src='%s' style='width: %spx;' />" % (
            IconWdg.get_icon_path("TRANSPARENT"), 3)

        #button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
        #top.add( button )
        #button.add_style("float: right")
        #button.add_style("margin-top: -3px")

        top.add(icon_img)
        top.add(spacing)
        top.add(icon_entry_text)

        return top
예제 #20
0
    def get_page_one(my):

        info_page = DivWdg()
        
        #info_page.add_class("spt_project_top")
        info_page.add_style("font-size: 12px")
        info_page.add_color("background", "background")
        info_page.add_color("color", "color")
        info_page.add_style("padding: 20px")



        from tactic.ui.input import TextInputWdg

        info_page.add("<b>Title:</b> &nbsp;&nbsp;")
    
        text = TextWdg("order_title")
        #text = TextInputWdg(title="project_title")
        info_page.add(text)
        text.add_style("width: 250px")
        info_page.add(HtmlElement.br(3))
        span = DivWdg()
        info_page.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("The order title can be descriptive and contain spaces and special characters.")
        info_page.add("<br/><br/><hr/><br/><br/>")
        text.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var title = bvr.src_el.value;
        var code = spt.convert_to_alpha_numeric(title);
        var top = bvr.src_el.getParent(".twog_wizard_top");
        var code_el = top.getElement(".spt_project_code");
        code_el.value = code;
        '''
        } )


        info_page.add("<b>Client Name: &nbsp;&nbsp;</b>")
        text = TextWdg("client_name")
        text.add_style("width: 250px")
        text.add_class("spt_client_name")
        info_page.add(text)

        # line breaks
        info_page.add(HtmlElement.br(2))

        info_page.add("<b>Special code: &nbsp;&nbsp;</b>")
        text = TextWdg("special code")
        text.add_style("width: 250px")

        # this is just meant for DOM element search covenience
        text.add_class("spt_special_code")

       
        # this behavior is go for eliminlating special symbols
        #MTM this will help get rid of the stupid ascii errors
        text.add_behavior( {
            'type': 'blur',
            'cbjs_action': '''
            var value = bvr.src_el.value;
            var code = spt.convert_to_alpha_numeric(value);
            bvr.src_el.value = code;
            '''
        } )

        info_page.add(text)

        
        info_page.add(HtmlElement.br(4))

        span = DivWdg()
        info_page.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("Some more info here.")
     
        info_page.add(span)

        info_page.add("<br/>")


        return info_page
예제 #21
0
    def get_info_wdg(self):

        div = DivWdg()

        div.add("<b>Create a share</b>")
        div.add("<br/>"*2)

        table = Table()
        div.add(table)
        table.add_style("margin-left: 15px")


        table.add_row()
        td = table.add_cell("Share Code: ")
        td.add_style("vertical-align: top")
        text = TextWdg("code")
        table.add_cell(text)
        text.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            var value = bvr.src_el.value;
            if (!value) {
                return;
            }
            var server = TacticServerStub.get();
            var expr = "@SOBJECT(sthpw/sync_server['code','"+value+"'])";
            var test = server.eval(expr);
            if (test.length > 0) {
                spt.alert("Share ["+value+"] already exists.");
                bvr.src_el.value = "";
                bvr.src_el.focus();
            }
            '''
        } )
        tr, td = table.add_row_cell()
        msg_div = DivWdg()
        td.add(msg_div)
        msg_div.add("The share code is used as a prefix for all transactions and allows TACTIC to separate transactions from each location.  By convention, these codes should be a short initial (ie: ABC).")
        msg_div.add_style("margin: 10px 20px 20px 20px")


        


        table.add_row()
        table.add_row_cell("&nbsp;")


        table.add_row()
        td = table.add_cell("Description: ")
        td.add_style("vertical-align: top")
        text = TextAreaWdg("description")
        td = table.add_cell(text)


        #table.add_row()
        #table.add_cell("Auth Ticket: ")
        #text = TextWdg("ticket")
        #table.add_cell(text)


        return div
예제 #22
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color', 'color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s" % app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)

        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not my.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = my.get_instantiation_wdg()
            table.add_cell(div)

        setting = my.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not my.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = my.get_element_name("connection")
                checkbox = CheckboxWdg(name)
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        if not my.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = my.get_element_name("dependency")
                checkbox = CheckboxWdg(name)

                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell(ConnectionSelectWdg())

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size', '6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell(port_div)

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        })

        return widget
예제 #23
0
    def get_display(self):
    
        widget = Widget()
        
        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color','color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s"%app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)
        
        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not self.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = self.get_instantiation_wdg()
            table.add_cell(div)


        setting = self.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not self.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = self.get_element_name("connection")
                checkbox = CheckboxWdg( name )
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({'type': 'click_up', 
                    'propagate_evt': True,
                     "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) 
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()



        if not self.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()
            
            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = self.get_element_name("dependency")
                checkbox = CheckboxWdg( name )

                
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({'type': 'click_up', 
                    'propagate_evt': True,
                     "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) 
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()



        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell( ConnectionSelectWdg() )

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size','6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell( port_div )

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        } )


        return widget
예제 #24
0
    def get_display(my):   
        widget = DivWdg()
        widget.add_attr('id','whole_fb_container_%s' % my.custom_top_name)
        if 'dir' in my.kwargs.keys():
            my.dir = my.kwargs.get('dir')
        if 'old_dir' in my.kwargs.keys():
            my.old_dir = my.kwargs.get('old_dir')
        else:
            my.old_dir = my.dir
        if 'mode' in my.kwargs.keys():
            my.mode = my.kwargs.get('mode')
            if my.mode in [None,'']:
                my.mode = 'classic'
        #print "DIR = %s, OLD DIR = %s" % (my.dir, my.old_dir)
        
        err_msg = ''
        if not os.path.isdir(my.dir):
            err_msg = '%s is not a valid directory' % my.dir 
            my.dir = my.old_dir
       
        trimmed_dir = my.dir
        if trimmed_dir[len(trimmed_dir) - 1] == '/' and len(trimmed_dir) > 1:
            trimmed_dir = trimmed_dir[:-1]
        
        prev_dir_s = trimmed_dir.split('/')
        prev_dir_s = prev_dir_s[:-1]
        prev_dir = ''
        
        for ct in range(0,len(prev_dir_s)):
            if prev_dir_s[ct] not in [None,'']:
                if prev_dir == '':
                    prev_dir = '/%s' % prev_dir_s[ct]
                else:   
                    prev_dir = '%s/%s' % (prev_dir, prev_dir_s[ct])
        if prev_dir in [None,'','//']:
            prev_dir = '/'
        #print "PREV DIR = %s" % prev_dir
        
        files_list = []
        dir_list = []
        
        files_dict = {}
        dirs_dict = {}
        
        longest_name_len = 0
        
        for f in os.listdir(my.dir):
            joined = join(my.dir,f)
            if os.path.isfile(joined):
                files_list.append(joined)
                last_modified = 'N/A'
                created = 'N/A'
                size = 'N/A'
                if joined.count('/') > 3:
                    last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    size = my.convertSize(os.path.getsize(joined),'file')
                file_name_s = joined.split('/')
                file_name = file_name_s[len(file_name_s) - 1]
                file_path = joined
                files_dict[joined] = {'last_modified': last_modified, 'created': created, 'size': size, 'name': file_name, 'path': joined}
                if len(file_name) > longest_name_len:
                    longest_name_len = len(file_name)
            
            elif os.path.isdir(joined):
                dir_name_s = joined.split('/')
                dir_name = dir_name_s[len(dir_name_s) - 1]
                if dir_name[0] != '.':
                    dir_list.append(joined)
                    size = 'N/A'
                    created = 'N/A'
                    last_modified = 'N/A'
                   
                    #This is to keep us from calculating the size of the huge base directories
                    #Probably want a way to turn directory sizes on and off
                    if joined.count('/') > 5:
                        last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        prepresize = commands.getoutput('du -s %s' % joined).split()[0]
                        try:
                            presize = float(prepresize)
                            if not math.isnan(presize):
                                size = my.convertSize(float(presize),'dir')
                        except ValueError:
                            print "GOT AN ERROR FOR %s" % joined
                            pass
                    dir_path = joined
                    dirs_dict[joined] = {'size': size, 'created': created, 'last_modified': last_modified, 'name': dir_name, 'path' : dir_path}
                    if len(dir_name) > longest_name_len:
                        longest_name_len = len(dir_name)
        
        #print "LONGEST NAME LEN = %s" % longest_name_len
        name_len = longest_name_len * 10
        
        # Displaying the table of the folders and files 
        top_tbl = Table()
        if err_msg != '':
            top_tbl.add_row()
            top_tbl.add_cell('<b><font color="#FF0000">%s</font></b>' % err_msg)
        top_tbl.add_row()
        dir_path_txt = TextWdg('dir_path')
        dir_path_txt.add_attr('id','dir_path')
        dir_path_txt.set_value(my.dir)
        dir_path_txt.set_option('size','100')
        dir_path_txt.add_behavior(my.change_location(my.old_dir))
        top_tbl.add_cell('Location: ')
        top_tbl.add_cell(dir_path_txt)
        
        div = DivWdg()
        
        back_tbl = Table()
        back_dir = back_tbl.add_cell("<-Back...")
        back_dir.add_attr('dir',prev_dir)
        back_dir.add_style('cursor: pointer;')
        back_dir.add_style('width: %spx;' % name_len)
        back_dir.add_behavior(my.dir_click())
        back_size = back_tbl.add_cell('Size')
        back_size.add_style('width: 100px;')
        back_created = back_tbl.add_cell('Created')
        back_created.add_style('width: 150px;')
        back_modified = back_tbl.add_cell('Last Modified')
        back_modified.add_style('width: 150px;')
        div.add(back_tbl)
    
        content_counter = 0
        dir_list.sort()
        files_list.sort()
        mult_dirs = DivWdg()
        mult_dirs.add_attr('class','DragContainer')
        mult_dirs.add_attr('id','DragContainer1')

        # Getting all the directories displayed, adding drag and drop attributes to each folder 
        for dr in dir_list:
         
            tbl = Table()
            tbl.add_row()
            dir_name = dirs_dict[dr]['name']
            dir_path = dirs_dict[dr]['path']
            FOLDER_ICON = my.folder_icon.replace("TITLE",dir_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FOLDER_ICON)
            
            directory_div = lil_tbl.add_cell('<b>%s</b>' % dir_name)
            
            if my.mode not in ['select']:
                directory_div.add_behavior(my.drag_controller())
                directory_div.add_style("-khtml-user-drag: element;")
                directory_div.add_attr("draggable", "true")
                directory_div.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% dir_path)
                directory_div.add_attr("ondragover", "spt.drag.allowDrop(event, this)")
                directory_div.add_attr("ondrop", "spt.drag.ondrop(event, this, {destination_location: '%s'})" % dir_path)

            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('dir',dr)
            lil_cell.add_attr('type','dir')
            lil_cell.add_attr('path_name',dr)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.dir_click())
            lil_cell.add_behavior(my.highlighter_ctrl());
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            
            sc = tbl.add_cell('<i>%s</i>' % dirs_dict[dr]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size of Contents')
            sc.add_attr('name','Size of Contents')
            sc.add_style('width: 100px;')
           
            cc = tbl.add_cell(dirs_dict[dr]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
         
            mc = tbl.add_cell(dirs_dict[dr]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_dir = DivWdg()
            div_dir.add(tbl)
            mult_dirs.add(div_dir)
            content_counter = content_counter + 1
        div.add(mult_dirs)
        mult_files = DivWdg()
        mult_files.add_attr('class','DragContainer')
        mult_files.add_attr('id','DragContainer2')
        
        for fl in files_list:
            tbl = Table()
            tbl.add_row()

            file_name = files_dict[fl]['name']
            path_name = files_dict[fl]['path']

            text_wdg_file_name = DivWdg(file_name)
            if my.mode not in ['select']:
                text_wdg_file_name.add_behavior(my.drag_controller())
                text_wdg_file_name.add_style("-khtml-user-drag: element;")
                text_wdg_file_name.add_attr("draggable", "true")
                text_wdg_file_name.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% path_name)
            
            FILE_ICON = my.file_icon.replace("TITLE",file_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FILE_ICON)
            file_div = lil_tbl.add_cell(text_wdg_file_name)
            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('file',fl)
            lil_cell.add_attr('type','file')
            lil_cell.add_attr('file_name',file_name)
            lil_cell.add_attr('path_name',path_name)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.highlighter_ctrl())
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            else:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
             
            sc = tbl.add_cell('<i>%s</i>' % files_dict[fl]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size')
            sc.add_attr('name','Size')
            sc.add_style('width: 100px;')
            cc = tbl.add_cell(files_dict[fl]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
            mc = tbl.add_cell(files_dict[fl]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_fl = DivWdg()
            div_fl.add(tbl)
            mult_files.add(div_fl)
            content_counter = content_counter + 1
        div.add(mult_files)
        widget.add(top_tbl)
        widget.add(div)
        widget.add_behavior(my.click_anywhere())
        return widget 
예제 #25
0
    def get_display(my):
        login = Environment.get_login()
        user_name = login.get_login()
        work_order_code = ''
        if 'work_order_code' in my.kwargs.keys():
            work_order_code = str(my.kwargs.get('work_order_code'))
        else:
            sobject = my.get_current_sobject()
            work_order_code = sobject.get_code()
        work_order = my.server.eval("@SOBJECT(twog/work_order['code','%s'])" % work_order_code)[0]
        widget = DivWdg()
        widget.add_attr('class','ov_sources_%s' % work_order_code)
        table = Table()
        table.add_attr('width','100%s' % '%')
        table.add_attr('class','source_display_%s' % work_order_code)
        at_least1 = False


        table.add_row()
        tbl_top = Table()
        tbl_top.add_row()
        missing = tbl_top.add_cell('<u>Report Missing Source</u>')
        missing.add_attr('nowrap','nowrap')
        missing.add_style('cursor: pointer;')
        missing.add_behavior(my.report_missing(work_order_code, user_name, work_order.get('platform'))) 
        middle = tbl_top.add_cell(' ')
        middle.set_style('width: 100%s;' % '%')
        right = tbl_top.add_cell('Add Source: ')
        right.add_attr('nowrap','nowrap')
        right.add_attr('align','right')
        add_tb = TextWdg('wo_barcode_insert_%s' % work_order_code)
        add_tb.add_behavior(my.get_wo_barcode_insert_behavior(work_order_code))
        adder = tbl_top.add_cell(add_tb)
        adder.add_behavior(my.get_wo_barcode_insert_behavior(work_order_code)) 
        table.add_row()
        table.add_cell(tbl_top)
        #INS
        wo_sources = my.server.eval("@SOBJECT(twog/work_order_sources['work_order_code','%s'])" % work_order_code)
        for wo_source in wo_sources:
            table.add_row()
            table.add_cell(my.make_source_unit(wo_source, work_order_code, 'IN', 'SRC'))
            at_least1 = True
            
           
        passin_deliverables = my.server.eval("@SOBJECT(twog/work_order_passin['work_order_code','%s'])" % work_order_code)
        for wo_source in passin_deliverables:
            if wo_source.get('deliverable_source_code') not in [None,'']:
                table.add_row()
                table.add_cell(my.make_source_unit(wo_source, work_order_code, 'IN', 'SRC-PASSIN'))
                at_least1 = True
            
        passin_interms = my.server.eval("@SOBJECT(twog/work_order_passin['work_order_code','%s'])" % work_order_code)
        for interm in passin_interms:
            if interm.get('intermediate_file_code') not in [None,'']:
                table.add_row()
                table.add_cell(my.make_intermediate_unit(interm, work_order_code, 'IN', 'INTM-PASSIN'))
                at_least1 = True

        #OUTS
        intermediates = my.server.eval("@SOBJECT(twog/work_order_intermediate['work_order_code','%s'])" % work_order_code)
        for interm in intermediates:
            table.add_row()
            table.add_cell(my.make_intermediate_unit(interm, work_order_code, 'OUT', 'INTM-OUT'))
            at_least1 = True

        deliverable_sources = my.server.eval("@SOBJECT(twog/work_order_deliverables['work_order_code','%s'])" % work_order_code)
        for dsource in deliverable_sources:
            table.add_row()
            table.add_cell(my.make_source_unit(dsource, work_order_code, 'OUT', 'DLV-OUT'))
            at_least1 = True
        #also need intermediates and other stuff shown in work_order_assets_wdg
        if at_least1:
            table.add_row()
            button_cell = table.add_cell('<input type="button" value="Issue Alert(s)"/>')
            button_cell.add_behavior(my.alert_popup(work_order_code, user_name, work_order.get('platform')))
            cell3 = table.add_cell(' ')
            cell3.add_attr('width','80%s' % '%') 
        widget.add(table)
        #--print "LEAVING OBLW"

        return widget
예제 #26
0
    def get_set_limit_wdg(my):
        limit_content = DivWdg()
        limit_content.add_style("font-size: 10px")
        #limit_content.add_style("padding", "5px")
        #limit_content.add_border()

        limit_content.add("Show ")

        limit_select = SelectWdg("limit_select")
        limit_select.add_class("spt_search_limit_select")
        limit_select.set_option("values", "10|20|50|100|200|Custom")
        limit_select.add_style("font-size: 10px")
        limit_content.add(limit_select)
        limit_content.add(" items per page<br/>")

        if my.search_limit in [10, 20, 50, 100, 200]:
            limit_select.set_value(my.search_limit)
            is_custom = False
        else:
            limit_select.set_value("Custom")
            is_custom = True

        limit_select.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var value = bvr.src_el.value;
            var custom = top.getElement(".spt_search_limit_custom");
            if (value == 'Custom') {
                custom.setStyle("display", "");
            }
            else {
                custom.setStyle("display", "none");
            }

            '''
        })

        custom_limit = DivWdg()
        limit_content.add(custom_limit)
        custom_limit.add_class("spt_search_limit_custom")
        custom_limit.add("<br/>Custom: ")
        text = TextWdg("custom_limit")
        text.add_class("spt_search_limit_custom_text")
        text.add_style("width: 50px")
        if not is_custom:
            custom_limit.add_style("display: none")
        else:
            text.set_value(my.search_limit)
        custom_limit.add(text)
        text.add(" items")
        behavior = {
            'type':
            'keydown',
            'cbjs_action':
            '''
                 if (evt.key=='enter') {
                    // register this as changed item
                    var value = bvr.src_el.value;
                    if (isNaN(value) || value.test(/[\.-]/)) {
                        spt.error('You have to use an integer.');
                    }
                }
        '''
        }

        text.add_behavior(behavior)

        return limit_content
예제 #27
0
    def get_display(my):
        widget = DivWdg(id='new_item_panel')
        widget.add_class("new_item_panel")
        widget.add_class("spt_new_item_top")

        div = DivWdg()
        div.add_color("background", "background")
        div.add_color("color", "color")
        div.add_style("padding", "5px")
        div.add_border()

        if my.is_personal:
            is_personal = 'true'
        else:
            is_personal = 'false'

        if my.type == 'new_folder':
            #div.set_attr('spt_view', 'new_folder')
            div.add(HtmlElement.b('Create New Folder'))
            div.add(HtmlElement.br(2))
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            """
            # add exisiting views in the div for checking with client's input
             # add exiting views:
            from panel_wdg import ViewPanelSaveWdg
            views = ViewPanelSaveWdg.get_existing_views(my.is_personal)
            hidden = HiddenWdg('existing_views', '|'.join(views))
            div.add(hidden)
            """
            text2 = TextWdg("new_title")
            text2.add_class("spt_new_item_title")
            span = SpanWdg("Title: ")
            span.set_id('create_new_title')
            #span.add_style('display: none')
            span.add_style('padding-left: 8px')
            span.add(text2)
            div.add(span)
            div.add(HtmlElement.br(2))

            div.add_style("width: 350px")

            action = '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var title = bvr.src_el.value;
            var name = title.replace(/[\?.!@#$%^&*()'"]/g, "");
            name = name.replace(/ /g, "_");
            name = name.toLowerCase();
            name_el.value = name;
            '''

            # change the name based on the title
            text2.add_behavior({'type': 'change', 'cbjs_action': action})

            div.add(
                "The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>"
            )
            text = TextWdg('new_name')
            text.add_class("spt_new_item_name")
            span = SpanWdg('Name: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))

            #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');"
            #link = HtmlElement.js_href(script, data='[ Predefined View ]')
            #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display())
            #div.add(div3)
            #item_div = DivWdg(css='spt_new_item spt_side_bar_content')
            #div.add(item_div)

            div.add("<hr/>")

            #save_div = SpanWdg(css='med hand')
            #div.add(save_div)
            #save_div.add(IconWdg('Save Folder', IconWdg.SAVE))

            save_button = ActionButtonWdg(title='Create',
                                          tip='Create a new folder')
            div.add(save_button)

            bvr = {
                "type":
                "click_up",
                "view":
                my.view,
                "is_personal":
                is_personal == 'true',
                'cbjs_action':
                '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var name_value = name_el.value;
            if (name_value == "") {
                var title_el = top.getElement(".spt_new_item_title");
                var title = title_el.value;
                var name = spt.convert_to_alpha_numeric(title);
                name_el.value = name;
            }
            if (name_value == "") {
                spt.alert("Please fill in a value for name.");
                return;
            }
            spt.side_bar.manage_section_action_cbk(
                    { 'value':'save_folder'}, bvr.view, bvr.is_personal);
            '''
            }
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br())

        elif my.type == 'new_link':

            div.set_attr('spt_view', 'new_link')
            div.add(HtmlElement.b('Create New Link'))
            div.add(HtmlElement.br())

            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)

            text = TextWdg('new_link_title')
            span = SpanWdg('Title: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))
            cb = CheckboxWdg('include_search_view',
                             label='Include Saved Search')
            cb.set_default_checked()
            div.add(cb)

            div.add(HtmlElement.br(2))
            div.add("Select a search type and view of this link")
            div.add(HtmlElement.br())

            select = SelectWdg("new_search_type")
            select.add_empty_option("-- Select Search type --")

            security = Environment.get_security()
            if security.check_access("builtin", "view_site_admin", "allow"):
                search_types = Project.get().get_search_types(
                    include_sthpw=True, include_config=True)
            else:
                search_types = Project.get().get_search_types()

            values = [x.get_value("search_type") for x in search_types]
            labels = [
                "%s (%s)" % (x.get_value("search_type"), x.get_title())
                for x in search_types
            ]
            values.append("CustomLayoutWdg")
            labels.append("CustomLayoutWdg")
            select.set_option("values", values)
            select.set_option("labels", labels)

            #security = Environment.get_security()
            #if security.check_access("builtin", "view_site_admin", "allow"):
            #    select_mode =  SearchTypeSelectWdg.ALL
            #else:
            #    select_mode =  SearchTypeSelectWdg.ALL_BUT_STHPW
            #select = SearchTypeSelectWdg(name='new_search_type', \
            #    mode=select_mode)

            select.add_behavior({
                'type':
                'change',
                'cbjs_action':
                '''
                var top = bvr.src_el.getParent(".new_item_panel");
                var link_view_select = top.getElement(".link_view_select");
                var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 
                'is_refresh': 'true'}; 
                spt.panel.refresh(link_view_select, values);'''
            })
            div.add(HtmlElement.br())
            div.add(select)

            div.add(HtmlElement.br())

            link_view_sel = NewLinkViewSelectWdg()
            div.add(HtmlElement.br())
            div.add(link_view_sel)

            div.add(HtmlElement.br())
            #select.add_behavior('change')
            div.add(HtmlElement.hr())
            div.add(HtmlElement.br())

            #save_div = DivWdg(css='med hand')
            #div.add(save_div)
            #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE)
            #save_div.add(save_button)

            save_button = ActionButtonWdg(title='Create',
                                          tip='Create a new link')
            div.add(save_button)
            bvr = { "type": "click_up",
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_link'},'%s', %s);" %(my.view, is_personal)}
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br(1))

        elif my.type == 'new_separator':
            div.set_attr('spt_view', 'new_separator')
            div.add(HtmlElement.b('Creating New Separator. . .'))
            div.add(HtmlElement.br())

            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            # since it's automated, this button is not needed
            """ 
            save_div = SpanWdg(css='med hand')
            save_div.add(IconWdg('Save', IconWdg.SAVE))
        
            bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_separator'},'%s');" %my.view}
            save_div.add_behavior(bvr)
            div.add(save_div)
            """
        widget.add(div)
        return widget
예제 #28
0
    def get_set_limit_wdg(my):
        limit_content = DivWdg()
        limit_content.add_style("font-size: 10px")
        #limit_content.add_style("padding", "5px")
        #limit_content.add_border()

        limit_content.add("Show ")

        limit_select = SelectWdg("limit_select")
        limit_select.add_class("spt_search_limit_select")
        limit_select.set_option("values", "10|20|50|100|200|Custom")
        limit_select.add_style("font-size: 10px")
        limit_content.add(limit_select)
        limit_content.add(" items per page<br/>")

        if my.search_limit in [10,20,50,100,200]:
            limit_select.set_value(my.search_limit)
            is_custom = False
        else:
            limit_select.set_value("Custom")
            is_custom = True

        limit_select.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var value = bvr.src_el.value;
            var custom = top.getElement(".spt_search_limit_custom");
            if (value == 'Custom') {
                custom.setStyle("display", "");
            }
            else {
                custom.setStyle("display", "none");
            }

            '''
        } )


        custom_limit = DivWdg()
        limit_content.add(custom_limit)
        custom_limit.add_class("spt_search_limit_custom")
        custom_limit.add("<br/>Custom: ")
        text = TextWdg("custom_limit")
        text.add_class("spt_search_limit_custom_text")
        text.add_style("width: 50px")
        if not is_custom:
            custom_limit.add_style("display: none")
        else:
            text.set_value(my.search_limit)
        custom_limit.add(text)
        text.add(" items")
        behavior = {
                'type': 'keydown',
                'cbjs_action': '''
                 if (evt.key=='enter') {
                    // register this as changed item
                    var value = bvr.src_el.value;
                    if (isNaN(value) || value.test(/[\.-]/)) {
                        spt.error('You have to use an integer.');
                    }
                }
        '''}

        
        text.add_behavior(behavior)

        return limit_content
예제 #29
0
    def get_display(my):
        widget = DivWdg()
        table = Table()
        table.add_attr('class', 'scraper')
        table.add_style('background-color: #FFFFFF;')
        table.add_style('height: 1000px;')
        table.add_row()
        tb = TextWdg('title_box')
        tb.add_attr('id', 'title_box')
        tb.add_attr('size', '45')
        multiple_titles = None
        searched_imdb = False
        orders = []

        # TODO: Remove hard-coded URL
        no_img = 'http://tactic.2gdigital.com/imdb_images/no_image.png'
        if 'code' in my.kwargs.keys() and my.title_of_show in [None, '']:
            server = TacticServerStub.get()
            this_order = server.eval("@SOBJECT(twog/order['code','%s'])" % my.kwargs.get('code'))[0]
            my.title_of_show = this_order.get('name')

        if my.title_of_show not in [None, '']:
            tb.set_value(my.title_of_show)
            if my.search_when_loaded:
                # poster_url_text = my.get_poster_url(my.title_of_show)
                # poster_url = poster_url_text.split('=')[1]
                server = TacticServerStub.get()
                orders = server.eval("@SOBJECT(twog/order['name','~','%s']['classification','not in','Master|Cancelled'])" % my.title_of_show)
                # order_s = Search("twog/order")
                # order_s.add_where("\"name\" like '%s%s%s'" %  ('%', my.title_of_show.lower(), '%'))
                # statement = order_s.get_statement()
                # print "STATEMENT = %s" % statement
                # orders = order_s.get_sobjects()
                # print "ORDER LEN = %s" % len(orders)
                if len(orders) > 0:
                    multiple_titles = get_multiple_title_info(my.title_of_show)
                    # print "MULTIPLE TITLES = %s" % multiple_titles
                    searched_imdb = True
        tb.add_behavior(my.get_search())
        top_tbl = Table()
        top_tbl.add_attr('width', '400px')
        top_tbl.add_attr('height', '50px')
        top_tbl.add_attr('cellpadding', '20')
        top_tbl.add_attr('cellspacing', '20')
        top_tbl.add_style('background-color: #417e97;')
        top_tbl.add_row()

        if len(orders) > 0:
            butt = top_tbl.add_cell('<input type="button" value="Associate All Selected"/>')
            butt.add_behavior(my.get_associate_em())

        sn = top_tbl.add_cell('<font color="#d9af1f"><b>Search Name:</b></font>&nbsp;&nbsp;&nbsp;&nbsp;')
        sn.add_attr('align', 'right')
        sn.add_attr('nowrap', 'nowrap')
        tb_cell1 = top_tbl.add_cell(tb)
        tb_cell = table.add_cell(top_tbl)
        tb_cell.add_attr('colspan', '2')
        tb_cell.add_attr('align', 'center')
        order_table = Table()
        order_table.add_attr('border', '1')
        order_table.add_attr('cellpadding', '10')
        order_table.add_row()

        if len(orders) > 0:
            toggler = CustomCheckboxWdg(name='chk_toggler', additional_js=my.get_toggler(), value_field='toggler',
                                        id='selection_toggler', checked='false', text='<b><- Select/Deselect ALL</b>',
                                        text_spot='right', text_align='left', nowrap='nowrap')
            order_table.add_cell(toggler)
            order_table.add_row()
            order_table.add_cell('Selector')
            order_table.add_cell('Poster')
            order_table.add_cell('Order Builder')
            order_table.add_cell('Code')
            order_table.add_cell('Name')
            order_table.add_cell('Client')
            order_table.add_cell('PO Number')
            order_table.add_cell('Classification')
            order_table.add_cell('Platform')
            order_table.add_cell('Due Date')
            order_table.add_cell('Completion Ratio')
            order_table.add_cell('Scheduler')
        elif my.title_of_show not in [None, ''] and my.search_when_loaded:
            description_box = order_table.add_cell('<b>No Tactic Orders Were Found With "%s" In The Name</b>' % my.title_of_show)
            description_box.add_style('font-size: 14px;')
        else:
            description_box = order_table.add_cell('<b>Please type the name of the show in the box above</b>')
            description_box.add_style('font-size: 14px;')
        for order in orders:
            checkbox = CustomCheckboxWdg(name='associate_order_%s' % order.get('code'),
                                         additional_js=my.highlight_order_row(order.get('code')),
                                         alert_name=order.get('name'),
                                         value_field=order.get('code'),
                                         checked='false',
                                         dom_class='associated_orders')
            imarow = order_table.add_row()
            imarow.add_attr('id', 'row_%s' % order.get('code'))
            chk = order_table.add_cell(checkbox)
            chk.add_attr('align', 'center')
            poster_cell = order_table.add_cell(OrderImageWdg(code=order.get('code')))
            poster_cell.add_attr('id', 'img_%s' % order.get('code'))
            ob = OrderBuilderLauncherWdg(code=order.get('code'))
            obc = order_table.add_cell(ob)
            obc.add_attr('align', 'center')
            order_table.add_cell(order.get('code'))
            order_table.add_cell(order.get('name'))
            order_table.add_cell(order.get('client_name'))
            order_table.add_cell(order.get('po_number'))
            order_table.add_cell(order.get('classification'))
            order_table.add_cell(order.get('platform'))
            order_table.add_cell(order.get('due_date'))
            order_table.add_cell('%s/%s' % (order.get('titles_completed'), order.get('titles_total')))
            order_table.add_cell(order.get('login'))
        imdb_table = Table()
        imdb_table.add_attr('border', '1')
        imdb_table.add_attr('cellpadding', '10')
        if multiple_titles not in [None, ''] and len(multiple_titles) > 0:
            mcount = 0
            seen_titles = []
            for m in multiple_titles:
                title_id = m['TopLevel']['title_id']
                if title_id not in seen_titles:
                    seen_titles.append(title_id)
                    imarow = imdb_table.add_row()
                    imarow.add_attr('id', 'row_%s' % m['TopLevel']['title_id'])
                    this_img = no_img

                    # TODO: Download the image and save in a temp folder
                    if m['TopLevel']['poster'] not in [None, '']:
                        this_img = m['TopLevel']['poster']
                        imdb_image_url = m['TopLevel']['poster']
                    checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % m['TopLevel']['title_id'],
                                                 additional_js=my.act_like_radio(m['TopLevel']['title_id']),
                                                 alert_name=m['TopLevel']['title'],
                                                 value_field=m['TopLevel']['title_id'],
                                                 checked='false',
                                                 dom_class='associated_imdb',
                                                 extra1=m['TopLevel']['title_id'],
                                                 extra2=m['TopLevel']['title'],
                                                 extra3=m['TopLevel']['runtime'],
                                                 extra4=m['TopLevel']['release_date'],
                                                 extra5=m['TopLevel']['imdb_url'],
                                                 extra6=this_img)
                    chk = imdb_table.add_cell(checkbox)
                    chk.add_attr('align', 'center')
                    imdb_table.add_cell('<img src="%s"/>' % this_img)
                    info_tbl = Table()
                    info_tbl.add_row()
                    title_cell = info_tbl.add_cell('<b>Title: %s</b>' % m['TopLevel']['title'])
                    title_cell.add_style('cursor: pointer;')
                    title_cell.add_behavior(my.get_more_info(mcount))
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Original Title: %s</i>' % m['TopLevel']['original_title'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Run Time: %s</i>' % m['TopLevel']['runtime'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Release Date: %s</i>' % m['TopLevel']['release_date'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Rating: %s</i>' % m['TopLevel']['rating'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>IMDb URL: %s</i>' % m['TopLevel']['imdb_url'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Plot: %s</i>' % m['TopLevel']['plot'])
                    info2 = Table()
                    mkeys = m.keys()
                    for k in mkeys: 
                        if k not in ['media_images', 'recommended_titles', 'videos', 'cinematographers', 'editors',
                                     'producers', 'cast', 'directors', 'writers', 'stars', 'plot_keywords', 'musicians',
                                     'TopLevel']:
                            info2.add_row()
                            info2.add_cell('<b><u>%s</u></b>' % k)
                            dudes = m[k]
                            dkeys = dudes.keys()
                            for d in dkeys:
                                info2.add_row()
                                info2.add_cell('%s: %s' % (d, dudes[d]))
                    intable = imdb_table.add_cell(info_tbl)
                    intable.add_attr('valign', 'top')
                    intable.add_attr('align', 'left')
                    # intable.add_behavior(my.get_hover_behavior(mcount))
                    hidrow = imdb_table.add_row()
                    hidrow.add_attr('hidden_id', mcount)
                    hidrow.add_attr('class', 'hidden_info')
                    hidrow.add_style('display: none;')
                    intable2 = imdb_table.add_cell(info2)
                    intable2.add_attr('valign', 'top')
                    intable2.add_attr('align', 'left')
                    mcount += 1
        elif my.title_of_show not in [None, ''] and searched_imdb:
            imdb_table.add_row()
            description_box = imdb_table.add_cell('<b>No IMDb Titles Were Found With "%s" In The Name</b>' % my.title_of_show)
            description_box.add_style('font-size: 14px;')
            imarow = imdb_table.add_row()
            imarow.add_attr('id', 'row_%s' % 'none')
            checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % 'none', additional_js=my.act_like_radio('none'),
                                         alert_name='No IMDb Link', value_field='none', checked='false',
                                         dom_class='associated_imdb', extra1='none', extra2='No IMDb Link', extra3='',
                                         extra4='', extra5='none', extra6=no_img)
            chk = imdb_table.add_cell(checkbox)
            chk.add_attr('align', 'center')
            imdb_table.add_cell('<img src="%s"/>' % no_img)
            info_tbl = Table()
            info_tbl.add_row()
            title_cell = info_tbl.add_cell('<b>Title: %s</b>' % 'No IMDb Link')
            title_cell.add_style('cursor: pointer;')
            intable = imdb_table.add_cell(info_tbl)
            intable.add_attr('valign', 'top')
            intable.add_attr('align', 'left')
            hidrow = imdb_table.add_row()
            hidrow.add_attr('class', 'hidden_info')
            hidrow.add_style('display: none;')
        elif my.title_of_show not in [None, '']:
            imdb_table.add_row()
            description_box = imdb_table.add_cell("<b>No Tactic Orders Found, Didn't Query IMDb</b>")
            description_box.add_style('font-size: 14px;')
        table.add_row()
        order_div = DivWdg()
        order_div.add_style('overflow-y: scroll;')
        order_div.add_style('height: 1000px;')
        order_div.add_style('width: 750px;')
        order_div.add('<font size=7><b>Tactic Orders</b></font>')
        order_div.add(order_table)
        ot = table.add_cell(order_div)
        ot.add_attr('valign', 'top')
        imdb_div = DivWdg()
        imdb_div.add_style('overflow-y: scroll;')
        imdb_div.add_style('height: 1000px;')
        imdb_div.add_style('width: 750px;')
        imdb_div.add('<font size=7><b>IMDb</b></font>')
        imdb_div.add(imdb_table)
        it = table.add_cell(imdb_div)
        it.add_attr('valign', 'top')
        widget.add(table)
        return widget
예제 #30
0
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.named_events.fire_event("side_bar|hide")
            '''
        } )
        top.add_style("width: 100%")
        top.add_color("background", "background", -10)
        top.add_style("padding-top: 10px")
        top.add_style("padding-bottom: 50px")
        top.add_class("spt_project_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_style("width: 700px")
        inner.add_style("float: center")
        inner.add_border()
        inner.center()
        inner.add_style("padding: 30px")
        inner.add_color("background", "background")


        from tactic.ui.container import WizardWdg


        title = DivWdg()
        title.add("Create A New Project")

        wizard = WizardWdg(title=title, width="100%")
        inner.add(wizard)


        help_button = ActionButtonWdg(title="?", tip="Create Project Help", size='s')
        title.add(help_button)
        help_button.add_style("float: right")
        help_button.add_style("margin-top: -20px")
        help_button.add_style("margin-right: -10px")
        help_button.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
            spt.help.set_top();
            spt.help.load_alias("create-new-project");
            '''
        })




        info_page = DivWdg()
        wizard.add(info_page, 'Info')
        info_page.add_class("spt_project_top")
        info_page.add_style("font-size: 12px")
        info_page.add_color("background", "background")
        info_page.add_color("color", "color")
        info_page.add_style("padding: 20px")



        from tactic.ui.input import TextInputWdg

        info_page.add("<b>Project Title:</b> &nbsp;&nbsp;")
    
        text = TextWdg("project_title")
        text.add_behavior( {
            'type': 'blur',
            'cbjs_action': '''
            if (bvr.src_el.value == '') {
                spt.alert("You must enter a project title");
                return;
            }
        '''})

        #text = TextInputWdg(title="project_title")
        info_page.add(text)
        text.add_style("width: 250px")
        info_page.add(HtmlElement.br(3))
        span = DivWdg()
        info_page.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("The project title can be descriptive and contain spaces and special characters.")
        info_page.add("<br/><br/><hr/><br/><br/>")
        text.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var title = bvr.src_el.value;
        if (title.length > 100) {
            spt.alert("Title cannot exceed 100 characters.");
            return;
        }
        var code = spt.convert_to_alpha_numeric(title);
        code = code.substring(0,30);
        var top = bvr.src_el.getParent(".spt_project_top");
        var code_el = top.getElement(".spt_project_code");
        code_el.value = code;
        '''
        } )


        info_page.add("<b>Project Code: &nbsp;&nbsp;</b>")
        text = TextWdg("project_code")
        #text = TextInputWdg(title="project_code")
        text.add_behavior( {
            'type': 'blur',
            'cbjs_action': '''
            var value = bvr.src_el.value;
            var code = spt.convert_to_alpha_numeric(value);
            bvr.src_el.value = code;
            
            if (code == '') {
                spt.alert("You must enter a project code.");
                return;
            }
            if (spt.input.has_special_chars(code)) {
                spt.alert("Project code cannot contain special characters.");
                return;
            }
        
            if (code.test(/^\d/)) {
                spt.alert("Project code cannot start with a number.");
                return;
            }
            if (code.length > 30) {
                 spt.alert("Project code cannot exceed 30 characters.");
                return;
            }
       
            '''
        } )


        info_page.add(text)
        text.add_style("width: 250px")
        text.add_class("spt_project_code")
        info_page.add(HtmlElement.br(4))

        span = DivWdg()
        info_page.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("The project code is a very important key that will tie many components of the project together.")
        span.add("<br/><br/>")
        span.add("* Note: the project code must contain only alphanumeric characters [A-Z]/[0-9] and only an '_' as a separator")
        info_page.add(span)

        info_page.add("<br/>"*2)


        projects = Project.get_all_projects()

        info_page.add("<b>Is Main Project? </b>")

        checkbox = CheckboxWdg("is_main_project")
        default_project_code = Config.get_value("install", "default_project")
        info_page.add(checkbox)
        if default_project_code:
            default_project = Project.get_by_code(default_project_code)
        else:
            default_project = None

        if default_project:
            default_title = default_project.get_value("title")
            info_span = SpanWdg()
            info_page.add(info_span)
            info_span.add("%sCurrent: %s (%s)" % ("&nbsp;"*3, default_title, default_project_code))
            info_span.add_style("font-size: 0.9em")
            info_span.add_style("font-style: italic")
        else:
            if len(projects) == 0:
                checkbox.set_checked()

        info_page.add("<br/>"*2)

        span = DivWdg()
        info_page.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("A TACTIC installation can have multiple projects, but one can be designated as the main project.  This project will appear at the root of the url. This is meant for building custom project launcher which is based on a main project.")
        span.add("<br/>"*2)
        span.add("* Note: TACTIC may need to be restarted in order for this to take effect")
        info_page.add(span)

        info_page.add("<br/>")









        # add an icon for this project
        image_div = DivWdg()
        wizard.add(image_div, 'Preview Image')
        image_div.add_class("spt_image_top")
        image_div.add_color("background", "background")
        image_div.add_color("color", "color")
        image_div.add_style("padding: 20px")


        image_div.add("<b>Project Image: </b>")
        image_div.add("<br/>"*3)
        on_complete = '''var server = TacticServerStub.get();
        var file = spt.html5upload.get_file(); 
        if (file) { 

            var top = bvr.src_el.getParent(".spt_image_top");
            var text = top.getElement(".spt_image_path");
            var display = top.getElement(".spt_path_display");
            var check_icon = top.getElement(".spt_check_icon");

            var server = TacticServerStub.get();
            var ticket = spt.Environment.get().get_ticket();


            display.innerHTML = "Uploaded: " + file.name;
            display.setStyle("padding", "10px");
            check_icon.setStyle("display", "");
          
          
            var filename = file.name;
            filename = spt.path.get_filesystem_name(filename);
            var kwargs = {
                ticket: ticket,
                filename: filename
            }
            try {
                var ret_val = server.execute_cmd("tactic.command.CopyFileToAssetTempCmd", kwargs);
                var info = ret_val.info;
                var path = info.web_path;
                text.value = info.lib_path;
                display.innerHTML = display.innerHTML + "<br/><br/><div style='text-align: center'><img style='width: 80px;' src='"+path+"'/></div>";
            }
            catch(e) {
                spt.alert(spt.exception.handler(e));
            }
            spt.app_busy.hide();
            }
        else {
            spt.alert('Error: file object cannot be found.') 
        }
            spt.app_busy.hide();
        '''
        button = UploadButtonWdg(title="Browse", on_complete=on_complete) 
        button.add_style("margin-left: auto")
        button.add_style("margin-right: auto")
        image_div.add(button)


        text = HiddenWdg("project_image_path")
        text.add_class("spt_image_path")
        image_div.add(text)

        check_div = DivWdg()
        image_div.add(check_div)
        check_div.add_class("spt_check_icon")
        check_icon = IconWdg("Image uploaded", IconWdg.CHECK)
        check_div.add(check_icon)
        check_div.add_style("display: none")
        check_div.add_style("float: left")
        check_div.add_style("padding-top: 8px")

        path_div = DivWdg()
        image_div.add(path_div)
        path_div.add_class("spt_path_display")

        image_div.add(HtmlElement.br(3))
        span = DivWdg()
        image_div.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add_color("background", "background3")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add("The project image is a small image that will be used in various places as a visual representation of this project.")

        info_page.add("<br/><br/>")





        # get all of the template projects that are installed
        copy_div = DivWdg()
        wizard.add(copy_div, "Template")
        copy_div.add_style("padding-top: 20px")





        template = ActionButtonWdg(title="Manage", tip="Manage Templates")
        copy_div.add(template)
        template.add_style("float: right")
        template.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var class_name = 'tactic.ui.app.ProjectTemplateWdg'
                spt.panel.load_popup("Templates", class_name)
            '''
        } )
        template.add_style("margin-top: -5px")




        copy_div.add("<b>Copy From Template: &nbsp;&nbsp;</b>")



        search = Search("sthpw/project")
        search.add_filter("is_template", True)
        template_projects = search.get_sobjects()
        values = [x.get_value("code") for x in template_projects]
        labels = [x.get_value("title") for x in template_projects]


        # find all of the template projects installed
        template_dir = Environment.get_template_dir()
        import os
        if not os.path.exists(template_dir):
            paths = []
        else:
            paths = os.listdir(template_dir);


            file_values = []
            file_labels = []
            for path in paths:
                if path.endswith("zip"):
                    orig_path = '%s/%s'%(template_dir, path)
                    path = path.replace(".zip", "")
                    parts = path.split("-")
                    plugin_code = parts[0]

                    # skip if there is a matching project in the database
                    #match_project = plugin_code.replace("_template", "")
                    
                    match_project = plugin_code
                    old_style_plugin_code = re.sub( '_template$', '', plugin_code)

                    if match_project in values:
                        continue
                    elif old_style_plugin_code in values:
                        continue

                    label = "%s (from file)" % Common.get_display_title(match_project)

                    # for zip file, we want the path as well
                    value = '%s|%s'%(plugin_code, orig_path)
                    file_values.append(value)
                    file_labels.append(label)

            if file_values:
                values.extend(file_values)
                labels.extend(file_labels)


        values.insert(0, "_empty")
        labels.insert(0, "- Empty Project -")

        select = SelectWdg("project_source")
        copy_div.add(select)
        select.set_option("values", values)
        select.set_option("labels", labels)
        #select.add_empty_option("-- Select --")

        select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        var top = bvr.src_el.getParent(".spt_project_top");
        var type = top.getElement(".spt_custom_project_top");
        var namespace_option = top.getElement(".spt_custom_namespace_top");

        var theme_el = top.getElement(".spt_theme_top");

        if (bvr.src_el.value == "_empty") {
            spt.show(type);
            spt.show(namespace_option);

            spt.show(theme_el);

        }
        else {
            spt.hide(type);
            spt.hide(namespace_option);

            spt.hide(theme_el);
        }
        '''
        } )



        copy_div.add(HtmlElement.br(3))
        span = DivWdg()
        copy_div.add(span)
        span.add_style("padding: 20px 20px 20px 20px")
        span.add(IconWdg("INFO", IconWdg.CREATE))
        span.add_color("background", "background3")
        span.add("This will use the selected project template as a basis and copy all of the configuration elements.  Only template projects should be copied.")

        #copy_div.add(HtmlElement.br(2))
        #span = DivWdg("This will create an empty project with no predefined configuration.")
        #copy_div.add(span)

        #
        # Theme
        #
        theme_div = DivWdg()
        theme_div.add_class("spt_theme_top")
        theme_div.add_style("padding: 10px")
        theme_div.add_style("margin-top: 20px")
        copy_div.add(theme_div)
        theme_div.add("<b>Theme: </b>&nbsp; ")
        theme_div.add_style('padding-right: 6px')

        theme_select = SelectWdg('project_theme')
        theme_div.add(theme_select)



        # look in the plugins for all of the themes?
        from pyasm.biz import PluginUtil
        plugin_util = PluginUtil()
        data = plugin_util.get_plugins_data("theme")

        builtin_dir = Environment.get_builtin_plugin_dir()
        plugin_util = PluginUtil(base_dir=builtin_dir)

        data2 = plugin_util.get_plugins_data("theme")


        data = dict(data.items() + data2.items())

        themes = data.keys()
        themes.sort()




        theme_select.set_option("values", themes)
        theme_select.add_empty_option('- No Theme -')
        default_theme = "TACTIC/default_theme"
        theme_select.set_value(default_theme)

        theme_select.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_project_top");
            var img_div = top.getElement(".spt_project_theme_div");
            var theme = bvr.src_el.value;

            var img_els = img_div.getElements(".spt_project_theme_image");
            for (var i = 0; i < img_els.length; i++) {
                if (theme == img_els[i].getAttribute("spt_theme") ) {
                    img_els[i].setStyle("display", "");
                }
                else {
                    img_els[i].setStyle("display", "none");
                }
            }
            '''
        } )

        theme_img_div = DivWdg()
        theme_div.add(theme_img_div)
        theme_img_div.add_class("spt_project_theme_div")

        for theme in themes:
            theme_item = DivWdg()
            theme_item.add_style("margin: 15px")
            theme_img_div.add(theme_item)
            theme_item.add_attr("spt_theme", theme)
            theme_item.add_class("spt_project_theme_image")
            if theme != default_theme:
                theme_item.add_style("display: none")

            table = Table()
            theme_item.add(table)
            table.add_row()

            if Environment.is_builtin_plugin(theme):
                theme_img = HtmlElement.img(src="/tactic/builtin_plugins/%s/media/screenshot.jpg" % theme)
            else:
                theme_img = HtmlElement.img(src="/tactic/plugins/%s/media/screenshot.jpg" % theme)
            theme_img.add_border()
            theme_img.set_box_shadow("1px 1px 1px 1px")
            theme_img.add_style("margin: 20px 10px")
            theme_img.add_style("width: 240px")

            plugin_data = data.get(theme)

            description = plugin_data.get("description")
            if not description:
                description = "No Description"

            table.add_cell(theme_img)
            table.add_cell( description )



        theme_img_div.add_style("text-align: center")
        theme_img_div.add_style("margin: 10px")

 

        #
        # namespace
        #
        ns_div = DivWdg()
        ns_div.add_class("spt_custom_namespace_top")
        ns_div.add_style("padding: 10px")
        copy_div.add(ns_div)
        ns_div.add("<br/>")
        ns = HtmlElement.b("Namespace:")
        ns.add_style('padding-right: 6px')
        ns_div.add(ns)

        text = TextWdg('custom_namespace')
        text.add_class("spt_custom_namespace")
        text.add_behavior( {
            'type': 'blur',
            'cbjs_action': '''
                 var project_namespace = bvr.src_el.value;
                 if (['sthpw','prod'].contains(project_namespace)) 
                    spt.alert('Namespace [' + project_namespace + '] is reserved.');

                 if (project_namespace.strip()=='') 
                    spt.alert('A "default" namespace will be used if you leave it empty.');
            
            '''})

        ns_div.add(text)

        hint = HintWdg('This will be used as the prefix for your sTypes. You can use your company name for instance')
        ns_div.add(hint)

        # is_template
        is_template_div = DivWdg()
        #is_template_div.add_style('display: none')

        is_template_div.add_class("spt_custom_project_top")
        is_template_div.add_style("padding: 10px")
        copy_div.add(is_template_div)
        is_template_div.add("<br/>")
        is_template_div.add("<b>Is this project a template: </b>")

        text = CheckboxWdg("custom_is_template")
        text.add_class("spt_custom_is_template")
        is_template_div.add(text)

        is_template_div.add(HtmlElement.br(2))
        span = DivWdg("Template projects are used as a blueprint for generating new projects.")
        is_template_div.add(span)



        # Disabling for now ... advanced feature and may not be necessary
        #stypes_div = my.get_stypes_div()
        #is_template_div.add(stypes_div)








        last_page = DivWdg()
        wizard.add(last_page, "Complete")

        last_page.add_style("padding-top: 80px")
        last_page.add_style("padding-left: 30px")

        cb = RadioWdg('jump_project', label='Jump to New Project')
        cb.set_option("value", "project")
        #cb.set_option('disabled','disabled')
        cb.set_checked()
        last_page.add(cb)

        last_page.add(HtmlElement.br(2))

        cb = RadioWdg('jump_project', label='Jump to Project Admin')
        cb.set_option("value", "admin")
        last_page.add(cb)


        last_page.add(HtmlElement.br(2))

        cb = RadioWdg('jump_project', label='Create Another Project')
        cb.set_option("value", "new")
        last_page.add(cb)




        last_page.add(HtmlElement.br(5))


        button_div = DivWdg()

        create_button = ActionButtonWdg(title="Create >>", tip="Create new project")
        wizard.add_submit_button(create_button)
        #button_div.add(create_button)
        create_button.add_style("float: right")

        create_button.add_behavior({
        'type': "click_up",
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_project_top");
        var values = spt.api.Utility.get_input_values(top, null, null, null, {cb_boolean: true});

        var project_code = values['project_code'][0];
        if (project_code == '') {
            spt.alert("You must enter a project code.");
            return;
        }
        if (spt.input.has_special_chars(project_code)) {
            spt.alert("Project code cannot contain special characters.");
            return;
        }
        
        if (project_code.test(/^\d/)) {
            spt.alert("Project code cannot start with a number.");
            return;
        }
        if (values['project_title'] == '') {
            spt.alert("You must enter a project title");
            return;
        }

        var project_source = values.project_source[0];

        var project_image_path = values['project_image_path'][0];

        var project_theme = values['project_theme'][0];

        var options = {
            'project_code': project_code,
            'project_title': values['project_title'][0],
            'project_image_path': project_image_path,
            'project_theme': project_theme,
        }

        //'copy_pipelines': values['copy_pipelines'][0]

        var class_name;
        var busy_title;
        var busy_msg;
        var use_transaction;
        if (project_source == '') {
            spt.alert("Please select a template to copy or select create an empty project");
            return;
        }
        else if (project_source != '_empty') {
            busy_title = "Copying Project"; 
            busy_msg = "Copying project ["+project_source+"] ...";
            use_transaction = false;

            class_name = 'tactic.command.ProjectTemplateInstallerCmd';
            if (project_source.test(/\|/)) {
                var tmps = project_source.split('|');
                project_source = tmps[0];
                var path = tmps[1];
                options['path'] = path;
            }
            options['template_code'] = project_source;
            options['force_database'] = true;

        }
        else {
            class_name = "tactic.command.CreateProjectCmd";
            busy_title = "Creating New Project"; 
            busy_msg = "Creating new project based on project info ...";
            use_transaction = true;

            // use project code as the project type if namespace is not specified
            var project_namespace = values['custom_namespace'][0];
            if (['sthpw','prod'].contains(project_namespace)) {
                spt.alert('Namespace [' + project_namespace + '] is reserved.');
                return;
            }
            options['project_type'] =  project_namespace ? project_namespace : project_code
            var is_template = values['custom_is_template'];
            if (is_template) {
                options['is_template'] = is_template[0];
            }
            // This has been commented out in the UI
            //options['project_stype'] = values['project_stype'].slice(1);


            var is_main_project = values['is_main_project'];
            if (is_main_project) {
                options['is_main_project'] = is_main_project[0];
            }

        }

        // Display app busy pop-up until create project command
        // has completed executing.
        spt.app_busy.show( busy_title, busy_msg ); 

        setTimeout( function() {

            var ret_val = '';
            var server = TacticServerStub.get();
            try {
                ret_val = server.execute_cmd(class_name, options, {}, {use_transaction: true});
            }
            catch(e) {
                spt.app_busy.hide();
                spt.alert("Error: " + spt.exception.handler(e));
                return;
                throw(e);
            }
            spt.api.Utility.clear_inputs(top);

            // show feedback at the end
            var jump = values['jump_project'][0];
            if (jump == 'project' || jump == 'admin') {
                var location;
                if (jump == 'admin') {
                    location = "/tactic/" + project_code + "/admin";
                }
                else if (project_theme) {
                    location = "/tactic/" + project_code + "/";
                }
                else {
                    location = "/tactic/" + project_code + "/admin/link/_startup";
                }
                setTimeout( function() {
                    document.location = location;
                    }, 1000);
            }
            else { 
                // Refresh header
                spt.panel.refresh(top);
                setTimeout( function() {
                    spt.panel.refresh('ProjectSelectWdg');
                }, 2800);


                spt.app_busy.hide();
            }

            // don't hide because it gives the false impression that nothing
            // happened as it waits for the timeout
            //spt.app_busy.hide();
        }, 0 );

        '''


        })


        cancel_script = my.kwargs.get("cancel_script")
        if cancel_script:
            cancel_button = ActionButtonWdg(title="Cancel")
            cancel_button.add_style("float: left")

            cancel_button.add_behavior({
                'type': "click_up",
                'cbjs_action': cancel_script
            })

            button_div.add(cancel_button)

            create_button.add_style("margin-right: 15px")
            create_button.add_style("margin-left: 75px")


        button_div.add("<br clear='all'/>")

        last_page.add(button_div)


        inner.add(HtmlElement.br())
   
        return top
예제 #31
0
    def get_display(my):
        my.icon_string = my.get_value("icon")
        my.icon_label = my.get_value("label")

        top = DivWdg()
        top.add_class("spt_icon_chooser_top")

        # FIXME: this is being generated every time .... where to put is?
        icon_chooser = IconChooserWdg( is_popup=True )
        top.add( icon_chooser )

        icon_entry_text = TextWdg(my.get_input_name())
        icon_entry_text.set_option("size", "30")
        #icon_entry_text.set_attr("disabled", "disabled")
        icon_entry_text.add_class( "SPT_ICON_ENTRY_TEXT" )


        button = ActionButtonWdg(title='Choose', tip='Click to select an icon')

        icon_img = HtmlElement.img()
        icon_img.add_class( "SPT_ICON_IMG" )

        if my.icon_string:
            # icon_path = IconWdg.icons.get(my.icon_string)
            icon_path = IconWdg.get_icon_path(my.icon_string)
            if icon_path:
                # icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
                icon_img.set_attr("src", icon_path)
            else:
                icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))

            icon_entry_text.set_value( my.icon_string )
        else:
            icon_entry_text.set_value( "" )
            icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))


        named_event_name = "ICON_CHOOSER_SELECTION_MADE"
        icon_entry_text.add_behavior( {'type': 'listen', 'event_name': named_event_name,
           'cbjs_action': '''
                var top = $("IconChooserPopup");
                var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
                //var chooser = spt.get_cousin( bvr.src_el,
                //    ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );

                var icon_name = chooser.getProperty("spt_icon_selected");
                var icon_path = chooser.getProperty("spt_icon_path");
                // bvr.src_el.innerHTML = icon_name;
                bvr.src_el.value = icon_name;
                if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
                var img_el = spt.get_cousin( bvr.src_el,
                    ".spt_icon_chooser_top", ".SPT_ICON_IMG" );
                if( icon_path ) {
                    img_el.setProperty("src", icon_path);
                } else {
                    img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
                }
           ''' } )

        top.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )

        #top.add( my.icon_label )
        spacing = "<img src='%s' style='width: %spx;' />" % (IconWdg.get_icon_path("TRANSPARENT"), 3)

        #button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
        #top.add( button )
        #button.add_style("float: right")
        #button.add_style("margin-top: -3px")

        top.add( icon_img )
        top.add( spacing )
        top.add( icon_entry_text )



        return top
예제 #32
0
    def handle_item_div(my, item_div, dirname, basename):

        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")

        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")

        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg("No Changes", IconWdg.CHECK, width=12)
        elif status == 'added':
            check = IconWdg("Added", IconWdg.NEW, width=16)
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg("Unversioned", IconWdg.HELP, width=12)
        elif status == 'missing':
            check = IconWdg("Missing", IconWdg.WARNING, width=12)
        elif status == 'editable':
            check = IconWdg("Editable", IconWdg.EDIT, width=12)
        elif status == 'modified':
            check = IconWdg("Modified", IconWdg.WARNING, width=12)
        else:
            check = IconWdg("Error (unknown status)", IconWdg.ERROR, width=12)

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")

        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" %
                         status)

        spath = path.replace(" ", "_")

        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')

        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")

        subcontext.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            False,
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        subcontext.add_style("display: none")
        item_div.add(subcontext)
예제 #33
0
    def get_scale_wdg(my):

        if my.scale_called == True:
            return None
        my.scale_called = True

        show_scale = my.kwargs.get("show_scale")

        div = DivWdg()
        if show_scale in [False, 'false']:
            div.add_style("display: none")
        div.add_style("padding: 5px")
        div.add_class("spt_table_search")
        hidden = HiddenWdg("prefix", "tile_layout")
        div.add(hidden)
        div.add_behavior( {
            'type': 'load',
            'scale_prefix':  my.scale_prefix,
            'default_scale': my.scale,
            'aspect_ratio': my.aspect_ratio,
            'cbjs_action': '''
spt.tile_layout = {}
spt.tile_layout.layout = null;

spt.tile_layout.set_layout = function(layout) {
    if (!layout.hasClass("spt_layout")) {
        layout = layout.getParent(".spt_layout");
    }
    spt.tile_layout.layout = layout;
    return layout;
}

spt.tile_layout.get_scale = function() {
    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    var value = scale_value.value;
    value = parseInt(value);
    return value;
}


spt.tile_layout.set_scale = function(scale) {

    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    scale_value.value = scale;

    var size_x = bvr.aspect_ratio[0]*scale/100;
    var size_y = bvr.aspect_ratio[1]*scale/100;

    //var top = bvr.src_el.getParent(".spt_tile_layout_top");
    var top = spt.tile_layout.layout;
    var els = top.getElements(".spt_tile_content");
    for (var i = 0; i < els.length; i++) {
        var el = els[i];
        el.setStyle( "width",  size_x);
        el.setStyle( "height", size_y);
    }

    var container_id = "tile_layout::scale"+bvr.scale_prefix;
    spt.container.set_value( container_id, scale);
}


spt.tile_layout.drag_start_x = null;
spt.tile_layout.drag_start_value = null;

spt.tile_layout.drag_setup = function(evt, bvr, mouse_411) {
    spt.tile_layout.set_layout(bvr.src_el);
    spt.tile_layout.drag_start_x = mouse_411.curr_x;
    var src_el = spt.behavior.get_bvr_src( bvr );
    if (!src_el.value) {
        src_el.value = 0;
    }
    spt.tile_layout.drag_start_value = src_el.value;
    src_el.focus();
    src_el.select();
}
spt.tile_layout.drag_motion = function(evt, bvr, mouse_411) {
    var start_value = spt.tile_layout.drag_start_value; 
    if (isNaN(parseInt(start_value))) {
        return;
    }
    var dx = mouse_411.curr_x - spt.tile_layout.drag_start_x;
    var increment = parseInt(dx / 5);
    var multiplier;
    if (increment < 0)
        multiplier = 0.975;
    else
        multiplier = 1 / 0.975;
    increment = Math.abs(increment);
    var scale = spt.tile_layout.drag_start_value;
    for (var i = 0; i < increment; i++) {
        scale = scale * multiplier;
    }
    if (scale > 400)
        scale = 400;
    scale = parseInt(scale);
    spt.tile_layout.set_scale(scale);

}
spt.tile_layout.setup_control = function() {
   var slider = spt.tile_layout.layout.getElement('.spt_slider');
   var container_id = "tile_layout::scale"+bvr.scale_prefix;
   var initial_value = spt.container.get_value(container_id) ?  spt.container.get_value(container_id) : bvr.default_scale;

   spt.tile_layout.set_scale(initial_value);
   new Slider(slider, slider.getElement('.knob'), {
    range: [30, 400],
    steps: 74,
    initialStep: initial_value,
    onChange: function(value){
      if (value) spt.tile_layout.set_scale(value);
    }
  });
}



spt.tile_layout.image_drag_setup = function(evt, bvr, mouse_411) {
    bvr.use_copy = true;
    bvr.use_delta = true;
    //bvr.border_color = border_color;
    bvr.dx = 10;
    bvr.dy = 10;
    bvr.drop_code = 'DROP_ROW';


}

spt.tile_layout.image_drag_motion = function(evt, bvr, mouse_411) {

    spt.mouse._smart_default_drag_motion(evt, bvr, mouse_411);
    var target_el = spt.get_event_target(evt);
    target_el = spt.mouse.check_parent(target_el, bvr.drop_code);
    if (target_el) {
        var orig_border_color = target_el.getStyle('border-color');
        var orig_border_style = target_el.getStyle('border-style');
        target_el.setStyle('border','dashed 2px ' + bvr.border_color);
        if (!target_el.getAttribute('orig_border_color')) {
            target_el.setAttribute('orig_border_color', orig_border_color);
            target_el.setAttribute('orig_border_style', orig_border_style);
        }
    }

}

spt.tile_layout.image_drag_action = function(evt, bvr, mouse_411) {
    if (spt.drop) {
        spt.drop.sobject_drop_action(evt, bvr);
    }
    else {
        if( bvr._drag_copy_el ) {
            spt.behavior.destroy_element(bvr._drag_copy_el);
        }
    }
}

        ''' } )


        scale = my.kwargs.get("scale")


        div.add_behavior( {
        'type': 'load',
        'scale': scale,
        'cbjs_action': '''
        spt.tile_layout.set_layout(bvr.src_el);

        spt.tile_layout.setup_control();

        if (bvr.scale) {
            spt.tile_layout.set_scale(bvr.scale);
        }
      
        '''
        } )

        table = Table()
        div.add(table)
        table.add_row()

        """
        # TO BE DELETED
        less_div = DivWdg()
        less_div.add("<input type='button' value='&lt;&lt;'/>")
        table.add_cell(less_div)

        less_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale * 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )
        """

        dark_color = div.get_color("background", -5)
        light_color = div.get_color('color')
        med_color = div.get_color('color2')
        
        slider_div = DivWdg(css='spt_slider')
        slider_div.add_styles('valign: bottom; background: %s; height: 6px; width: 100px;'% light_color)
        knob_div = DivWdg(css='knob')
        knob_div.add_behavior({'type':'click',
                'cbjs_action': 'spt.tile_layout.set_layout(bvr.src_el)'
                })
        knob_div.add_styles('background: %s; bottom: 4px;\
                height: 16px; width: 12px; border-radius: 6px 6px 0 0;\
                border: 1px %s solid'\
                %(dark_color, med_color ))
        slider_div.add(knob_div)
        td = table.add_cell(slider_div)
        value_wdg = TextWdg("scale")
        value_wdg.add_class("spt_scale_value")
        td = table.add_cell(value_wdg)
        td.add("&nbsp;%")

        td.add_style("padding: 3px 8px")

        """
        # TO BE DELETED
        from tactic.ui.filter import FilterData
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix("tile_layout")
        if data_list:
            data = data_list[0]
        else:
            data = {}
        my.scale = data.get("scale")
        if my.scale == None:
            my.scale = my.kwargs.get("scale")
        """
        if my.scale:
            value_wdg.set_value(my.scale)
        value_wdg.add_style("width: 28px")
        value_wdg.add_style("text-align: center")
        value_wdg.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )
        value_wdg.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        if (!value) {
            value = 100;
        }
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )



 
        value_wdg.add_behavior( {
            'type': 'smart_drag',
            'bvr_match_class': 'spt_scale_value',
            'ignore_default_motion' : True,
            "cbjs_setup": 'spt.tile_layout.drag_setup( evt, bvr, mouse_411 );',
            "cbjs_motion": 'spt.tile_layout.drag_motion( evt, bvr, mouse_411 );'
        } )

        
        """
        # TO BE DELETED
        more_div = DivWdg()
        more_div.add("<input type='button' value='&gt;&gt;'/>")
        table.add_cell(more_div)

        more_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale / 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )

        """


       

        return div
예제 #34
0
    def get_display(my):
        widget = DivWdg(id='new_item_panel')
        widget.add_class("new_item_panel")
        widget.add_class("spt_new_item_top")

        div = DivWdg()
        div.add_color("background", "background")
        div.add_color("color", "color")
        div.add_style("padding", "5px")
        div.add_border()

        if my.is_personal:
            is_personal = 'true'
        else:
            is_personal = 'false'

        if my.type == 'new_folder':
            #div.set_attr('spt_view', 'new_folder')
            div.add(HtmlElement.b('Create New Folder'))
            div.add(HtmlElement.br(2))
            """
            # add exisiting views in the div for checking with client's input
             # add exiting views:
            from panel_wdg import ViewPanelSaveWdg
            views = ViewPanelSaveWdg.get_existing_views(my.is_personal)
            hidden = HiddenWdg('existing_views', '|'.join(views))
            div.add(hidden)
            """
            text2 = TextWdg("new_title")
            text2.add_class("spt_new_item_title")
            span = SpanWdg("Title: ")
            span.set_id('create_new_title')
            #span.add_style('display: none')
            span.add_style('padding-left: 8px')
            span.add(text2)
            div.add(span)
            div.add(HtmlElement.br(2))

            div.add_style("width: 350px")


            action = '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var title = bvr.src_el.value;
            var name = title.replace(/[\?.!@#$%^&*()'"]/g, "");
            name = name.replace(/ /g, "_");
            name = name.toLowerCase();
            name_el.value = name;
            '''


            # change the name based on the title
            text2.add_behavior( {
            'type': 'change',
            'cbjs_action': action
            } )

            div.add("The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>")
            text = TextWdg('new_name')
            text.add_class("spt_new_item_name")
            span = SpanWdg('Name: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))
            
            #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');"
            #link = HtmlElement.js_href(script, data='[ Predefined View ]')
            #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display())
            #div.add(div3)
            #item_div = DivWdg(css='spt_new_item spt_side_bar_content')
            #div.add(item_div)

            div.add("<hr/>")

           
            #save_div = SpanWdg(css='med hand')
            #div.add(save_div)
            #save_div.add(IconWdg('Save Folder', IconWdg.SAVE))

            save_button = ActionButtonWdg(title='Create', tip='Create a new folder')
            div.add(save_button)
       
            bvr = {
            "type": "click_up",
            "view": my.view,
            "is_personal": is_personal == 'true',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var name_value = name_el.value;
            if (name_value == "") {
                var title_el = top.getElement(".spt_new_item_title");
                var title = title_el.value;
                var name = spt.convert_to_alpha_numeric(title);
                name_el.value = name;
            }
            if (name_value == "") {
                spt.alert("Please fill in a value for name.");
                return;
            }
            spt.side_bar.manage_section_action_cbk(
                    { 'value':'save_folder'}, bvr.view, bvr.is_personal);
            ''' }
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br())


        elif my.type == 'new_link':

            div.set_attr('spt_view', 'new_link')
            div.add(HtmlElement.b('Create New Link'))
            div.add(HtmlElement.br())
         
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            
            text = TextWdg('new_link_title')
            span = SpanWdg('Title: ')
            span.add(text)
            div.add(span)
            
            div.add(HtmlElement.br(2))
            cb = CheckboxWdg('include_search_view', label='Include Saved Search')
            cb.set_default_checked()
            div.add(cb)

            div.add(HtmlElement.br(2))
            div.add("Select a search type and view of this link")
            div.add(HtmlElement.br())

           
            select = SelectWdg("new_search_type")
            select.add_empty_option("-- Select Search type --")
    
            security = Environment.get_security()
            if security.check_access("builtin", "view_site_admin", "allow"):
                search_types = Project.get().get_search_types(include_sthpw=True, include_config=True)
            else:
                search_types = Project.get().get_search_types()

            values = [x.get_value("search_type") for x in search_types]
            labels = ["%s (%s)" % (x.get_value("search_type"), x.get_title()) for x in search_types]
            values.append("CustomLayoutWdg")
            labels.append("CustomLayoutWdg")
            select.set_option("values", values)
            select.set_option("labels", labels)

    
            #security = Environment.get_security()
            #if security.check_access("builtin", "view_site_admin", "allow"):
            #    select_mode =  SearchTypeSelectWdg.ALL
            #else:
            #    select_mode =  SearchTypeSelectWdg.ALL_BUT_STHPW
            #select = SearchTypeSelectWdg(name='new_search_type', \
            #    mode=select_mode)

            select.add_behavior({'type': 'change',
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".new_item_panel");
                var link_view_select = top.getElement(".link_view_select");
                var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 
                'is_refresh': 'true'}; 
                spt.panel.refresh(link_view_select, values);'''
            })
            div.add(HtmlElement.br())
            div.add(select)
      

            div.add(HtmlElement.br())
                  
            
            
            link_view_sel = NewLinkViewSelectWdg()
            div.add(HtmlElement.br())
            div.add(link_view_sel)

            div.add(HtmlElement.br())
            #select.add_behavior('change')
            div.add(HtmlElement.hr())
            div.add(HtmlElement.br())
            
            #save_div = DivWdg(css='med hand')
            #div.add(save_div)
            #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE)
            #save_div.add(save_button)

            save_button = ActionButtonWdg(title='Create', tip='Create a new link')
            div.add(save_button)
            bvr = { "type": "click_up",
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_link'},'%s', %s);" %(my.view, is_personal)}
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br(1))

        elif my.type == 'new_separator':
            div.set_attr('spt_view', 'new_separator')
            div.add(HtmlElement.b('Creating New Separator. . .'))
            div.add(HtmlElement.br())
           
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            # since it's automated, this button is not needed
            """ 
            save_div = SpanWdg(css='med hand')
            save_div.add(IconWdg('Save', IconWdg.SAVE))
        
            bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_separator'},'%s');" %my.view}
            save_div.add_behavior(bvr)
            div.add(save_div)
            """
        widget.add(div)
        return widget
예제 #35
0
    def get_display(my):

        search_type = my.kwargs.get("search_type")
        view = my.kwargs.get("view")
        assert search_type
        assert view

        # my.handle_search()

        config_xml = my.kwargs.get("config_xml")
        if not config_xml:
            config_xml = "<config/>"

        # extraneous variables inherited from TableLayoutWdg
        my.edit_permission = False

        top = DivWdg()
        top.add_class("spt_freeform_layout_top")
        my.set_as_panel(top)
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("height: 100%")
        top.add_style("width: 100%")
        border_color = top.get_color("border")
        top.add_style("border: dashed 1px %s" % border_color)

        is_refresh = my.kwargs.get("is_refresh")

        config = WidgetConfig.get(view=view, xml=config_xml)

        # define canvas
        canvas = top
        canvas.add_class("spt_freeform_canvas")
        canvas.add_style("position: relative")

        my.kwargs["view"] = view

        element_names = config.get_element_names()
        view_attrs = config.get_view_attributes()

        canvas_height = view_attrs.get("height")
        if not canvas_height:
            canvas_height = "400px"
        canvas.add_style("height: %s" % canvas_height)

        canvas_width = view_attrs.get("width")
        if not canvas_width:
            width = "600px"
        canvas.add_style("width: %s" % canvas_width)

        if not my.sobjects:
            search = Search(search_type)
            sobject = search.get_sobject()
        else:
            sobject = my.sobjects[0]

        dialog_id = my.kwargs.get("dialog_id")

        canvas.add_behavior(
            {
                "type": "smart_click_up",
                "search_type": search_type,
                "view": view,
                "bvr_match_class": "SPT_ELEMENT_SELECT",
                "cbjs_action": """
        var element = bvr.src_el;
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var attr = top.getElement(".spt_freeform_attr_top");

        var element_id = element.getAttribute("spt_element_id");
        var attrs = element.attrs;
        if (!attrs) {
            attrs = {};
        }

        var class_name = 'tactic.ui.tools.freeform_layout_wdg.FreeFormAttrWdg';
        var kwargs = {
            element_id: element_id,
            element_name: element.getAttribute("spt_element_name"),
            display_handler: element.getAttribute("spt_display_handler"),
            display_options: attrs
        }
        spt.panel.load(attr, class_name, kwargs);

        var dialog_id = '%s';
        spt.show( $(dialog_id) );

        """
                % dialog_id,
            }
        )

        canvas.add_behavior({"type": "load", "cbjs_action": my.get_onload_js()})

        canvas.add_behavior(
            {
                "type": "load",
                "cbjs_action": """
        var top = bvr.src_el;
        spt.freeform.init(top);
        """,
            }
        )

        for element_name in element_names:

            widget_div = DivWdg()
            canvas.add(widget_div)
            widget_div.add_style("position: absolute")
            widget_div.add_style("vertical-align: top")

            widget_div.add_class("SPT_ELEMENT_SELECT")

            widget_div.add_behavior(
                {
                    "type": "load",
                    "cbjs_action": """
                bvr.src_el.makeDraggable()
                """,
                }
            )

            el_attrs = config.get_element_attributes(element_name)
            height = el_attrs.get("height")
            if height:
                widget_div.add_style("height: %s" % height)

            width = el_attrs.get("width")
            if width:
                widget_div.add_style("width: %s" % width)

            display_handler = config.get_display_handler(element_name)
            display_options = config.get_display_options(element_name)

            widget_div.add_attr("spt_display_handler", display_handler)

            widget_div.add_behavior(
                {
                    "type": "load",
                    "display_options": display_options,
                    "cbjs_action": """
            bvr.src_el.attrs = bvr.display_options;
            """,
                }
            )

            try:
                widget = config.get_display_widget(element_name)
            except:
                continue

            widget.set_sobject(sobject)
            widget_div.add_attr("spt_element_name", element_name)
            widget_div.add_class("spt_element")

            content = DivWdg()
            widget_div.add(content)
            content.add_class("spt_element_content")
            content.add(widget)

            try:
                is_resizable = widget.is_resizable()
            except:
                is_resizable = False

            number = random.randint(0, 10000)
            element_id = "element%s" % number
            widget_div.set_attr("spt_element_id", element_id)

            # HACK for action button widget.  This widget takes over the
            # mouse hover very strongly, so need some padding to have
            # the widget_div trigger first
            if isinstance(widget, ActionButtonWdg):
                widget_div.add_style("padding: 2px")
                widget_div.add_style("height: 30px")

            # right now, the hover behavior has to be put on each element
            widget_div.add_behavior(
                {
                    "type": "hover",
                    "cbjs_action_over": """
            var size = bvr.src_el.getSize();
            var buttons = bvr.src_el.getElement(".spt_freeform_button_top");
            var buttons_size = buttons.getSize();
            spt.show(buttons);
            if (size.y < 32) {
                size.y = 32;
            }
            buttons.setStyle("width", size.x + 20);
            buttons.setStyle("height", size.y );
            buttons.setStyle("border", "solid 1px blue");
            """,
                    "cbjs_action_out": """
            var buttons = bvr.src_el.getElement(".spt_freeform_button_top");
            spt.hide(buttons);
            buttons.setStyle("width", "100%")
            buttons.setStyle("height", "100%")
            """,
                }
            )

            dummy = TextWdg("foo")
            widget_div.add(dummy)
            dummy.add_class("spt_foo")
            dummy.add_style("position: absolute")
            dummy.add_style("left: -100000")
            widget_div.add_behavior(
                {
                    "type": "mouseover",
                    "cbjs_action": """
            var foo = bvr.src_el.getElement(".spt_foo");
            foo.focus();
            """,
                }
            )
            widget_div.add_behavior(
                {
                    "type": "mouseleave",
                    "cbjs_action": """
            var foo = bvr.src_el.getElement(".spt_foo");
            foo.blur();
            """,
                }
            )

            dummy.add_behavior(
                {
                    "type": "keyup",
                    "cbjs_action": """
            var keys = ['tab','enter','delete','left','right','up','down'];
            var key = evt.key;
            //console.log(key);
            if (keys.indexOf(key) > -1) evt.stop();

            var element = bvr.src_el.getParent(".SPT_ELEMENT_SELECT");
            var canvas = bvr.src_el.getParent(".spt_freeform_canvas");
            var pos = element.getPosition();
            var cpos = canvas.getPosition();
            pos = { x: pos.x - cpos.x -1, y: pos.y - cpos.y -1 };

            if (key == 'delete') {
                element.destroy()
            }

            var step = 1;
            if (evt.shift == true) {
                step = 10;
            }

            if (key == 'left') {
                pos.x = pos.x - step;
            }
            else if (key == 'right') {
                pos.x = pos.x + step;
            }
            else if (key == 'up') {
                pos.y = pos.y - step;
            }
            else if (key == 'down') {
                pos.y = pos.y + step;
            }

            element.position(pos);

            """,
                }
            )

            xpos = el_attrs.get("xpos")
            if not xpos:
                xpos = "100px"
            widget_div.add_style("left: %s" % xpos)

            ypos = el_attrs.get("ypos")
            if not ypos:
                ypos = "100px"
            widget_div.add_style("top: %s" % ypos)

            buttons_div = DivWdg()
            widget_div.add(buttons_div)
            buttons_div.add_class("spt_freeform_button_top")
            buttons_div.add_style("display: none")
            buttons_div.add_style("position: absolute")
            buttons_div.add_style("top: 0px")
            buttons_div.add_style("left: -10px")
            buttons_div.add_style("height: 100%")
            buttons_div.add_style("width: 105%")
            buttons_div.add_class("hand")

            buttons_div.add_border()

            # icon = IconWdg('Move', icon=IconWdg.ADD)
            # buttons_div.add(icon)
            # icon.add_class("move")

            is_resizable = True
            if is_resizable:
                icon_div = DivWdg()
                icon_div.add_style("cursor: move")
                buttons_div.add(icon_div)
                icon_div.add_style("position: absolute")
                icon_div.add_style("bottom: 0px")
                icon_div.add_style("right: 0px")
                icon = IconWdg("Scale", icon=IconWdg.RESIZE_CORNER)
                icon_div.add(icon)
                icon_div.add_behavior(
                    {"type": "drag", "drag_el": "@", "cb_set_prefix": "spt.freeform.resize_element_drag"}
                )

                # icon.add_class("spt_resize_element")

        # for TableLayoutWdg??
        top.add_class("spt_table_top")
        class_name = Common.get_full_class_name(my)
        top.add_attr("spt_class_name", class_name)

        top.add("<br clear='all'/>")

        icon_div = DivWdg()
        top.add(icon_div)

        icon_div.add_class("spt_resize_canvas")
        icon_div.add_style("cursor: nw-resize")
        icon_div.add_style("z-index: 1000")
        icon_div.add_class("spt_popup_resize")
        icon_div.add_style("top: %s" % canvas_height)
        icon_div.add_style("left: %s" % canvas_width)
        icon_div.add_style("margin-left: -15px")
        icon_div.add_style("margin-top: -15px")
        icon_div.add_style("position: absolute")
        icon_div.add_behavior({"type": "drag", "drag_el": "@", "cb_set_prefix": "spt.freeform.resize_drag"})

        icon = IconWdg("Resize", IconWdg.RESIZE_CORNER)
        icon_div.add(icon)

        size_div = DivWdg()
        icon_div.add(size_div)
        size_div.add_class("spt_resize_title")
        size_div.add_style("display: none")
        size_div.add_style("margin-left: -60px")
        size_div.add_style("margin-top: -30px")
        size_div.add_style("width: 150px")

        return top
예제 #36
0
    def get_display(my):
        my.title_code = str(my.kwargs.get('title_code'))
        my.title_sk = str(my.kwargs.get('title_sk'))
        my.order_sk = str(my.kwargs.get('order_sk'))

        origin_search = Search("twog/title_origin")
        origin_search.add_filter('title_code',my.title_code)
        origins = origin_search.get_sobjects()

        groups_str = ''
        user_group_names = Environment.get_group_names()
        for mg in user_group_names:
            if groups_str == '':
                groups_str = mg
            else:
                groups_str = '%s,%s' % (groups_str, mg)
        user_is_scheduler = False
        if 'scheduling' in groups_str:
            user_is_scheduler = True

        table = Table()
        table.add_attr('width','100%s' % '%')
        table.add_attr('bgcolor','#cbe49e')
        table.add_style('border-bottom-right-radius', '10px')
        table.add_style('border-bottom-left-radius', '10px')
        table.add_style('border-top-right-radius', '10px')
        table.add_style('border-top-left-radius', '10px')
        table.add_row()
        source_limit = 7
        count = 0
        if len(origins) > 0:
            table.add_row()
            mr_title = table.add_cell('<b><u><i>Sources</i></u></b>')
            mr_title.add_style('font-size: 90%s;' % '%')
        seen = []
        for origin in origins:
            source_code = origin.get_value('source_code')
            if source_code not in seen:
                seen.append(source_code)
                source_search = Search("twog/source")
                source_search.add_filter('code',source_code)
                source = source_search.get_sobject()
                if count % source_limit == 0:
                    table.add_row()
                celly = None
                if not source.get_value('high_security'):
                    celly = table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (source.get_value('barcode'),source.get_value('title')))
                else:
                    celly = table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (source.get_value('barcode'),source.get_value('title')))
                celly.add_attr('nowrap','nowrap')
                celly.add_style('cursor: pointer;')
                celly.add_style('font-size: 80%s;' % '%')
                celly.add_behavior(get_launch_source_behavior(my.title_code, my.title_sk, source.get_value('code'), source.get_search_key(), my.order_sk))

                table.add_cell(' &nbsp;&nbsp; ')
                count += 1
            else:

                my.server = TacticServerStub.get()
                my.server.retire_sobject(origin.get_search_key())
        table2 = Table()
        if user_is_scheduler:
            table2.add_row()
            barcode_text_wdg = TextWdg('barcode_insert')
            barcode_text_wdg.add_behavior(my.get_barcode_insert_behavior(my.title_code, my.title_sk, my.order_sk))
            bct = table2.add_cell(barcode_text_wdg)
            bct.add_attr('align','right')
            bct.add_attr('width','100%s' % '%')
        two_gether = Table()
        two_gether.add_row()
        srcs = two_gether.add_cell(table)
        srcs.add_attr('width','100%s' % '%')
        srcs.add_attr('valign','top')
        if user_is_scheduler:
            bcentry = two_gether.add_cell(table2)
            bcentry.add_attr('valign','top')

        return two_gether
예제 #37
0
    def get_scale_wdg(my):

        if my.scale_called == True:
            return None
        my.scale_called = True

        show_scale = my.kwargs.get("show_scale")

        div = DivWdg()
        if show_scale in [False, 'false']:
            div.add_style("display: none")
        div.add_style("padding: 5px")
        div.add_class("spt_table_search")
        hidden = HiddenWdg("prefix", "tile_layout")
        div.add(hidden)
        div.add_behavior( {
            'type': 'load',
            'scale_prefix':  my.scale_prefix,
            'default_scale': my.scale,
            'aspect_ratio': my.aspect_ratio,
            'cbjs_action': '''
spt.tile_layout = {}
spt.tile_layout.layout = null;

spt.tile_layout.set_layout = function(layout) {
    if (!layout.hasClass("spt_layout")) {
        layout = layout.getParent(".spt_layout");
    }
    spt.tile_layout.layout = layout;
    return layout;
}

spt.tile_layout.get_scale = function() {
    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    var value = scale_value.value;
    value = parseInt(value);
    return value;
}


spt.tile_layout.set_scale = function(scale) {

    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    scale_value.value = scale;

    var size_x = bvr.aspect_ratio[0]*scale/100;
    var size_y = bvr.aspect_ratio[1]*scale/100;

    //var top = bvr.src_el.getParent(".spt_tile_layout_top");
    var top = spt.tile_layout.layout;
    var els = top.getElements(".spt_tile_content");
    for (var i = 0; i < els.length; i++) {
        var el = els[i];
        el.setStyle( "width",  size_x);
        el.setStyle( "height", size_y);
    }

    var container_id = "tile_layout::scale"+bvr.scale_prefix;
    spt.container.set_value( container_id, scale);
}


spt.tile_layout.drag_start_x = null;
spt.tile_layout.drag_start_value = null;

spt.tile_layout.drag_setup = function(evt, bvr, mouse_411) {
    spt.tile_layout.set_layout(bvr.src_el);
    spt.tile_layout.drag_start_x = mouse_411.curr_x;
    var src_el = spt.behavior.get_bvr_src( bvr );
    if (!src_el.value) {
        src_el.value = 0;
    }
    spt.tile_layout.drag_start_value = src_el.value;
    src_el.focus();
    src_el.select();
}
spt.tile_layout.drag_motion = function(evt, bvr, mouse_411) {
    var start_value = spt.tile_layout.drag_start_value; 
    if (isNaN(parseInt(start_value))) {
        return;
    }
    var dx = mouse_411.curr_x - spt.tile_layout.drag_start_x;
    var increment = parseInt(dx / 5);
    var multiplier;
    if (increment < 0)
        multiplier = 0.975;
    else
        multiplier = 1 / 0.975;
    increment = Math.abs(increment);
    var scale = spt.tile_layout.drag_start_value;
    for (var i = 0; i < increment; i++) {
        scale = scale * multiplier;
    }
    if (scale > 400)
        scale = 400;
    scale = parseInt(scale);
    spt.tile_layout.set_scale(scale);

}
spt.tile_layout.setup_control = function() {
   var slider = spt.tile_layout.layout.getElement('.spt_slider');
   var container_id = "tile_layout::scale"+bvr.scale_prefix;
   var initial_value = spt.container.get_value(container_id) ?  spt.container.get_value(container_id) : bvr.default_scale;

   spt.tile_layout.set_scale(initial_value);
   new Slider(slider, slider.getElement('.knob'), {
    range: [30, 400],
    steps: 74,
    initialStep: initial_value,
    onChange: function(value){
      if (value) spt.tile_layout.set_scale(value);
    }
  });
}



spt.tile_layout.image_drag_setup = function(evt, bvr, mouse_411) {
    bvr.use_copy = true;
    bvr.use_delta = true;
    //bvr.border_color = border_color;
    bvr.dx = 10;
    bvr.dy = 10;
    bvr.drop_code = 'DROP_ROW';
    bvr.accepted_search_type = bvr.search_type;


}

spt.tile_layout.image_drag_motion = function(evt, bvr, mouse_411) {

    spt.mouse._smart_default_drag_motion(evt, bvr, mouse_411);
    var target_el = spt.get_event_target(evt);
    target_el = spt.mouse.check_parent(target_el, bvr.drop_code);
    if (target_el) {
        var orig_border_color = target_el.getStyle('border-color');
        var orig_border_style = target_el.getStyle('border-style');
        target_el.setStyle('border','dashed 2px ' + bvr.border_color);
        if (!target_el.getAttribute('orig_border_color')) {
            target_el.setAttribute('orig_border_color', orig_border_color);
            target_el.setAttribute('orig_border_style', orig_border_style);
        }
    }

}

spt.tile_layout.image_drag_action = function(evt, bvr, mouse_411) {
    if (spt.drop) {

        spt.drop.sobject_drop_action(evt, bvr);
    }
    else {
        if( bvr._drag_copy_el ) {
            spt.behavior.destroy_element(bvr._drag_copy_el);
        }
    }
}

        ''' } )


        scale = my.kwargs.get("scale")


        div.add_behavior( {
        'type': 'load',
        'scale': scale,
        'cbjs_action': '''
        spt.tile_layout.set_layout(bvr.src_el);

        spt.tile_layout.setup_control();

        if (bvr.scale) {
            spt.tile_layout.set_scale(bvr.scale);
        }
      
        '''
        } )

        table = Table()
        div.add(table)
        table.add_row()

        """
        # TO BE DELETED
        less_div = DivWdg()
        less_div.add("<input type='button' value='&lt;&lt;'/>")
        table.add_cell(less_div)

        less_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale * 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )
        """

        dark_color = div.get_color("background", -5)
        light_color = div.get_color('color')
        med_color = div.get_color('color2')
        
        slider_div = DivWdg(css='spt_slider')
        slider_div.add_styles('valign: bottom; background: %s; height: 6px; width: 100px;'% light_color)
        knob_div = DivWdg(css='knob')
        knob_div.add_behavior({'type':'click',
                'cbjs_action': 'spt.tile_layout.set_layout(bvr.src_el)'
                })
        knob_div.add_styles('background: %s; bottom: 4px;\
                height: 16px; width: 12px; border-radius: 6px 6px 0 0;\
                border: 1px %s solid'\
                %(dark_color, med_color ))
        slider_div.add(knob_div)
        td = table.add_cell(slider_div)
        value_wdg = TextWdg("scale")
        value_wdg.add_class("spt_scale_value")
        td = table.add_cell(value_wdg)
        td.add("&nbsp;%")

        td.add_style("padding: 3px 8px")

        """
        # TO BE DELETED
        from tactic.ui.filter import FilterData
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix("tile_layout")
        if data_list:
            data = data_list[0]
        else:
            data = {}
        my.scale = data.get("scale")
        if my.scale == None:
            my.scale = my.kwargs.get("scale")
        """
        if my.scale:
            value_wdg.set_value(my.scale)
        value_wdg.add_style("width: 28px")
        value_wdg.add_style("text-align: center")
        value_wdg.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )
        value_wdg.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        if (!value) {
            value = 100;
        }
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )



 
        value_wdg.add_behavior( {
            'type': 'smart_drag',
            'bvr_match_class': 'spt_scale_value',
            'ignore_default_motion' : True,
            "cbjs_setup": 'spt.tile_layout.drag_setup( evt, bvr, mouse_411 );',
            "cbjs_motion": 'spt.tile_layout.drag_motion( evt, bvr, mouse_411 );'
        } )

        
        """
        # TO BE DELETED
        more_div = DivWdg()
        more_div.add("<input type='button' value='&gt;&gt;'/>")
        table.add_cell(more_div)

        more_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale / 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )

        """


       

        return div
예제 #38
0
    def get_display(my):
        from tactic_client_lib import TacticServerStub
        widget = DivWdg()
        server = TacticServerStub.get()
        allowed_groups = ['admin','audio','billing and accounts receivable','compression','compression supervisor','edeliveries','edit','edit supervisor','executives','it','machine room','machine room supervisor','management','media vault','media vault supervisor','office employees','qc','qc supervisor','sales','sales supervisor','scheduling','scheduling supervisor','senior_staff','streamz','technical services']
        sobject = None
        code = None
        user_name = None 
        do_inserted_msg = False
        table = Table() 
        table.add_attr('class','source_security_wdg')
        if 'source_code' in my.kwargs.keys():
            code = str(my.kwargs.get('source_code'))    
        if code in [None,'']:
            if 'code' in my.kwargs.keys():
                code = my.kwargs.get('code')
        if 'user_name' in my.kwargs.keys():
            user_name = my.kwargs.get('user_name')
        else:
            login = Environment.get_login()
            user_name = login.get_login()
        if 'from' in my.kwargs.keys():
            if my.kwargs.get('from') == 'insert':
                do_inserted_msg = True
                table.add_attr('from','insert')
        if not do_inserted_msg:
            table.add_attr('from','i dunno')
        group = None
        login_in_groups = server.eval("@SOBJECT(sthpw/login_in_group['login','%s']['login_group','not in','user|client'])" % user_name)
        for lg in login_in_groups:
            if not group:
                group = lg.get('login_group')
            if 'supervisor' in lg.get('login_group'): 
                group = lg.get('login_group')
        
        
        checks = server.eval("@SOBJECT(twog/source_req['source_code','%s'])" % code)
        visi = 'display: none;'
        if len(checks) > 0:
            visi = 'display: table-row;';
        if do_inserted_msg:
            table.add_row()
            inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>')
            colspan = 2
            if group in allowed_groups:
                colspan = 3
            inserted_row.add_attr('colspan',colspan)
        top_row = table.add_row()
        top_row.add_style(visi)
        if group in allowed_groups:
            table.add_cell(' ')
        table.add_cell(' ')
        table.add_cell('Satisfied?')
        for check in checks:
            check_row = table.add_row()
            check_row.add_attr('class','row_%s' % check.get('__search_key__'))
            if group in allowed_groups:
                killer = table.add_cell(my.x_butt)
                killer.add_style('cursor: pointer;')
                killer.add_behavior(my.get_killer_behavior(check.get('__search_key__')))
            table.add_cell(check.get('requirement'))
            checkbox = CheckboxWdg('satisfied_%s' % check.get('__search_key__'))
            #checkbox.set_persistence()
            if check.get('satisfied'): 
                checkbox.set_value(True)
            else:
                checkbox.set_value(False)
            checkbox.add_behavior(my.get_change_satisfied(check.get('__search_key__')))
            table.add_cell(checkbox)
        
        table.add_row()
        if group in allowed_groups:
            table.add_cell(' ')
        req_text = TextWdg('new_source_req')
        req_text.add_style('width: 500px')
        req_text.add_behavior(my.get_insert_new_req_from_change(code, user_name))
        table.add_cell(req_text)
        add_button = table.add_cell('<input type="button" class="add_req_button" value="+"/>')
        add_button.add_behavior(my.get_insert_new_req(code, user_name))
        if do_inserted_msg:
            table.add_row()
            inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>')
            colspan = 2
            if group in allowed_groups:
                colspan = 3
            inserted_row.add_attr('colspan',colspan)
 
        widget.add(table)
        return widget
예제 #39
0
    def get_display(my):
        my.work_order_code = str(my.kwargs.get('work_order_code'))
        my.work_order_sk = str(my.kwargs.get('work_order_sk'))
        my.work_order_sk = my.server.build_search_key('twog/work_order', my.work_order_code)
        my.order_sk = str(my.kwargs.get('order_sk'))

        wsource_search = Search("twog/work_order_sources")
        wsource_search.add_filter('work_order_code', my.work_order_code)
        wo_sources = wsource_search.get_sobjects()
        table = Table()
        table.add_attr('width', '100%')
        table.add_attr('bgcolor', '#c6c6e4')
        table.add_style('border-bottom-left-radius', '10px')
        table.add_style('border-top-left-radius', '10px')
        table.add_row()
        source_limit = 4
        pass_search = Search("twog/work_order_passin")
        pass_search.add_filter('work_order_code', my.work_order_code)
        passins = pass_search.get_sobjects()
        sources = []
        inter_passins = []
        for passin in passins:
            if passin.get_value('deliverable_source_code') not in [None,'']:
                source_search = Search("twog/source")
                source_search.add_filter('code', passin.get_value('deliverable_source_code'))
                that_src = source_search.get_sobject()
                sources.append(that_src)
            elif passin.get_value('intermediate_file_code') not in [None,'']:
                inter_search = Search("twog/intermediate_file")
                inter_search.add_filter('code', passin.get_value('intermediate_file_code'))
                inter_file = inter_search.get_sobject()
                inter_passins.append(inter_file)

        seen = []
        for wo_source in wo_sources:
            source_code = wo_source.get_value('source_code')
            if source_code not in seen:
                seen.append(source_code)
                source_search = Search("twog/source")
                source_search.add_filter("code", source_code)
                source = source_search.get_sobject()
                sources.append(source)

        if len(sources) > 0:
            table.add_row()
            mr_title = table.add_cell('<b><u><i>Sources</i></u></b>')
            mr_title.add_style('font-size: 90%;')

        count = 0
        for source in sources:
            inner_table = Table()
            inner_table.add_row()

            if not source.get_value('high_security'):
                celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (source.get_value('barcode'),source.get_value('title')))
            else:
                celly = inner_table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (source.get_value('barcode'),source.get_value('title')))
            celly.add_attr('nowrap','nowrap')
            celly.add_style('cursor: pointer;')
            celly.add_style('font-size: 80%s;' % '%')
            celly.add_behavior(get_launch_wo_source_behavior(my.work_order_code, my.work_order_sk,
                                                             source.get_value('code'), my.order_sk))
            if count % source_limit == 0:
                table.add_row()
            inner_cell = table.add_cell(inner_table)
            inner_cell.add_attr('valign', 'top')
            table.add_cell(' &nbsp;&nbsp; ')
            count += 1

        inter_pass_table = Table()
        inter_pass_table.add_attr('width', '100%')
        inter_pass_table.add_attr('bgcolor', '#c6c6e4')
        if len(inter_passins) > 0:
            inter_pass_table.add_row()
            mr_title = inter_pass_table.add_cell('<b><u><i>Intermediate Sources</i></u></b>')
            mr_title.add_attr('nowrap', 'nowrap')
            mr_title.add_style('font-size: 90%;')
            if len(sources) < 1:
                inter_pass_table.add_style('border-top-left-radius', '10px')
                inter_pass_table.add_style('border-bottom-left-radius', '10px')
        count = 0
        for intermediate in inter_passins:
            inner_table = Table()
            inner_table.add_row()
            celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>%s</u></b></font>' % (intermediate.get_value('title')))
            celly.add_attr('nowrap', 'nowrap')
            celly.add_style('cursor: pointer;')
            celly.add_style('font-size: 80%;')
            celly.add_behavior(get_launch_wo_inter_behavior(my.work_order_code, my.work_order_sk,
                                                            intermediate.get_value('code'), my.order_sk))
            if count % source_limit == 0:
                inter_pass_table.add_row()
            inner_cell = inter_pass_table.add_cell(inner_table)
            inner_cell.add_attr('valign','top')
            inter_pass_table.add_cell(' &nbsp;&nbsp; ')

            count += 1

        # Need to enter Interims and Delivs Here
        inter_table = Table()
        inter_table.add_attr('width', '100%')
        inter_table.add_attr('bgcolor', '#acbe49e')
        wointer_search = Search("twog/work_order_intermediate")
        wointer_search.add_filter('work_order_code', my.work_order_code)
        wointers = wointer_search.get_sobjects()
        if len(wointers) > 0:
            inter_table.add_row()
            mr_title = inter_table.add_cell('<b><u><i>Intermediate Results</i></u></b>')
            mr_title.add_attr('nowrap', 'nowrap')
            mr_title.add_style('font-size: 90%s;' % '%')
            if len(sources) < 1 and len(inter_passins) < 1:
                inter_table.add_style('border-top-left-radius', '10px')
                inter_table.add_style('border-bottom-left-radius', '10px')
        count = 0
        for wointer in wointers:
            inter_code = wointer.get_value('intermediate_file_code')
            if inter_code not in seen:
                seen.append(inter_code)
                inter_search = Search("twog/intermediate_file")
                inter_search.add_filter('code',inter_code)
                intermediate = inter_search.get_sobject()
                inner_table = Table()
                inner_table.add_row()
                celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>%s</u></b></font>' % (intermediate.get_value('title')))
                celly.add_attr('nowrap','nowrap')
                celly.add_style('cursor: pointer;')
                celly.add_style('font-size: 80%s;' % '%')
                celly.add_behavior(get_launch_wo_inter_behavior(my.work_order_code, my.work_order_sk, inter_code,
                                                                my.order_sk))
                if count % source_limit == 0:
                    inter_table.add_row()
                inner_cell = inter_table.add_cell(inner_table)
                inner_cell.add_attr('valign', 'top')
                inter_table.add_cell(' &nbsp;&nbsp; ')

                count += 1

        # Need deliverables listed here
        deliv_table = Table()
        deliv_table.add_attr('width','100%s' % '%')
        deliv_table.add_attr('bgcolor','#acbe49e')
        deliv_table.add_style('border-bottom-right-radius', '10px')
        deliv_table.add_style('border-top-right-radius', '10px')
        d_search = Search("twog/work_order_deliverables")
        d_search.add_filter('work_order_code',my.work_order_code)
        wodelivs = d_search.get_sobjects()
        if len(wodelivs) > 0:
            deliv_table.add_row()
            mr_title = deliv_table.add_cell('<b><u><i>Permanent Results</i></u></b>')
            mr_title.add_attr('nowrap','nowrap')
            mr_title.add_style('font-size: 90%s;' % '%')
            if len(sources) < 1 and len(inter_passins) < 1 and len(wointers) < 1:
                deliv_table.add_style('border-top-left-radius', '10px')
                deliv_table.add_style('border-bottom-left-radius', '10px')
        count = 0
        for wodeliv in wodelivs:
            deliv_code = wodeliv.get_value('deliverable_source_code')
            if deliv_code not in seen:
                seen.append(deliv_code)
                s_search = Search("twog/source")
                s_search.add_filter('code',deliv_code)
                deliverable = s_search.get_sobjects()
                if len(deliverable) > 0:
                    deliverable = deliverable[0]
                    inner_table = Table()
                    inner_table.add_row()

                    if not deliverable.get_value('high_security'):
                        celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (deliverable.get_value('barcode'), deliverable.get_value('title')))
                    else:
                        celly = inner_table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (deliverable.get_value('barcode'), deliverable.get_value('title')))
                    celly.add_attr('nowrap','nowrap')
                    celly.add_style('cursor: pointer;')
                    celly.add_style('font-size: 80%s;' % '%')
                    celly.add_behavior(get_launch_wo_deliv_behavior(my.work_order_code, my.work_order_sk, deliv_code,
                                                                    my.order_sk))
                    if count % source_limit == 0:
                        deliv_table.add_row()
                    inner_cell = deliv_table.add_cell(inner_table)
                    inner_cell.add_attr('valign','top')
                    deliv_table.add_cell(' &nbsp;&nbsp; ')

                    count += 1
                else:
                    with open('/var/www/html/Lost_Sources','a') as lostsources:
                        lostsources.write('%s:%s SOURCE: %s\n' % (my.order_sk, my.work_order_code, deliv_code))
                        lostsources.close()

        if len(wodelivs) < 1:
            inter_table.add_style('border-bottom-right-radius', '10px')
            inter_table.add_style('border-top-right-radius', '10px')
        if len(wodelivs) < 1 and len(wointers) < 1:
            inter_pass_table.add_style('border-bottom-right-radius', '10px')
            inter_pass_table.add_style('border-top-right-radius', '10px')
        if len(inter_passins) < 1 and len(wointers) < 1 and len(wodelivs) < 1:
            table.add_style('border-bottom-right-radius', '10px')
            table.add_style('border-top-right-radius', '10px')

        table2 = Table()
        table2.add_row()
        barcode_text_wdg = TextWdg('wo_barcode_insert')
        barcode_text_wdg.add_behavior(get_wo_barcode_insert_behavior(my.work_order_code, my.work_order_sk, my.order_sk))
        bct = table2.add_cell(barcode_text_wdg)
        bct.add_attr('align', 'right')
        bct.add_attr('width', '100%')

        two_gether = Table()
        two_gether.add_row()
        if len(sources) > 0:
            srcs = two_gether.add_cell(table)
            srcs.add_attr('width', '100%')
            srcs.add_attr('valign', 'top')
        if len(inter_passins) > 0:
            ips = two_gether.add_cell(inter_pass_table)
            ips.add_attr('width', '100%')
            ips.add_attr('valign', 'top')
        if len(wointers) > 0:
            intr = two_gether.add_cell(inter_table)
            intr.add_attr('width', '100%')
            intr.add_attr('valign', 'top')
        if len(wodelivs) > 0:
            delvs = two_gether.add_cell(deliv_table)
            delvs.add_attr('width', '100%')
            delvs.add_attr('valign', 'top')
        long = two_gether.add_cell(' ')
        long.add_style('width: 100%')
        bcentry = two_gether.add_cell(table2)
        bcentry.add_attr('valign', 'top')
        bcentry.add_attr('align', 'right')

        for source in sources:
            if source.get_value('children') in [None,'']:
                update_str = ''
                for wod in wodelivs:
                    if update_str == '':
                        update_str = wod.get_value('deliverable_source_code')
                    else:
                        update_str = '%s,%s' % (update_str, wod.get_value('deliverable_source_code'))
                    d_search = Search("twog/source")
                    d_search.add_filter('code', wod.get_value('deliverable_source_code'))
                    d_src = d_search.get_sobject()
                    ancestors = d_src.get_value('ancestors')
                    if ancestors.find(source.get_value('code')) == -1:
                        if ancestors in [None,'']:
                            ancestors = source.get_value('code')
                        else:
                            ancestors = '%s,%s' % (ancestors, source.get_value('code'))
                        my.server.update(d_src.get_search_key(), {'ancestors': ancestors})
                if len(wodelivs) > 0:
                    my.server.update(source.get_search_key(), {'children': update_str})

        return two_gether