diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-05-09 10:41:39 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-05-09 10:41:39 +0200 |
| commit | 104615333c062e96896f3783edea1bb1b441d36c (patch) | |
| tree | f7ba96cc95d0ba1ac1d383db548c4f6266f2e6cc /addons/web/static/src | |
| parent | dd47079a116a8f535dd0ca3c27b1357aff033508 (diff) | |
| parent | e4fdf1b061b7cc859e3d257dcab504caf8e8ebf2 (diff) | |
[MERGE] Merge trunk
bzr revid: fme@openerp.com-20120509084139-q0jae332yok87ae1
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/boot.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/corelib.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 110 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 36 |
6 files changed, 103 insertions, 53 deletions
diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 29d953aadd8..f83dbc97095 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -37,7 +37,7 @@ }; openerp.instances[new_instance._session_id] = new_instance; for(var i=0; i < modules.length; i++) { - openerp[modules[i]](new_instance); + openerp[modules[i]](new_instance,new_instance[modules[i]]); } return new_instance; } diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 465ad2c921b..b30350a9502 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1046,7 +1046,9 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ '<li>Source: %(source)s</li>' + '</ul>'; try { - var ctx = this.test_eval_contexts(source.contexts); + // see Session.eval_context in Python + var ctx = this.test_eval_contexts( + ([this.context] || []).concat(source.contexts)); if (!_.isEqual(ctx, expected.context)) { instance.webclient.notification.warn('Context mismatch, report to xmo', _.str.sprintf(match_template, { diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 00fdb9aec98..8e7b5d4f75d 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -279,7 +279,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess instance[mod] = {}; // init module mod if(instance._openerp[mod] != undefined) { - instance._openerp[mod](instance); + instance._openerp[mod](instance,instance[mod]); this.module_loaded[mod] = true; } } diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 607e92f0802..03889a91757 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -6,8 +6,34 @@ var QWeb = instance.web.qweb; /** @namespace */ instance.web.form = {}; +/** + * Interface implemented by the form view or any other object + * able to provide the features necessary for the fields to work. + * + * Properties: + * - display_invalid_fields : if true, all fields where is_valid() return true should + * be displayed as invalid. + * Events: + * - view_content_has_changed : when the values of the fields have changed. When + * this event is triggered all fields should reprocess their modifiers. + */ +instance.web.form.FieldManagerMixin = { + /** + * Must return the asked field as in fields_get. + */ + get_field: function(field_name) {}, + /** + * Called by the field when the translate button is clicked. + */ + open_translate_dialog: function(field) {}, + /** + * Returns true when the view is in create mode. + */ + is_create_mode: function() {}, +}; + instance.web.views.add('form', 'instance.web.FormView'); -instance.web.FormView = instance.web.View.extend({ +instance.web.FormView = instance.web.View.extend(_.extend({}, instance.web.form.FieldManagerMixin, { /** * Indicates that this view is not searchable, and thus that no search * view should be displayed (if there is one active). @@ -859,6 +885,15 @@ instance.web.FormView = instance.web.View.extend({ is_create_mode: function() { return !this.datarecord.id; }, +})); + +/** + * Interface to be implemented by rendering engines for the form view. + */ +instance.web.form.FormRenderingEngineInterface = instance.web.Class.extend({ + set_fields_view: function(fields_view) {}, + set_fields_registry: function(fields_registry) {}, + render_to: function($element) {}, }); /** @@ -866,7 +901,7 @@ instance.web.FormView = instance.web.View.extend({ * * It is necessary to set the view using set_view() before usage. */ -instance.web.form.FormRenderingEngine = instance.web.Class.extend({ +instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInterface.extend({ init: function(view) { this.view = view; }, @@ -1381,10 +1416,6 @@ instance.web.form.FormWidget = instance.web.Widget.extend(_.extend({}, instance. this._super(); this.$element.addClass(this.node.attrs["class"] || ""); }, - start: function() { - this._super(); - instance.web.form.InvisibilityChangerMixin.start.call(this); - }, destroy: function() { $.fn.tipsy.clear(); this._super.apply(this, arguments); @@ -1558,32 +1589,6 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ }); /** - * Interface implemented by the form view or any other object - * able to provide the features necessary for the fields to work. - * - * Properties: - * - display_invalid_fields : if true, all fields where is_valid() return true should - * be displayed as invalid. - * Events: - * - view_content_has_changed : when the values of the fields have changed. When - * this event is triggered all fields should reprocess their modifiers. - */ -instance.web.form.FieldManagerInterface = { - /** - * Must return the asked field as in fields_get. - */ - get_field: function(field_name) {}, - /** - * Called by the field when the translate button is clicked. - */ - open_translate_dialog: function(field) {}, - /** - * Returns true when the view is in create mode. - */ - is_create_mode: function() {}, -}; - -/** * Interface to be implemented by fields. * * Properties: @@ -1594,10 +1599,10 @@ instance.web.form.FieldManagerInterface = { * - changed_value: triggered to inform the view to check on_changes * */ -instance.web.form.FieldInterface = { +instance.web.form.FieldMixin = { /** * Constructor takes 2 arguments: - * - field_manager: Implements FieldManagerInterface + * - field_manager: Implements FieldManagerMixin * - node: the "<field>" node in json form */ init: function(field_manager, node) {}, @@ -1658,7 +1663,7 @@ instance.web.form.FieldInterface = { }; /** - * Abstract class for classes implementing FieldInterface. + * Abstract class for classes implementing FieldMixin. * * Properties: * - effective_readonly: when it is true, the widget is displayed as readonly. Vary depending @@ -1668,7 +1673,7 @@ instance.web.form.FieldInterface = { * a 'changed_value' event that inform the view to trigger on_changes. * */ -instance.web.form.AbstractField = instance.web.form.FormWidget.extend(/** @lends instance.web.form.AbstractField# */{ +instance.web.form.AbstractField = instance.web.form.FormWidget.extend(_.extend({}, instance.web.form.FieldMixin, { /** * @constructs instance.web.form.AbstractField * @extends instance.web.form.FormWidget @@ -1677,7 +1682,6 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(/** @lends * @param node */ init: function(field_manager, node) { - this._super(field_manager, node); this.field_manager = field_manager; this.name = this.node.attrs.name; @@ -1701,9 +1705,8 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(/** @lends this._check_css_flags(); }); }, - start: function() { - var self = this; - this._super.apply(this, arguments); + renderElement: function() { + this._super(); if (this.field.translate) { this.$element.addClass('oe_form_field_translatable'); this.$element.find('.oe_field_translate').click(_.bind(function() { @@ -1714,13 +1717,17 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(/** @lends this.do_attach_tooltip(this, this.view.$element.find('label[for=' + this.id_for_label + ']')[0] || this.$element); } if (!this.disable_utility_classes) { - var set_required = function() { - self.$element.toggleClass('oe_form_required', self.get("required")); - }; - this.on("change:required", this, set_required); - set_required(); + this.off("change:required", this, this._set_required); + this.on("change:required", this, this._set_required); + this._set_required(); } }, + /** + * Private. Do not use. + */ + _set_required: function() { + this.$element.toggleClass('oe_form_required', this.get("required")); + }, set_value: function(value_) { this._inhibit_on_change = true; this.set({'value': value_}); @@ -1775,7 +1782,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(/** @lends set_input_id: function(id) { this.id_for_label = id; }, -}); +})); /** * A mixin to apply on any field that has to completely re-render when its readonly state @@ -3797,7 +3804,10 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ }); /** - * Registry of form widgets, called by :js:`instance.web.FormView` + * Registry of form fields, called by :js:`instance.web.FormView`. + * + * All referenced classes must implement FieldMixin. Those represent the classes whose instances + * will substitute to the <field> tags as defined in OpenERP's views. */ instance.web.form.widgets = new instance.web.Registry({ 'char' : 'instance.web.form.FieldChar', @@ -3823,6 +3833,12 @@ instance.web.form.widgets = new instance.web.Registry({ 'statusbar': 'instance.web.form.FieldStatus' }); +/** + * Registry of widgets usable in the form view that can substitute to any possible + * tags defined in OpenERP's form views. + * + * Every referenced class should extend FormWidget. + */ instance.web.form.tags = new instance.web.Registry({ 'button' : 'instance.web.form.WidgetButton', }); diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index e539d17e63f..83b219a211a 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -377,7 +377,7 @@ openerp.web.list_editable = function (instance) { renderElement: function() {} }); - instance.web.ListEditableRenderingEngine = instance.web.Class.extend({ + instance.web.ListEditableRenderingEngine = instance.web.form.FormRenderingEngineInterface.extend({ init: function(view) { this.view = view; }, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index ed8a5115e98..6d43846c9e5 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -264,6 +264,32 @@ </div> </t> +<t t-name="WebClient"> + <table class="oe_webclient"> + <tr> + <td colspan="2" class="oe_topbar"> + <div class="oe_menu_placeholder"/> + <div class="oe_user_menu_placeholder"/> + <div class="oe_systray"/> + </td> + </tr> + <tr> + <td class="oe_leftbar" valign="top"> + <t t-js="d"> + d.url = '/' + (window.location.search || ''); + </t> + <a t-att-href="url" class="oe_logo"><img t-att-src='_s + "/web/static/src/img/logo.png"'/></a> + <div class="oe_secondary_menus_container"/> + <div class="oe_footer"> + Powered by <a href="http://www.openerp.com"><span>Open</span>ERP</a> + </div> + </td> + <td class="oe_application"> + </td> + </tr> + </table> +</t> + <t t-name="Menu"> <ul class="oe_menu" t-if="widget.data"> <li t-foreach="widget.data.data.children" t-as="menu"> @@ -307,7 +333,7 @@ t-att-data-action-model="menu.action ? menu.action.split(',')[0] : ''" t-att-data-action-id="menu.action ? menu.action.split(',')[1] : ''"> <t t-esc="menu.name"/> - <t t-if="menu.needaction_enabled && menu.needaction_counter"> + <t t-if="menu.needaction_enabled and menu.needaction_counter"> <div class="oe_menu_counter"> <t t-esc="menu.needaction_counter"/> </div> @@ -429,7 +455,7 @@ <td> <div class="oe_view_manager_header2_row2"> <ul class="oe_view_manager_switch oe_button_group oe_right"> - <t t-if="widget.views_src.length > 2" t-foreach="widget.views_src" t-as="view"> + <t t-if="widget.views_src.length gt 2" t-foreach="widget.views_src" t-as="view"> <li t-if="view.view_type != 'form'"><a t-attf-class="oe_vm_switch_#{view.view_type} oe_i" t-att-data-view-type="view.view_type" t-att-title="view.label || view.view_type"> </a></li> </t> @@ -908,6 +934,7 @@ t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" t-attf-class="field_char #{widget.is_field_number ? 'oe-number' : ''}" + t-att-placeholder="widget.node.attrs.placeholder" /><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> </div> </t> @@ -924,6 +951,7 @@ t-att-id="widget.id_for_label" t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" + t-att-placeholder="widget.node.attrs.placeholder" /> </td> <td width="16"> @@ -949,6 +977,7 @@ t-att-id="widget.id_for_label" t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" + t-att-placeholder="widget.node.attrs.placeholder" /> </td> <td width="16"> @@ -972,6 +1001,7 @@ class="field_text" t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" + t-att-placeholder="widget.node.attrs.placeholder" ></textarea> <img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/> @@ -982,6 +1012,7 @@ <input type="text" class="oe_datepicker_container" disabled="disabled" style="display: none;"/> <input type="text" t-att-name="widget.name" + t-att-placeholder="widget.getParent().node.attrs.placeholder" t-attf-class="oe_datepicker_master field_#{widget.type_of_date} oe_form_field_#{widget.type_of_date}" /><img class="oe_input_icon oe_datepicker_trigger" t-att-src='_s + "/web/static/src/img/ui/field_calendar.png"' title="Select date" width="16" height="16" border="0"/> @@ -1014,6 +1045,7 @@ t-att-id="widget.id_for_label" t-att-tabindex="widget.node.attrs.tabindex" t-att-autofocus="widget.node.attrs.autofocus" + t-att-placeholder="widget.node.attrs.placeholder" /> <span class="oe-m2o-drop-down-button"> <img t-att-src='_s + "/web/static/src/img/down-arrow.png"' /></span> |
