mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
Fix Separator to generate bold label when field is required
issue5243 review24001002
This commit is contained in:
parent
272fa5c60e
commit
9ad16079e2
1 changed files with 35 additions and 31 deletions
|
@ -651,32 +651,9 @@
|
|||
}
|
||||
});
|
||||
|
||||
Sao.View.Form.Separator = Sao.class_(Sao.View.Form.StateWidget, {
|
||||
init: function(text, attributes) {
|
||||
Sao.View.Form.Separator._super.init.call(this, attributes);
|
||||
this.el = jQuery('<div/>', {
|
||||
'class': 'form-separator'
|
||||
});
|
||||
if (text) {
|
||||
this.el.append(jQuery('<label/>', {
|
||||
text: text
|
||||
}));
|
||||
}
|
||||
this.el.append(jQuery('<hr/>'));
|
||||
}
|
||||
});
|
||||
|
||||
Sao.View.Form.Label = Sao.class_(Sao.View.Form.StateWidget, {
|
||||
class_: 'form-label',
|
||||
init: function(text, attributes) {
|
||||
Sao.View.Form.Label._super.init.call(this, attributes);
|
||||
this.el = jQuery('<label/>', {
|
||||
text: text,
|
||||
'class': this.class_ + ' form-label'
|
||||
});
|
||||
},
|
||||
Sao.View.Form.LabelMixin = Sao.class_(Sao.View.Form.StateWidget, {
|
||||
set_state: function(record) {
|
||||
Sao.View.Form.Label._super.set_state.call(this, record);
|
||||
Sao.View.Form.LabelMixin._super.set_state.call(this, record);
|
||||
var field;
|
||||
if (this.attributes.name && record) {
|
||||
field = record.model.fields[this.attributes.name];
|
||||
|
@ -686,7 +663,7 @@
|
|||
if (record) {
|
||||
text = field.get_client(record) || '';
|
||||
}
|
||||
this.el.val(text);
|
||||
this.label_el.val(text);
|
||||
}
|
||||
var state_changes;
|
||||
if (record) {
|
||||
|
@ -696,20 +673,47 @@
|
|||
}
|
||||
if ((field && field.description.required) ||
|
||||
state_changes.required) {
|
||||
this.el.addClass('required');
|
||||
this.label_el.addClass('required');
|
||||
} else {
|
||||
this.el.removeClass('required');
|
||||
this.label_el.removeClass('required');
|
||||
}
|
||||
if ((field && field.description.readonly) ||
|
||||
state_changes.readonly) {
|
||||
this.el.removeClass('editable');
|
||||
this.el.removeClass('required');
|
||||
this.label_el.removeClass('editable');
|
||||
this.label_el.removeClass('required');
|
||||
} else {
|
||||
this.el.addClass('editable');
|
||||
this.label_el.addClass('editable');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Sao.View.Form.Separator = Sao.class_(Sao.View.Form.LabelMixin, {
|
||||
init: function(text, attributes) {
|
||||
Sao.View.Form.Separator._super.init.call(this, attributes);
|
||||
this.el = jQuery('<div/>', {
|
||||
'class': 'form-separator'
|
||||
});
|
||||
if (text) {
|
||||
this.label_el = jQuery('<label/>', {
|
||||
text: text
|
||||
});
|
||||
this.el.append(this.label_el);
|
||||
}
|
||||
this.el.append(jQuery('<hr/>'));
|
||||
}
|
||||
});
|
||||
|
||||
Sao.View.Form.Label = Sao.class_(Sao.View.Form.LabelMixin, {
|
||||
class_: 'form-label',
|
||||
init: function(text, attributes) {
|
||||
Sao.View.Form.Label._super.init.call(this, attributes);
|
||||
this.el = this.label_el = jQuery('<label/>', {
|
||||
text: text,
|
||||
'class': this.class_ + ' form-label'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Sao.View.Form.Notebook = Sao.class_(Sao.View.Form.StateWidget, {
|
||||
class_: 'form-notebook',
|
||||
init: function(attributes) {
|
||||
|
|
Loading…
Reference in a new issue