def get_section_three_subsection_one(self):
        label_value_pairs = (
            ('Forced narrative on feature?', 'forced_narrative_feature',
             'Does not overlap any credits or other text?', 'overlap_credits_text_1'),
            ('Forced narrative on trailer?', 'forced_narrative_trailer',
             'Does not overlap any credits or other text?', 'overlap_credits_text_2'),
            ('Subtitles on feature?', 'subtitles_on_feature',
             'Does not overlap any credits or other text?', 'overlap_credits_text_3'),
            ('Subtitles on trailer?', 'subtitles_on_trailer',
             'Does not overlap any credits or other text?', 'overlap_credits_text_4'),
        )

        table = Table()

        for label_value_pair in label_value_pairs:
            label_1, value_1, label_2, value_2 = label_value_pair

            table.add_row()
            table.add_cell(label_1)
            table.add_cell(self.get_true_false_select_wdg(value_1))
            table.add_cell(label_2)
            table.add_cell(self.get_true_false_select_wdg(value_2))

        section_div = DivWdg()
        section_div.add(table)

        return section_div
Beispiel #2
0
 def get_display(my):
     widget = DivWdg()
     table = Table()
     table.add_attr('class','my_preferences_wdg')
    
     prefs = my.login_obj.get('twog_preferences').split(',')
     for pref in prefs:
         if pref not in [None,'']:
             kv = pref.split('=')
             key = kv[0]
             val = kv[1]
             table.add_row()
             desc = table.add_cell(my.key_dict[key])
             desc.add_attr('nowrap','nowrap')
             this_sel = SelectWdg(key)
             this_sel.add_attr('id',key)
             this_sel.add_style('width: 100px;')
             this_sel.append_option('True','true')
             this_sel.append_option('False','false')
             this_sel.set_value(val)
             table.add_cell(this_sel)
     table.add_row()
     t2 = Table()
     t2.add_row()
     t2.add_cell()
     tc = t2.add_cell('<input type="button" name="Save My Preferences" value="Save My Preferences"/>')
     tc.add_attr('width', '50px')
     tc.add_behavior(my.get_save_preferences())
     t2.add_cell()
     table.add_cell(t2)
     widget.add(table)
     return widget
    def get_save_wdg(my):

        from tactic.ui.container import DialogWdg
        dialog = DialogWdg(display=False, width=200, offset={'x':0,'y':50}, show_pointer=False)
        dialog_id = dialog.get_id()

        title = 'Save a New View'

        dialog.add_title(title)

        div = DivWdg()
        dialog.add(div)
        div.add_style("padding: 5 5 5 20")
        div.add_color("background", "background")

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


        from tactic.ui.panel import ViewPanelSaveWdg
        save_wdg = ViewPanelSaveWdg(
            search_type=my.kwargs.get("search_type"),
            dialog_id=dialog_id,
            table_id=my.table_id
        )
        div.add(save_wdg)

        return dialog
    def get_section_four(self):
        label_value_pairs_1 = (
            ('Image is a JPEG (.jpg extension)?', 'image_is_jpeg_chapter'),
            ('DPI is 72 or greater?', 'dpi_is_72_chapter'),
            ('Color profile is RGB?', 'color_profile_rgb_chapter'),
            ('Same aspect ratio as video?', 'same_aspect_ratio_as_video_chapter'),
            ('Only active pixels are included (no dirty edges)?', 'only_active_pixels_chapter'),
            ('Horizontal dimension is at least 640?', 'horizontal_dimension_640_chapter'),
            ('Each chapter has a thumbnail?', 'each_chapter_thumbnail_chapter')
        )

        label_value_pairs_2 = (
            ('Image is a JPEG (.jpg extension)?', 'image_is_jpeg_poster'),
            ('DPI is 72 or greater?', 'dpi_is_72_poster'),
            ('Color profile is RGB?', 'color_profile_rgb_poster'),
            ('Resolution is at least 1400x2100?', 'resolution_poster'),
            ('Aspect ratio is 2:3?', 'aspect_ratio_poster'),
            ('Contains key art and title only (no film rating on image)?', 'contains_key_art_poster'),
            ('No DVD cover, date stamp, URL or promo tagging included?', 'no_promo_poster')
        )

        section_div = DivWdg()

        section_div.add(self.get_section_four_table_one(label_value_pairs_1))
        section_div.add(self.get_section_four_table_two(label_value_pairs_2))

        return section_div
Beispiel #5
0
    def get_sobject_info_wdg(my):
        div = DivWdg()
        return div

        attr_table = Table()
        div.add(attr_table)

        attr_table.add_color("color", "color")

        sobject = my.get_sobject()

        titles, exprs = my.get_sobject_info()
        for title, expr in zip(titles, exprs):
            try:
                value = Search.eval(expr, sobject)
            except Exception, e:
                print "WARNING: ", e.message
                continue


            if value == '':
                value = '<i>none</i>'
            if len(value) > 100:
                value = "%s..." % value[:100]

            attr_table.add_row()
            th = attr_table.add_header("%s: " % title)
            th.add_style("text-align: left")
            td = attr_table.add_cell(value)
Beispiel #6
0
    def get_related_wdg(my, aliases):
        div = DivWdg()
        div.add("<b>Related links</b>: &nbsp;&nbsp")
        div.add_style("margin-top: 5px")
        div.add_style("margin-bottom: 5px")
        div.add_style("margin-left: 10px")

        titles = [Common.get_display_title(x.replace("-"," ")) for x in aliases]
        for alias, title in zip(aliases, titles):

            link_div = SpanWdg()
            div.add(link_div)
            link_div.add_color("background", "background")
            link_div.add(title)
            link_div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.help.set_top();
                spt.help.load_alias("%s");
                ''' % alias
            } )
            link_div.add_class("spt_link")
            link_div.add_class("hand")

        return div
Beispiel #7
0
    def get_display(self):

        top = self.top

        height = self.get_option('height')
        if not height:
            height = 300

        inner = DivWdg()
        top.add(inner)
        inner.add_style("overflow-y: auto")
        inner.add_style("overflow-x: hidden")
        inner.add_style("min-width: 300px")
        inner.add_style("max-width: 300px")
        inner.add_style("max-height: %s" % height)
        inner.add_style("margin-right: -3px")
        
        sobject = self.get_current_sobject()

        data = sobject.get_json_value( self.get_name() )
        if not data:
            data = {}

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

        for key in keys:
            value = data.get(key)
            inner.add("%s = %s<br/>"% (key, value))



        return top
    def get_async_element_wdg(my, xml, element_name, load):

        tmp_config = WidgetConfig.get('tmp', xml=xml)
        display_handler = tmp_config.get_display_handler(element_name)
        display_options = tmp_config.get_display_options(element_name)

        div = DivWdg()
        unique_id = div.set_unique_id()

        if load == "sequence":
            my.sequence_data.append( {
                'class_name': display_handler,
                'kwargs': display_options,
                'unique_id': unique_id
            } )
        else:
            div.add_behavior( {
                'type': 'load',
                'class_name': display_handler,
                'kwargs': display_options,
                'cbjs_action': '''
                spt.panel.async_load(bvr.src_el, bvr.class_name, bvr.kwargs);
                '''
            } )

        loading_div = DivWdg()
        loading_div.add_style("margin: auto auto")
        loading_div.add_style("width: 150px")
        loading_div.add_style("text-align: center")
        loading_div.add_style("padding: 20px")
        div.add(loading_div)
        loading_div.add('''<img src="/context/icons/common/indicator_snake.gif" border="0"/> <b>Loading ...</b>''')

        return div
    def get_display(my):

        search_key = my.kwargs.get('parent_key')

        div = DivWdg()

        if not search_key:
            div.add("Search Key for SObjectHeaderHdg is empty")
            return div

        sobject = Search.get_by_search_key( search_key )
        if not sobject:
            div.add("SObject with Search Key [%s] does not exist" % search_key)
            return div


        search_type_obj = sobject.get_search_type_obj()
        title = search_type_obj.get_title()
        title_wdg = DivWdg()
        title_wdg.add_style("font-size: 1.8em")

        name = sobject.get_display_value()
        title_wdg.add("%s: %s" % (title, name ))

        div.add(title_wdg)
        div.add(HtmlElement.hr())

        return div
Beispiel #10
0
    def get_menu_item(my, element_name, display_handler):

        content = DivWdg()
        content.add_attr("spt_element_name", element_name)
        content.add_class("hand")

        # add the drag/drop behavior
        behavior = {
            "type": "drag",
            "mouse_btn": "LMB",
            "modkeys": "",
            "src_el": "@",
            "cbfn_setup": "spt.side_bar.pp_setup",
            "cbfn_motion": "spt.side_bar.pp_motion",
            "cbfn_action": "spt.side_bar.pp_action",
        }
        content.add_behavior(behavior)

        content.set_id("manage_%s" % element_name)
        content.add_style("position: relative")
        content.add_style("margin: 3px")
        content.add_style("left: 0")
        content.add_style("top: 0")
        content.add_style("z-index: 100")
        if display_handler == "SeparatorWdg":
            content.add(HtmlElement.hr())
        else:
            content.add(element_name)

        return content
Beispiel #11
0
    def get_section_wdg(my, view, editable=True, default=False):

        title = ""
        if editable:
            edit_mode = "edit"
        else:
            edit_mode = "read"
        kwargs = {
            "title": title,
            "config_search_type": my.search_type,
            "view": view,
            "width": "300",
            "mode": edit_mode,
            "default": str(default),
        }
        if view in ["definition", "custom_definition"]:
            kwargs["recurse"] = "false"

        from view_section_wdg import ViewSectionWdg

        section_wdg = ViewSectionWdg(**kwargs)
        class_path = Common.get_full_class_name(section_wdg)

        section_div = DivWdg(css="spt_panel")
        section_div.add_style("display: block")
        section_div.set_attr("spt_class_name", class_path)
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_div.add(section_wdg)
        return section_div
Beispiel #12
0
    def get_ping_wdg(self):
        div = DivWdg()
        div.add_class("spt_diagnostics_ping")

        ping_div = DivWdg()
        div.add(ping_div)

        ping_div.add( CheckboxWdg() )

        ping_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            var server = TacticServerStub.get();
            var result = server.ping();

            var msg = 'wow';

            var status_el = spt.get_cousin(bvr.src_el, ".spt_diagnostics_ping",".spt_diagnostics_ping_status");
            status_el.innerHTML = result;
            '''
        } )




        # Test database connection
        ping_div.add("Test Server Ping")

        status_div = DivWdg()
        status_div.add_class("spt_diagnostics_ping_status")
        status_div.add("Checking ...")
        div.add(status_div)

        return div
    def get_display(my):
        sobject = my.get_current_sobject()
        code = sobject.get_code()
        sk = my.server.build_search_key("twog/movement", code)
        shipping_class = sobject.get_value("shipping_class")
        title = sobject.get_value("name")
        waybill = sobject.get_value("waybill")
        sending_company_code = sobject.get_value("sending_company_code")
        receiving_company_code = sobject.get_value("receiving_company_code")
        shipper_code = sobject.get_value("shipper_code")
        description = sobject.get_value("description")
        timestamp = sobject.get_value("timestamp")

        widget = DivWdg()
        table = Table()
        table.add_attr("width", "50px")
        table.add_row()
        cell1 = table.add_cell(
            '<img border="0" style="vertical-align: middle" title="" src="/context/icons/silk/printer.png">'
        )
        launch_behavior = my.get_launch_behavior()
        cell1.add_attr("sk", sk)
        cell1.add_attr("shipping_class", shipping_class)
        cell1.add_attr("to_comp", receiving_company_code)
        cell1.add_attr("from_comp", sending_company_code)
        cell1.add_attr("waybill", waybill)
        cell1.add_attr("title", title)
        cell1.add_attr("shipper", shipper_code)
        cell1.add_attr("description", description)
        cell1.add_attr("timestamp", timestamp)
        cell1.add_style("cursor: pointer;")
        cell1.add_behavior(launch_behavior)
        widget.add(table)

        return widget
Beispiel #14
0
    def get_display(self):

        sobject = self.get_current_sobject()
        sobject_id = sobject.get_id()
        result = self.data.get(sobject_id)

        top = DivWdg()
        if not result:
            return top


        expression = self.get_option("expression")
        if expression:
            value = Search.eval(expression, result)
        else:
            column = self.get_option("column")
            if not column:
                column = self.get_name()
            try:
                value = result.get_value(column)
            except:
                value = ""

        top.add(value)

        return top
    def get_display(my):
        sobject = None
        code = ''
        show_checks = False
        if 'source_code' in my.kwargs.keys():
            code = str(my.kwargs.get('source_code'))    
        else:
            sobject = my.get_current_sobject()
            code = sobject.get_code()
        if sobject.get_value('high_security') in [True,'T','t','1']:
            show_checks = True
        widget = DivWdg()
        table = Table()
        table.add_attr('width', '50px')
        if show_checks:
            table.add_style('background-color: #ff0000;')
            login = Environment.get_login()
            user_name = login.get_login()
            table.add_row()
            cell1 =  table.add_cell('<img border="0" style="vertical-align: middle" title="Security Checklist" name="Security Checklist" src="/context/icons/32x32/lock_32_01.png">')
            cell1.add_attr('user', user_name)
            launch_behavior = my.get_launch_behavior(code,user_name)
            cell1.add_style('cursor: pointer;')
            cell1.add_behavior(launch_behavior)
        widget.add(table)

        return widget
Beispiel #16
0
    def get_display(self):
        sobject = self.get_current_sobject()

        snapshots = []
        if isinstance(sobject, Layer):
            # for layer renders, we try to get all render sobjects
            renders = Render.get_all_by_sobject(sobject)
            if renders:
                snapshots = Snapshot.get_by_sobjects(renders, is_current=True)
        else: # for object that has direct snapshots like plates
            snapshot = Snapshot.get_current_by_sobject(sobject)
            if snapshot:
                snapshots.append(snapshot)

        if not snapshots:
            return "<i>- no files -</i>"

        div = DivWdg()

        for snapshot in snapshots:
            file_types = snapshot.get_all_file_types()
            table = Table(css='embed')

            for file_type in file_types:
                table.add_row()
                
                table.add_cell( self.get_open_wdg(snapshot, file_type) )
                dir = snapshot.get_client_lib_dir(file_type=file_type)
                
                
                table.add_cell( "%s: <i>%s</i>" % (file_type, dir) )
         

            div.add(table)
        return div
    def get_display(my):
        name = ''
        if 'code' in my.kwargs.keys():
            code = my.kwargs.get('code') 
        else: 
            sobject = my.get_current_sobject()
            code = sobject.get_code()
            name = sobject.get_value('name')
        if 'name' in my.kwargs.keys():
            name = my.kwargs.get('name')
        search_on_load = 'false'
        if 'search_on_load' in my.kwargs.keys():
            search_on_load = my.kwargs.get('search_on_load')

        widget = DivWdg()
        table = Table()
        table.add_attr('width', '50px')
        table.add_row()
        cell1 = table.add_cell('<img border="0" style="vertical-align: middle" title="" src="/context/icons/custom/imdb.png">')
        cell1.add_attr('code', code)
        cell1.add_attr('name', name)
        cell1.add_attr('search_on_load', search_on_load)
        launch_behavior = my.get_launch_behavior()
        cell1.add_style('cursor: pointer;')
        cell1.add_behavior(launch_behavior)
        widget.add(table)

        return widget
Beispiel #18
0
    def get_search_wdg(self):
        filter_div = DivWdg()
        filter_div.add_style("width: 100px")

        buttons_list = [
            {'label': 'Run Search', 'tip': 'Run search with this criteria' },
        ]

        txt_btn_set = TextBtnSetWdg( position='', buttons=buttons_list, spacing=6, size='large', side_padding=4 )
        run_search_bvr = {
            'type':         'click_up',
            'cbjs_action':  '''
                spt.app_busy.show('Search ...', 'Searching Active Directory for matching users.');
                setTimeout( function() {
                var top = bvr.src_el.getParent('.ad_search_wdg_top');
                var values = spt.api.Utility.get_input_values(top);
                spt.panel.refresh(top, values);
                spt.app_busy.hide();
                }, 100);
            '''
        }
        txt_btn_set.get_btn_by_label('Run Search').add_behavior( run_search_bvr )
        #filter_div.add( txt_btn_set )

        div = DivWdg()
        div.add_behavior(run_search_bvr)
        button = ProdIconButtonWdg("Run Search")
        button.add_behavior(run_search_bvr)

        div.add(button)
        filter_div.add(div)
        return filter_div
Beispiel #19
0
    def get_display(my):
        my.view = my.kwargs.get('view')
        if not my.view:
            my.view = 'publish'
        widget = Widget()
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        if my.get_option('preview') != 'false': 
            my.thumb.set_current_index(my.get_current_index())
            widget.add(my.thumb)

        publish_link = PublishLinkWdg(search_type,search_id, config_base=my.view) 
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build a popup link to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        browse_link.add_behavior({'type': 'click_up',
            'cbjs_action': 'spt.popup.get_widget(evt, bvr)',
            'options': {'popup_id' : 'publish_browser',
                        'class_name' : 'pyasm.prod.web.PublishBrowserWdg' ,
                        'title': 'Publish Browser'},
            'args' : { 'search_type': search_type,
                        'search_id' : search_id }
            })
        div.add(browse_link)
        div.set_style('padding-top: 6px')


        return widget
Beispiel #20
0
    def get_example_display(self):

        div = DivWdg()

        # --- Example of using _handoff_ property in behavior -----------------------------------------------------

        table = Table()
        table.add_row()
        td = table.add_cell()
        td.set_style( "background: #0f0f0f; color: #9f9f9f; border: 1px solid black; padding: 4px;" )
        td_id = 'HandOffSource'
        td.set_id(td_id)
        td.add( "Element '%s' with '_handoff_' property in bvr spec" % td_id )
        td.add_behavior( {
                '_handoff_': '$(@.parentNode).getElement("#HandOffTarget")',

                'type': 'click',
                'cbfn_action': 'spt.ui_play.test_handoff',
                'dst_el': '$(@.parentNode).getElement("#DestElForBvr");'
            } )

        td = table.add_cell()
        td.set_style( "background: #2f2f2f; color: #9f9f9f; border: 1px solid black; padding: 4px; cursor: pointer;" )
        td_id = 'HandOffTarget'
        td.set_id(td_id)
        td.add( "Element '%s' that receives the handed off behavior" % td_id );

        td = table.add_cell()
        td.set_style( "background: #4f4f4f; color: #9f9f9f; border: 1px solid black; padding: 4px;" )
        td_id = 'DestElForBvr'
        td.set_id(td_id)
        td.add( "Element '%s' specified as dst_el for handed off behavior" % td_id );
        div.add( table )

        return div
Beispiel #21
0
    def get_display(my):
        widget = DivWdg(id='link_view_select')
        widget.add_class("link_view_select")
        if my.refresh:
            widget = Widget()
        else:
            my.set_as_panel(widget)
        
        views = []
        if my.search_type:
            from pyasm.search import WidgetDbConfig
            search = Search( WidgetDbConfig.SEARCH_TYPE )
            search.add_filter("search_type", my.search_type)
            search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI")
            search.add_order_by('view')
            widget_dbs = search.get_sobjects()
            views = SObject.get_values(widget_dbs, 'view')
        
        labels = [view for view in views]

        views.insert(0, 'table')
        labels.insert(0, 'table (Default)')
        st_select = SelectWdg('new_link_view', label='View: ')
        st_select.set_option('values', views)
        st_select.set_option('labels', labels)
        widget.add(st_select)
        return widget
Beispiel #22
0
    def get_action_html(my):
        search_key = SearchKey.get_by_sobject(my.sobjects[0])
        behavior_submit = {
            'type': 'click_up',
            'cb_fire_named_event': 'append_pressed',
            'element_names': my.element_names,
            'search_key': search_key,
            'input_prefix': my.input_prefix

        }
        behavior_cancel = {
            'type': 'click_up',
            'cb_fire_named_event': 'preclose_edit_popup',
            'cbjs_postaction': "spt.popup.destroy( spt.popup.get_popup( $('edit_popup') ) );"
        }
        button_list = [{'label':  "%s/Close" % my.mode.capitalize(),
            'bvr': behavior_submit},
            {'label':  "Cancel", 'bvr': behavior_cancel}]        
        edit_close = TextBtnSetWdg( buttons=button_list, spacing =6, size='large', \
                align='center',side_padding=10)
        
       
        div = DivWdg()
        div.add_styles('height: 35px; margin-top: 10px;')
       
        div.center()
        div.add(edit_close)

        return div
Beispiel #23
0
    def get_camera_wdg(self):
        widget = Widget()

        div = DivWdg(css="filter_box")
        sequence_filter = SequenceFilterWdg()
        epi_code, sequence_code = sequence_filter.get_value()
        div.add(sequence_filter)

        search = Search("prod/camera")

        columns = ['shot_code', 'description']
        search_filter = SearchFilterWdg("camera_search", columns=columns,\
            has_persistence=False)
     
        search_filter.alter_search(search)
        div.add(search_filter)
        widget.add(div)

        if sequence_code:
            search.add_where("shot_code in (select code from shot where sequence_code = '%s')" % sequence_code)

        table = TableWdg("prod/camera")
        table.set_search(search)
        widget.add(table)
        return widget
    def get_folder_wdg(my, element_name, config, options, base_path, current_path, info, personal, use_same_config):
        li = HtmlElement.li()
        li.add_class("spt_side_bar_link")
        li.add_class("main_li")


        title = my._get_title(config, element_name)
        title_wdg = DivWdg()
        title_wdg.add_class("menu_header")
        li.add(title_wdg)
        title_wdg.add(title)


        ul = HtmlElement.ul()
        li.add(ul)
        ul.add_class("spt_side_bar_section")
        ul.add_class("sub_ul")

        # then get view name from options in order to read a new
        # config and recurse ...
        options_view_name = options.get('view')
        if options_view_name:
            if use_same_config:
                xml = config.get_xml()
                sub_config = WidgetConfig.get(xml=xml)
                sub_config.set_view(options_view_name)
            else:
                sub_config = my.get_config( my.config_search_type, options_view_name, default=my.default, personal=personal)

            info['level'] += 1
            my.generate_section( sub_config, ul, info, base_path=current_path, personal=personal, use_same_config=use_same_config )
            info['level'] -= 1

        return li
 def get_display(my):
     do_button = False
     if 'work_order_code' not in my.kwargs.keys(): 
         sobject = my.get_current_sobject()
         code = sobject.get_code()
     else:
         code = my.kwargs.get('work_order_code')    
         do_button = True
     
     widget = DivWdg()
     table = Table()
     table.add_attr('width', '50px')
     table.add_row()
     launch_behavior = my.get_launch_behavior(code)
     what_goes_in = '<img border="0" style="vertical-align: middle" title="" src="/context/icons/silk/printer.png">'
     if do_button:
        what_goes_in = ButtonSmallNewWdg(title="Print Work Order", icon=IconWdg.PRINTER)
        what_goes_in.add_behavior(launch_behavior) 
     cell1 = table.add_cell(what_goes_in)
     cell1.add_attr('code',code)
     cell1.add_style('cursor: pointer;')
     if not do_button:
         cell1.add_behavior(launch_behavior)
     widget.add(table)
     if do_button:
         return what_goes_in
     else:
         return widget
Beispiel #26
0
    def get_section_wdg(self, view, editable=True, default=False):

        title = ""
        target_id = "sobject_relation"
        if editable:
            edit_mode = 'edit'
        else:
            edit_mode = 'read'
        kwargs = {
            'title': title,
            'config_search_type': self.search_type,
            'view': view,
            'target_id': target_id,
            'width': '300',
            'prefix': 'manage_side_bar',
            'mode': edit_mode,
            'default': str(default)
        }
        if view in ["definition", "custom_definition"]:
            kwargs['recurse'] = "false"

        section_wdg = ViewSectionWdg(**kwargs)
        class_path = Common.get_full_class_name(section_wdg)

        section_div = DivWdg()
        section_div.add_style("display: block")
        section_div.set_attr('spt_class_name', class_path)
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_div.add(section_wdg)
        return section_div
Beispiel #27
0
    def get_tables_wdg(my):
        
        div = DivWdg()
        div.set_name("Tables")

        div.add("In order to fully register a database, you must bind it to a TACTIC project")
        div.add("<br/>")



        project_code = "mongodb"
        database = "test_database"

        db_resource = DbResource(
                server='localhost',
                vendor='MongoDb',
                database=database
        )


        try:
            connect = DbContainer.get(db_resource)
        except Exception, e:
            div.add("Could not connect")
            div.add_style("padding: 30px")
            div.add("<br/>"*2)
            div.add(str(e))
            return div
Beispiel #28
0
    def get_art_reference(self):

        widget = Widget()
        help = HelpItemWdg('References', 'References tab lets the user organize art references. Each reference can be [related] to one or more assets defined in TACTIC. It can be set up when you [Edit] the reference.')
        self.add(help)
        div = DivWdg(css="filter_box")
        
        widget.add(div)
        columns = ['description','keywords']
        search_filter = SearchFilterWdg("art_ref_search", columns=columns,\
            has_persistence=False)
       
        div.add(search_filter)
           
        select = FilterSelectWdg("art_ref_category", label='Category: ', css='snall')
        select.set_option("setting", "art_reference_category")
        select.add_empty_option('-- Any --')
        
        div.add( select )

        table = TableWdg("prod/art_reference")
        search = Search("prod/art_reference")
       
        search_filter.alter_search(search)
       
        value = select.get_value()
        if value != "":
            search.add_filter("category", value)
        table.set_search(search)
        widget.add(table)
        return widget
Beispiel #29
0
    def get_example_display(my):

        div = DivWdg()

        # --- Example of new spt.fx animation slider --------------------------------------------------------------

        slide_div = DivWdg()
        slide_div.set_id( "ui_play_sliding_thing" )
        slide_div.set_style( "background: #9f9f9f; color: #0f0f0f; border: 1px solid black;" )
        slide_div.add( "For a moment after Mr. and Mrs. Darling left the house the night-lights by the beds of the three children continued to burn clearly. They were awfully nice little night-lights, and one cannot help wishing that they could have kept awake to see Peter; but Wendy&#39;s light blinked and gave such a yawn that the other two yawned also, and before they could close their mouths all the three went out. There was another light in the room now, a thousand times brighter than the night-lights, and in the time we have taken to say this, it had been in all the drawers in the nursery, looking for Peter&#39;s shadow, rummaged the wardrobe and turned every pocket inside out. It was not really a light; it made this light by flashing about so quickly, but when it came to rest for a second you saw it was a fairy, no longer than your hand, but still growing. It was a girl called Tinker Bell exquisitely gowned in a skeleton leaf, cut low and square, through which her figure could be seen to the best advantage. She was slightly inclined to embonpoint." )

        div.add( slide_div )

        div.add( '<br/>' )
        click_slide = DivWdg()
        click_slide.add( "Click Me to Slide!" )
        click_slide.set_style( "background: #0f0f0f; color: #9f9f9f; border: 1px solid black; width: 100px; " \
                               "cursor: pointer;" )

        click_slide.add_behavior( { 'type': 'click_up',
                                    'dst_el': 'ui_play_sliding_thing',
                                    'cbfn_action': 'spt.fx.slide_anim_cbk',
                                    'options': { 'direction': 'vertical',
                                                 'duration': 500,  # time in milliseconds
                                                 'frame_rate': 15   # frames per second
                                                }
                                    } )

        div.add( click_slide )
        return div
Beispiel #30
0
    def add_header(my, table, sobj_title):
        title_str = my.kwargs.get("title")

        if not title_str:
            if my.mode == 'insert':
                action = 'Add New Item'
            elif my.mode == 'edit':
                action = 'Save Changes'
            else:
                action = my.mode
            
            title_str =  action.capitalize() + " to " + sobj_title
            if my.mode == 'edit':
                title_str = '%s (%s)' %(title_str, my.sobjects[0].get_code())
            

        th = table.add_header()
        
        title_div = DivWdg()
        title_div.set_attr('title', my.view)
        th.add(title_div)
        title_div.add(title_str)
        th.add_color("background", "background3")
        if my.color_mode == "default":
            th.add_color("border-color", "table_border", default="border")
            th.add_style("border-width: 1px")
            th.add_style("border-style: solid")
        th.set_attr("colspan", "2")
        th.add_style("height: 30px")
Beispiel #31
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(
            include_multi_project=show_multi_project)

        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()

        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.app.ProjectStartWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("project_setup", "Project Setup", class_name)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New Searchable Type (sType)",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        })

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
        })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;" * 5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add(
                "Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours."
            )
            div.add("<br/>" * 2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add(
                "Click on the 'Add' button above to start adding new types.")
            return top

        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")

        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()

        # group mouse over
        table.add_relay_behavior({
            'type':
            "mouseover",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        })
        table.add_relay_behavior({
            'type':
            "mouseout",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        })

        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")

        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i % 2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2)

            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue

            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)

            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                title,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })
            button.add_style("float: left")

            arrow_button = IconButtonWdg(tip="More Views",
                                         icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)

            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type,
                             activator=arrow_button,
                             cbk=cbk,
                             is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior({
                'type':
                'listen',
                'search_type':
                search_type,
                'event_name':
                'startup_save:' + search_type_obj.get_title(),
                'title':
                search_type_obj.get_title(),
                'cbjs_action':
                '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            })
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                search_type_obj.get_title(),
                'cbjs_action':
                '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            })
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """

            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                "Import Data",
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns",
                                   icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                "Add Custom Columns",
                'cbjs_action':
                '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Workflow',
                'search_type':
                search_type,
                'cbjs_action':
                '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Trigger',
                'search_type':
                search_type,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Trigger',
                'search_type':
                search_type,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type",
                                   icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_type_obj.get_search_key(),
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            })
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """

        columns_wdg = DivWdg()
        top.add(columns_wdg)

        return top
Beispiel #32
0
        retrieve_button = ButtonWdg("Retrieve Search")
        behavior = {
            'type': 'click',
            'cbjs_action': 'spt.dg_table.retrieve_search_cbk(evt, bvr);'
        }
        retrieve_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event(
            "onclick", "$('retrieve_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(retrieve_button)
        button_div.add("&nbsp;&nbsp;")
        button_div.add(cancel_button)
        div.add(button_div)

        popup.add(div, "content")

        return popup

    def get_save_wdg(my):

        # add the popup
        popup = PopupWdg(id='save_search_wdg')
        popup.add("Save Search", "title")

        div = DivWdg()
Beispiel #33
0
    def get_display(my):

        element_data_dict = {}

        config = my.get_config()
        element_names = config.get_element_names()
        content_wdg = DivWdg()


        if not element_names:
            element_names = ['keywords']

        my.set_content(content_wdg)

        
        # this is somewhat duplicated logic from alter_search, but since this is called 
        # in ViewPanelWdg, it's a diff instance and needs to retrieve again
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix(my.prefix)
        for data in data_list:
            handler = data.get("handler")
            element_name = data.get("element_name")
            if not element_name:
                continue

            element_data_dict[element_name] = data

        elements_wdg = DivWdg()
        content_wdg.add(elements_wdg)
        elements_wdg.add_color("color", "color")
        elements_wdg.add_style("padding-top: 10px")
        elements_wdg.add_style("padding-bottom: 15px")

        #elements_wdg.add_color("background", "background3", 0)
        elements_wdg.add_color("background", "background", -3)
        elements_wdg.add_border()



        if len(element_names) == 1:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
            elements_wdg.add_style("padding-right: 50px" )
        else:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )

        table = Table()
        table.add_color("color", "color")
        elements_wdg.add(table)
        table.add_class("spt_simple_search_table")
        
        columns = my.kwargs.get("columns")
        if not columns:
            columns = 2
        else:
            columns = int(columns) 
       
        num_rows = int(len(element_names)/columns)+1
        tot_rows = int(len(element_names)/columns)+1
        project_code = Project.get_project_code()
        # my.search_type could be the same as my.base_search_type
        full_search_type = SearchType.build_search_type(my.search_type, project_code)


        visible_rows = my.kwargs.get("visible_rows")
        if visible_rows:
            visible_rows = int(visible_rows)
            num_rows = visible_rows
        else:
            visible_rows = 0

        titles = config.get_element_titles() 
        row_count = 0
        for i, element_name in enumerate(element_names):
            attrs = config.get_element_attributes(element_name)
            if i % columns == 0:

                if visible_rows and row_count == visible_rows:
                    tr, td = table.add_row_cell("+ more ...")
                    td.add_class("hand")
                    td.add_class("SPT_DTS")
                    td.add_class("spt_toggle")
                    td.add_style("padding-left: 10px")

                    td.add_behavior( {
                        'type': 'click_up',
                        'visible_rows': visible_rows,
                        'cbjs_action': '''
                        var top = bvr.src_el.getParent(".spt_simple_search_table");
                        var expand = true;
                        var rows = top.getElements(".spt_simple_search_row");
                        for (var i = 0; i < rows.length; i++) {
                            var row = rows[i];
                            if (row.getStyle("display") == "none") {
                                row.setStyle("display", "");
                            }
                            else {
                                row.setStyle("display", "none");
                                expand = false;
                            }
                        }
                        var spacer = top.getElements(".spt_spacer");
                        var cell = top.getElement(".spt_toggle");
                        if (expand) {
                            spacer.setStyle("height", (rows.length+bvr.visible_rows)*20);
                            cell.innerHTML = "- less ...";
                        }
                        else {
                            spacer.setStyle("height", bvr.visible_rows*20);
                            cell.innerHTML = "+ more ...";
                        }

                        '''
                    } )


                tr = table.add_row()
                if visible_rows and row_count >= visible_rows:

                    tr.add_class("spt_simple_search_row")
                    tr.add_style("display: none")
                    tr.add_style("height: 0px")

                row_count += 1

            icon_td = table.add_cell()
            title_td = table.add_cell()
            element_td =table.add_cell()


            # show the title
            title_td.add_style("text-align: right")
            title_td.add_style("padding-right: 5px")
            title_td.add_style("min-width: 100px")


            element_wdg = DivWdg()
            if attrs.get('view') == 'false':
                element_wdg.add_style('display: none')
            element_td.add(element_wdg)

            #title_td.add_style("border: solid 1px red")
            #element_td.add_style("border: solid 1px blue")
            #element_wdg.add_style("border: solid 1px yellow")


            if i >= 0  and i < columns -1 and len(element_names) > 1:
                spacer = DivWdg()
                spacer.add_class("spt_spacer")
                spacer.add_style("border-style: solid")
                spacer.add_style("border-width: 0 0 0 0")
                #spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("width: 10px")
                spacer.add_style("border-color: %s" % spacer.get_color("border") )
                spacer.add("&nbsp;")
                td = table.add_cell(spacer)
                td.add_attr("rowspan", tot_rows)

            #element_wdg.add_color("color", "color3")
            #element_wdg.add_color("background", "background3")
            #element_wdg.set_round_corners()
            #element_wdg.add_border()

            element_wdg.add_style("padding: 4px 10px 4px 5px")
            element_wdg.add_class("spt_table_search")
            element_wdg.add_style("margin: 1px")
            element_wdg.add_style("min-height: 20px")
            element_wdg.add_style("min-width: 250px")

            # this is done at get_top()
            #element_wdg.add_class("spt_search")
            element_wdg.add( HiddenWdg("prefix", my.prefix))

            display_handler = config.get_display_handler(element_name)
            element_wdg.add( HiddenWdg("handler", display_handler))


            element_wdg.add( HiddenWdg("element_name", element_name))
        

            from pyasm.widget import ExceptionWdg
            try:
                widget = config.get_display_widget(element_name)
                if widget:
                    widget.set_title(titles[i])

            except Exception, e:
                element_wdg.add(ExceptionWdg(e))
                continue


            if not widget:
                # the default for KeywordFilterElementWdg is mode=keyword
                if not my.column_choice:
                    my.column_choice = my.get_search_col(my.search_type)
                widget = KeywordFilterElementWdg(column=my.column_choice)
                widget.set_name(element_name)
                


            from pyasm.widget import IconWdg
            icon_div = DivWdg()
            icon_td.add(icon_div)
            icon_div.add_style("width: 20px")
            icon_div.add_style("margin-top: 2px")
            icon_div.add_style("padding-left: 5px")
            icon_div.add_class("spt_filter_top")


            widget.set_show_title(False)
            #element_wdg.add("%s: " % title)
            data = element_data_dict.get(element_name)
			
			
            view_panel_keywords = my.kwargs.get("keywords")
            #user data takes precedence over view_panel_keywords
            if isinstance(widget, KeywordFilterElementWdg):
                if view_panel_keywords:
                    widget.set_value("value", view_panel_keywords)
            if data:
                widget.set_values(data)

                
           
			    
                    

            if isinstance(widget, KeywordFilterElementWdg) and not full_search_type.startswith('sthpw/sobject_list'):
                widget.set_option('filter_search_type', full_search_type)
            try:
                if attrs.get('view') != 'false':
                    title_td.add(widget.get_title_wdg())

                element_wdg.add(widget.get_buffer_display())
            except Exception, e:
                element_wdg.add(ExceptionWdg(e))
                continue
Beispiel #34
0
    def get_top(my):
        top = my.top
        top.add_color("background", "background", -5)
        top.add_style("margin-bottom: -2px")
        top.add_class("spt_filter_top")


        table = Table()
        top.add(table)


        title_div = DivWdg()
        tr, td = table.add_row_cell()
        td.add(title_div)
        title_div.add("<div style='font-size: 16px'>Search Criteria</div>")
        title_div.add("<div>Select filters to refine your search</div>")
        title_div.add_style("padding: 20px 0px 0px 20px")

        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("margin-bottom: 15px")
        table.add_style("width: 100%")


        tr = table.add_row()

        if not my.content:
            my.content = DivWdg()
            my.content.add("No Content")

        td = table.add_cell()
        td.add(my.content)
        #my.content.add_style("margin: -2 -1 0 -1")


        show_search = my.kwargs.get("show_search")
        if show_search in [False, 'false']:
            show_search = False
        else:
            show_search = True
        show_search = False
        if show_search:
            search_wdg = my.get_search_wdg()
            table.add_row()
            search_wdg.add_style("float: left")

            search_wdg.add_style("padding-top: 6px")
            search_wdg.add_style("padding-left: 10px")
            search_wdg.add_style("height: 33px")

            td = table.add_cell()
            td.add(search_wdg)
            td.add_style("padding: 5px 20px")
            #td.add_border()
            #td.add_color("background", "background", -10)



        hidden = HiddenWdg("prefix", my.prefix)
        top.add(hidden)
        # this cannot be spt_search as it will confuse spt.dg_table.search_cbk() 
        top.add_class("spt_simple_search")

        return top
Beispiel #35
0
    def get_widget_from_hash(cls,
                             hash,
                             return_none=False,
                             force_no_index=False,
                             kwargs={}):

        from pyasm.web import DivWdg
        if hash.startswith("//"):
            use_top = False
            hash = hash[1:]
        else:
            use_top = True

        import re
        p = re.compile("^/(\w+)")
        m = p.search(hash)
        if not m:
            if return_none:
                return None
            print "Cannot parse hash[%s]" % hash
            return DivWdg("Cannot parse hash [%s]" % hash)
        key = m.groups()[0]

        if key != 'login':
            security = Environment.get_security()
            login = security.get_user_name()
            # guest user should never be able to see admin site
            if login == "guest" and key == 'admin':
                #from pyasm.widget import Error403Wdg
                #return Error403Wdg().get_buffer_display()
                from pyasm.widget import WebLoginWdg
                # HACK: if the guest access is full, the the outer form
                # is not defined ... force it in here.  This is because the
                # top used it TopWdg and not TitleTopWdg
                div = DivWdg()
                div.add(
                    "<form id='form' name='form' method='post' enctype='multipart/form-data'>\n"
                )
                web_login_wdg = WebLoginWdg().get_buffer_display()
                div.add(web_login_wdg)
                div.add("</form>\n")
                return div

        sobject = cls._get_predefined_url(key, hash)

        # look up the url
        if not sobject:
            search = Search("config/url")
            search.add_filter("url", "/%s/%%" % key, "like")
            search.add_filter("url", "/%s" % key)
            search.add_where("or")
            sobject = search.get_sobject()

        if not sobject:
            if return_none:
                return None
            return DivWdg("No Widget found for hash [%s]" % hash)

        config = sobject.get_value("widget")
        config = config.replace('&', '&amp;')

        url = sobject.get_value("url")
        url = url.strip()

        # update the config value with expressions
        options = Common.extract_dict(hash, url)
        for name, value in options.items():
            config = config.replace("{%s}" % name, value)

        xml = Xml()
        xml.read_string(config)

        use_index, use_admin, use_sidebar = cls._get_flags(
            xml, sobject, force_no_index, kwargs)

        if use_admin:
            # use admin
            from tactic.ui.app import PageNavContainerWdg
            top = PageNavContainerWdg(hash=hash, use_sidebar=use_sidebar)
            return top.get_buffer_display()

        elif use_index:

            # check if there is an index
            search = Search("config/url")
            search.add_filter("url", "/index")
            index = search.get_sobject()
            # just use admin if no index page is found
            if not index:
                from tactic.ui.app import PageNavContainerWdg
                top = PageNavContainerWdg(hash=hash, use_sidebar=use_sidebar)
                return top.get_buffer_display()

            config = index.get_value("widget")
            xml = Xml()
            xml.read_string(config)
            node = xml.get_node("element/display")

            options.update(xml.get_node_values_of_children(node))

            class_name = xml.get_value("element/display/@class")
            if class_name:
                options['class_name'] = class_name

            # this passes the hash value to the index widget
            # which must handle it accordingly
            options['hash'] = hash
            top = cls.build_widget(options)

            return top.get_buffer_display()

        # process the options and then build the widget from the xml

        options = Common.extract_dict(hash, url)
        for name, value in kwargs.items():
            options[name] = value

        node = xml.get_node("element/display")
        options.update(xml.get_node_values_of_children(node))

        class_name = xml.get_value("element/display/@class")
        if class_name:
            options['class_name'] = class_name

        widget = cls.build_widget(options)

        name = hash.lstrip("/")
        name_array = name.split("/")
        if name_array:
            name_end = name_array[-1]
            name_end = name_end.replace("_", " ")
            widget.set_name(name_end)
        else:
            widget.set_name(name)

        return widget
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('add_new_files_to_task')

        if self.division_sobject:
            outer_div.add(get_label_widget('Path'))
            outer_div.add(get_text_input_wdg('new_file_path', 800))

            outer_div.add(get_label_widget('Classification'))
            outer_div.add(get_file_classification_select_wdg())

            submit_button = SubmitWdg('Submit')
            submit_button.add_behavior(self.get_submit_button_behavior())

            outer_div.add(submit_button)
        else:
            outer_div.add(
                '<div>You cannot add files to an Order until a Client Division has been selected.</div>'
            )

        return outer_div
Beispiel #37
0
    def get_display(my):

        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New User",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        })

        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL', 'BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add(
                "Click on the 'Add' button above to start adding new users.")

            return top

        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")

        table = Table()
        table.set_max_width()
        table.add_style("margin-top: 10px")
        div.add(table)

        # group mouse over
        table.add_relay_behavior({
            'type':
            "mouseover",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        })
        table.add_relay_behavior({
            'type':
            "mouseout",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        })

        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")

        for i, login in enumerate(logins):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i % 2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2)

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'login_code':
                login_code,
                'full_name':
                full_name,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            })

        return top
    def get_display(my):
        div = DivWdg()

        div.add_class("spt_security")
        div.add_attr("id", "SecurityManagerWdg")
        div.add_attr("spt_class_name", Common.get_full_class_name(my))
        div.add_attr("spt_search_key", my.search_key)
        div.add_attr("spt_update", "true")

        project_div = DivWdg()
        project_div.add_color("background", "background")
        project_div.add_color("color", "color")
        project_div.add_style("padding: 10px")
        project_div.add_border()
        project_div.add_style("width: 300px")

        #project_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        #project_div.set_dimensions( width_str='175px', content_height_str='100px' )

        group = SearchKey.get_by_search_key(my.search_key)

        title = DivWdg()
        title.add_class("maq_search_bar")
        name = group.get_value("login_group")
        title.add("Global security settings for %s" % name)

        project_div.add(title)

        access_rules = group.get_xml_value("access_rules")
        access_manager = AccessManager()
        access_manager.add_xml_rules(access_rules)

        group = "builtin"
        global_default_access = "deny"

        list_div = DivWdg()
        list_div.add_style("color: #222")
        for item in permission_list:
            if item.get('group'):
                group_div = DivWdg()
                list_div.add(group_div)
                group_div.add_style("margin-top: 10px")
                group_div.add_style("font-weight: bold")
                group_div.add(item.get('group'))
                group_div.add("<hr/>")
                continue

            item_div = DivWdg()
            list_div.add(item_div)
            item_div.add_style("margin-top: 5px")

            key = item.get('key')
            item_default = item.get('default')
            if item_default:
                default_access = item_default
            else:
                default_access = global_default_access

            allowed = access_manager.check_access(group,
                                                  key,
                                                  "allow",
                                                  default=default_access)

            checkbox = CheckboxWdg("rule")
            if allowed:
                checkbox.set_checked()
            checkbox.set_option("value", key)

            item_div.add(checkbox)

            item_div.add_style("color: #222")
            item_div.add(item.get('title'))

        project_div.add(list_div)

        project_div.add("<hr>")

        #close_script = "spt.popup.close(bvr.src_el.getParent('.spt_popup'))"

        save_button = ActionButtonWdg(title="Save",
                                      tip="Save Security Settings")
        save_button.add_behavior({
            "type":
            "click_up",
            "cbjs_action":
            "el=bvr.src_el.getParent('.spt_security');spt.panel.refresh(el);"
        })

        save_button.add_style("margin-left: auto")
        save_button.add_style("margin-right: auto")
        project_div.add(save_button)

        div.add(project_div)
        if my.update == "true":
            div.add(HtmlElement.br())
            div.add(HtmlElement.b(my.description))

        return div
        if not summary:
            return None

        # parse the expression
        my.vars = my.get_vars()
 
        expression, title = my.get_expression(summary)
        try:
            result = Search.eval(expression, sobjects=sobjects, vars=my.vars)
        except Exception, e:
            print "WARNING: ", e.message
            result = 0
            title = ''

        div = DivWdg()
        div.add(str(result))
        div.add_style("text-align: right")

        return div, result



    def get_expression(my, summary):
        if summary == 'total':
            expression = '@SUM(.%s)' % my.get_name()
            title = "Total: "
        elif summary == 'average':
            expression = '@AVG(.%s)' % my.get_name()
            title = "Avg: "
        else:
            expression = '@COUNT()'
Beispiel #40
0
    def get_display(self):
        sobject = self.get_current_sobject()
        search_key = SearchKey.build_by_sobject(sobject)

        display = DivWdg()
        display.add_style("position: relative")
        display.add_class("spt_button_top")
        display.add_style("width: 26px")
        display.add_style("margin-left: auto")
        display.add_style("margin-right: auto")

        BASE = '/context/themes2/default/'
        over_div = DivWdg()
        display.add(over_div)
        over_div.add_class("spt_button_over")
        over_img = "<img src='%s/MainButton_over.png'/>" % BASE
        over_div.add(over_img)
        over_div.add_style("position: absolute")
        over_div.add_style("top: -9px")
        over_div.add_style("left: 0px")
        over_div.add_style("display: none")

        click_div = DivWdg()
        display.add(click_div)
        click_div.add_class("spt_button_click")
        click_img = "<img src='%s/MainButton_click.png'/>" % BASE
        click_div.add(click_img)
        click_div.add_style("position: absolute")
        click_div.add_style("top: -9px")
        click_div.add_style("left: 0px")
        click_div.add_style("display: none")

        if self.get_option('align') == 'left':
            display.add_style("text-align: left")
        else:
            display.add_style("text-align: center")

        icon = self.get_option("icon")
        if not icon:
            icon = "create"

        icon_tip = self.get_option("icon_tip")
        if not icon_tip:
            icon_tip = self.get_option("hint")
        if not icon_tip:
            icon_tip = ""

        enable = self.get_option("enable")
        if enable:
            result = ExpressionParser().eval(enable, sobject)
            if not result:
                return "&nbsp;"

        if not self.script_obj and not self.script:
            icon_wdg = IconButtonWdg("No Script Found", IconWdg.ERROR)
        else:
            icon_link = icon.upper()

            icon_wdg = IconButtonWdg(icon_tip, icon=icon_link)
            if not sobject.is_insert():
                icon_wdg.add_class("hand")
                #icon_wdg.add_behavior(self.behavior)
                icon_wdg.add_class("spt_button_%s" % self.name)

        icon_div = DivWdg()
        icon_div.add(icon_wdg)
        icon_div.add_style("position: absolute")
        icon_div.add_style("top: 2px")
        icon_div.add_style("left: 5px")
        display.add(icon_div)

        hit_wdg = icon_div
        hit_wdg.add_class("spt_button_hit")

        if sobject.is_insert():
            hit_wdg.add_style("opacity: 0.4")
        else:
            hit_wdg.add_class("spt_button_hit_wdg")

        display.add_style("height: 18px")
        display.add_style("min-width: 21px")
        #display.add_style("overflow: hidden")
        display.add_style("margin-top: 0px")

        expression = self.kwargs.get('expression')
        if expression:
            value = Search.eval(expression, sobject, single=True)

            if value:

                badge = DivWdg()
                badge.add_style("position: absolute")

                badge.add_style("right: -30px")
                badge.add_style("top: -2px")
                badge.add_style("margin: 4px 3px 3px 6px")
                badge.add_style("opacity: 0.5")
                badge.add_style("font-size: 0.7em")
                badge.add_class("badge")
                badge.add(value)

                display.add(badge)
                display.add_style("position: relative")

                #return top

        return display
Beispiel #41
0
    def init(my):

        # get the args in the URL
        args = WebContainer.get_web().get_form_args()
        search_type = args['search_type']
        search_id = args['search_id']

        sobject = Search.get_by_id(search_type, search_id)

        main_div = DivWdg()
        main_div.add_style("width: 95%")
        main_div.add_style("float: right")
        my.add(main_div)

        
        if isinstance(sobject, Shot):

            content_id ='summary_story_%s' %sobject.get_id()
            title_id = 'story_head_%s' %sobject.get_id()
            story_div = DivWdg(id=content_id)
            story_div.add_style('display','block')
            
            story_head = HtmlElement.h3("Storyboard")
            my.add_title_style(story_head, title_id, content_id)
            
            main_div.add(story_head)
            main_div.add(story_div)

            storyboard_table = TableWdg("prod/storyboard", "summary", css='minimal')
            search = Search("prod/storyboard")
            search.add_filter( sobject.get_foreign_key(), sobject.get_code() )
            sobjects = search.get_sobjects()
            storyboard_table.set_sobjects(sobjects)
            story_div.add(storyboard_table)


        # add reference material
        search = Search("sthpw/connection")
        search.add_filter("src_search_type", search_type)
        search.add_filter("src_search_id", search_id)
        connections = search.get_sobjects()

        if connections:
            content_id ='summary_ref_%s' %sobject.get_id()
            title_id = 'ref_head_%s' %sobject.get_id()

            ref_head = HtmlElement.h3("Reference")
            my.add_title_style(ref_head, title_id, content_id)
            
            ref_div = DivWdg(id = content_id)
            ref_div.add_style('display','block')
            
            for connection in connections:
                thumb = ThumbWdg()
                thumb.set_name("snapshot")
                dst_search_type = connection.get_value("dst_search_type")
                dst_search_id = connection.get_value("dst_search_id")
                dst = Search.get_by_id(dst_search_type, dst_search_id)
                thumb.set_sobject(dst)
                ref_div.add(thumb)

            
            main_div.add(ref_head)
            main_div.add(ref_div)


       
        task_head = HtmlElement.h3("Tasks")
        content_id ='summary_task_%s' %sobject.get_id()
        title_id = 'task_head_%s' %sobject.get_id()
        my.add_title_style(task_head, title_id, content_id)
        
        main_div.add(task_head)

        task_div = DivWdg(id=content_id)
        task_div.add_style('display','block')
        
        main_div.add(task_div)
        
        search = Search("sthpw/task")
        #if process != "":
        #    search.add_filter("process", process)

        search.add_filter("search_type", search_type)
        search.add_filter("search_id", search_id)

        #search.set_limit(4)
        task_table = TableWdg("sthpw/task", "summary", css='minimal')
        task_table.set_id('sthpw/task%s' % search_id)
        task_table.set_search(search)
        task_div.add(task_table)

        content_id ='summary_hist_%s' %sobject.get_id()
        title_id = 'hist_head_%s' %sobject.get_id()
        hist_head = HtmlElement.h3("Checkin History")
        my.add_title_style(hist_head, title_id, content_id)
        
        hist_div = DivWdg(id=content_id)
        hist_div.add_style('display','block')
        
        
        main_div.add(hist_head)
        main_div.add(hist_div)
        from flash_asset_history_wdg import FlashAssetHistoryWdg
        history = FlashAssetHistoryWdg()
        hist_div.add(history)
        main_div.add(HtmlElement.br())
    def get_display(my):
        sobject = my.get_current_sobject()

        column =  my.kwargs.get('column')
        if column:
            name = column
        else:
            name = my.get_name()
        
        value = my.get_value(name=name)

        if sobject:
            data_type = SearchType.get_column_type(sobject.get_search_type(), name)
        else:
            data_type = 'text'

        if type(value) in types.StringTypes:
            wiki = WikiUtil()
            value = wiki.convert(value) 
        if name == 'id' and value == -1:
            value = ''

        elif data_type in ["timestamp","time"] or name == "timestamp":
            if value == 'now':
                value = ''
            elif value:
                # This date is assumed to be GMT
                date = parser.parse(value)
                # convert to user timezone
                if not SObject.is_day_column(name):
                    date = my.get_timezone_value(date)
                try:
                    encoding = locale.getlocale()[1]		
                    value = date.strftime("%b %d, %Y - %H:%M").decode(encoding)
                except:
                    value = date.strftime("%b %d, %Y - %H:%M")

            else:
                value = ''
        else:
            if isinstance(value, Widget):
                return value
            elif not isinstance(value, basestring):
                try:
                    value + 1
                except TypeError:
                    value = str(value)
                #else:
                #    value_wdg.add_style("float: right")
                #    value_wdg.add_style("padding-right: 3px")



        if sobject and SearchType.column_exists(sobject.get_search_type(), name):
            value_wdg = DivWdg()
            value_wdg.add_update( {
                'search_key': sobject.get_search_key(),
                'column': name
            } )
            # don't call str() to prevent utf-8 encode error
            value_wdg.add(value)
            return value_wdg

        return value
Beispiel #43
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
Beispiel #44
0
    def get_display(self):
        main_wdg = DivWdg()
        main_wdg.set_id('prequal_eval_panel')

        main_wdg.add(self.get_name_section())
        main_wdg.add(self.get_client_section())

        main_wdg.add(self.get_operator_section())
        main_wdg.add(self.get_title_section())
        main_wdg.add(self.get_season_section())
        main_wdg.add(self.get_episode_section())
        main_wdg.add(self.get_version_section())
        main_wdg.add(self.get_video_aspect_ratio_section())

        main_wdg.add(self.get_general_comments_section())

        if hasattr(self, 'prequal_eval_sobject') and self.prequal_eval_sobject:
            main_wdg.add(PrequalEvalLinesWdg(prequal_eval_code=self.prequal_eval_sobject.get_code()))
            main_wdg.add(self.get_save_button())
            main_wdg.add(self.get_export_to_pdf_button())
            main_wdg.add(self.get_save_as_new_button())
        else:
            main_wdg.add(self.get_save_new_button())

        return main_wdg
Beispiel #45
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        if my.top_styles:
            div.add_styles(my.top_styles)
        inner = DivWdg()
        div.add(inner)


        
        menus_in = {}
        # set up the context menus
        if my.show_context_menu == True:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        elif my.show_context_menu == 'none':
            div.add_event('oncontextmenu', 'return false;')
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )
 




        

        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")
       

        inner.add_attr("ondragenter", "return false")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")

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

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Beispiel #46
0
    def get_display(my):

        # get the args in the URL
        args = WebContainer.get_web().get_form_args()
        search_type = args['search_type']
        search_id = args['search_id']

        sobject = Search.get_by_id(search_type, search_id)

        main_div = DivWdg()
        main_div.add_style("width: 98%")
        main_div.add_style("float: right")
        my.add(main_div)

        # get planned assets
        planned_head, planned_div = my.get_planned_wdg(sobject)
        main_div.add(planned_head)
        main_div.add(planned_div)


        # add notes
        notes_head, notes_div = my.get_sobject_wdg(sobject, "sthpw/note", "summary")
        main_div.add(notes_head)
        main_div.add(notes_div)

        # add storyboards
        story_head, story_div = my.get_sobject_wdg(sobject, "prod/storyboard", "summary")
        main_div.add(story_head)
        main_div.add(story_div)

        # add references
        ref_head, ref_div = my.get_sobject_wdg(sobject, "sthpw/connection","detail",title="Reference Material")
        main_div.add(ref_head)
        main_div.add(ref_div)
        
        task_head, task_div = my.get_sobject_wdg(sobject, "sthpw/task", "summary")
        main_div.add(task_head)
        main_div.add(task_div)



        # add dailies: need a special function for this
        dailies_head, dailies_div = my.get_dailies_wdg(sobject)
        main_div.add(dailies_head)
        main_div.add(dailies_div)


        # add history div
        hist_head, hist_div = my.get_history_wdg(sobject)
        main_div.add(hist_head)
        main_div.add(hist_div)

        return main_div
Beispiel #47
0
    def get_display(my):
        my.check()
        if my.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            my.set_as_panel(div)
            div.add_style('padding','6px')
            min_width = '300px'
            div.add_style('min-width', min_width)
            div.add_color('background','background')
            div.add_class('spt_add_task_panel')


        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="creating-tasks")
        div.add(help_button)
        help_button.add_style("float: right")
        help_button.add_style("margin-top: -5px")

        if not my.search_key_list:
            msg_div = DivWdg()
            msg_table = Table()
            msg_div.add(msg_table)
            msg_table.add_row()
            msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) )
            msg_table.add_cell('Please select at least 1 item to add tasks to.')

            msg_div.add_style('margin: 10px')
            msg_table.add_style("font-weight: bold")
            div.add(msg_div)
            return div

        msg_div = DivWdg()
        msg_div.add_style('margin-left: 4px')
        div.add(msg_div, 'info')
        msg_div.add('Total: %s items to add tasks to' %len(my.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        msg_div.add(hint)
        msg_div.add(HtmlElement.br())
        
        
        option_div = DivWdg(css='spt_ui_options')
        option_div.add_style('margin-left: 12px')
        
        sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
        sel.set_option('values', ['simple process','context', 'standard'])
        sel.set_option('labels', ['process','context', 'all contexts in process'])
        sel.set_persistence()
        sel.add_behavior({'type':'change',
                 'cbjs_action': 'spt.panel.refresh(bvr.src_el)'}) 
        
        option_div.add(sel)

        value = sel.get_value()
        # default to simple process
        if not value:
            value = 'simple process'
        msg = ''
        if value not in ['simple process','context','standard']:
            value = 'simple process'
        
        if value == 'context':
            msg = 'In context mode, a single task will be created for each selected context.'
        elif value == 'simple process':
            msg = 'In process mode, a single task will be created for each selected process.'

        elif value == 'standard':
            msg = 'In this mode, a task will be created for all contexts of each selected process.'

        option_div.add(HintWdg(msg))
        div.add(option_div)
        div.add(HtmlElement.br())

        title = DivWdg('Assigned Pipelines')
        title.add_style('padding: 6px')
        title.add_color('background','background2')
        title.add_color('color','color', +120)
        div.add(title)
    
        content_div = DivWdg()
        content_div.add_style('min-height', '150px')
        div.add(content_div)
        content_div.add_border()
        
        filtered_search_key_list = []
        for sk in my.search_key_list:
            id = SearchKey.extract_id(sk)
            if id=='-1':
                continue
            filtered_search_key_list.append(sk)

        sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
        skipped = []
        pipeline_codes = []
        for sobject in sobjects:
            if isinstance(sobject, Task):
                msg_div = DivWdg('WARNING: Creation of task for [Task] is not allowed.')
                msg_div.add_style('margin-left: 10px')
                div.add(msg_div, 'info')
                return div
            pipeline_code = sobject.get_value('pipeline_code', no_exception=True)
            if not pipeline_code:
                skipped.append(sobject)
            if pipeline_code not in pipeline_codes:
                pipeline_codes.append(pipeline_code)
       

        pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes)
        if pipelines == None:
            pipelines = []
        #if not pipelines:
        #    msg_div = DivWdg('WARNING: No Pipelines found for selected.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #    return div

        # expand the width according to num of pipelines
        content_div.add_style('min-width', len(pipelines)*250)
        mode_cb = SelectWdg('pipeline_mode') 
        mode_cb.set_persistence()
        mode = mode_cb.get_value()
        if 'context' == mode:
            mode = 'context'
        else:   
            mode = 'process'

        show_subpipeline = True
        min_height = '150px'



        # create a temp default pipeline
        if not pipelines:
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "__default__")
            pipeline.set_value("pipeline", '''
<pipeline>
    <process name='publish'/>
</pipeline>
            ''')
            # FIXME: HACK to initialize virtual pipeline
            pipeline.set_pipeline(pipeline.get_value("pipeline"))
            pipelines = [pipeline]

        for pipeline in pipelines:
            span = SpanWdg("Pipeline: %s" % pipeline.get_code())
            span.add_style('font-weight: bold')
            v_div = FloatDivWdg(span)
            v_div.add_style('margin: 20px')
            v_div.add_style('min-height', min_height)
            v_div.add(HtmlElement.br(2))
            content_div.add(v_div)    
            processes = pipeline.get_processes(recurse=show_subpipeline)

            cb_name = '%s|task_process'  %pipeline.get_code()
            master_cb = CheckboxWdg('master_control')
            master_cb.set_checked()
            master_cb.add_behavior({'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                        ''' %cb_name})
            toggle_div = DivWdg()
            toggle_div.add(SpanWdg(master_cb, css='small'))
            label = HtmlElement.i('toggle all')
            label.add_style('color: #888')
            toggle_div.add_styles('border-bottom: 1px solid #888; width: 170px')
            toggle_div.add(label)
            v_div.add(toggle_div)
            process_names = []

            for process in processes:
                process_labels = []
                if process.is_from_sub_pipeline():
                    process_name  = process.get_full_name()
                else:
                    process_name  = process.get_name()

                process_label = process.get_label()
                if not process_label:
                    process_label = ''
                if mode =='context':
                    contexts =  pipeline.get_output_contexts(process.get_name())
                    
                    labels = contexts
                    if process.is_from_sub_pipeline():
                        labels = ['%s/%s'%(process.parent_pipeline_code, x) for x in contexts]
                    
                    for x in labels: 
                        process_labels.append(process_label)
                    
                    # prepend process to contexts in this mode to ensure uniqueness
                    contexts = ['%s:%s' %(process_name, x) for x in contexts]
                else:
                    contexts = [process_name]
                    labels = contexts
                
                    process_labels.append(process_label)

                for idx, context in enumerate(contexts):
                    cb = CheckboxWdg(cb_name)
                    cb.set_checked()
                    cb.set_option('value', context)
                    v_div.add(SpanWdg(cb, css='small'))
                    if mode == 'context':
                        span = SpanWdg(process_name, css='med')
                        #span.add_color('color','color')
                        v_div.add(span)
                    v_div.add(SpanWdg(labels[idx]))
                    process_label = process_labels[idx]
                    if process_label:
                        v_div.add(SpanWdg("(%s)" %process_label, css='small'))
                    v_div.add(HtmlElement.br())
        
       
        content_div.add("<br clear='all'/>")

        skipped = [] 
        #if len(skipped) == len(sobjects):
        #if skipped:
        #    msg_div = DivWdg('WARNING: No valid item to add task for.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #else:
        if True:
            #btn = TextBtnWdg(size='medium', label='Add Tasks', horiz_aligh='center')
            btn = ActionButtonWdg(title='Add Tasks')
            btn.add_behavior({'type' : 'click_up',
            'post_event': 'search_table_%s'% my.table_id,
            'cbjs_action': '''
            spt.dg_table.add_task_selected(bvr);
            ''',
            'search_key_list': my.search_key_list
            })
            cb = CheckboxWdg('skip_duplicated', label='skip duplicated')
            cb.set_checked()
            option_div =DivWdg(cb)
            option_div.add_style('width', '130px')
            hint = HintWdg("If checked, it won't add the task if a task for the checked process has already been created.")
            option_div.add(hint)
            option_div.add_style('align: left')
            div.add(option_div)
            div.add(HtmlElement.br())
            btn.add_style("float: right")
            div.add(btn)
            div.add(HtmlElement.br(clear="all"))


        if skipped:
            content_div.add(HtmlElement.br())
            skip_div = DivWdg('Missing pipeline code (Skipped)')
            skip_div.add_style('text-decoration: underline')
            content_div.add(skip_div)
            content_div.add(HtmlElement.br())
            item_div = DivWdg()
            item_div.add_style('margin-left: 10px')
            content_div.add(item_div)
        for skip in skipped:
            item_div.add(skip.get_code())
            item_div.add(HtmlElement.br())



        return div
Beispiel #48
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()

        
        div.add_class("spt_tile_top")
        div.add_class("unselectable")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_key_v2", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        display_value = sobject.get_display_value(long=True)
        div.add_attr("spt_display_value", display_value)

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        border_color = div.get_color('border', modifier=20)

        thumb_drag_div = DivWdg()
        div.add(thumb_drag_div)
        thumb_drag_div.add_class("spt_tile_drag")
        thumb_drag_div.add_style("width: auto")
        thumb_drag_div.add_style("height: auto")
        thumb_drag_div.add_behavior( {
            "type": "drag",
            #'drag_el': 'drag_ghost_copy',
            #//'use_copy': 'true',
            "drag_el": '@',
            'drop_code': 'DROP_ROW',
            'border_color': border_color,
            "cb_set_prefix": 'spt.tile_layout.image_drag'
        } )

        thumb_div = DivWdg()
        thumb_drag_div.add(thumb_div)
        thumb_div.add_class("spt_tile_content")


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        kwargs = {'show_name_hover': my.show_name_hover}

        thumb = ThumbWdg2(**kwargs)
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())
        

        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")

        return div
Beispiel #49
0
    def get_display(self):
        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = self.kwargs.get("search_type")
        if not search_type:
            node_name = self.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = [
            'task', 'note', 'work_hour', 'login', 'login_group', 'schema',
            'project', 'login_in_group', 'snapshot', 'file', 'trigger',
            'spt_trigger', 'widget_config', 'custom_script', 'notification',
            'notification_log', 'file_access', 'cache', 'exception_log',
            'milestone', 'pipeline', 'pref_list', 'pref_setting',
            'project_type', 'repo', 'remote_repo', 'search_sobject',
            'sobject_list', 'ticket', 'db_resource', 'wdg_settings',
            'status_log', 'debug_log', 'transaction_log', 'sobject_log'
        ]

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s' % tbl:
                top.add("sType [%s] is internal and cannot be deleted!" %
                        search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" % (
            table, project_code, project_code)
        rtn = Search.eval(expr)

        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' % (
                ', '.join(rtn), table)

        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label, search_type))
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" %
                    table)

        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(
                SpanWdg("Number of related notes: %s" % note_count,
                        css='small'))
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(
                SpanWdg("Number of related tasks: %s" % task_count,
                        css='small'))
            content.add(HtmlElement.br())

            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(
                SpanWdg("Number of related snapshots: %s" % snapshot_count,
                        css='small'))
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value', 'sthpw/pipeline')
        content.add(cb)
        content.add(
            SpanWdg("Number of related pipelines: %s" % pipeline_count,
                    css='small'))
        content.add(HtmlElement.br(2))

        content.add(
            "<b>WARNING: Deleting the sType will delete all of these items.</b> "
        )
        content.add("<br/>" * 2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_type':
            search_type,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

        return top
Beispiel #50
0
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 20px")


        if sobject.get_base_search_type() not in ["sthpw/snapshot"]:
            detail_div = DivWdg()
            div.add(detail_div)
            detail_div.add_class("spt_tile_detail")
            detail_div.add_style("float: right")
            detail_div.add_style("margin-top: -2px")

            #detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
            detail = IconButtonWdg(title="Detail", icon="BS_SEARCH")
            detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        #header_div.add_attr("title",'[ draggable ]')
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")
        header_div.add_style("overflow-y: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")
        # to prevent clicking on the checkbox directly and not turning on the yellow border
        #checkbox.add_attr("disabled","disabled")

        title_expr = my.kwargs.get("title_expr")
        if title_expr:
            title = Search.eval(title_expr, sobject, single=True)
        elif sobject.get_base_search_type() == "sthpw/snapshot":
            title = sobject.get_value("context")
        else:
            title = sobject.get_value("name", no_exception=True)
        if not title:
            title = sobject.get_value("code", no_exception=True)
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")
        title_div.add_class("hand")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
Beispiel #51
0
    def get_display(my):

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")

        login = Environment.get_user_name()
        if login != 'admin':
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            return top



        site = my.kwargs.get("site")
        if site:
            Site.set_site(site)



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

        # check if delete permissions exist for this site and project
        security = Environment.get_security()
        if False and not security.check_access("project", project_code, "delete"):
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Not permitted to delete this project")
            top.add_style("padding: 30px")
            top.add_style("text-align: center")
            top.add_style("margin: 50px 30px")
            top.add_border()
            top.add_color("background", "background3")
            return top


        


        if project_code:
            project = Project.get_by_code(project_code)
            if not project:
                top.add(IconWdg(icon=IconWdg.WARNING))
                top.add("No project [%s] exists in this database" % project_code)
                top.add_style("padding: 30px")
                top.add_style("text-align: center")
                top.add_style("margin: 50px 30px")
                top.add_border()
                top.add_color("background", "background3")
                return top
            search_key = project.get_search_key()
        else:
            search_key = my.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

       
           
        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title") ) 
            title_wdg.add_color("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")


        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data and files will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            warning_wdg = DivWdg(warning_msg, css='warning')
            content.add(warning_wdg)
            warning_wdg.add_style("margin: 20 10px")
            content.add("<br/>")

        
        if not project_code:
            content.add("This project [%s] has been deleted."%search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted."%project_code)
            return top


        assert project_code
        assert project

        content.add("<br/>")

        content.add("<b>NOTE: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> ")


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

        total_items_wdg = DivWdg()
        total_items = 0
        content.add(total_items_wdg)


        # find all of the sTypes
        details_wdg = DivWdg()
        content.add(details_wdg)
        details_wdg.add_style("max-height: 300px")
        details_wdg.add_style("overflow-y: auto")
        details_wdg.add_style("padding-left: 15px")
        details_wdg.add_border()

        search_types = project.get_search_types()

        related_types = []

        for search_type_obj in search_types:
            search_type_wdg = DivWdg()
            title = search_type_obj.get_title()
            search_type = search_type_obj.get_value("search_type")

            search_type_wdg.add_style("margin-top: 5px")
            search_type_wdg.add_style("margin-bottom: 5px")


            details_wdg.add(search_type_wdg)
            search_type_wdg.add(title)
            search_type_wdg.add(" (%s)" % search_type )

            search = Search( search_type, project_code=project_code )
            count = search.get_count()
            total_items += count
            search_type_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

            # TODO: this is similar to SearchType.get_related_types(). streamline at some point. 
            related_types = my.get_related_types(search_type)
            for related_type in related_types:

                try:
                    search = Search(related_type)
                except Exception, e:
                    print "WARNING: ", e
                    continue
                full_search_type = "%s?project=%s" % (search_type, project_code)
                if related_type.startswith("sthpw/"):
                    search.add_filter("search_type", full_search_type)
                count = search.get_count()
                if count == 0:
                    continue
                total_items += count


                related_wdg = DivWdg()
                related_wdg.add_style('padding-left: 25px')
                search_type_wdg.add(related_wdg)
                related_wdg.add(related_type)
                related_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)
Beispiel #52
0
    def get_display(self):

        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")
        site = self.kwargs.get("site")
        set_site = self.kwargs.get("set_site")

        if set_site != False and site:
            Site.set_site(site)

        login = Environment.get_user_name()

        security = Environment.get_security()

        if not security.is_admin() and not security.is_in_group(
                self.delete_group):

            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            if set_site and site:
                Site.pop_site()
            return top

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

        # check if delete permissions exist for this site and project
        security = Environment.get_security()
        if False and not security.check_access("project", project_code,
                                               "delete"):
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Not permitted to delete this project")
            top.add_style("padding: 30px")
            top.add_style("text-align: center")
            top.add_style("margin: 50px 30px")
            top.add_border()
            top.add_color("background", "background3")
            return top

        if project_code:
            project = Project.get_by_code(project_code)
            if not project:
                top.add(IconWdg(icon=IconWdg.WARNING))
                top.add("No project [%s] exists in this database" %
                        project_code)
                top.add_style("padding: 30px")
                top.add_style("text-align: center")
                top.add_style("margin: 50px 30px")
                top.add_border()
                top.add_color("background", "background3")
                return top
            search_key = project.get_search_key()
        else:
            search_key = self.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title"))
            title_wdg.add_color("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data and files will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            warning_wdg = DivWdg(warning_msg, css='warning')
            content.add(warning_wdg)
            warning_wdg.add_style("margin: 20 10px")
            content.add("<br/>")

        if not project_code:
            content.add("This project [%s] has been deleted." % search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted." % project_code)
            return top

        assert project_code
        assert project

        content.add("<br/>")

        content.add(
            "<b>NOTE: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> "
        )

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

        total_items_wdg = DivWdg()
        total_items = 0
        content.add(total_items_wdg)

        # find all of the sTypes
        details_wdg = DivWdg()
        content.add(details_wdg)
        details_wdg.add_style("max-height: 300px")
        details_wdg.add_style("overflow-y: auto")
        details_wdg.add_style("padding-left: 15px")
        details_wdg.add_border()

        search_types = project.get_search_types()

        related_types = []

        for search_type_obj in search_types:
            search_type_wdg = DivWdg()
            title = search_type_obj.get_title()
            search_type = search_type_obj.get_value("search_type")

            search_type_wdg.add_style("margin-top: 5px")
            search_type_wdg.add_style("margin-bottom: 5px")

            details_wdg.add(search_type_wdg)
            search_type_wdg.add(title)
            search_type_wdg.add(" (%s)" % search_type)

            search = Search(search_type, project_code=project_code)
            count = search.get_count()
            total_items += count
            search_type_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

            # TODO: this is similar to SearchType.get_related_types(). streamline at some point.
            related_types = self.get_related_types(search_type)
            for related_type in related_types:

                try:
                    search = Search(related_type)
                except Exception as e:
                    print("WARNING: ", e)
                    continue
                full_search_type = "%s?project=%s" % (search_type,
                                                      project_code)
                if related_type.startswith("sthpw/"):
                    search.add_filter("search_type", full_search_type)
                count = search.get_count()
                if count == 0:
                    continue
                total_items += count

                related_wdg = DivWdg()
                related_wdg.add_style('padding-left: 25px')
                search_type_wdg.add(related_wdg)
                related_wdg.add(related_type)
                related_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

        if total_items:
            total_items_wdg.add("Total # of items to be deleted: ")
            total_items_wdg.add(total_items)
            total_items_wdg.add_style("font-size: 14px")
            total_items_wdg.add_style("font-weight: bold")
            total_items_wdg.add("<br/>")

        content.add("<br/>" * 2)
        content.add("<b>Do you wish to continue deleting? </b>")
        radio = RadioWdg("mode")
        radio.add_class("spt_mode_radio")
        radio.set_value("delete")
        radio.add_style("margin-left: 15")
        radio.add_style("margin-top: 5")
        content.add(radio)
        content.add("<br/>" * 3)

        #content.add("<b>Or do you just wish to retire the project? </b>")
        #radio = RadioWdg("mode")
        #radio.add_class("spt_mode_radio")
        #radio.set_value("retire")
        #content.add(radio)
        #content.add(radio)

        #content.add("<br/>"*2)

        #button = ActionButtonWdg(title="Retire")
        #content.add(button)
        #button.add_style("float: left")

        buttons = Table()
        content.add(buttons)
        buttons.add_row()
        buttons.add_style("margin-left: auto")
        buttons.add_style("margin-right: auto")
        buttons.add_style("width: 250px")

        button = ActionButtonWdg(title="Delete", color="danger")
        buttons.add_cell(button)

        command_class = self.kwargs.get("command_class")
        if not command_class:
            command_class = 'tactic.ui.tools.DeleteProjectCmd'

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

        button.add_behavior({
            'type':
            'click_up',
            #'search_type': search_type,
            'project_code':
            project_code,
            'site':
            site,
            'related_types':
            related_types,
            'command_class':
            command_class,
            'on_complete':
            on_complete,
            'cbjs_action':
            '''
            spt.app_busy.show("Deleting");
            var class_name = bvr.command_class;
            var kwargs = {
                'site': bvr.site,
                'project_code': bvr.project_code,
                'related_types': bvr.related_types
            };

            var top = bvr.src_el.getParent(".spt_delete_project_tool_top");
            var radios = top.getElements(".spt_mode_radio");

            //if (!radios[0].checked && !radios[1].checked) {
            if (!radios[0].checked) {
                spt.alert("Please confirm the delete by checking the radio button.");
                spt.app_busy.hide();
                return;
            }

            var mode = 'retire';
            if (radios[0].checked == true) {
                mode = 'delete';
            }


            if (mode == 'retire') {
                return;
            }



            var success = false;
            var server = TacticServerStub.get();
            setTimeout(function() {
                spt.app_busy.show("Deleting Project ["+bvr.project_code+"]")
                var error_message = "Error deleting project ["+bvr.project_code+"]";
                try {
                    server.start({'title': 'Deleted Project ', 'description': 'Deleted Project [' + bvr.project_code + ']'});
                    server.execute_cmd(class_name, kwargs);
                    success = true;
                }
                catch(e) {
                    error_message = spt.exception.handler(e);
                }

                
                spt.app_busy.hide();

                if (success) {


                    if (bvr.on_complete) {
                       on_complete = function() {
                           eval(bvr.on_complete);
                       }
                       on_complete();
                    }

                    spt.notify.show_message("Successfully deleted project ["+bvr.project_code+"]");

                    spt.tab.set_main_body_tab();
                    spt.tab.reload_selected();
                }
                else {
                    if (error_message.test(/does not exist/))
                        error_message += '. You are advised to sign out and log in again.';
                    spt.error(error_message);
                }
                
                
                var top = bvr.src_el.getParent(".spt_popup");
                spt.popup.destroy(top);
                server.finish();
                    
                    
            }, 100);
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        buttons.add_cell(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        spt.popup.destroy(top);
        '''
        })

        if site:
            Site.pop_site()

        return top
Beispiel #53
0
    def get_example_display(self):

        div = DivWdg()
        div.add_styles("background: grey; padding: 10px; width: 450px;")
        div.add("<br/><br/>")

        from tactic.ui.container import RoundedCornerDivWdg
        rc_wdg = RoundedCornerDivWdg(corner_size=10)
        # rc_wdg.set_dimensions(width_str="100%", content_height_str='100%', height_str="100%")
        rs0_wdg = ResizeScrollWdg(
            width=300,
            height=200,
            scroll_bar_size_str='thin',
            scroll_expansion='inside',
            # max_content_w=500, max_content_h=400,
            set_max_to_content_size=True,
            min_content_w=100,
            min_content_h=50)
        rs0_wdg.add(self.get_popwin_oversize_content())

        rc_wdg.add(rs0_wdg)
        div.add(rc_wdg)

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

        div.add(
            "<p style='color: black;'>Resize/Scroll Widget example ...</p>")
        rs_wdg = ResizeScrollWdg(width=300,
                                 height=200,
                                 scroll_bar_size_str='thin',
                                 scroll_expansion='inside')
        rs_wdg.add(self.get_popwin_oversize_content())
        div.add(rs_wdg)

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

        div.add( "<p style='color: black;'>Resize/Scroll Widget example WITH NO RESIZE CAPABILITY" \
                 " (just scroll bars) ...</p>" )
        rs2_wdg = ResizeScrollWdg(width=300,
                                  height=200,
                                  scroll_bar_size_str='thin',
                                  scroll_expansion='inside',
                                  no_resize=True)
        rs2_wdg.add(self.get_popwin_oversize_content())
        div.add(rs2_wdg)

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

        popwin_id = "NewPopupWindowTest"
        popwin_title = "New Popup Window Widget Test"
        popwin = PopWindowWdg(top_id=popwin_id,
                              title=popwin_title,
                              width=150,
                              height=150)
        popwin.add(self.get_popwin_oversize_content())
        div.add(popwin)
        pwin_launch = DivWdg()

        pwin_launch.add_styles(
            "cursor: pointer; background-color: red; color: black; border: 1px solid black; width: 100px; height: 50px;"
        )
        pwin_launch.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            'spt.popup.open("' + popwin_id + '");'
        })
        pwin_launch.add("Click to launch New Popup Window")
        div.add(pwin_launch)

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

        test_div = DivWdg()
        test_div.add_styles(
            "background: black; padding: 10px; width: 350px; text-align: center;"
        )

        test_div.add(
            SpanWdg("This black DIV has<br/>text-align set to center"))

        my_table = Table()
        my_table.add_row()
        my_table.add_cell("This").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("that").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("and").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("The").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("other").add_styles(
            "border: 1px solid white; padding: 4px;")

        test_div.add("<br/><br/>")
        test_div.add(my_table)

        test_div.add("<br/><br/>")
        tmp_div = DivWdg()
        tmp_div.add_styles(
            "width: 200px; background-color: green; color: black; padding: 10px;"
        )
        tmp_div.add("I am a DIV without self margins set")
        test_div.add(tmp_div)

        test_div.add("<br/><br/>")
        tmp_div = DivWdg()
        tmp_div.add_styles(
            "width: 200px; background-color: green; color: black; padding: 10px;"
        )
        tmp_div.center()
        tmp_div.add(
            "I am a DIV with self margins<br/>set using HtmlElement.center()")
        test_div.add(tmp_div)

        test_div.add("<br/><br/>")
        buttons_list = [{
            'label': "Insert",
            'tip': "This is an insert",
            'bvr': {
                'cbjs_action': 'alert("Insert!");'
            }
        }, {
            'label': 'Cancel',
            'tip': 'Cancel',
            'bvr': {
                'cbjs_action': 'alert("Cancel!");'
            }
        }]
        buttons = TextBtnSetWdg(float="",
                                align="center",
                                buttons=buttons_list,
                                spacing=6,
                                size='medium',
                                side_padding=4)
        test_div.add(buttons)

        div.add(test_div)

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

        buttons_list = [
            {
                'label': 'One',
                'tip': 'Button One',
                'bvr': {
                    'cbjs_action': 'alert("First button!");'
                }
            },
            {
                'label': 'Two',
                'tip': 'Button Two',
                'bvr': {
                    'cbjs_action': 'alert("Second button!");'
                }
            },
            {
                'label': 'Three',
                'tip': 'Button Three',
                'bvr': {
                    'cbjs_action': 'alert("Third button!");'
                }
            },
            {
                'label': 'Four',
                'tip': 'Button Four',
                'bvr': {
                    'cbjs_action': 'alert("Fourth button!");'
                }
            },
        ]

        txt_btn_set = TextBtnSetWdg(float='right',
                                    buttons=buttons_list,
                                    spacing=6,
                                    size='large',
                                    side_padding=4)
        txt_btn_set.get_btn_by_label('Three').add_behavior({
            'type':
            'click_up',
            'modkeys':
            'SHIFT',
            'cbjs_action':
            'alert("SHIFT happened!");'
        })
        div.add(txt_btn_set)

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

        d1 = self.get_simple_div(
            "Drop Zone (runs cbjs_action of drag-drop element on drop)", None)
        d1.set_attr("SPT_ACCEPT_DROP", "Qweejibo")
        d1.add_behavior({
            'type': 'hover',
            'mod_styles': 'background-color: green;'
        })

        table1 = Table()
        tr = table1.add_row()
        tr.add_behavior({
            'type': 'hover',
            'mod_styles': 'background-color: #f11; color: green'
        })

        td = table1.add_cell('what')
        #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: orange;' } )
        td = table1.add_cell('is')
        #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: green;' } )
        div.add(table1)

        # d2 = self.get_simple_div( "Pick Up!", "white" )
        d2 = self.get_simple_div("Override with 'accept_drop' behavior!", None)
        d2.add_looks("menu")

        # NOTE: with 'accept_drop' behavior you do not need to set the "SPT_ACCEPT_DROP" attribute on the
        #       given drop-on element, just need to add the same value to a 'drop_code' attribute in the
        #       'accept_drop' bvr spec (doing this will automatically add it to the SPT_ACCEPT_DROP at
        #       behavior construction time
        # so we do not need this here --> d2.set_attr("SPT_ACCEPT_DROP","Qweejibo")
        d2.add_behavior({
            'type': 'accept_drop',
            'cbjs_action': 'log.debug("Override #1 on Qweejibo");',
            'drop_code': 'Qweejibo'
        })
        d2.add_behavior({
            'type': 'accept_drop',
            'cbjs_action': '''
                log.debug("Override #2 on Qweejibo");
                var el = bvr._drop_source_bvr.src_el;
                el.setStyle("background-color", "white");
            ''',
            'drop_code': 'Qweejibo'
        })

        d2.add_behavior({'type': 'hover', 'add_looks': 'menu_hover'})
        d2.add_behavior({
            'type': 'hover',
            'mod_styles': 'border: 1px solid red;',
            'drag_drop_codes': 'Qweejibo',
        })

        div.add(d1)
        div.add("<br/>")
        div.add(d2)

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

        btn = DivWdg()
        btn.add("TEST JS LOG TIME")
        btn.add_styles(
            "padding: 4px; width: 150px; cursor: pointer; background: red; color: white; "
            + "border: 1px solid white;")
        btn.add_behavior({
            'type': 'click',
            'cbjs_action': 'spt.js_log.test_perf();'
        })

        div.add(btn)
        div.add("<br/><br/>")

        dragme = DivWdg()
        dragme.add_styles( "background: blue; padding: 10px; width: 200px; border: 1px solid black; " \
                           "position: absolute; top: 200px; left: 400px; cursor: default;" )
        dragme.add("Click me OR Drag me!")

        # dragme.add_behavior( { 'type': 'drag', 'drag_el': '@', 'use_default_cbs': 'true',
        #                        'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' } )

        dragme.add_behavior({
            'type':
            'smart_drag',
            'drag_el':
            '@',
            'use_copy':
            'true',
            'use_delta':
            'true',
            'dx':
            1,
            'dy':
            1,
            'drop_code':
            'Qweejibo',
            'copy_styles':
            'background: red; opacity: .3;',
            'cbjs_action':
            'alert("Got Qweejibo");',
            'cbjs_action_onnomotion':
            'alert("I\'ve been clicked!");'
        })

        div.add(dragme)
        div.add("<br/><br/>")

        select = SelectWdg("OnChangeTestSelectWidget")
        select.add_behavior({
            'type':
            'change',
            'cbjs_preaction':
            '''
                alert("Click OK then see Web Client Output Log for 'change' behavior activity");
                log.debug("[preaction] My value is now: "+bvr.src_el.value);
                ''',
            'cbjs_action':
            'log.debug("[action] My value is now: "+bvr.src_el.value);',
            'cbjs_postaction':
            'log.debug("[postaction] My value is now: "+bvr.src_el.value);'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #2!");'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #3!");'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #4!");'
        })
        select.set_option("values", "One|Day|In|Your|Life")
        select.set_value("Life")

        # Test for set_behavior override with stacked onchange behaviors ...
        '''
        select.set_behavior( {'type': 'change', 'cbjs_action': 'alert("This is what me gots: "+bvr.src_el.value);'} );
        select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #5!");'} );
        select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #6!");'} );
        '''

        div.add(select)

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

        click_core_div = DivWdg()
        click_core_div.add_styles(
            "background-color: blue; color: white; border: 1px solid black; padding: 10px"
        )
        click_core_div.add_styles("cursor: pointer;")
        click_core_div.add("Click me for preaction, action, postaction test")
        click_core_div.add_behavior({
            'type':
            'click',
            'cbjs_preaction':
            '''
                alert("Click OK then see Web output log for 'click' behavior activity");
                log.debug("Click pre-action");
            ''',
            'cbjs_action':
            'log.debug("Click action");',
            'cbjs_postaction':
            'log.debug("Click post-action");'
        })

        div.add(click_core_div)

        div.add("<br/><br/>")
        override = DivWdg()
        override.add_styles(
            "padding: 4px; background: white; color: black; border: 1px solid black; cursor: pointer;"
        )
        override.add("Set Behavior Override Test")

        bvr = {
            'type': 'click',
            'modkeys': 'SHIFT',
            'cbjs_action': 'alert("Load ONE");'
        }
        override.add_behavior(bvr)

        bvr = {
            'type': 'click',
            'modkeys': 'SHIFT',
            'cbjs_action': 'alert("Load ONE OVERRIDDEN!");'
        }
        override.set_behavior(bvr)

        div.add(override)

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

        div1 = DivWdg()
        div1.add_styles(
            "background: #444477; border: solid 1px black; padding: 10px;")
        div1.add("Div1")
        div1.set_id("Div_1")

        div2 = DivWdg()
        div2.add_styles(
            "background: #4444BB; border: solid 1px black; padding: 10px; cursor: pointer;"
        )
        div2.add("Div2")
        div2.set_id("Div_2")

        # div2.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_2","after");' } )
        div2.add_behavior({
            'type': 'click_up',
            'cbjs_action': '$("Div_3").inject("Div_1","bottom");'
        })

        div1.add(div2)

        div.add(div1)
        div.add("<br/><br/>")

        div3 = DivWdg()
        div3.add_styles(
            "background: #4444FF; border: solid 1px black; padding: 10px;")
        div3.add("Div3")
        div3.set_id("Div_3")

        div.add(div3)

        return div
Beispiel #54
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 400px")
        top.add_border()

        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects or not sobject:
            msg = "%s not found" % search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg

        self.search_keys = search_keys

        title = DivWdg()
        top.add(title)

        icon = IconWdg("WARNING", IconWdg.WARNING)
        icon.add_style("float: left")
        title.add(icon)

        if len(self.search_keys) > 1:
            title.add("Delete %s Items" % len(self.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 20px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        title.add("<hr/>")

        content = DivWdg()
        top.add(content)
        content.add_style("margin: 5px 10px 20px 10px")

        content.add(
            "The item to be deleted has a number of dependencies as described below:<br/>",
            'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type,
                                                     direction='children')

        items_div = DivWdg()
        content.add(items_div)
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print("WARNING: related_type is *")
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object', 'sthpw/search_type']:
                continue

            item_div = self.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1

        if valid_related_ctr > 0:
            #icon = IconWdg("Note", "BS_NOTE")
            #icon.add_style("float: left")
            #content.add( icon )
            content.add(
                "<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>"
            )
            content.add("<br/>" * 2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>",
                        'heading')

        num_items = len(self.search_keys)
        if num_items == 1:
            verb = "is 1 item"
        else:
            verb = "are %s items" % num_items
        content.add("There %s to be deleted" % verb)
        content.add("<br/>" * 2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 3)

        button_div = DivWdg()
        button_div.add_class("spt_buttons")
        content.add(button_div)
        button_div.add_style('text-align: center')

        button = ActionButtonWdg(title="Delete", width=100, color="danger")
        button_div.add(button)
        button.add_style("display: inline-block")

        deleting_div = DivWdg()
        content.add(deleting_div)
        deleting_div.add(
            "<img src='/context/icons/common/indicator_snake.gif'/>")
        deleting_div.add_class("spt_delete_msg")
        deleting_div.add(" Deleting ...")
        deleting_div.add_style("text-align: center")
        deleting_div.add_style("font-size: 16px")
        deleting_div.add_style("margin: 20px")
        deleting_div.add_style("display: none")

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

        button.add_behavior({
            'type':
            'click_up',
            'search_keys':
            self.search_keys,
            'on_complete':
            on_complete,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting");
        //spt.notify.show_message("Deleting ...");

        //var button_el = bvr.src_el.getParent(".spt_buttons");
        //button_el.setStyle("display", "none");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();

        server.execute_cmd(class_name, kwargs, null, {
            on_complete: function() {
                //spt.notify.show_message("Finshed deleting ...");

                // run the post delete and destroy the popup
                var popup = bvr.src_el.getParent(".spt_popup");
                if (popup.spt_on_post_delete) {
                    popup.spt_on_post_delete();
                }

                del_trigger();

                spt.popup.destroy(popup);


                if (bvr.on_complete) {
                   on_complete = function() {
                       eval(bvr.on_complete);
                   }
                   on_complete();
                }

                spt.app_busy.hide();
            },
            on_error: function(e) {
                spt.notify.show_message("Error on delete");
                spt.alert(spt.exception.handler(e));
                spt.app_busy.hide();
            }
        } );

        '''
        })

        button = ActionButtonWdg(title="Cancel", width=100)
        button_div.add(button)
        button.add_style("display: inline-block")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

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

        return top
Beispiel #55
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_tile_top")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        thumb_div = DivWdg()
        #thumb_div.add_styles('margin-left: auto; margin-right: auto')
        thumb_div.add_class("spt_tile_content")
        #thumb_div.add_class("spt_tile_detail")
        div.add(thumb_div)


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        thumb = ThumbWdg2()
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())


        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")


        return div
Beispiel #56
0
    def get_popwin_oversize_content(self):

        div = DivWdg()
        div.add_styles(
            "background-color: orange; color: black; padding: 20px; width: 600px;"
        )
        div.add('''
<p>SCENE I. DUKE ORSINO's palace.</p>

<p>Enter DUKE ORSINO, CURIO, and other Lords; Musicians attending</p>

<h2>DUKE ORSINO</h2>

<p>If music be the food of love, play on;
Give me excess of it, that, surfeiting,
The appetite may sicken, and so die.
That strain again! it had a dying fall:
O, it came o'er self ear like the sweet sound,
That breathes upon a bank of violets,
Stealing and giving odour! Enough; no more:
'Tis not so sweet now as it was before.
O spirit of love! how quick and fresh art thou,
That, notwithstanding thy capacity
Receiveth as the sea, nought enters there,
Of what validity and pitch soe'er,
But falls into abatement and low price,
Even in a minute: so full of shapes is fancy
That it alone is high fantastical.</p>

<h2>CURIO</h2>

<p>Will you go hunt, self lord?</p>

<h2>DUKE ORSINO</h2>

<p>What, Curio?</p>

<h2>CURIO</h2>

<p>The hart.</p>

<h2>DUKE ORSINO</h2>

<p>Why, so I do, the noblest that I have:
O, when mine eyes did see Olivia first,
Methought she purged the air of pestilence!
That instant was I turn'd into a hart;
And self desires, like fell and cruel hounds,
E'er since pursue me.</p>

<p><i>Enter VALENTINE</i><p>

<p>How now! what news from her?</p>

<h2>VALENTINE</h2>

<p>So please self lord, I might not be admitted;
But from her handmaid do return this answer:
The element itself, till seven years' heat,
Shall not behold her face at ample view;
But, like a cloistress, she will veiled walk
And water once a day her chamber round
With eye-offending brine: all this to season
A brother's dead love, which she would keep fresh
And lasting in her sad remembrance.</p>

<h2>DUKE ORSINO</h2>

<p>O, she that hath a heart of that fine frame
To pay this debt of love but to a brother,
How will she love, when the rich golden shaft
Hath kill'd the flock of all affections else
That live in her; when liver, brain and heart,
These sovereign thrones, are all supplied, and fill'd
Her sweet perfections with one self king!
Away before me to sweet beds of flowers:
Love-thoughts lie rich when canopied with bowers.</p>

<p><i>Exeunt</i></p>

        ''')

        return div
Beispiel #57
0
    def get_display(self):

        self.sobject_data = {}

        top = self.top
        top.add_style
        top.add_class("spt_gallery_top")

        inner = DivWdg()
        top.add(inner)

        # make the whole Gallery unselectable
        inner.add_class('unselectable')
        inner.add_style("position: fixed")
        inner.add_style("top: 0px")
        inner.add_style("left: 0px")
        inner.add_style("width: 100%")
        #inner.add_style("height: 100%")
        inner.add_style("bottom: 0px")
        inner.add_style("padding-bottom: 40px")

        #inner.add_style("background: rgba(0,0,0,0.5)")
        inner.add_style("background: rgba(0,0,0,1)")
        inner.add_style("z-index: 2000")

        width = self.kwargs.get("width")
        height = self.kwargs.get("height")

        # default to top.
        align = self.kwargs.get("align")
        if not align:
            align = "top"

        if not width:
            width = 1300
        else:
            width = int(width)

        paths = self.get_paths(file_type='main')
        # icon type may be too small
        thumb_paths = self.get_paths(file_type='web')

        descriptions = []
        for path in paths:
            sobject = self.sobject_data.get(path)
            if not sobject:
                descriptions.append("")
            else:
                description = sobject.get("description")
                if not description:
                    description = ""
                descriptions.append(description)

        total_width = width * len(paths)
        inner.add_behavior({
            'type':
            'load',
            'width':
            width,
            'total_width':
            total_width,
            'descriptions':
            descriptions,
            'cbjs_action':
            '''
        spt.gallery = {};
        // 1250 is defined also in the css styles
        spt.gallery.portrait = window.innerWidth < 1250;
        spt.gallery.portrait = false

        
        spt.gallery.top = bvr.src_el;
        spt.gallery.content = spt.gallery.top.getElement(".spt_gallery_content");
        spt.gallery.content.setStyle('opacity','0.1')
        spt.gallery.desc_el = spt.gallery.top.getElement(".spt_gallery_description");
        
        //window.addEvent('domready', function() {
        setTimeout(function() {
		// set the img h or w directly
		var items = bvr.src_el.getElements('.spt_gallery_item img');
		// fade in
        spt.gallery.content.set('tween', {duration: 250}).fade('in');

        /*
		for (var k=0; k < items.length; k++) {
		    var sizes = items[k].getSize();
		    var item_h = sizes.y;
		    var item_w = sizes.x;
		    if (item_h >= item_w){
			    //items[k].setStyle('width', 'auto');
			    //items[k].setStyle('height', '100%');
		    }
		    else {
			    //items[k].setStyle('width','auto');
			    //items[k].setStyle('height','100%');
		    }
		    
		}
        */


        }, 50)

        spt.gallery.width = bvr.width;
        spt.gallery.descriptions = bvr.descriptions;
        spt.gallery.index = 0;
        spt.gallery.total = bvr.descriptions.length;
        spt.gallery.left_arrow = bvr.src_el.getElement('.spt_left_arrow');
        spt.gallery.right_arrow = bvr.src_el.getElement('.spt_right_arrow');
        spt.gallery.videos = {};
       

        spt.gallery.init = function() {
            
        }

        spt.gallery.stack = [];

        spt.gallery.push_stack = function(key) {
            spt.gallery.stack.push(key);
        }


        spt.gallery.show_next = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.right_arrow;
           
            if (spt.gallery.index >= spt.gallery.total-2) {
                spt.hide(src_el);
            }
            if (spt.gallery.index == spt.gallery.total-1) {
                return;
            }
            spt.gallery.index += 1;
            spt.gallery.show_index(spt.gallery.index);
        }

        spt.gallery.show_prev = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.left_arrow;
            if (spt.gallery.index <= 1) {
                spt.hide(src_el);
            
            }
            if (spt.gallery.index == 0) {
                return;
            }
            
            spt.gallery.index -= 1;
            spt.gallery.show_index(spt.gallery.index);
        }


        spt.gallery.show_index = function(index) {

          
            // stop all videos
            var videos = spt.gallery.top.getElements(".video-js");
            for (var i = 0; i < videos.length; i++) {
                try {
                    var video = videos[i];
                    var video_id = video.get("id");
                    var video_obj = videojs(video_id,  {"nativeControlsForTouch": false});
                    video_obj.pause();

                }
                catch(e) {
                }
            }


            // can't tween percentage with this library???
            var width = spt.gallery.width;
            var margin = - width * index;
            var content = spt.gallery.content;
            //content.setStyle("margin-left", margin + "px");
            new Fx.Tween(content,{duration: 250}).start("margin-left", margin);
 


            spt.gallery.index = index;
            var total = spt.gallery.total;
            
           
            if (index == 0) {
                spt.hide(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
            else if (index == total - 1) {
                spt.show(spt.gallery.left_arrow);
                spt.hide(spt.gallery.right_arrow);
            }
            else {
                spt.show(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
                

            
            var description = spt.gallery.descriptions[index];
            if (!description) {
                description = (index+1)+" of "+total;
            }
            else {
                description = (index+1)+" of "+total+" - " + description;
            }
            spt.gallery.set_description(description);
        }


        spt.gallery.close = function() {
            var content = spt.gallery.content;
            var top = content.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
        }


        spt.gallery.set_description = function(desc) {
            var desc_el = spt.gallery.desc_el;
            desc_el.innerHTML = desc;
        }

        '''
        })

        scroll = DivWdg(css='spt_gallery_scroll')
        inner.add(scroll)
        scroll.set_box_shadow()
        scroll.add_style("width: %s" % width)
        if height:
            scroll.add_style("height: %s" % height)
        scroll.add_style("overflow-x: hidden")
        scroll.add_style("overflow-y: hidden")
        scroll.add_style("background: #000")

        #scroll.add_style("position: absolute")
        scroll.add_style("margin-left: auto")
        scroll.add_style("margin-right: auto")

        content = DivWdg()
        top.add_attr('tabindex', '-1')

        scroll.add(content)
        content.add_class("spt_gallery_content")

        # make the items vertically align to bottom (flex-emd)
        # on a regular monitor, align to top (flex-start) is better
        if align == 'bottom':
            align_items = 'flex-end'
        else:
            align_items = 'flex-start'
        content.add_styles(
            "display: flex; flex-flow: row nowrap; align-items: %s; justify-content: center;"
            % align_items)

        content.add_style("width: %s" % total_width)

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        top.add_behavior({
            'type':
            'mouseenter',
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })
        top.add_behavior({
            'type':
            'mouseleave',
            'cbjs_action':
            '''
            bvr.src_el.blur();
            '''
        })
        """
        input = TextWdg("keydown")
        content.add(input)
        input.add_style("position: absolute")
        input.add_style("left: -5000px")
        """
        top.add_behavior({
            'type':
            'keydown',
            'cbjs_action':
            '''
            var key = evt.key;
            
            if (key == "left") {
                spt.gallery.push_stack(key);
                spt.gallery.show_prev();
            }
            else if (key == "right") {
                spt.gallery.push_stack(key);
                spt.gallery.show_next();
            }
            else if (key == "esc" || key == "enter") {
                
                var top = bvr.src_el
                spt.behavior.destroy_element(top);
            }



            '''
        })

        curr_index = 0
        for i, path in enumerate(paths):
            path_div = DivWdg(css='spt_gallery_item')
            content.add(path_div)
            #path_div.add_style("float: left")
            path_div.add_style("display: inline-block")
            path_div.add_style("vertical-align: middle")

            if path == self.curr_path:
                curr_index = i

            try:
                thumb_path = thumb_paths[i]
            except IndexError:
                print "Cannot find the thumb_path [%s] " % i
                thumb_path = ''

            #path_div.add_style("width: %s" % width)
            #if height:
            #    path_div.add_style("height: %s" % height)
            path_div.add_style("width: 100%")
            path_div.add_style("height: 100%")
            path_div.add_style("overflow-x: hidden")
            path_div.add_style("overflow-y: hidden")

            from tactic.ui.widget import EmbedWdg
            embed = EmbedWdg(src=path,
                             click=False,
                             thumb_path=thumb_path,
                             index=i,
                             controls="true")
            path_div.add(embed)

        content.add_behavior({
            'type':
            'load',
            'index':
            curr_index,
            'cbjs_action':
            '''
            if (!bvr.index) bvr.index = 0;
            spt.gallery.show_index(bvr.index);
            '''
        })

        #icon = IconWdg(title="Close", icon="/plugins/remington/pos/icons/close.png")
        icon = IconWdg(title="Close",
                       icon="/context/icons/glyphs/close.png",
                       width="40px")
        inner.add(icon)
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("top: 30px")
        icon.add_style("right: 38px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
            '''
        })
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")

        icon = IconWdg(title="Previous",
                       icon="/context/icons/glyphs/chevron_left.png")
        inner.add(icon)
        icon.add_class('spt_left_arrow')
        icon.add_style("cursor: pointer")
        icon.add_style("position: absolute")
        icon.add_style("top: 40%")
        icon.add_style("left: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var arrow = bvr.src_el;
            spt.gallery.show_prev(arrow); 
            '''
        })
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")

        icon = IconWdg(title="Next",
                       icon="/context/icons/glyphs/chevron_right.png")
        inner.add(icon)
        icon.add_class('spt_right_arrow')
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("top: 40%")
        icon.add_style("right: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var arrow = bvr.src_el;
            spt.gallery.show_next(arrow); 
            '''
        })
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")

        desc_div = DivWdg()
        desc_div.add_class("spt_gallery_description")
        desc_div.add_style("height: 30px")
        desc_div.add_style("width: %s" % width)
        desc_div.add_style("text-align: center")
        desc_div.add_style("background: rgba(0,0,0,1)")
        desc_div.add_style("color: #bbb")
        desc_div.add_style("font-weight: bold")
        desc_div.add_style("font-size: 16px")
        desc_div.add_style("padding-top: 10px")
        desc_div.add_style("margin-left: -%s" % (width / 2))
        desc_div.add_style("z-index: 1000")
        desc_div.add("")

        desc_outer_div = DivWdg()
        inner.add(desc_outer_div)
        desc_outer_div.add_style("position: fixed")
        desc_outer_div.add(desc_div)
        desc_outer_div.add_style("bottom: 0px")
        desc_outer_div.add_style("left: 50%")

        return top
Beispiel #58
0
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 16px")


        detail_div = DivWdg()
        div.add(detail_div)
        detail_div.add_class("spt_tile_detail")
        detail_div.add_style("float: right")
        detail_div.add_style("margin-top: -2px")

        detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
        detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        header_div.add_class("hand")
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")

        title = sobject.get_name()
        if not title:
            title = sobject.get_code()
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
Beispiel #59
0
    def get_subdisplay(self, views):
        div = DivWdg()
        div.set_attr('spt_class_name', Common.get_full_class_name(self))

        div.add(self.get_bookmark_menu_wdg("", None, views))
        return div
Beispiel #60
0
    def init(self):

        self.item_cls = self.kwargs.get('left_search_type')
        self.container_cls = self.kwargs.get('right_search_type')
        self.grouping_cls = self.kwargs.get('search_type')

        self.item_sobj = self.container_sobj = None

        # List the items
        search = Search(self.item_cls)
        self._order_search(search)

        items = search.get_sobjects()
        if items:
            self.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')

        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()

        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value())
            user_table.add_cell(checkbox)

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell("[ %s ]" % project_code)
            else:
                user_table.add_cell("[ * ]")

            user_table.add_cell(item.get_description())
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(self.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)

        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width', '12em')
        main_table.add_cell(self._get_target_span(), 'valign_top')

        self.add(main_table)

        # register command here
        if self.item_sobj and self.container_sobj:
            marshaller = WebContainer.register_cmd(
                "pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", self.grouping_cls)
            marshaller.set_option("item_foreign_key",
                                  self.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key",
                                  self.container_sobj.get_foreign_key())