Esempio n. 1
0
 def update_params(self, d):
     super(TaskActionWidget, self).update_params(d)
     d['task_details']['onclick'] = "TaskDisable('%s',%s, %s); return false;" % (
         d.get('action'),
         jsonify_for_html({'t_id': d['task_details'].get('t_id')}),
         jsonify_for_html(self.get_options(d)),
         )
Esempio n. 2
0
 def update_params(self, d):
     super(RetentionTagWidget, self).update_params(d)
     d['attrs']['id'] = 'job_retentiontag'
     d['attrs']['onchange'] = "RetentionTagChange('%s',%s, %s)" % (
         url(d.get('action')),
         jsonify_for_html({'id': d.get('job_id')}),
         jsonify_for_html(self.get_options(d)),
         )
Esempio n. 3
0
 def update_params(self, d):
     super(ProductWidget, self).update_params(d)
     d['attrs']['id'] = 'job_product'
     d['attrs']['class'] = 'input-block-level'
     d['attrs']['onchange'] = "ProductChange('%s',%s, %s)" % (
         url(d.get('action')),
         jsonify_for_html({'id': d.get('job_id')}),
         jsonify_for_html(self.get_options(d)),
         )
Esempio n. 4
0
 def display(self, value=None, **params):
     missing = [(i, True) for i in ['action', 'data', 'callback']
                   if not params.get(i)]
     if any(missing):
         raise ValueError('Missing arguments to %s: %s' %
             (self.__class__.__name__, ','.join(dict(missing).keys())))
     params['action_type'] = params.get('action_type', 'delete')
     params['data'] = jsonify_for_html(params['data'])
     return super(DeleteLinkWidgetAJAX, self).display(value, **params)
Esempio n. 5
0
 def update_params(self, d):
     super(ReportProblemForm, self).update_params(d)
     d['system'] = d['options']['system']
     d['recipe'] = d['options'].get('recipe')
     d['hidden_fields'] = []
     d['hidden_fields'].append(HiddenField(name='system', attrs= {'value' : d['system'] }))
     if d['recipe']:
         d['hidden_fields'].append(HiddenField(name='recipe_id', attrs={'value' : d['recipe'].id}))
     d['submit'].attrs.update({'onClick' :  "return ! system_action_remote_form_request('%s', %s, '%s');" % (
         d['options']['name'], jsonify_for_html(self.get_options(d)), d['action'])})
Esempio n. 6
0
    def display(self, value=None, **params): 
        if 'options' in params: 
            if 'columns' in params['options']:
                params['columns'] = params['options']['columns']
            if 'simplesearch' in params['options']:
                params['simplesearch'] = params['options']['simplesearch']     
            if 'result_columns' in params['options']:
                json_this = {} 
                for elem in params['options']['result_columns']: 
                    json_this.update({elem : 1})
                params['default_result_columns'] = jsonify_for_html(json_this)
            else:
                params['default_result_columns'] = 'null'
            if 'col_options' in params['options']:
                params['col_options'] = params['options']['col_options']
            else:
                params['col_options'] = []
            if 'col_defaults' in params['options']:
                params['col_defaults'] = params['options']['col_defaults']
            if 'enable_custom_columns' in params['options']:
                params['enable_custom_columns'] = params['options']['enable_custom_columns']
            if 'extra_hiddens' in params['options']:
                params['extra_hiddens'] = [(k,v) for k,v in params['options']['extra_hiddens'].iteritems()] 

        if value and not 'simplesearch' in params:
            params['advanced'] = 'True'
            params['simple'] = 'none'
        elif value and params['simplesearch'] is None: 
            params['advanced'] = 'True'
            params['simple'] = 'none'
        else:  
            params['advanced'] = 'none'
            params['simple'] = 'True'
        if value and isinstance(value, list) and len(value) > 1:
            params['repetitions'] = len(value)
        return super(SearchBar, self).display(value, **params)
Esempio n. 7
0
    def __init__(self, table, search_controller=None, extra_selects=None,
            extra_inputs=None, extra_hiddens=None, enable_custom_columns=False,
            *args, **kw):
        super(SearchBar,self).__init__(*args, **kw)
        self.enable_custom_columns = enable_custom_columns
        self.search_controller=search_controller
        self.repetitions = 1
        self.extra_hiddens = extra_hiddens
        self.default_result_columns = {}
        table_field = SingleSelectFieldJSON(name="table",
                options=sorted(table.keys()),
                validator=validators.NotEmpty())
        operation_field = SingleSelectFieldJSON(name="operation", options=[None], validator=validators.NotEmpty())
        value_field = TextFieldJSON(name="value")

        self.fields = [table_field, operation_field, value_field]
        new_selects = []
        self.extra_callbacks = {} 
        self.search_object = jsonify_for_html(table)
            
        if extra_selects is not None: 
            new_class = [] 
            for elem in extra_selects:
                if elem.has_key('display'):
                    if elem['display'] == 'none':
                        new_class.append('hide_parent')
                callback = elem.get('callback',None)
                if callback:
                    self.extra_callbacks[elem['name']] = callback 
                new_select = SingleSelectFieldJSON(name=elem['name'],options=[None], css_classes = new_class, validator=validators.NotEmpty(),for_column=elem['column'] )
                if elem['name'] == 'keyvalue':
                    self.keyvaluevalue = new_select
 
                if elem.has_key('pos'):
                    self.fields.insert(elem['pos'] - 1,new_select)
                else:
                    self.fields.append(new_select) 

        new_inputs = []
        if extra_inputs is not None:
            for the_name in extra_inputs:
                new_input = TextField(name=the_name,display='none')
                new_inputs.append(new_input) 

        if 'simplesearch_label' in kw:
            self.simplesearch_label = kw['simplesearch_label']
        else:
            self.simplesearch_label = 'Search'

        self.quickly_searches = []
        if 'quick_searches' in kw:
            if kw['quick_searches'] is not None: 
                for elem,name in kw['quick_searches']:
                    vals = elem.split('-')
                    if len(vals) != 3:
                        log.error('Quick searches expects vals as <column>-<operation>-<value>. The following is incorrect: %s' % (elem)) 
                    else: 
                        self.quickly_searches.append((name, '%s-%s-%s' % (vals[0],vals[1],vals[2])))
        self.date_picker = jsonify_for_html(kw.get('date_picker',list()) )
        controllers = kw.get('table_search_controllers',dict())  
        self.table_search_controllers_stringified = str(controllers)
        self.extra_callbacks_stringified = str(self.extra_callbacks)
        self.fields.extend(new_inputs)
        self.fields.extend(new_selects) 
Esempio n. 8
0
 def update_params(self, d):
     super(InlineRemoteForm, self).update_params(d)
     d['form_attrs']['onSubmit'] = "return !remoteFormRequest(this, '%s', %s);" % (
         d.get("update", ''), jsonify_for_html(self.get_options(d)))
Esempio n. 9
0
 def update_params(self, d):
     super(JobWhiteboard, self).update_params(d)
     d['form_attrs']['onsubmit'] = "return !remoteFormRequest(this, null, %s);" % (
         jsonify_for_html(self.get_options(d)))