Add support for plugins and add translate view as example
issue7942 review54461002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add support for plugins
|
||||
* Add support for expand, height and width attributes
|
||||
* Add drag & drop support on attachment button
|
||||
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ module.exports = function(grunt) {
|
||||
'src/window.js',
|
||||
'src/wizard.js',
|
||||
'src/board.js',
|
||||
'src/bus.js'
|
||||
'src/bus.js',
|
||||
'src/plugins.js'
|
||||
];
|
||||
|
||||
// Project configuration.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/* This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var Translate = {};
|
||||
Translate.translate_view = function(data) {
|
||||
var model = data.model;
|
||||
Sao.Tab.create({
|
||||
model: 'ir.translation',
|
||||
domain: [['model', '=', model]],
|
||||
mode: ['tree', 'form'],
|
||||
name: Sao.i18n.gettext('Translate view'),
|
||||
});
|
||||
};
|
||||
Translate.get_plugins = function(model) {
|
||||
var access = Sao.common.MODELACCESS.get(model);
|
||||
if (access.create && access.write) {
|
||||
return [
|
||||
[Sao.i18n.gettext('Translate view'), Translate.translate_view],
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
Sao.Plugins.push(Translate);
|
||||
}());
|
||||
@@ -1085,6 +1085,8 @@ var Sao = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
Sao.Plugins = [];
|
||||
|
||||
// Fix stacked modal
|
||||
jQuery(document)
|
||||
.on('show.bs.modal', '.modal', function(event) {
|
||||
|
||||
+61
-6
@@ -565,13 +565,20 @@
|
||||
var menu = button.find('.dropdown-menu');
|
||||
button.click(function() {
|
||||
menu.find('.' + menu_action[0] + '_button').remove();
|
||||
var buttons = screen.get_buttons();
|
||||
menu.find('.divider').remove();
|
||||
menu.find('.' + menu_action[0] + '_plugin').remove();
|
||||
var buttons = screen.get_buttons().filter(
|
||||
function(button) {
|
||||
return menu_action[0] == (
|
||||
button.attributes.keyword || 'action');
|
||||
});
|
||||
if (buttons.length) {
|
||||
menu.append(jQuery('<li/>', {
|
||||
'role': 'separator',
|
||||
'class': 'divider',
|
||||
}));
|
||||
}
|
||||
buttons.forEach(function(button) {
|
||||
var button_kw = (button.attributes.keyword ||
|
||||
'action');
|
||||
if (button_kw != menu_action[0]) {
|
||||
return;
|
||||
}
|
||||
var item = jQuery('<li/>', {
|
||||
'role': 'presentation',
|
||||
'class': menu_action[0] + '_button'
|
||||
@@ -589,6 +596,54 @@
|
||||
})
|
||||
.appendTo(menu);
|
||||
});
|
||||
|
||||
var kw_plugins = [];
|
||||
Sao.Plugins.forEach(function(plugin) {
|
||||
plugin.get_plugins(screen.model.name).forEach(
|
||||
function(spec) {
|
||||
var name = spec[0],
|
||||
func = spec[1],
|
||||
keyword = spec[2] || 'action';
|
||||
if (keyword != menu_action[0]) {
|
||||
return;
|
||||
}
|
||||
kw_plugins.push([name, func]);
|
||||
});
|
||||
});
|
||||
if (kw_plugins.length) {
|
||||
menu.append(jQuery('<li/>', {
|
||||
'role': 'separator',
|
||||
'class': 'divider',
|
||||
}));
|
||||
}
|
||||
kw_plugins.forEach(function(plugin) {
|
||||
var name = plugin[0],
|
||||
func = plugin[1];
|
||||
jQuery('<li/>', {
|
||||
'role': 'presentation',
|
||||
'class': menu_action[0] + '_plugin',
|
||||
}).append(
|
||||
jQuery('<a/>', {
|
||||
'role': 'menuitem',
|
||||
'href': '#',
|
||||
'tabindex': -1,
|
||||
}).append(name))
|
||||
.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
var ids = screen.current_view.selected_records()
|
||||
.map(function(record) {
|
||||
return record.id;
|
||||
});
|
||||
var id = screen.current_record ?
|
||||
screen.current_record.id : null;
|
||||
func({
|
||||
'model': screen.model.name,
|
||||
'ids': ids,
|
||||
'id': id,
|
||||
});
|
||||
})
|
||||
.appendTo(menu);
|
||||
});
|
||||
});
|
||||
|
||||
toolbars[menu_action[0]].forEach(function(action) {
|
||||
|
||||
Reference in New Issue
Block a user