Antony Lesuisse (OpenERP) has proposed merging
lp:~openerp-dev/openerp-web/trunk-access-ui-jam into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-access-ui-jam/+merge/120483
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-access-ui-jam/+merge/120483
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-access-ui-jam.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-08-30 07:20:24 +0000
+++ addons/web/static/src/js/view_form.js 2012-08-31 04:54:18 +0000
@@ -148,9 +148,17 @@
if(this.fields_view.toolbar) {
this.sidebar.add_toolbar(this.fields_view.toolbar);
}
+ if (self._is_action_enabled('delete')){
+ this.sidebar.add_items('other', [
+ { label: _t('Delete'), callback: self.on_button_delete },
+ ]);
+ }
+ if (self._is_action_enabled('create')){
+ this.sidebar.add_items('other', [
+ { label: _t('Duplicate'), callback: self.on_button_duplicate }
+ ]);
+ }
this.sidebar.add_items('other', [
- { label: _t('Delete'), callback: self.on_button_delete },
- { label: _t('Duplicate'), callback: self.on_button_duplicate },
{ label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } }
]);
}
@@ -3454,7 +3462,8 @@
}
},
do_activate_record: function(index, id) {
- var self = this;
+ var self = this,
+ attr_readonly = (_.has(this.fields_view.arch.attrs, 'edit'))?JSON.parse(this.fields_view.arch.attrs.edit):true;
var pop = new instance.web.form.FormOpenPopup(self.o2m.view);
pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), {
title: _t("Open: ") + self.o2m.string,
@@ -3470,7 +3479,7 @@
return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments);
},
form_view_options: {'not_interactible_on_create':true},
- readonly: self.o2m.get("effective_readonly")
+ readonly: attr_readonly ? self.o2m.get("effective_readonly") : true,
});
},
do_button_action: function (name, id, callback) {
@@ -3558,7 +3567,7 @@
});
instance.web.form.One2ManyList = instance.web.ListView.List.extend({
pad_table_to: function (count) {
- this._super(count > 0 ? count - 1 : 0);
+ this._super(this.view._is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length);
// magical invocation of wtf does that do
if (this.view.o2m.get('effective_readonly')) {
@@ -3571,36 +3580,38 @@
}).length;
if (this.options.selectable) { columns++; }
if (this.options.deletable) { columns++; }
- var $cell = $('<td>', {
- colspan: columns,
- 'class': 'oe_form_field_one2many_list_row_add'
- }).append(
- $('<a>', {href: '#'}).text(_t("Add a row"))
- .mousedown(function () {
- // FIXME: needs to be an official API somehow
- if (self.view.editor.is_editing()) {
- self.view.__ignore_blur = true;
- }
- })
- .click(function (e) {
- e.preventDefault();
- e.stopPropagation();
- // FIXME: there should also be an API for that one
- if (self.view.editor.form.__blur_timeout) {
- clearTimeout(self.view.editor.form.__blur_timeout);
- self.view.editor.form.__blur_timeout = false;
- }
- self.view.ensure_saved().then(function () {
- self.view.do_add_record();
- });
- }));
+ if (this.view._is_action_enabled('create')){
+ var $cell = $('<td>', {
+ colspan: columns,
+ 'class': 'oe_form_field_one2many_list_row_add'
+ }).append(
+ $('<a>', {href: '#'}).text(_t("Add a row"))
+ .mousedown(function () {
+ // FIXME: needs to be an official API somehow
+ if (self.view.editor.is_editing()) {
+ self.view.__ignore_blur = true;
+ }
+ })
+ .click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ // FIXME: there should also be an API for that one
+ if (self.view.editor.form.__blur_timeout) {
+ clearTimeout(self.view.editor.form.__blur_timeout);
+ self.view.editor.form.__blur_timeout = false;
+ }
+ self.view.ensure_saved().then(function () {
+ self.view.do_add_record();
+ });
+ }));
- var $padding = this.$current.find('tr:not([data-id]):first');
- var $newrow = $('<tr>').append($cell);
- if ($padding.length) {
- $padding.before($newrow);
- } else {
- this.$current.append($newrow)
+ var $padding = this.$current.find('tr:not([data-id]):first');
+ var $newrow = $('<tr>').append($cell);
+ if ($padding.length) {
+ $padding.before($newrow);
+ } else {
+ this.$current.append($newrow)
+ }
}
}
});
=== modified file 'addons/web/static/src/js/view_list.js'
--- addons/web/static/src/js/view_list.js 2012-08-24 18:27:07 +0000
+++ addons/web/static/src/js/view_list.js 2012-08-31 04:54:18 +0000
@@ -351,11 +351,19 @@
if (!this.sidebar && this.options.$sidebar) {
this.sidebar = new instance.web.Sidebar(this);
this.sidebar.appendTo(this.options.$sidebar);
+ if (self._is_action_enabled('create')){
+ this.sidebar.add_items('other', [
+ { label: _t("Import"), callback: this.on_sidebar_import }
+ ]);
+ }
this.sidebar.add_items('other', [
- { label: _t("Import"), callback: this.on_sidebar_import },
- { label: _t("Export"), callback: this.on_sidebar_export },
- { label: _t('Delete'), callback: this.do_delete_selected }
+ { label: _t("Export"), callback: this.on_sidebar_export }
]);
+ if (self._is_action_enabled('delete')){
+ this.sidebar.add_items('other', [
+ { label: _t('Delete'), callback: this.do_delete_selected }
+ ]);
+ }
this.sidebar.add_toolbar(this.fields_view.toolbar);
this.sidebar.$el.hide();
}
=== modified file 'addons/web/static/src/js/view_list_editable.js'
--- addons/web/static/src/js/view_list_editable.js 2012-08-29 10:23:00 +0000
+++ addons/web/static/src/js/view_list_editable.js 2012-08-31 04:54:18 +0000
@@ -750,7 +750,7 @@
instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{
row_clicked: function (event) {
- if (!this.view.editable()) {
+ if (!this.view.editable() || ! this.view._is_action_enabled('edit')) {
return this._super.apply(this, arguments);
}
var record_id = $(event.currentTarget).data('id');
=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js 2012-08-30 10:27:46 +0000
+++ addons/web/static/src/js/views.js 2012-08-31 04:54:18 +0000
@@ -1357,6 +1357,14 @@
*/
reload: function () {
return $.when();
+ },
+ _is_action_enabled: function(action) {
+ /**
+ * Takes action (e.g. create/edit/delete) and return the tag attribute from
+ * the view (e.g. <from string="" create="false" edit="false" delete="false">)
+ * will help to check access ui of the view.
+ */
+ return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true;
}
});
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2012-08-30 14:34:12 +0000
+++ addons/web/static/src/xml/base.xml 2012-08-31 04:54:18 +0000
@@ -635,7 +635,7 @@
<t t-if="column.tag !== 'button'"><t t-esc="column.string"/></t>
</th>
</t>
- <th t-if="options.deletable" width="13px"/>
+ <th t-if="options.deletable and _is_action_enabled('delete')" width="13px"/>
</tr>
</thead>
<tfoot>
@@ -644,12 +644,12 @@
<td t-foreach="aggregate_columns" t-as="column" class="oe_list_footer oe_number"
t-att-data-field="column.id" t-att-title="column.label">
</td>
- <td t-if="options.deletable"/>
+ <td t-if="options.deletable and _is_action_enabled('delete')"/>
</tr>
</tfoot>
</table>
<div t-name="ListView.buttons" class="oe_list_buttons">
- <t t-if="!widget.no_leaf and widget.options.action_buttons !== false and widget.options.addable">
+ <t t-if="!widget.no_leaf and widget.options.action_buttons !== false and widget.options.addable and widget._is_action_enabled('create')">
<button type="button" class="oe_button oe_list_add oe_highlight">
<t t-esc="widget.options.addable"/>
</button>
@@ -691,7 +691,7 @@
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="13px">
+ <td t-if="options.deletable and view._is_action_enabled('delete')" class='oe_list_record_delete' width="13px">
<button type="button" name="delete" class="oe_i">d</button>
</td>
</tr>
@@ -725,10 +725,14 @@
<div t-name="FormView.buttons" class="oe_form_buttons">
<t t-if="widget.options.action_buttons !== false">
<span class="oe_form_buttons_view">
- <div style="display: inline-block;"> <!-- required for the bounce effect on button -->
- <button type="button" class="oe_button oe_form_button_edit">Edit</button>
- </div>
+ <t t-if="widget._is_action_enabled('edit')">
+ <div style="display: inline-block;"> <!-- required for the bounce effect on button -->
+ <button type="button" class="oe_button oe_form_button_edit">Edit</button>
+ </div>
+ </t>
+ <t t-if="widget._is_action_enabled('create')">
<button type="button" class="oe_button oe_form_button_create">Create</button>
+ </t>
</span>
<span class="oe_form_buttons_edit">
<button type="button" class="oe_button oe_form_button_save oe_highlight">Save</button> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_form_button_cancel">Discard</a>
=== modified file 'addons/web_diagram/static/src/js/diagram.js'
--- addons/web_diagram/static/src/js/diagram.js 2012-08-24 18:27:07 +0000
+++ addons/web_diagram/static/src/js/diagram.js 2012-08-31 04:54:18 +0000
@@ -47,7 +47,7 @@
return label.tag == "label";
});
- this.$el.html(QWeb.render("DiagramView", this));
+ this.$el.html(QWeb.render("DiagramView", {'widget': this}));
this.$el.addClass(this.fields_view.arch.attrs['class']);
_.each(self.labels,function(label){
=== modified file 'addons/web_diagram/static/src/xml/base_diagram.xml'
--- addons/web_diagram/static/src/xml/base_diagram.xml 2012-08-19 12:46:07 +0000
+++ addons/web_diagram/static/src/xml/base_diagram.xml 2012-08-31 04:54:18 +0000
@@ -2,9 +2,11 @@
<t t-name="DiagramView">
<div class="oe_diagram_header" t-att-id="element_id + '_header'">
<h3 class="oe_diagram_title"/>
- <div class="oe_diagram_buttons">
- <button type="button" id="new_node" class="oe_button oe_diagram_button_new">New Node</button>
- </div>
+ <t t-if="widget._is_action_enabled('create')">
+ <div class="oe_diagram_buttons">
+ <button type="button" id="new_node" class="oe_button oe_diagram_button_new">New Node</button>
+ </div>
+ </t>
<div class="oe_diagram_pager">
<t t-call="ViewPager">
<span class="oe_pager_index">0</span> / <span class="oe_pager_count">0</span>
=== modified file 'addons/web_gantt/static/src/js/gantt.js'
--- addons/web_gantt/static/src/js/gantt.js 2012-08-24 18:27:07 +0000
+++ addons/web_gantt/static/src/js/gantt.js 2012-08-31 04:54:18 +0000
@@ -183,12 +183,13 @@
self.on_task_display(task_info.internal_task);
}
});
-
- // insertion of create button
- var td = $($("table td", self.$el)[0]);
- var rendered = QWeb.render("GanttView-create-button");
- $(rendered).prependTo(td);
- $(".oe_gantt_button_create", this.$el).click(this.on_task_create);
+ if (this._is_action_enabled('create')){
+ // insertion of create button
+ var td = $($("table td", self.$el)[0]);
+ var rendered = QWeb.render("GanttView-create-button");
+ $(rendered).prependTo(td);
+ $(".oe_gantt_button_create", this.$el).click(this.on_task_create);
+ }
},
on_task_changed: function(task_obj) {
var self = this;
=== modified file 'addons/web_kanban/static/src/js/kanban.js'
--- addons/web_kanban/static/src/js/kanban.js 2012-08-29 11:47:13 +0000
+++ addons/web_kanban/static/src/js/kanban.js 2012-08-31 04:54:18 +0000
@@ -71,11 +71,11 @@
return JSON.parse(this.fields_view.arch.attrs.quick_create);
return !! this.group_by;
},
- _is_create_enabled: function() {
+ _is_action_enabled: function(action) {
if (! this.options.creatable)
return false;
- if (this.fields_view.arch.attrs.create !== undefined)
- return JSON.parse(this.fields_view.arch.attrs.create);
+ if (_.has(this.fields_view.arch.attrs, action))
+ return JSON.parse(this.fields_view.arch.attrs[action]);
return true;
},
add_qweb_template: function() {
@@ -635,7 +635,12 @@
self.view.dataset.ids.push(id);
self.do_add_records(records, true);
});
- }
+ },
+ _is_action_enabled: function(action) {
+ if (_.has(this.fields_view.arch.attrs, action))
+ return JSON.parse(this.fields_view.arch.attrs[action]);
+ return true;
+ }
});
instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
@@ -737,7 +742,9 @@
var $action = $(this),
type = $action.data('type') || 'button',
method = 'do_action_' + (type === 'action' ? 'object' : type);
- if (_.str.startsWith(type, 'switch_')) {
+ if ((type === 'edit' || type === 'delete') && ! self.view._is_action_enabled(type)){
+ self.view.open_record(self.id);
+ } else if (_.str.startsWith(type, 'switch_')) {
self.view.do_switch_view(type.substr(7));
} else if (typeof self[method] === 'function') {
self[method]($action);
@@ -907,6 +914,9 @@
},
kanban_compute_domain: function(domain) {
return instance.web.form.compute_domain(domain, this.values);
+ },
+ _is_action_enabled: function(action) {
+ return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true;
}
});
=== modified file 'addons/web_kanban/static/src/xml/web_kanban.xml'
--- addons/web_kanban/static/src/xml/web_kanban.xml 2012-08-27 14:03:10 +0000
+++ addons/web_kanban/static/src/xml/web_kanban.xml 2012-08-31 04:54:18 +0000
@@ -14,7 +14,7 @@
</t>
<div t-name="KanbanView.buttons" class="oe_kanban_buttons">
<t t-if="widget.options.action_buttons !== false">
- <t t-if="widget._is_create_enabled()">
+ <t t-if="widget._is_action_enabled('create')">
<button type="button" class="oe_kanban_button_new oe_highlight">
<t t-esc="widget.options.create_text || _t('Create')"/>
</button>
@@ -28,7 +28,7 @@
<t t-name="KanbanView.group_header">
<td class="oe_kanban_group_header">
<t t-if="widget.view.group_by">
- <div class="oe_kanban_header">
+ <div class="oe_kanban_header oe_semantic_html_override">
<t t-if="widget.view._is_quick_create_enabled()">
<div class="oe_kanban_add oe_e">]</div>
</t>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp