summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorKunal Chavda (OpenERP) <kch@tinyerp.com>2011-09-09 17:19:33 +0530
committerKunal Chavda (OpenERP) <kch@tinyerp.com>2011-09-09 17:19:33 +0530
commit555610e41bdbb4904a2a042d916bedf122be2abc (patch)
treee12794d5bf44df20082739783bcca30fd8c95240 /addons/web/static
parentea82b312865db0bac4f6a951a0d023483dd5c0dd (diff)
[FIX]Fixed code for javascript problems as par review.
bzr revid: kch@tinyerp.com-20110909114933-4f0zgiedo9dp865h
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/data_import.js44
-rw-r--r--addons/web/static/src/xml/base.xml2
2 files changed, 26 insertions, 20 deletions
diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js
index ae22d2226c9..f31c694312c 100644
--- a/addons/web/static/src/js/data_import.js
+++ b/addons/web/static/src/js/data_import.js
@@ -24,8 +24,9 @@ function jsonp(form, attributes, callback) {
}, attributes));
}
openerp.web.DataImport = openerp.web.Dialog.extend({
+ template: 'ImportDataView',
+ dialog_title: "Import Data",
init: function(parent, dataset){
- this.parent = parent;
this._super(parent);
this.dataset = dataset;
},
@@ -87,23 +88,25 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
result_node.append(QWeb.render('ImportView-result',{'error': results['error']}));
}else if(results['success']){
self.stop();
- this.parent.reload_content();
+ if (((this.widget_parent['fields_view']['type']) == "tree") || ((this.widget_parent['fields_view']['type']) == "list")){
+ this.widget_parent.reload_content();
+ }
}
this.do_check_req_field(results['req_field']);
var selected_fields = [];
- $("td #sel_field").click(function(){
+ this.$element.find("td #sel_field").click(function(){
selected_fields = [];
- $("td #sel_field option:selected").each(function(){
+ self.$element.find("td #sel_field option:selected").each(function(){
selected_fields.push($(this).index());
});
});
- $("td #sel_field").change(function(){
- $("#message").empty();
- $("td #sel_field").css('background-color','');
- $(".ui-button-text:contains('Import File')").parent().attr("disabled",false);
+ this.$element.find("td #sel_field").change(function(){
+ self.$element.find("#message").empty();
+ self.$element.find("td #sel_field").css('background-color','');
+ self.$element.find(".ui-button-text:contains('Import File')").parent().attr("disabled",false);
self.do_check_req_field(results['req_field']);
var curr_selected = this.selectedIndex;
- if ($.inArray(curr_selected,selected_fields) > -1){
+ if ((curr_selected != 0) && _.contains(selected_fields, curr_selected)){
$(this).css('background-color','#FF6666');
$("#message").append("*Selected column should not be same.");
$(".ui-button-text:contains('Import File')").parent().attr("disabled",true);
@@ -114,19 +117,22 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
},
do_check_req_field: function(req_fld){
if (req_fld.length){
- var sel_fields =[];
- var required_fields = [];
- $("td #sel_field option:selected").each(function(){
- sel_fields.push($(this).val());
- });
- _.each(req_fld,function(fld){
- if ($.inArray(fld,sel_fields) <= -1){
- required_fields.push(fld);
- }
- });
+ var required_fields = "";
+ var sel_fields = _.map(this.$element.find("td #sel_field option:selected"), function(fld){
+ return fld['text']
+ });
+
+ required_fields = required_fields + _.filter(req_fld, function (fld){
+ if (!_.contains(sel_fields,fld)){
+ return fld + "," ;
+ }
+ });
+
if (required_fields.length){
$("#message").append("*Required Fields are not selected which is "+required_fields+". ");
$(".ui-button-text:contains('Import File')").parent().attr("disabled",true);
+ }else{
+ $(".ui-button-text:contains('Import File')").parent().attr("disabled",false);
}
}
},
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index a523b49a863..67729c262ac 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -1468,7 +1468,7 @@
<tr>
<t t-foreach="records.header" t-as="header">
<td>
- <select name="sel_field" id="sel_field">
+ <select id="sel_field">
<option selected="selected" value=""></option>
<t t-foreach="records.sel" t-as="selection">
<option t-att="{'selected': header[0] === selection ? 'selected' : null}"