[merge]
bzr revid: nicolas.vanhoren@openerp.com-20110608144119-r2gc5t4oq7jnqow5
This commit is contained in:
commit
c34f427789
|
@ -94,6 +94,12 @@ body.openerp {
|
|||
.openerp .login .oe_box2 td select {
|
||||
width: 100%;
|
||||
}
|
||||
.openerp .login .oe_box2 td.oe_remember {
|
||||
text-align:left;
|
||||
}
|
||||
.openerp .login .oe_box2 td.oe_remember input {
|
||||
width: inherit;
|
||||
}
|
||||
.openerp .login .oe_login_right_pane {
|
||||
padding:70px 35px 5px 10px;
|
||||
min-width: 200px;
|
||||
|
|
|
@ -776,6 +776,17 @@ openerp.base.Database = openerp.base.Controller.extend({
|
|||
openerp.base.Login = openerp.base.Controller.extend({
|
||||
init: function(session, element_id) {
|
||||
this._super(session, element_id);
|
||||
this.has_local_storage = typeof(localStorage) != 'undefined';
|
||||
this.selected_db = null;
|
||||
this.selected_login = null;
|
||||
this.selected_password = null;
|
||||
this.remember = false;
|
||||
if (this.has_local_storage && localStorage.getItem('remember_creditentials') === 'true') {
|
||||
this.remember = true;
|
||||
this.selected_db = localStorage.getItem('last_db_login_success');
|
||||
this.selected_login = localStorage.getItem('last_login_login_success');
|
||||
this.selected_password = localStorage.getItem('last_password_login_success');
|
||||
}
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -786,10 +797,10 @@ openerp.base.Login = openerp.base.Controller.extend({
|
|||
self.display();
|
||||
});
|
||||
},
|
||||
display: function() {
|
||||
display: function() {
|
||||
this.$element.html(QWeb.render("Login", this));
|
||||
this.$element.find("form").submit(this.on_submit);
|
||||
},
|
||||
},
|
||||
on_login_invalid: function() {
|
||||
this.$element.closest(".openerp").addClass("login-mode");
|
||||
},
|
||||
|
@ -803,10 +814,24 @@ openerp.base.Login = openerp.base.Controller.extend({
|
|||
var db = $e.find("form [name=db]").val();
|
||||
var login = $e.find("form input[name=login]").val();
|
||||
var password = $e.find("form input[name=password]").val();
|
||||
var remember = $e.find("form input[name=remember]").attr('checked');
|
||||
//$e.hide();
|
||||
// Should hide then call callback
|
||||
this.session.session_login(db, login, password, function() {
|
||||
if(self.session.session_is_valid()) {
|
||||
if (self.has_local_storage) {
|
||||
if(remember) {
|
||||
localStorage.setItem('remember_creditentials', 'true');
|
||||
localStorage.setItem('last_db_login_success', db);
|
||||
localStorage.setItem('last_login_login_success', login);
|
||||
localStorage.setItem('last_password_login_success', password);
|
||||
} else {
|
||||
localStorage.setItem('remember_creditentials', '');
|
||||
localStorage.setItem('last_db_login_success', '');
|
||||
localStorage.setItem('last_login_login_success', '');
|
||||
localStorage.setItem('last_password_login_success', '');
|
||||
}
|
||||
}
|
||||
self.on_login_valid();
|
||||
} else {
|
||||
self.$element.addClass("login_invalid");
|
||||
|
|
|
@ -64,9 +64,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
|
|||
},
|
||||
do_show: function () {
|
||||
var self = this;
|
||||
this.do_update_pager.add(function() {
|
||||
self.$element.show();
|
||||
});
|
||||
self.$element.show();
|
||||
if (this.dataset.index === null) {
|
||||
// null index means we should start a new record
|
||||
this.on_button_new();
|
||||
|
|
|
@ -60,14 +60,20 @@
|
|||
<table align="center" cellspacing="2px" cellpadding="0">
|
||||
<tr>
|
||||
<td><label for="db">Database:</label></td>
|
||||
<td class="oe_field_value">
|
||||
<td>
|
||||
<t t-if="!db_list">
|
||||
<input type="text" name="db" value="trunk" autofocus="true"/>
|
||||
</t>
|
||||
<t t-if="db_list">
|
||||
<select name="db">
|
||||
<t t-foreach="db_list" t-as="db">
|
||||
<option t-att-value="db" t-att-selected="db == 'trunk'"><t t-esc="db"/></option>
|
||||
<t t-if="selected_db === db">
|
||||
<option t-att-value="db" selected="true">
|
||||
<t t-esc="db"/></option>
|
||||
</t>
|
||||
<t t-if="selected_db !== db">
|
||||
<option t-att-value="db"><t t-esc="db"/></option>
|
||||
</t>
|
||||
</t>
|
||||
</select>
|
||||
</t>
|
||||
|
@ -75,15 +81,28 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><label for="login">User:</label></td>
|
||||
<td class="oe_field_value"><input type="text" name="login" value="admin" autofocus="true"/></td>
|
||||
<td><input type="text" name="login"
|
||||
t-att-value="selected_login || ''" autofocus="true"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Password:</label></td>
|
||||
<td class="oe_field_value"><input type="password" name="password" value="a"/></td>
|
||||
<td><input type="password" name="password"
|
||||
t-att-value="selected_password || ''"/></td>
|
||||
</tr>
|
||||
<tr t-if="has_local_storage">
|
||||
<td><label for="remember">Rember password:</label></td>
|
||||
<td class="oe_remember">
|
||||
<t t-if="remember">
|
||||
<input type="checkbox" name="remember" checked="yes"/>
|
||||
</t>
|
||||
<t t-if="!remember">
|
||||
<input type="checkbox" name="remember"/>
|
||||
</t>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="oe_field_value">
|
||||
<td>
|
||||
<button type="submit" name="submit">Login</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -14,6 +14,17 @@
|
|||
padding-bottom: 4px;
|
||||
padding-left: 0.2em
|
||||
}
|
||||
.openerp a.oe-dashboard-action-rename {
|
||||
float: left;
|
||||
padding-right: 4px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.openerp .oe-dashboard-action-input {
|
||||
height: 16px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.openerp .oe-dashboard-action .oe-dashboard-action-header:hover {
|
||||
cursor: move;
|
||||
|
@ -50,7 +61,8 @@
|
|||
.openerp .oe-dashboard-layout_1 .oe-dashboard-column {
|
||||
width: 100%;
|
||||
}
|
||||
.openerp .oe-dashboard-layout_1 .oe-dashboard-column.index_1 .oe-dashboard-column.index_2 {
|
||||
.openerp .oe-dashboard-layout_1 .oe-dashboard-column.index_1,
|
||||
.openerp .oe-dashboard-layout_1 .oe-dashboard-column.index_2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@ QWeb.add_template('/base_dashboard/static/src/xml/base_dashboard.xml');
|
|||
openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
||||
init: function(view, node) {
|
||||
this._super(view, node);
|
||||
this.template = "DashBoard";
|
||||
this.template = 'DashBoard';
|
||||
this.actions_attrs = {};
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.$element.find(".oe-dashboard-column").sortable({
|
||||
connectWith: ".oe-dashboard-column",
|
||||
this.$element.find('.oe-dashboard-column').sortable({
|
||||
connectWith: '.oe-dashboard-column',
|
||||
handle: '.oe-dashboard-action-header',
|
||||
scroll: false
|
||||
}).disableSelection().bind('sortstop', self.do_save_dashboard);
|
||||
|
||||
|
@ -21,7 +23,7 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
|||
this.$element.find('.oe-dashboard-link-reset').click(this.on_reset);
|
||||
this.$element.find('.oe-dashboard-link-add_widget').click(this.on_add_widget);
|
||||
this.$element.find('.oe-dashboard-link-change_layout').click(this.on_change_layout);
|
||||
this.$element.find('.oe-dashboard-column .ui-icon-minusthick').click(this.on_fold_action);
|
||||
this.$element.find('.oe-dashboard-column .oe-dashboard-fold').click(this.on_fold_action);
|
||||
this.$element.find('.oe-dashboard-column .ui-icon-closethick').click(this.on_close_action);
|
||||
|
||||
this.actions_attrs = {};
|
||||
|
@ -37,6 +39,8 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
|||
}, self.on_load_action);
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.find('a.oe-dashboard-action-rename').live('click', this.on_rename);
|
||||
},
|
||||
on_undo: function() {
|
||||
this.rpc('/base/view/undo_custom', {
|
||||
|
@ -50,6 +54,91 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
|||
}, this.do_reload);
|
||||
},
|
||||
on_add_widget: function() {
|
||||
var self = this;
|
||||
var action = {
|
||||
res_model : 'ir.actions.actions',
|
||||
views : [[false, 'list']],
|
||||
type : 'ir.actions.act_window',
|
||||
view_type : 'list',
|
||||
view_mode : 'list',
|
||||
limit : 80,
|
||||
auto_search : true,
|
||||
domain : [['type', '=', 'ir.actions.act_window']],
|
||||
flags : {
|
||||
sidebar : false,
|
||||
views_switcher : false,
|
||||
action_buttons : false
|
||||
}
|
||||
};
|
||||
// TODO: create a Dialog controller which optionally takes an action
|
||||
// Should set width & height automatically and take buttons & views callback
|
||||
var dialog_id = _.uniqueId('act_window_dialog');
|
||||
var action_manager = new openerp.base.ActionManager(this.session, dialog_id);
|
||||
var $dialog = $('<div id=' + dialog_id + '>').dialog({
|
||||
modal : true,
|
||||
title : 'Actions',
|
||||
width : 800,
|
||||
height : 600,
|
||||
buttons : {
|
||||
Cancel : function() {
|
||||
$(this).dialog('destroy');
|
||||
},
|
||||
Add : function() {
|
||||
self.do_add_widget(action_manager);
|
||||
$(this).dialog('destroy');
|
||||
}
|
||||
}
|
||||
});
|
||||
action_manager.start();
|
||||
action_manager.do_action(action);
|
||||
// TODO: should bind ListView#select_record in order to catch record clicking
|
||||
},
|
||||
do_add_widget : function(action_manager) {
|
||||
var self = this,
|
||||
actions = action_manager.viewmanager.views.list.controller.groups.get_selection().ids,
|
||||
results = [],
|
||||
qdict = { view : this.view };
|
||||
// TODO: should load multiple actions at once
|
||||
_.each(actions, function(aid) {
|
||||
self.rpc('/base/action/load', {
|
||||
action_id: aid
|
||||
}, function(result) {
|
||||
self.actions_attrs[aid] = {
|
||||
name: aid,
|
||||
string: _.trim(result.result.name)
|
||||
}
|
||||
qdict.action = {
|
||||
attrs : self.actions_attrs[aid]
|
||||
}
|
||||
self.$element.find('.oe-dashboard-column:first').prepend(QWeb.render('DashBoard.action', qdict));
|
||||
self.do_save_dashboard();
|
||||
self.on_load_action(result)
|
||||
});
|
||||
});
|
||||
},
|
||||
on_rename : function(e) {
|
||||
var self = this,
|
||||
id = parseInt($(e.currentTarget).parents('.oe-dashboard-action:first').attr('data-id'), 10),
|
||||
$header = $(e.currentTarget).parents('.oe-dashboard-action-header:first'),
|
||||
$rename = $header.find('a.oe-dashboard-action-rename').hide(),
|
||||
$title = $header.find('span.oe-dashboard-action-title').hide(),
|
||||
$input = $header.find('input[name=title]');
|
||||
$input.val($title.text()).show().focus().bind('keydown', function(e) {
|
||||
if (e.which == 13 || e.which == 27) {
|
||||
if (e.which == 13) { //enter
|
||||
var val = $input.val();
|
||||
if (!val) {
|
||||
return false;
|
||||
}
|
||||
$title.text(val);
|
||||
self.actions_attrs[id].string = val;
|
||||
self.do_save_dashboard();
|
||||
}
|
||||
$input.unbind('keydown').hide();
|
||||
$rename.show();
|
||||
$title.show();
|
||||
}
|
||||
});
|
||||
},
|
||||
on_change_layout: function() {
|
||||
var self = this;
|
||||
|
@ -64,7 +153,7 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
|||
}).html(QWeb.render('DashBoard.layouts', qdict));
|
||||
$dialog.find('li').click(function() {
|
||||
var layout = $(this).attr('data-layout');
|
||||
$dialog.dialog("destroy");
|
||||
$dialog.dialog('destroy');
|
||||
self.do_change_layout(layout);
|
||||
});
|
||||
},
|
||||
|
@ -91,9 +180,17 @@ openerp.base.form.DashBoard = openerp.base.form.Widget.extend({
|
|||
}
|
||||
},
|
||||
on_fold_action: function(e) {
|
||||
var $e = $(e.currentTarget);
|
||||
var $e = $(e.currentTarget),
|
||||
$action = $e.parents('.oe-dashboard-action:first'),
|
||||
id = parseInt($action.attr('data-id'), 10);
|
||||
if ($e.is('.ui-icon-minusthick')) {
|
||||
this.actions_attrs[id].fold = '1';
|
||||
} else {
|
||||
delete(this.actions_attrs[id].fold);
|
||||
}
|
||||
$e.toggleClass('ui-icon-minusthick ui-icon-plusthick');
|
||||
$e.parents('.oe-dashboard-action:first').find('.oe-dashboard-action-content').toggle();
|
||||
$action.find('.oe-dashboard-action-content').toggle();
|
||||
this.do_save_dashboard();
|
||||
},
|
||||
on_close_action: function(e) {
|
||||
$(e.currentTarget).parents('.oe-dashboard-action:first').remove();
|
||||
|
|
|
@ -22,19 +22,23 @@
|
|||
<div t-foreach="node.children" t-as="column" t-if="column.tag == 'column'"
|
||||
t-att-id="view.element_id + '_column_' + column_index" t-attf-class="oe-dashboard-column index_#{column_index}">
|
||||
|
||||
<div t-foreach="column.children" t-as="action" t-if="action.tag == 'action'" t-att-data-id="action.attrs.name"
|
||||
class="oe-dashboard-action ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
|
||||
|
||||
<div class="oe-dashboard-action-header ui-widget-header ui-corner-all">
|
||||
<t t-esc="action.attrs.string"/>
|
||||
<span class='ui-icon ui-icon-closethick'></span>
|
||||
<span class='ui-icon ui-icon-minusthick'></span>
|
||||
</div>
|
||||
<div t-att-id="view.element_id + '_action_' + action.attrs.name" class="oe-dashboard-action-content"></div>
|
||||
</div>
|
||||
<t t-foreach="column.children" t-as="action" t-if="action.tag == 'action'" t-call="DashBoard.action"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="DashBoard.action">
|
||||
<div t-att-data-id="action.attrs.name" class="oe-dashboard-action ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
|
||||
<div class="oe-dashboard-action-header ui-widget-header ui-corner-all">
|
||||
<a href="#" class="oe-dashboard-action-rename"><img src="/base/static/src/img/icons/gtk-edit.png" width="16" height="16"/></a>
|
||||
<span class="oe-dashboard-action-title"><t t-esc="action.attrs.string"/></span>
|
||||
<input class="oe-dashboard-action-input" type="text" name="title" value="" style="display: none"/>
|
||||
<span class='ui-icon ui-icon-closethick'></span>
|
||||
<span class='ui-icon ui-icon-minusthick oe-dashboard-fold' t-if="!action.attrs.fold"></span>
|
||||
<span class='ui-icon ui-icon-plusthick oe-dashboard-fold' t-if="action.attrs.fold"></span>
|
||||
</div>
|
||||
<div t-att-id="view.element_id + '_action_' + action.attrs.name" class="oe-dashboard-action-content" t-att-style="action.attrs.fold ? 'display: none' : null"></div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="DashBoard.layouts">
|
||||
<div class="oe-dashboard-layout-selector">
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue