diff options
| author | Sanjay Gohel (Open ERP) <sgo@tinyerp.com> | 2012-07-19 14:44:46 +0530 |
|---|---|---|
| committer | Sanjay Gohel (Open ERP) <sgo@tinyerp.com> | 2012-07-19 14:44:46 +0530 |
| commit | 7692acdc2cda0df2806b037b786f4825df05545a (patch) | |
| tree | 0e151b1a0c00aded19a22ec174f87b6d61598f2b /addons/web/static/src | |
| parent | ff71d6d1ade22e9e1299f81a6a05043466de26ba (diff) | |
[IMP]statusbar widget improve for stages clickable
bzr revid: sgo@tinyerp.com-20120719091446-qg93k0j6gqlb8udj
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 408 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 51 |
2 files changed, 190 insertions, 269 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 677b7cf7c4e..b615c9af6cd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -80,7 +80,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.reload_mutex = new $.Mutex(); this.__clicked_inside = false; this.__blur_timeout = null; - this.rendering_engine = new instance.web.form.FormRenderingEngine(this); + this.rendering_engine = new instance.web.form.FormRenderingEngineReadonly(this); this.qweb = null; // A QWeb instance will be created if the view is a QWeb template }, destroy: function() { @@ -239,13 +239,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } } }, - /** - * - * @param {Object} [options] - * @param {Boolean} [editable=false] whether the form should be switched to edition mode. A value of ``false`` will keep the current mode. - * @param {Boolean} [reload=true] whether the form should reload its content on show, or use the currently loaded record - * @return {$.Deferred} - */ do_show: function (options) { var self = this; options = options || {}; @@ -260,24 +253,23 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } this.$element.show().css('visibility', 'hidden'); this.$element.add(this.$buttons).removeClass('oe_form_dirty'); - - var shown = this.has_been_loaded; - if (options.reload !== false) { - shown = shown.pipe(function() { - if (self.dataset.index === null) { - // null index means we should start a new record - return self.on_button_new(); - } - return self.dataset.read_index(_.keys(self.fields_view.fields), { - context: { 'bin_size': true } + return this.has_been_loaded.pipe(function() { + var result; + if (self.dataset.index === null) { + // null index means we should start a new record + result = self.on_button_new(); + } else { + result = self.dataset.read_index(_.keys(self.fields_view.fields), { + context : { 'bin_size' : true } }).pipe(self.on_record_loaded); - }); - } - return shown.pipe(function() { - if (options.editable) { - self.set({mode: "edit"}); } - self.$element.css('visibility', 'visible'); + result.pipe(function() { + if (options.editable) { + self.set({mode: "edit"}); + } + self.$element.css('visibility', 'visible'); + }); + return result; }); }, do_hide: function () { @@ -338,20 +330,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.$element.add(self.$buttons).removeClass('oe_form_dirty'); }); }, - /** - * Loads and sets up the default values for the model as the current - * record - * - * @return {$.Deferred} - */ - load_defaults: function () { - var keys = _.keys(this.fields_view.fields); - if (keys.length) { - return this.dataset.default_get(keys) - .pipe(this.on_record_loaded); - } - return this.on_record_loaded({}); - }, on_form_changed: function() { this.trigger("view_content_has_changed"); }, @@ -622,11 +600,22 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM on_button_new: function() { var self = this; this.set({mode: "edit"}); - return $.when(this.has_been_loaded).pipe(function() { + var def = $.Deferred(); + $.when(this.has_been_loaded).then(function() { if (self.can_be_discarded()) { - return self.load_defaults(); + var keys = _.keys(self.fields_view.fields); + if (keys.length) { + self.dataset.default_get(keys).pipe(self.on_record_loaded).then(function() { + def.resolve(); + }); + } else { + self.on_record_loaded({}).then(function() { + def.resolve(); + }); + } } }); + return def.promise(); }, on_button_edit: function() { return this.set({mode: "edit"}); @@ -685,14 +674,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM values = {}, first_invalid_field = null; for (var f in self.fields) { - if (!self.fields.hasOwnProperty(f)) { continue; } f = self.fields[f]; if (!f.is_valid()) { form_invalid = true; if (!first_invalid_field) { first_invalid_field = f; } - } else if (f.name !== 'id' && (!self.datarecord.id || (!f.get("readonly") && f._dirty_flag))) { + } else if (f.name !== 'id' && !f.get("readonly") && (!self.datarecord.id || f._dirty_flag)) { // Special case 'id' field, do not save this field // on 'create' : save all non readonly fields // on 'edit' : save non readonly modified fields @@ -701,9 +689,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } if (form_invalid) { self.set({'display_invalid_fields': true}); - for (var g in self.fields) { - if (!self.fields.hasOwnProperty(g)) { continue; } - self.fields[g]._check_css_flags(); + for (var f in self.fields) { + self.fields[f]._check_css_flags(); } first_invalid_field.focus(); self.on_invalid(); @@ -735,15 +722,14 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM });}); }, on_invalid: function() { - var warnings = _(this.fields).chain() - .filter(function (f) { return !f.is_valid(); }) - .map(function (f) { - return _.str.sprintf('<li>%s</li>', - _.escape(f.string)); - }).value(); - warnings.unshift('<ul>'); - warnings.push('</ul>'); - this.do_warn("The following fields are invalid :", warnings.join('')); + var msg = "<ul>"; + _.each(this.fields, function(f) { + if (!f.is_valid()) { + msg += "<li>" + f.string + "</li>"; + } + }); + msg += "</ul>"; + this.do_warn("The following fields are invalid :", msg); }, on_saved: function(r, success) { if (!r.result) { @@ -821,10 +807,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var ids = this.get_selected_ids(); values["id"] = ids.length > 0 ? ids[0] : false; _.each(this.fields, function(value_, key) { - if (_.include(blacklist, key)) { + if (_.include(blacklist, key)) return; - } - values[key] = value_.get_value(); + var val = value_.get_value(); + values[key] = val; }); return values; }, @@ -879,9 +865,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return option[0] === value; })[1]; break; - case 'many2one': - displayed = field.get_displayed(); - break; } return { @@ -959,9 +942,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM is_create_mode: function() { return !this.datarecord.id; }, - open_translate_dialog: function(field) { - return this._super(field); - }, }); /** @@ -1005,6 +985,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } }); } + selector = 'form[version!="7.0"] page,form[version!="7.0"]'; }, render_to: function($target) { var self = this; @@ -1138,7 +1119,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt if (found) return; - var $label = $('<label/>').attr({ + $label = $('<label/>').attr({ 'for' : name, "modifiers": JSON.stringify({invisible: field_modifiers.invisible}), "string": $field.attr('string'), @@ -1352,7 +1333,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt return $new_label; }, handle_common_properties: function($new_element, $node) { - var str_modifiers = $node.attr("modifiers") || "{}"; + var str_modifiers = $node.attr("modifiers") || "{}" var modifiers = JSON.parse(str_modifiers); var ic = null; if (modifiers.invisible !== undefined) @@ -1363,6 +1344,12 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt }, }); +instance.web.form.FormRenderingEngineReadonly = instance.web.form.FormRenderingEngine.extend({ + alter_field: function(field) { + field.set({"force_readonly": true}); + }, +}); + instance.web.form.FormDialog = instance.web.Dialog.extend({ init: function(parent, options, view_id, dataset) { this._super(parent, options); @@ -1471,27 +1458,24 @@ instance.web.form.compute_domain = function(expr, fields) { */ instance.web.form.InvisibilityChangerMixin = { init: function(field_manager, invisible_domain) { - var self = this; - this._ic_field_manager = field_manager; + this._ic_field_manager = field_manager this._ic_invisible_modifier = invisible_domain; this._ic_field_manager.on("view_content_has_changed", this, function() { - var result = self._ic_invisible_modifier === undefined ? false : - instance.web.form.compute_domain( - self._ic_invisible_modifier, - self._ic_field_manager.fields); - self.set({"invisible": result}); + var result = this._ic_invisible_modifier === undefined ? false : + instance.web.form.compute_domain(this._ic_invisible_modifier, this._ic_field_manager.fields); + this.set({"invisible": result}); }); this.set({invisible: this._ic_invisible_modifier === true, force_invisible: false}); var check = function() { - if (self.get("invisible") || self.get('force_invisible')) { - self.set({"effective_invisible": true}); + if (this.get("invisible") || this.get('force_invisible')) { + this.set({"effective_invisible": true}); } else { - self.set({"effective_invisible": false}); + this.set({"effective_invisible": false}); } }; this.on('change:invisible', this, check); this.on('change:force_invisible', this, check); - check.call(this); + _.bind(check, this)(); }, start: function() { this.on("change:effective_invisible", this, this._check_visibility); @@ -1555,7 +1539,6 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi var compute_domain = instance.web.form.compute_domain; var to_set = {}; for (var a in this.modifiers) { - if (!this.modifiers.hasOwnProperty(a)) { continue; } if (!_.include(["invisible"], a)) { var val = compute_domain(this.modifiers[a], this.view.fields); to_set[a] = val; @@ -1702,7 +1685,11 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ on_confirmed: function() { var self = this; - var context = this.build_context(); + var context = this.node.attrs.context; + if (context && context.__ref) { + context = new instance.web.CompoundContext(context); + context.set_eval_context(this._build_eval_context()); + } return this.view.do_execute_action( _.extend({}, this.node.attrs, {context: context}), @@ -1755,18 +1742,18 @@ instance.web.form.FieldInterface = { /** * Get the current value of the widget. * - * Must always return a syntactically correct value to be passed to the "write" method of the osv class in + * Must always return a syntaxically correct value to be passed to the "write" method of the osv class in * the OpenERP server, although it is not assumed to respect the constraints applied to the field. - * For example if the field is marked as "required", a call to get_value() can return false. + * For example if the field is marqued as "required", a call to get_value() can return false. * * get_value() can also be called *before* a call to set_value() and, in that case, is supposed to - * return a default value according to the type of field. + * return a defaut value according to the type of field. * * This method is always assumed to perform synchronously, it can not return a promise. * * If there was no user interaction to modify the value of the field, it is always assumed that * get_value() return the same semantic value than the one passed in the last call to set_value(), - * although the syntax can be different. This can be the case for type of fields that have a different + * altough the syntax can be different. This can be the case for type of fields that have a different * syntax for "read" and "write" (example: m2o: set_value([0, "Administrator"]), get_value() => 0). */ get_value: function() {}, @@ -1781,7 +1768,7 @@ instance.web.form.FieldInterface = { */ is_valid: function() {}, /** - * Returns true if the field holds a value which is syntactically correct, ignoring + * Returns true if the field holds a value which is syntaxically correct, ignoring * the potential semantic restrictions applied to the field. */ is_syntax_valid: function() {}, @@ -1811,7 +1798,6 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w * @param node */ init: function(field_manager, node) { - var self = this this._super(field_manager, node); this.field_manager = field_manager; this.name = this.node.attrs.name; @@ -1824,13 +1810,13 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w // some events to make the property "effective_readonly" sync automatically with "readonly" and // "force_readonly" this.set({"readonly": this.modifiers['readonly'] === true}); - this.set({"force_readonly": false}); var test_effective_readonly = function() { - self.set({"effective_readonly": self.get("readonly") || !!self.get("force_readonly")}); + this.set({"effective_readonly": this.get("readonly") || !!this.get("force_readonly")}); }; this.on("change:readonly", this, test_effective_readonly); this.on("change:force_readonly", this, test_effective_readonly); - test_effective_readonly.call(this); + _.bind(test_effective_readonly, this)(); + this.on("change:value", this, function() { if (! this._inhibit_on_change) this.trigger('changed_value'); @@ -1907,7 +1893,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w */ delay_focus: function($elem) { setTimeout(function() { - $elem[0].focus(); + $elem.focus(); }, 50); }, /** @@ -2250,11 +2236,6 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we } else { this.$textarea.attr('disabled', 'disabled'); } - this.$element.keyup(function (e) { - if (e.which === $.ui.keyCode.ENTER) { - e.stopPropagation(); - } - }); this.setupFocus(this.$textarea); }, set_value: function(value_) { @@ -2307,58 +2288,9 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we }, }); -/** - * FieldTextHtml Widget - * Intended for FieldText widgets meant to display HTML content. This - * widget will instantiate the CLEditor (see cleditor in static/src/lib) - * To find more information about CLEditor configutation: go to - * http://premiumsoftware.net/cleditor/docs/GettingStarted.html - */ -instance.web.form.FieldTextHtml = instance.web.form.FieldText.extend({ - - initialize_content: function() { - this.$textarea = this.$element.find('textarea'); - var width = ((this.node.attrs || {}).editor_width || 468); - var height = ((this.node.attrs || {}).editor_height || 100); - this.$textarea.cleditor({ - width: width, // width not including margins, borders or padding - height: height, // height not including margins, borders or padding - controls: // controls to add to the toolbar - "bold italic underline strikethrough | size " + - "| removeformat | bullets numbering | outdent " + - "indent | link unlink", - sizes: // sizes in the font size popup - "1,2,3,4,5,6,7", - bodyStyle: // style to assign to document body contained within the editor - "margin:4px; font:12px monospace; cursor:text; color:#1F1F1F" - }); - this.$cleditor = this.$textarea.cleditor()[0]; - // call super now, because cleditor resets the disable attr - this._super.apply(this, arguments); - // propagate disabled property to cleditor - this.$cleditor.disable(this.$textarea.prop('disabled')); - }, - - set_value: function(value_) { - this._super.apply(this, arguments); - this._dirty_flag = true; - }, - - render_value: function() { - this._super.apply(this, arguments); - this.$cleditor.updateFrame(); - }, - - get_value: function() { - this.$cleditor.updateTextArea(); - return this.$textarea.val(); - }, -}); - instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ template: 'FieldBoolean', start: function() { - var self = this; this._super.apply(this, arguments); this.$checkbox = $("input", this.$element); this.setupFocus(this.$checkbox); @@ -2366,10 +2298,10 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ this.set({'value': this.$checkbox.is(':checked')}); }, this)); var check_readonly = function() { - self.$checkbox.prop('disabled', self.get("effective_readonly")); + this.$checkbox.prop('disabled', this.get("effective_readonly")); }; this.on("change:effective_readonly", this, check_readonly); - check_readonly.call(this); + _.bind(check_readonly, this)(); }, set_value: function(value_) { this._super.apply(this, arguments); @@ -2832,7 +2764,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc }); return false; }); - $(".oe_form_m2o_follow", this.$element).html(follow); + $(".oe_form_m2o_follow").html(follow); } }, set_value: function(value_) { @@ -2849,9 +2781,6 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this._super(value_); this.inhibit_on_change = false; }, - get_displayed: function() { - return this.display_value["" + this.get("value")]; - }, add_id: function(id) { this.display_value = {}; this.set({value: id}); @@ -2982,7 +2911,6 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ selectable: self.multi_selection, sortable: false, import_enabled: false, - deletable: true }); if (self.get("effective_readonly")) { _.extend(view.options, { @@ -3212,7 +3140,6 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({ form: 'instance.web.form.One2ManyFormView', kanban: 'instance.web.form.One2ManyKanbanView', }); - this.__ignore_blur = false; }, switch_view: function(mode, unused) { if (mode !== 'form') { @@ -3262,34 +3189,19 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ this._super(parent, dataset, view_id, _.extend(options || {}, { ListType: instance.web.form.One2ManyList })); - this.on('edit:before', this, this.proxy('_before_edit')); - this.on('save:before cancel:before', this, this.proxy('_before_unedit')); - - this.records - .bind('add', this.proxy("changed_records")) - .bind('edit', this.proxy("changed_records")) - .bind('remove', this.proxy("changed_records")); - }, - start: function () { - var ret = this._super(); - this.$element - .off('mousedown.handleButtons') - .on('mousedown.handleButtons', 'table button', this.proxy('_button_down')); - return ret; - }, - changed_records: function () { - this.o2m.trigger_on_change(); }, is_valid: function () { - var form = this.editor.form; - + var form; + // A list not being edited is always valid + if (!(form = this.first_edition_form())) { + return true; + } // If the form has not been modified, the view can only be valid // NB: is_dirty will also be set on defaults/onchanges/whatever? // oe_form_dirty seems to only be set on actual user actions if (!form.$element.is('.oe_form_dirty')) { return true; } - this.o2m._dirty_flag = true; // Otherwise validate internal form return _(form.fields).chain() @@ -3300,6 +3212,19 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ .all(_.identity) .value(); }, + first_edition_form: function () { + var get_form = function (group_or_list) { + if (group_or_list.edition) { + return group_or_list.edition_form; + } + return _(group_or_list.children).chain() + .map(get_form) + .compact() + .first() + .value(); + }; + return get_form(this.groups); + }, do_add_record: function () { if (this.options.editable) { this._super.apply(this, arguments); @@ -3354,58 +3279,55 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); }, do_button_action: function (name, id, callback) { - if (!_.isNumber(id)) { - instance.webclient.notification.warn( - _t("Action Button"), - _t("The o2m record must be saved before an action can be used")); - return; - } - var parent_form = this.o2m.view; - var self = this; - this.ensure_saved().pipe(function () { - return parent_form.do_save(); - }).then(function () { - self.handle_button(name, id, callback); + var _super = _.bind(this._super, this); + + this.o2m.view.do_save().then(function () { + _super(name, id, callback); }); - }, + } +}); +instance.web.form.One2ManyList = instance.web.ListView.List.extend({ + KEY_RETURN: 13, + // blurring caused by hitting the [Return] key, should skip the + // autosave-on-blur and let the handler for [Return] do its thing + __return_blur: false, + render_row_as_form: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + // Replace the "Save Row" button with "Cancel Edition" + self.edition_form.$element + .undelegate('button.oe_list_edit_row_save', 'click') + .delegate('button.oe_list_edit_row_save', 'click', function () { + self.cancel_pending_edition(); + }); - _before_edit: function () { - this.__ignore_blur = false; - this.editor.form.on('blurred', this, this._on_form_blur); - }, - _before_unedit: function () { - this.editor.form.off('blurred', this, this._on_form_blur); - }, - _button_down: function () { - // If a button is clicked (usually some sort of action button), it's - // the button's responsibility to ensure the editable list is in the - // correct state -> ignore form blurring - this.__ignore_blur = true; + // Overload execute_action on the edition form to perform a simple + // reload_record after the action is done, rather than fully + // reload the parent view (or something) + var _execute_action = self.edition_form.do_execute_action; + self.edition_form.do_execute_action = function (action, dataset, record_id, _callback) { + return _execute_action.call(this, action, dataset, record_id, function () { + self.view.reload_record( + self.view.records.get(record_id)); + }); + }; + + self.edition_form.on('blurred', null, function () { + if (self.__return_blur) { + delete self.__return_blur; + return; + } + if (!self.edition_form.widget_is_stopped) { + self.view.ensure_saved(); + } + }); + }); }, - /** - * Handles blurring of the nested form (saves the currently edited row), - * unless the flag to ignore the event is set to ``true`` - * - * Makes the internal form go away - */ - _on_form_blur: function () { - if (this.__ignore_blur) { - this.__ignore_blur = false; - return; - } - // FIXME: why isn't there an API for this? - if (this.editor.form.$element.hasClass('oe_form_dirty')) { - this.save_edition(); - return; + on_row_keyup: function (e) { + if (e.which === this.KEY_RETURN) { + this.__return_blur = true; } - this.cancel_edition(); - }, - keyup_ENTER: function () { - // blurring caused by hitting the [Return] key, should skip the - // autosave-on-blur and let the handler for [Return] do its thing (save - // the current row *anyway*, then create a new one/edit the next one) - this.__ignore_blur = true; - this._super.apply(this, arguments); + this._super(e); } }); @@ -3574,7 +3496,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({ }, start: function() { this._super.apply(this, arguments); - this.$element.addClass('oe_form_field oe_form_field_many2many'); + this.$element.addClass('oe_form_field_many2many'); var self = this; @@ -3949,16 +3871,14 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ display_popup: function() { var self = this; this.renderElement(); - var dialog = new instance.web.Dialog(this, { + new instance.web.Dialog(this, { min_width: '800px', - dialogClass: 'oe_act_window', + dialogClass: 'oe_act_window', close: function() { self.check_exit(true); }, title: this.options.title || "", - buttons: [{text:"tmp"}], }, this.$element).open(); - this.$buttonpane = dialog.$element.dialog("widget").find(".ui-dialog-buttonpane").html(""); this.start(); }, on_write_completed: function() {}, @@ -3974,18 +3894,16 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ if (this.row_id !== null) { options.initial_mode = this.options.readonly ? "view" : "edit"; } - _.extend(options, { - $buttons: this.$buttonpane, - }); this.view_form = new instance.web.FormView(this, this.dataset, false, options); if (this.options.alternative_form_view) { this.view_form.set_embedded_view(this.options.alternative_form_view); } this.view_form.appendTo(this.$element.find(".oe_popup_form")); this.view_form.on_loaded.add_last(function() { + var $buttons = self.view_form.$element.find(".oe_form_buttons"); var multi_select = self.row_id === null && ! self.options.disable_multiple_selection; - self.$buttonpane.html(QWeb.render("AbstractFormPopup.buttons", {multi_select: multi_select})); - var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new"); + $buttons.html(QWeb.render("AbstractFormPopup.buttons", {multi_select: multi_select})); + var $snbutton = $buttons.find(".oe_abstractformpopup-form-save-new"); $snbutton.click(function() { $.when(self.view_form.do_save()).then(function() { self.view_form.reload_mutex.exec(function() { @@ -3993,7 +3911,7 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ }); }); }); - var $sbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save"); + var $sbutton = $buttons.find(".oe_abstractformpopup-form-save"); $sbutton.click(function() { $.when(self.view_form.do_save()).then(function() { self.view_form.reload_mutex.exec(function() { @@ -4001,7 +3919,7 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ }); }); }); - var $cbutton = self.$buttonpane.find(".oe_abstractformpopup-form-close"); + var $cbutton = $buttons.find(".oe_abstractformpopup-form-close"); $cbutton.click(function() { self.check_exit(); }); @@ -4110,7 +4028,6 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend 'selectable': !self.options.disable_multiple_selection, 'read_only': true, 'import_enabled': false, - '$buttons': self.$buttonpane, }, self.options.list_view_options || {})); self.view_list.popup = self; self.view_list.appendTo($(".oe_popup_list", self.$element)).pipe(function() { @@ -4119,12 +4036,16 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend self.searchview.do_search(); }); self.view_list.on_loaded.add_last(function() { - self.$buttonpane.html(QWeb.render("SelectCreatePopup.search.buttons", {widget:self})); - var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-close"); + var $buttons = self.view_list.$element.find(".oe-actions"); + $buttons.prepend(QWeb.render("SelectCreatePopup.search.buttons")); + var $cbutton = $buttons.find(".oe_selectcreatepopup-search-close"); $cbutton.click(function() { self.destroy(); }); - var $sbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-select"); + var $sbutton = $buttons.find(".oe_selectcreatepopup-search-select"); + if(self.options.disable_multiple_selection) { + $sbutton.hide(); + } $sbutton.click(function() { self.on_select_elements(self.selected_ids); self.destroy(); @@ -4575,9 +4496,25 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ * state (given by the key of (key, label)). */ render_elements: function () { + var self = this; var content = instance.web.qweb.render("FieldStatus.content", {widget: this, _:_}); this.$element.html(content); - + clickable = this.node.attrs.clickable; + if(clickable == 'true') + { + var elemts = this.$element.find('.oe_form_steps_item') + _.each(elemts, function(element){ + $item = $(element); + if($item.attr("data-id") != self.selected_value){ + $item.attr("style", "cursor: pointer;"); + $item.click(function(event){ + var data_id = parseInt($(this).attr("data-id")) + self.view.dataset.call('stage_set', [[self.view.datarecord.id],data_id]).then(function() { + return self.view.reload();}); + }); + }; + }); + } var colors = JSON.parse((this.node.attrs || {}).statusbar_colors || "{}"); var color = colors[this.selected_value]; if (color) { @@ -4602,7 +4539,6 @@ instance.web.form.widgets = new instance.web.Registry({ 'email' : 'instance.web.form.FieldEmail', 'url' : 'instance.web.form.FieldUrl', 'text' : 'instance.web.form.FieldText', - 'text_html' : 'instance.web.form.FieldTextHtml', 'date' : 'instance.web.form.FieldDate', 'datetime' : 'instance.web.form.FieldDatetime', 'selection' : 'instance.web.form.FieldSelection', diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index ed63b5fbfbe..e387b68ebfb 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -371,7 +371,6 @@ </t> <t t-name="WebClient"> - <div class="openerp openerp_webclient_container"> <table class="oe_webclient"> <tr> <td colspan="2" class="oe_topbar"> @@ -395,13 +394,6 @@ </td> </tr> </table> - </div> -</t> - -<t t-name="EmbedClient"> - <div class="openerp"> - <div class="oe_application"></div> - </div> </t> <t t-name="ViewManager"> @@ -630,9 +622,9 @@ <button type="button" class="oe_button oe_list_add oe_highlight"> <t t-esc="widget.options.addable"/> </button> - <span class="oe_alternative" t-if="widget.options.import_enabled"> + <t t-if="widget.options.import_enabled"> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a> - </span> + </t> </t> </div> <t t-name="ListView.pager"> @@ -652,7 +644,6 @@ <tr t-name="ListView.row" t-att-class="row_parity" t-att-data-id="record.get('id')" t-att-style="view.style_for(record)"> - <t t-set="asData" t-value="record.toForm().data"/> <t t-foreach="columns" t-as="column"> <td t-if="column.meta"> @@ -664,26 +655,23 @@ <input t-if="!options.radio" type="checkbox" name="radiogroup" t-att-checked="checked"/> </th> <t t-foreach="columns" t-as="column"> - <t t-set="number" t-value="column.type === 'integer' or column.type == 'float'"/> - <t t-set="modifiers" t-value="column.modifiers_for(asData)"/> + <t t-set="align" t-value="column.type === 'integer' or column.type == 'float'"/> <td t-if="!column.meta and column.invisible !== '1'" t-att-title="column.help" - t-attf-class="oe_list_field_cell oe_list_field_#{column.widget or column.type} #{number ? 'oe_number' : ''} #{column.tag === 'button' ? 'oe-button' : ''} #{modifiers.readonly ? 'oe_readonly' : ''}" - t-att-data-field="column.id" - ><t t-raw="render_cell(record, column)"/></td> + t-att-class="'oe_list_field_cell' + (align ? ' oe_number' : '') + + (column.tag === 'button' ? ' oe_button' : '')" + t-att-data-field="column.id"> + <t t-raw="render_cell(record, column)"/> + </td> </t> <td t-if="options.deletable" class='oe_list_record_delete' width="1"> <button type="button" name="delete" class="oe_i">d</button> </td> </tr> -<t t-extend="ListView.buttons"> - <t t-jquery="button.oe_list_add" t-operation="after"> - <button class="oe_button oe_list_save oe_highlight" - type="button">Save</button> - </t> - <t t-jquery="a.oe_list_button_import" t-operation="after"> - <a href="#" class="oe_bold oe_list_discard">discard</a> - </t> +<t t-name="ListView.row.save"> + <td> + <button class='oe_i oe_list_edit_row_save' type='button' name='save'/> + </td> </t> <t t-name="FormView"> @@ -960,7 +948,7 @@ <span class="oe_form_m2o_follow"/> </t> <t t-if="!widget.get('effective_readonly')"> - <a href="#" tabindex="-1" class="oe_m2o_cm_button oe_e oe_right">/</a> + <a href="#" class="oe_m2o_cm_button oe_e oe_right">/</a> <div> <input type="text" t-att-id="widget.id_for_label" @@ -1028,7 +1016,7 @@ <t t-set="size" t-value="widget.to_show.length"/> <t t-foreach="_.range(size)" t-as="i"> <li t-att-class="widget.to_show[i][0] === widget.selected_value ? 'oe_form_steps_active' : ''"> - <span><t t-esc="widget.to_show[i][1]"/></span> + <span class="oe_form_steps_item" t-att-data-id="widget.to_show[i][0]"><t t-esc="widget.to_show[i][1]"/></span> <img t-att-src='_s + "/web/static/src/img/form_steps.png"' class="oe_form_steps_arrow" t-if="i < size - 1"/> </li> </t> @@ -1480,11 +1468,8 @@ </div> </t> <t t-name="SelectCreatePopup.search.buttons"> - <t t-if="! widget.options.disable_multiple_selection"> - <button type="button" class="oe_button oe_selectcreatepopup-search-select" disabled="disabled">Select</button> - or - </t> - <a class="oe_button oe_selectcreatepopup-search-close oe_bold oe_form_button_cancel" href="javascript:void(0)">Cancel</a> + <button type="button" class="oe_button oe_selectcreatepopup-search-select" disabled="disabled">Select</button> + <button type="button" class="oe_button oe_selectcreatepopup-search-close">Cancel</button> </t> <t t-name="AbstractFormPopup.buttons"> <t t-if="! multi_select"> @@ -1494,7 +1479,7 @@ <button type="button" class="oe_button oe_abstractformpopup-form-save-new oe_highlight">Save & New</button> <button type="button" class="oe_button oe_abstractformpopup-form-save oe_highlight">Save & Close</button> </t> - or <a class="oe_button oe_abstractformpopup-form-close oe_bold oe_form_button_cancel" href="javascript:void(0)">Cancel</a> + <button type="button" class="oe_button oe_abstractformpopup-form-close">Cancel</button> </t> <t t-extend="ListView.row"> <!-- adds back padding to row being rendered after edition, if necessary @@ -1502,7 +1487,7 @@ missing columns --> <t t-jquery="> :last" t-operation="after"> - <td t-if="edited and !options.deletable" class="oe-listview-padding"/> + <td t-if="edited and !options.deletable" class="oe_list_padding"/> </t> </t> |
