diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js index 8359b7fcb..fcfd667dc 100644 --- a/install/ui/src/freeipa/details.js +++ b/install/ui/src/freeipa/details.js @@ -43,6 +43,12 @@ define([ */ var exp = {}; +/** + * CSS classes for defining basic layout of sections in details facets + * @type {String} + */ +exp.details_section_layout_class = 'col-sm-12 col-md-6'; + /** * Details builder * @@ -194,10 +200,9 @@ exp.section_builder = IPA.section_builder = function(spec) { /** * Default section factory * - * TODO: should be modified so it can be a class too - * @property {IPA.composite_widget} + * @property {IPA.composite_widget|Object} */ - that.section_factory = spec.section_factory || IPA.details_section; + that.section_spec = spec.section_spec || IPA.details_section; /** * Field builder @@ -231,23 +236,32 @@ exp.section_builder = IPA.section_builder = function(spec) { * is not specified in spec */ that.build_section = function(section_spec, index) { - section_spec.entity = that.container.entity; - section_spec.facet = that.container; - if (!section_spec.label && section_spec.name && that.container.entity) { - var section_label = '@i18n:objects.'+that.container.entity.name+ - '.' + section_spec.name; - section_spec.label = section_label; + var spec = section_spec; + var overrides = {}; + var spec_type = typeof that.section_spec; + if (spec_type === 'object') { + spec = lang.mixin({}, that.section_spec); + spec = lang.mixin(spec, section_spec); + } else if (spec_type === "function") { + overrides = that.section_spec; } - if(!section_spec.name) section_spec.name = 'section'+index; + if (!spec.label && spec.name && that.container.entity) { + var section_label = '@i18n:objects.'+that.container.entity.name+ + '.' + spec.name; + spec.label = section_label; + } - section_spec.$factory = section_spec.$factory || that.section_factory; - var section = section_spec.$factory(section_spec); + if (!spec.name) spec.name = 'section'+index; + + var section = builder.build('widget', spec, { + entity: that.container.entity, + facet: that.container + }, overrides); that.container.widgets.add_widget(section); - - that.create_fields(section, section_spec.fields); + that.create_fields(section, spec.fields); }; /** @@ -564,6 +578,12 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { that.fields.container_add_field(field); }; + /** + * Class for details section, defines layout + * @property {string} + */ + that.section_layout_class = spec.section_layout_class || exp.details_section_layout_class; + /** * Dirty * @@ -1091,7 +1111,11 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) { var section_builder = IPA.section_builder({ container: that, widget_builder: widget_builder, - field_builder: field_builder + field_builder: field_builder, + section_spec: { + $factory: IPA.details_section, + layout_css_class: that.section_layout_class + } }); that.builder = IPA.details_builder({ diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js index a7f5e09fd..228bc218d 100644 --- a/install/ui/src/freeipa/dialog.js +++ b/install/ui/src/freeipa/dialog.js @@ -252,7 +252,7 @@ IPA.dialog = function(spec) { }).appendTo(that.dom_node); that.dialog_node = $('
', { - 'class': 'rcue-dialog', + 'class': 'rcue-dialog row', id: that.get_id(), 'data-name' : that.name, role: 'dialog', diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index ae76b59a1..1efdb55a3 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -416,7 +416,7 @@ IPA.dnszone_name_section_layout = function(spec) { var label_text = widget.label + that.get_measurement_unit_text(widget); - var label_cont = $('
', { 'class': 'control-label col-sm-3' }); + var label_cont = $('
', { 'class': that.label_cls }); widget.create_radio(label_cont); diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index c17f7ca27..39b1192ef 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -143,13 +143,29 @@ IPA.widget = function(spec) { */ that.visible = spec.visible === undefined ? true : spec.visible; + /** + * Default main element's css classes + * @type {string} + */ + that.base_css_class = spec.base_css_class || 'widget'; + + /** + * Additional main element's css classes + * + * Intended to be overridden in spec objects + * + * @type {string} + */ + that.css_class = spec.css_class || ''; + /** * Create HTML representation of a widget. * @method * @param {HTMLElement} container - Container node */ that.create = function(container) { - container.addClass('widget'); + container.addClass(that.base_css_class); + container.addClass(that.css_class); that.container = container; }; @@ -659,6 +675,7 @@ IPA.text_widget = function(spec) { */ that.input_type = spec.input_type || 'text'; + that.base_css_class = that.base_css_class + ' text-widget'; /** * Select range of text @@ -674,8 +691,6 @@ IPA.text_widget = function(spec) { that.widget_create(container); - container.addClass('text-widget'); - that.display_control = $('

', { name: that.name, 'class': 'form-control-static', @@ -831,6 +846,8 @@ IPA.multivalued_widget = function(spec) { that.rows = []; + that.base_css_class = that.base_css_class + ' multivalued-widget'; + that.on_child_value_changed = function(row) { if (that.test_dirty_row(row)) { that.toggle_remove_link(row, false); @@ -1047,8 +1064,6 @@ IPA.multivalued_widget = function(spec) { that.create = function(container) { - container.addClass('multivalued-widget'); - that.widget_create(container); that.create_error_link(container); @@ -1658,11 +1673,12 @@ IPA.radio_widget = function(spec) { var that = IPA.input_widget(spec); IPA.option_widget_base(spec, that); + that.base_css_class = that.base_css_class + ' radio-widget'; + /** @inheritDoc */ that.create = function(container) { that.widget_create(container); that.owb_create(container); - container.addClass('radio-widget'); if (that.undo) { that.create_undo(container); @@ -1810,12 +1826,12 @@ IPA.select_widget = function(spec) { that.options = spec.options || []; + that.base_css_class = that.base_css_class + ' select-widget'; + that.create = function(container) { that.widget_create(container); - container.addClass('select-widget'); - that.select = $('