misc: use a more readable conversion of python to css class name (#39314)
This commit is contained in:
parent
01e435d8f5
commit
acbcbbc132
|
@ -571,12 +571,19 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
|
|||
return ''
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
def legacy_class_name(self):
|
||||
# legacy class name used in some themes
|
||||
return self.__class__.__name__.lower()
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
# convert CamelCase Python class name into a lower and dashed version
|
||||
# appropriate for CSS
|
||||
return re.sub('([A-Z]+)', r'-\1', self.__class__.__name__).lower()[1:]
|
||||
|
||||
@property
|
||||
def css_class_names(self):
|
||||
return self.class_name + ' ' + self.extra_css_class
|
||||
return ' '.join([self.class_name, self.legacy_class_name, self.extra_css_class])
|
||||
|
||||
@classmethod
|
||||
def get_cell_classes(cls, class_filter=lambda x: True):
|
||||
|
|
|
@ -254,13 +254,13 @@ $(function() {
|
|||
}
|
||||
}
|
||||
|
||||
$('.cell.tipipaymentformcell select').on('change', function() {
|
||||
$('.cell.tipi-payment-form-cell select').on('change', function() {
|
||||
handle_tipi_form($(this));
|
||||
compute_max_height($(this).parents('div.cell'));
|
||||
});
|
||||
$('.cell.tipipaymentformcell select').trigger('change');
|
||||
$('.cell.tipi-payment-form-cell select').trigger('change');
|
||||
|
||||
$('.cell.tipipaymentformcell').on('combo:cellform-reloaded', function() {
|
||||
$('.cell.tipi-payment-form-cell').on('combo:cellform-reloaded', function() {
|
||||
var $select = $(this).find('select');
|
||||
$select.on('change', function() {
|
||||
handle_tipi_form($select);
|
||||
|
|
|
@ -399,7 +399,7 @@ def test_config_json_cell():
|
|||
assert cell.get_label() == 'Foobar'
|
||||
assert cell.url == 'http://test/'
|
||||
assert cell.template_name == 'combo/json/foobar.html'
|
||||
assert cell.css_class_names.split() == ['configjsoncell', 'foobar']
|
||||
assert cell.css_class_names.split() == ['config-json-cell', 'configjsoncell', 'foobar']
|
||||
|
||||
with mock.patch('combo.utils.requests.get') as requests_get:
|
||||
requests_get.return_value = mock_json_response(content=json.dumps({'hello': 'world'}), status_code=200)
|
||||
|
|
Loading…
Reference in New Issue