[MERGE] vieweditor extraction
bzr revid: fme@openerp.com-20120801145907-16oe3cu5jb04phmv
This commit is contained in:
commit
b56849da72
|
@ -53,7 +53,6 @@ This module provides the core of the OpenERP Web Client.
|
|||
"static/src/js/view_list.js",
|
||||
"static/src/js/view_list_editable.js",
|
||||
"static/src/js/view_tree.js",
|
||||
"static/src/js/view_editor.js"
|
||||
],
|
||||
'css' : [
|
||||
"static/lib/jquery.ui.bootstrap/css/custom-theme/jquery-ui-1.8.16.custom.css",
|
||||
|
|
|
@ -2474,27 +2474,6 @@
|
|||
.openerp .oe_trad_field.touched {
|
||||
border: 1px solid green !important;
|
||||
}
|
||||
.openerp .oe_view_editor {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-left: -12px;
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
border-spacing: 0;
|
||||
}
|
||||
.openerp .oe_view_editor td {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
border: 1px solid #d8d8d8;
|
||||
cursor: pointer;
|
||||
font-size: 90%;
|
||||
}
|
||||
.openerp .oe_view_editor_field td {
|
||||
border: 0px !important;
|
||||
}
|
||||
.openerp .oe_view_editor tr:hover {
|
||||
background-color: #ecebf2;
|
||||
}
|
||||
.openerp .oe_layout_debugging .oe_form_group {
|
||||
outline: 2px dashed green;
|
||||
}
|
||||
|
|
|
@ -1929,25 +1929,6 @@ $sheet-max-width: 860px
|
|||
.oe_trad_field.touched
|
||||
border: 1px solid green !important
|
||||
// }}}
|
||||
// View Editor {{{
|
||||
.oe_view_editor
|
||||
width: 100%
|
||||
border-collapse: collapse
|
||||
margin-left: -12px
|
||||
width: 100%
|
||||
background-color: white
|
||||
border-spacing: 0
|
||||
td
|
||||
text-align: center
|
||||
white-space: nowrap
|
||||
border: 1px solid #D8D8D8
|
||||
cursor: pointer
|
||||
font-size: 90%
|
||||
.oe_view_editor_field td
|
||||
border: 0px !important
|
||||
.oe_view_editor tr:hover
|
||||
background-color: #ecebf2
|
||||
// }}}
|
||||
// Debugging stuff {{{
|
||||
.oe_layout_debugging
|
||||
.oe_form_group
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
* OpenERP Web web module split
|
||||
*---------------------------------------------------------*/
|
||||
openerp.web = function(session) {
|
||||
var files = ["corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import","view_editor"];
|
||||
var files = ["corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import"];
|
||||
for(var i=0; i<files.length; i++) {
|
||||
if(openerp.web[files[i]]) {
|
||||
openerp.web[files[i]](session);
|
||||
|
|
|
@ -2461,9 +2461,6 @@ instance.web.form.FieldProgressBar = instance.web.form.AbstractField.extend({
|
|||
}
|
||||
});
|
||||
|
||||
instance.web.form.FieldTextXml = instance.web.form.AbstractField.extend({
|
||||
// to replace view editor
|
||||
});
|
||||
|
||||
instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
||||
template: 'FieldSelection',
|
||||
|
|
|
@ -755,15 +755,6 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
|
|||
width: '95%'}, $root).open();
|
||||
});
|
||||
break;
|
||||
case 'manage_views':
|
||||
if (current_view.fields_view && current_view.fields_view.arch) {
|
||||
var view_editor = new instance.web.ViewEditor(current_view, current_view.$element, this.dataset, current_view.fields_view.arch);
|
||||
view_editor.start();
|
||||
} else {
|
||||
this.do_warn(_t("Manage Views"),
|
||||
_t("Could not find current view declaration"));
|
||||
}
|
||||
break;
|
||||
case 'edit_workflow':
|
||||
return this.do_action({
|
||||
res_model : 'workflow',
|
||||
|
@ -1384,7 +1375,6 @@ instance.web.xml_to_json = function(node) {
|
|||
}
|
||||
instance.web.json_node_to_xml = function(node, human_readable, indent) {
|
||||
// For debugging purpose, this function will convert a json node back to xml
|
||||
// Maybe useful for xml view editor
|
||||
indent = indent || 0;
|
||||
var sindent = (human_readable ? (new Array(indent + 1).join('\t')) : ''),
|
||||
r = sindent + '<' + node.tag,
|
||||
|
|
|
@ -1502,70 +1502,6 @@
|
|||
</select>
|
||||
</t>
|
||||
|
||||
<t t-name="view_editor">
|
||||
<table class="oe_view_editor">
|
||||
<t t-call="view_editor.row"/>
|
||||
</table>
|
||||
</t>
|
||||
<t t-name="view_editor.row">
|
||||
<tr t-att-id="'viewedit-' + rec.id" t-att-level="rec.level" t-foreach="data" t-as="rec">
|
||||
<td width="90%">
|
||||
<table class="oe_view_editor_field">
|
||||
<tr>
|
||||
<td width="16px" t-att-style="'background-position: ' + 20*rec.level + 'px; padding-left: ' + 20*rec.level + 'px'">
|
||||
<img t-if="rec.child_id.length" t-att-id="'parentimg-' + rec.id"
|
||||
t-att-src='_s + "/web/static/src/img/collapse.gif"' width="16" height="16" border="0"/>
|
||||
</td>
|
||||
<td style="cursor: pointer;">
|
||||
<a style="text-decoration:none" href="javascript:void(0);">
|
||||
<t t-esc="rec.name"/>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-add" t-att-src='_s + "/web/static/src/img/icons/gtk-add.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img id="side-remove" t-att-src='_s + "/web/static/src/img/icons/gtk-remove.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length and !_.include(no_properties, rec.att_list[0])"
|
||||
id="side-edit" t-att-src='_s + "/web/static/src/img/icons/gtk-edit.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-up" t-att-src='_s + "/web/static/src/img/icons/gtk-go-up.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-down" t-att-src='_s + "/web/static/src/img/icons/gtk-go-down.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<t t-if="rec.child_id.length">
|
||||
<t t-set="data" t-value="rec.child_id"/>
|
||||
<t t-call="view_editor.row"/>
|
||||
</t>
|
||||
</tr>
|
||||
</t>
|
||||
<t t-name="vieweditor_char">
|
||||
<input type="text" t-att-id="widget.name" class="field_char" size="50"/>
|
||||
</t>
|
||||
<t t-name="vieweditor_selection">
|
||||
<select t-att-id="widget.name" >
|
||||
<t t-if="widget.selection" t-foreach="widget.selection" t-as="option">
|
||||
<option
|
||||
t-att-value="typeof option === 'object' ? option[0] : option">
|
||||
<t t-esc="typeof option === 'object' ? option[1] : option"/>
|
||||
</option>
|
||||
</t>
|
||||
</select>
|
||||
</t>
|
||||
<t t-name="vieweditor_boolean">
|
||||
<input type="checkbox" t-att-id="widget.name"/>
|
||||
</t>
|
||||
|
||||
<t t-name="ExportView">
|
||||
<a id="exportview" href="javascript: void(0)" style="text-decoration: none;color: #3D3D3D;">Export</a>
|
||||
</t>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "View Editor",
|
||||
"category": "Hidden",
|
||||
"description":
|
||||
"""
|
||||
OpenERP Web to edit views.
|
||||
""",
|
||||
"version": "2.0",
|
||||
"depends":['web'],
|
||||
"js": ["static/src/js/view_editor.js"],
|
||||
"css": ['static/src/css/view_editor.css'],
|
||||
"qweb": ['static/src/xml/view_editor.xml'],
|
||||
'auto_install': True,
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# Translations template for PROJECT.
|
||||
# Copyright (C) 2012 ORGANIZATION
|
||||
# This file is distributed under the same license as the PROJECT project.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2012-07-30 14:37+0530\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 0.9.6\n"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
.openerp .oe_view_editor {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-left: -12px;
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
border-spacing: 0;
|
||||
}
|
||||
.openerp .oe_view_editor td {
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
border: 1px solid #d8d8d8;
|
||||
cursor: pointer;
|
||||
font-size: 90%;
|
||||
}
|
||||
.openerp .oe_view_editor_field td {
|
||||
border: 0px !important;
|
||||
}
|
||||
.openerp .oe_view_editor tr:hover {
|
||||
background-color: #ecebf2;
|
||||
}
|
|
@ -1,7 +1,25 @@
|
|||
openerp.web.view_editor = function(instance) {
|
||||
openerp.web_view_editor = function(instance) {
|
||||
var _t = instance.web._t;
|
||||
var QWeb = instance.web.qweb;
|
||||
instance.web.ViewEditor = instance.web.OldWidget.extend({
|
||||
instance.web.ViewManagerAction.include({
|
||||
on_debug_changed:function(evt){
|
||||
var val = $(evt.currentTarget).find('option:selected').val(),
|
||||
current_view = this.views[this.active_view].controller;
|
||||
if(val === "manage_views"){
|
||||
if (current_view.fields_view && current_view.fields_view.arch) {
|
||||
var view_editor = new instance.web_view_editor.ViewEditor(current_view, current_view.$element, this.dataset, current_view.fields_view.arch);
|
||||
view_editor.start();
|
||||
} else {
|
||||
this.do_warn(_t("Manage Views"),
|
||||
_t("Could not find current view declaration"));
|
||||
}
|
||||
evt.currentTarget.selectedIndex = 0;
|
||||
}else{
|
||||
return this._super.apply(this,arguments);
|
||||
}
|
||||
}
|
||||
})
|
||||
instance.web_view_editor.ViewEditor = instance.web.OldWidget.extend({
|
||||
init: function(parent, element_id, dataset, view, options) {
|
||||
this._super(parent);
|
||||
this.element_id = element_id;
|
||||
|
@ -9,7 +27,7 @@ instance.web.ViewEditor = instance.web.OldWidget.extend({
|
|||
this.dataset = new instance.web.DataSetSearch(this, 'ir.ui.view', null, null),
|
||||
this.model = dataset.model;
|
||||
this.xml_element_id = 0;
|
||||
this.property = instance.web.ViewEditor.property_widget;
|
||||
this.property = instance.web_view_editor.ViewEditor.property_widget;
|
||||
this.one_object = false;
|
||||
},
|
||||
start: function() {
|
||||
|
@ -350,7 +368,7 @@ instance.web.ViewEditor = instance.web.OldWidget.extend({
|
|||
this.edit_xml_dialog.$element.find("tr[id=viewedit-" + row_id + "]").addClass('ui-selected');
|
||||
},
|
||||
do_parent_img_hide_show: function(img) {
|
||||
if ($(img).attr('src') == '/web/static/src/img/collapse.gif') {
|
||||
if (_.str.include($(img).attr('src'), '/web/static/src/img/collapse.gif')) {
|
||||
$(img).attr('src', '/web/static/src/img/expand.gif');
|
||||
this.on_expand(img);
|
||||
} else {
|
||||
|
@ -434,7 +452,7 @@ instance.web.ViewEditor = instance.web.OldWidget.extend({
|
|||
break;
|
||||
}
|
||||
if (view_find.attr('level') < min_level) {
|
||||
min_level = parseInt(view_find.attr('level'));
|
||||
min_level = parseInt(view_find.attr('level'));
|
||||
}
|
||||
}
|
||||
var val = _.detect(obj.att_list, function(val) {return val[0] == "name";});
|
||||
|
@ -1013,7 +1031,7 @@ instance.web.ViewEditor = instance.web.OldWidget.extend({
|
|||
});
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.Field = instance.web.Class.extend({
|
||||
instance.web_view_editor.ViewEditor.Field = instance.web.Class.extend({
|
||||
init: function(view, widget) {
|
||||
this.$element = view.$element;
|
||||
this.dirty = false;
|
||||
|
@ -1049,7 +1067,7 @@ instance.web.ViewEditor.Field = instance.web.Class.extend({
|
|||
return _.str.sprintf("<td id = %s>%s</td>", this.name, QWeb.render(this.template, {widget: this}))
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.FieldBoolean = instance.web.ViewEditor.Field.extend({
|
||||
instance.web_view_editor.ViewEditor.FieldBoolean = instance.web_view_editor.ViewEditor.Field.extend({
|
||||
template : "vieweditor_boolean",
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -1067,7 +1085,7 @@ instance.web.ViewEditor.FieldBoolean = instance.web.ViewEditor.Field.extend({
|
|||
return this.$element.find("input[id=" + this.name + "]").is(':checked')? "1" : null;
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.FieldChar = instance.web.ViewEditor.Field.extend({
|
||||
instance.web_view_editor.ViewEditor.FieldChar = instance.web_view_editor.ViewEditor.Field.extend({
|
||||
template : "vieweditor_char",
|
||||
start: function () {
|
||||
var self = this;
|
||||
|
@ -1083,7 +1101,7 @@ instance.web.ViewEditor.FieldChar = instance.web.ViewEditor.Field.extend({
|
|||
return this.$element.find("input[id=" + this.name + "]").val();
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.FieldSelect = instance.web.ViewEditor.Field.extend({
|
||||
instance.web_view_editor.ViewEditor.FieldSelect = instance.web_view_editor.ViewEditor.Field.extend({
|
||||
template : "vieweditor_selection",
|
||||
start: function () {
|
||||
var self = this;
|
||||
|
@ -1113,7 +1131,7 @@ instance.web.ViewEditor.FieldSelect = instance.web.ViewEditor.Field.extend({
|
|||
return this.$element.find("select[id=" + this.name + "]").val();
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.FieldSelectMulti = instance.web.ViewEditor.FieldSelect.extend({
|
||||
instance.web_view_editor.ViewEditor.FieldSelectMulti = instance.web_view_editor.ViewEditor.FieldSelect.extend({
|
||||
start: function () {
|
||||
this._super();
|
||||
this.$element.find("select[id=" + this.name + "]").css('height', '100px').attr("multiple", true);
|
||||
|
@ -1129,7 +1147,7 @@ instance.web.ViewEditor.FieldSelectMulti = instance.web.ViewEditor.FieldSelect.e
|
|||
});
|
||||
}
|
||||
});
|
||||
instance.web.ViewEditor.FieldFloat = instance.web.ViewEditor.FieldChar.extend({
|
||||
instance.web_view_editor.ViewEditor.FieldFloat = instance.web_view_editor.ViewEditor.FieldChar.extend({
|
||||
});
|
||||
|
||||
var _PROPERTIES = {
|
||||
|
@ -1202,11 +1220,11 @@ var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD',
|
|||
'terp-sale', 'terp-tools', 'terp-administration', 'terp-hr', 'terp-partner',
|
||||
'terp-project', 'terp-report', 'terp-stock', 'terp-calendar', 'terp-graph'
|
||||
];
|
||||
instance.web.ViewEditor.property_widget = new instance.web.Registry({
|
||||
'boolean' : 'instance.web.ViewEditor.FieldBoolean',
|
||||
'selection_multi' : 'instance.web.ViewEditor.FieldSelectMulti',
|
||||
'selection' : 'instance.web.ViewEditor.FieldSelect',
|
||||
'char' : 'instance.web.ViewEditor.FieldChar',
|
||||
'float' : 'instance.web.ViewEditor.FieldFloat'
|
||||
instance.web_view_editor.ViewEditor.property_widget = new instance.web.Registry({
|
||||
'boolean' : 'instance.web_view_editor.ViewEditor.FieldBoolean',
|
||||
'selection_multi' : 'instance.web_view_editor.ViewEditor.FieldSelectMulti',
|
||||
'selection' : 'instance.web_view_editor.ViewEditor.FieldSelect',
|
||||
'char' : 'instance.web_view_editor.ViewEditor.FieldChar',
|
||||
'float' : 'instance.web_view_editor.ViewEditor.FieldFloat'
|
||||
});
|
||||
};
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template>
|
||||
<t t-name="view_editor">
|
||||
<table class="oe_view_editor">
|
||||
<t t-call="view_editor.row"/>
|
||||
</table>
|
||||
</t>
|
||||
<t t-name="view_editor.row">
|
||||
<tr t-att-id="'viewedit-' + rec.id" t-att-level="rec.level" t-foreach="data" t-as="rec">
|
||||
<td width="90%">
|
||||
<table class="oe_view_editor_field">
|
||||
<tr>
|
||||
<td width="16px" t-att-style="'background-position: ' + 20*rec.level + 'px; padding-left: ' + 20*rec.level + 'px'">
|
||||
<img t-if="rec.child_id.length" t-att-id="'parentimg-' + rec.id"
|
||||
t-att-src='_s + "/web/static/src/img/collapse.gif"' width="16" height="16" border="0"/>
|
||||
</td>
|
||||
<td style="cursor: pointer;">
|
||||
<a style="text-decoration:none" href="javascript:void(0);">
|
||||
<t t-esc="rec.name"/>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-add" t-att-src='_s + "/web/static/src/img/icons/gtk-add.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img id="side-remove" t-att-src='_s + "/web/static/src/img/icons/gtk-remove.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length and !_.include(no_properties, rec.att_list[0])"
|
||||
id="side-edit" t-att-src='_s + "/web/static/src/img/icons/gtk-edit.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-up" t-att-src='_s + "/web/static/src/img/icons/gtk-go-up.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<td width="2%">
|
||||
<img t-if="rec.att_list.length"
|
||||
id="side-down" t-att-src='_s + "/web/static/src/img/icons/gtk-go-down.png"' style="cursor: pointer;"/>
|
||||
</td>
|
||||
<t t-if="rec.child_id.length">
|
||||
<t t-set="data" t-value="rec.child_id"/>
|
||||
<t t-call="view_editor.row"/>
|
||||
</t>
|
||||
</tr>
|
||||
</t>
|
||||
<t t-name="vieweditor_char">
|
||||
<input type="text" t-att-id="widget.name" class="field_char" size="50"/>
|
||||
</t>
|
||||
<t t-name="vieweditor_selection">
|
||||
<select t-att-id="widget.name" >
|
||||
<t t-if="widget.selection" t-foreach="widget.selection" t-as="option">
|
||||
<option
|
||||
t-att-value="typeof option === 'object' ? option[0] : option">
|
||||
<t t-esc="typeof option === 'object' ? option[1] : option"/>
|
||||
</option>
|
||||
</t>
|
||||
</select>
|
||||
</t>
|
||||
<t t-name="vieweditor_boolean">
|
||||
<input type="checkbox" t-att-id="widget.name"/>
|
||||
</t>
|
||||
</template>
|
Loading…
Reference in New Issue