diff options
| author | bth-openerp <bth@tinyerp.com> | 2013-04-17 11:38:18 +0530 |
|---|---|---|
| committer | bth-openerp <bth@tinyerp.com> | 2013-04-17 11:38:18 +0530 |
| commit | 4d0cb54886d293a8ff92c8aeaa95f891cc245865 (patch) | |
| tree | 35cd81f2980219789c4a37dc64a349a8de2ab2c2 /addons/web/static/src | |
| parent | 7e05448204ecef5ce4c957d0a842654811e9c429 (diff) | |
| parent | 97900c25a44cb4669f1e45401d69b31b88cdcd96 (diff) | |
[MERGE] Merge lp:openerp-web.
bzr revid: bth@tinyerp.com-20130417060818-rzznm2t8ersljdsv
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 41 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 36 | ||||
| -rw-r--r-- | addons/web/static/src/img/icons/input_radio-off.png | bin | 512 -> 0 bytes | |||
| -rw-r--r-- | addons/web/static/src/img/icons/input_radio-on.png | bin | 559 -> 0 bytes | |||
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 96 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 11 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 45 |
8 files changed, 156 insertions, 76 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 559b0e40e35..52107bc84d7 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2105,6 +2105,9 @@ .openerp .oe_form_invisible { display: none !important; } +.openerp .oe_form_editable .oe_read_only { + display: none !important; +} .openerp .oe_form_readonly .oe_edit_only, .openerp .oe_form_readonly .oe_form_field:empty { display: none !important; } @@ -2312,24 +2315,26 @@ .openerp .oe_form_field_radio.oe_horizontal { white-space: nowrap; } -.openerp .oe_form_field_radio.oe_horizontal .oe_radio_header { +.openerp .oe_form_field_radio.oe_form_required .oe_radio_input { + border: 1px solid transparent; display: inline-block; - text-align: center; + height: 12px; + width: 12px; + vertical-align: bottom; + border-radius: 10px; + margin: 1px 0; } -.openerp .oe_form_field_radio.oe_vertical .oe_radio_header { - cursor: pointer; +.openerp .oe_form_field_radio.oe_form_required.oe_form_invalid .oe_radio_input { + border-color: red; } -.openerp .oe_form_field_radio .oe_radio_input { - cursor: pointer; +.openerp .oe_form_field_radio.oe_horizontal label, +.openerp .oe_form_field_radio.oe_horizontal div { display: inline-block; - width: 20px; - background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center; -} -.openerp .oe_form_field_radio .oe_radio_input_on { - background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center; + text-align: center; + height: 16px; } -.openerp .oe_form_field_radio .oe_radio_label { - cursor: default; +.openerp .oe_form_field_radio.oe_vertical label { + margin-left: 4px; } .openerp .oe_form_field_progressbar.ui-progressbar { height: 22px; @@ -2401,6 +2406,7 @@ background: white; min-width: 60px; color: #1f1f1f; + font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; } .openerp .oe_form input[readonly], .openerp .oe_form select[readonly], .openerp .oe_form textarea[readonly], .openerp .oe_form input[disabled], .openerp .oe_form select[disabled] { background: #e5e5e5 !important; @@ -2415,6 +2421,7 @@ -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; + color: #4c4c4c; } .openerp .oe_form textarea.oe_inline[disabled] { border-left: 8px solid #eeeeee; @@ -3174,6 +3181,14 @@ .kitten-mode-activated > * { opacity: 0.7; } +.loading-kitten { + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + border-radius: 15px; + -moz-box-shadow: 0 0 5px 5px #999999; + -webkit-box-shadow: 0 0 5px 5px #999999; + box-shadow: 0 0 5px 5px #999999; +} div.ui-widget-overlay { background: black; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index d687ce21869..072fda44357 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -483,21 +483,25 @@ $sheet-padding: 16px .oe_form_field_radio &.oe_horizontal white-space: nowrap - .oe_radio_header + label display: inline-block text-align: center + height: 16px &.oe_vertical - .oe_radio_header - cursor: pointer - .oe_radio_input { - cursor: pointer - display: inline-block - width: 20px - background: transparent url(/web/static/src/img/icons/input_radio-off.png) no-repeat center center - .oe_radio_input_on - background: transparent url(/web/static/src/img/icons/input_radio-on.png) no-repeat center center - .oe_radio_label - cursor: default + label + margin-left: 4px + &.oe_form_required + .oe_radio_input + border: 2px solid transparent + display: inline-block + height: 12px + width: 12px + vertical-align: bottom + border-radius: 10px + margin: 1px 0 + &.oe_form_invalid + .oe_radio_input + border-color: red .oe_tags &.oe_inline min-width: 250px @@ -1681,6 +1685,9 @@ $sheet-padding: 16px @include box-shadow((0 1px 2px rgba(0, 0, 0, .1), 0 1px 1px rgba(255, 255, 255, .8) inset)) .oe_form_invisible display: none !important + .oe_form_editable + .oe_read_only + display: none !important .oe_form_readonly .oe_edit_only, .oe_form_field:empty display: none !important @@ -1901,6 +1908,7 @@ $sheet-padding: 16px background: white min-width: 60px color: #1f1f1f + font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif input[readonly], select[readonly], textarea[readonly], input[disabled], select[disabled] background: #E5E5E5 !important color: #666 @@ -1909,6 +1917,7 @@ $sheet-padding: 16px padding-left: 8px @include box-shadow(none) @include radius(0px) + color: #4c4c4c textarea.oe_inline[disabled] border-left: 8px solid #eee .oe_form_field_url button img @@ -2499,6 +2508,9 @@ $sheet-padding: 16px background-attachment: fixed >* opacity: 0.70 +.loading-kitten + @include radius(15px) + @include box-shadow(0 0 5px 5px #999) // }}} // jQueryUI top level {{{ diff --git a/addons/web/static/src/img/icons/input_radio-off.png b/addons/web/static/src/img/icons/input_radio-off.png Binary files differdeleted file mode 100644 index 790f7ed13b2..00000000000 --- a/addons/web/static/src/img/icons/input_radio-off.png +++ /dev/null diff --git a/addons/web/static/src/img/icons/input_radio-on.png b/addons/web/static/src/img/icons/input_radio-on.png Binary files differdeleted file mode 100644 index d55c291e795..00000000000 --- a/addons/web/static/src/img/icons/input_radio-on.png +++ /dev/null diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 696f25109a9..3870a7999b4 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1257,7 +1257,8 @@ instance.web.WebClient = instance.web.Client.extend({ $("body").addClass("kitten-mode-activated"); $("body").css("background-image", "url(" + instance.session.origin + "/web/static/src/img/back-enable.jpg" + ")"); if ($.blockUI) { - $.blockUI.defaults.message = '<img src="http://www.amigrave.com/kitten.gif">'; + var imgkit = Math.floor(Math.random() * 2 + 1); + $.blockUI.defaults.message = '<img src="http://www.amigrave.com/loading-kitten/' + imgkit + '.gif" class="loading-kitten">'; } } if (!self.session.session_is_valid()) { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3b851568fe6..53a7425c036 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2806,35 +2806,94 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan instance.web.form.FieldRadio = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { template: 'FieldRadio', + events: { + 'click input': 'click_change_value' + }, init: function(field_manager, node) { /* Radio button widget: Attributes options: * - "horizontal" to display in column * - "no_radiolabel" don't display text values - * - "display_readonly" to display radio button (not clickable) in read only mode */ - var self = this; this._super(field_manager, node); - this.horizontal = +this.options.horizontal; - this.no_radiolabel = +this.options.no_radiolabel; - this.display_readonly = +this.options.display_readonly; + this.selection = _.clone(this.field.selection) || []; + this.domain = false; }, initialize_content: function () { + this.uniqueId = _.uniqueId("radio"); + this.on("change:effective_readonly", this, this.render_value); + this.field_manager.on("view_content_has_changed", this, this.get_selection); + this.get_selection(); + }, + click_change_value: function (event) { + var val = $(event.target).val(); + val = this.field.type == "selection" ? val : +val; + if (val == this.get_value()) { + this.set_value(false); + } else { + this.set_value(val); + } + }, + /** Get the selection and render it + * selection: [[identifier, value_to_display], ...] + * For selection fields: this is directly given by this.field.selection + * For many2one fields: perform a search on the relation of the many2one field + */ + get_selection: function() { var self = this; - this.$el.on('click', '.oe_radio_input,.oe_radio_header', function (event) { - var id = $(event.target).data("id"); - id = isNaN(+id) ? id : +id; - if (id && !self.get("effective_readonly")) { - if (!self.field.required && id == self.get_value()) { - self.set_value(false); - } else { - self.set_value(id); - } + var selection = []; + var def = $.Deferred(); + if (self.field.type == "many2one") { + var domain = instance.web.pyeval.eval('domain', this.build_domain()) || []; + if (! _.isEqual(self.domain, domain)) { + self.domain = domain; + var ds = new instance.web.DataSet(self, self.field.relation); + ds.call('search', [self.domain]) + .then(function (records) { + ds.name_get(records).then(function (records) { + selection = records; + def.resolve(); + }); + }); + } else { + selection = self.selection; + def.resolve(); + } + } + else if (self.field.type == "selection") { + selection = self.field.selection || []; + def.resolve(); + } + return def.then(function () { + if (! _.isEqual(selection, self.selection)) { + self.selection = _.clone(selection); + self.renderElement(); + self.render_value(); } }); }, + set_value: function (value_) { + if (value_) { + if (this.field.type == "selection") { + value_ = _.find(this.field.selection, function (sel) { return sel[0] == value_}); + } + else if (!this.selection.length) { + this.selection = [value_]; + } + } + this._super(value_); + }, + get_value: function () { + var value = this.get('value'); + return value instanceof Array ? value[0] : value; + }, render_value: function () { - this.$(".oe_radio_input_on").removeClass("oe_radio_input_on"); - this.$(".oe_radio_input[data-id='" + this.get_value() + "'], .oe_radio_header[data-id='" + this.get_value() + "'] .oe_radio_input").addClass("oe_radio_input_on"); + var self = this; + this.$el.toggleClass("oe_readonly", this.get('effective_readonly')); + this.$("input:checked").prop("checked", false); + if (this.get_value()) { + this.$("input").filter(function () {return this.value == self.get_value()}).prop("checked", true); + this.$(".oe_radio_readonly").text(this.get('value') ? this.get('value')[1] : ""); + } } }); @@ -5329,11 +5388,6 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ var self = this; var content = QWeb.render("FieldStatus.content", {widget: self}); self.$el.html(content); - var colors = JSON.parse((self.node.attrs || {}).statusbar_colors || "{}"); - var color = colors[self.get('value')]; - if (color) { - self.$("oe_active").css("color", color); - } }, calc_domain: function() { var d = instance.web.pyeval.eval('domain', this.build_domain()); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index befbc7fe793..1143bdfc2af 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -662,13 +662,6 @@ instance.web.ViewManager = instance.web.Widget.extend({ }, add_breadcrumb: function(options) { var options = options || {}; - // 7.0 backward compatibility - if (typeof options == 'function') { - options = { - on_reverse_breadcrumb: options - }; - } - // end of 7.0 backward compatibility var self = this; var views = [this.active_view || this.views_src[0].view_type]; this.on('switch_mode', self, function(mode) { @@ -1371,7 +1364,7 @@ instance.web.View = instance.web.Widget.extend({ } else if (action_data.type=="action") { return this.rpc('/web/action/load', { action_id: action_data.name, - context: instance.web.pyeval.eval('context', context), + context: _.extend({'active_model': dataset.model, 'active_ids': dataset.ids, 'active_id': record_id}, instance.web.pyeval.eval('context', context)), do_not_eval: true }).then(handler); } else { @@ -1459,7 +1452,7 @@ instance.web.View = instance.web.Widget.extend({ is_action_enabled: function(action) { var attrs = this.fields_view.arch.attrs; return (action in attrs) ? JSON.parse(attrs[action]) : true; - } + }, }); /** diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 41067240b52..943326f5011 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -40,11 +40,11 @@ <td> <p> <t t-js="d"> - var message = d.error.data.message || d.error.data.fault_code; - d.error.html_error = context.engine.tools.html_escape(message) + var message = d.message ? d.message : d.error.data.message; + d.html_error = context.engine.tools.html_escape(message) .replace(/\n/g, '<br/>'); </t> - <t t-raw="error.html_error"/> + <t t-raw="html_error"/> </p> </td> </tr> @@ -1112,26 +1112,31 @@ </span> </t> <t t-name="FieldRadio"> - <span t-attf-class="oe_form_field oe_form_field_radio #{widget.horizontal ? 'oe_horizontal' : 'oe_vertical'}" t-att-style="widget.node.attrs.style"> - <t t-if="widget.horizontal"> - <t t-set="width" t-value="Math.floor(100 / widget.field.selection.length)"/> - <t t-if="!widget.no_radiolabel"> - <t t-foreach="widget.field.selection" t-as="selection"> - <div class="oe_radio_header" t-att-style="'width: ' + width + '%;'"><t t-esc="selection[1]"/></div> + <span t-attf-class="oe_form_field oe_form_field_radio #{widget.options.horizontal ? 'oe_horizontal' : 'oe_vertical'}" t-att-style="widget.node.attrs.style"> + <span t-if="!widget.get('effective_readonly')"> + <t t-if="widget.options.horizontal"> + <t t-set="width" t-value="Math.floor(100 / widget.selection.length)"/> + <t t-if="!widget.options.no_radiolabel"> + <t t-foreach="widget.selection" t-as="selection"> + <label t-att-for="widget.uniqueId + '_' + selection[0]" t-att-style="'width: ' + width + '%;'"><t t-esc="selection[1]"/></label> + </t> + <br/> + </t> + <t t-foreach="widget.selection" t-as="selection"> + <div t-att-style="'width: ' + width + '%;'"> + <span class="oe_radio_input"><input type="radio" t-att-name="widget.uniqueId" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-value="selection[0]"/></span> + </div> </t> - <br/> - </t> - <t t-foreach="widget.field.selection" t-as="selection"> - <div class="oe_radio_input" t-att-style="'width: ' + width + '%;'" t-att-data-id="selection[0]">&nbsp;</div> </t> - </t> - <t t-if="!widget.horizontal"> - <t t-foreach="widget.field.selection" t-as="selection"> - <div class="oe_radio_header" t-att-style="'width: ' + width + '%;'" t-att-data-id="selection[0]"> - <div class="oe_radio_input">&nbsp;</div><t t-if="!widget.no_radiolabel" t-esc="selection[1]"/> - </div> + <t t-if="!widget.options.horizontal"> + <t t-foreach="widget.selection" t-as="selection"> + <div> + <span class="oe_radio_input"><input type="radio" t-att-id="widget.uniqueId + '_' + selection[0]" t-att-name="widget.uniqueId" t-att-value="selection[0]"/></span><label t-if="!widget.options.no_radiolabel" t-att-for="widget.uniqueId + '_' + selection[0]"><t t-esc="selection[1]"/></label> + </div> + </t> </t> - </t> + </span> + <span t-if="widget.get('effective_readonly')" class="oe_radio_readonly"><t t-esc="widget.get('value')[1]"/></span> </span> </t> <t t-name="FieldMany2One"> |
