diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-08-22 11:10:13 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-08-22 11:10:13 +0200 |
| commit | e9f1287d7eeff3ef7f39511aa0ad5b6bf3ef70c6 (patch) | |
| tree | c1cffda2c091129fa8cb7130ba0ee99cd25264e7 /addons/web_linkedin/static | |
| parent | cd0b2b10e57b9510115f381d1afc3d34d7fa6c11 (diff) | |
[IMP] web_linkedin: changed way people and companies are presented
bzr revid: nicolas.vanhoren@openerp.com-20120822091013-dsfz80vn7b1r2kht
Diffstat (limited to 'addons/web_linkedin/static')
| -rw-r--r-- | addons/web_linkedin/static/src/js/linkedin.js | 43 | ||||
| -rw-r--r-- | addons/web_linkedin/static/src/xml/linkedin.xml | 5 |
2 files changed, 27 insertions, 21 deletions
diff --git a/addons/web_linkedin/static/src/js/linkedin.js b/addons/web_linkedin/static/src/js/linkedin.js index 8fcc17ba41e..483452d4278 100644 --- a/addons/web_linkedin/static/src/js/linkedin.js +++ b/addons/web_linkedin/static/src/js/linkedin.js @@ -155,7 +155,7 @@ openerp.web_linkedin = function(instance) { } }); var positions = entity.positions.values || []; - to_change.function = positions ? positions[0].title : false; + to_change.function = positions.length > 0 ? positions[0].title : false; /* TODO to_change.linkedinUrl = entity.publicProfileUrl; */ @@ -177,7 +177,7 @@ openerp.web_linkedin = function(instance) { init: function(parent, text) { this._super(parent, {title:_t("LinkedIn search")}); this.text = text; - this.limit = 15; + this.limit = 5; }, start: function() { this._super(); @@ -197,38 +197,41 @@ openerp.web_linkedin = function(instance) { encodeURI(this.text), this.limit)).result(function (result) { cdef.resolve(result); }); + var def = cdef.pipe(function(companies) { + var lst = companies.companies.values || []; + lst = _.first(lst, self.limit); + lst = _.map(lst, function(el) { + el.__type = "company"; + return el; + }); + console.debug("Linkedin companies found:", lst.length, lst); + return self.display_result(lst, self.$(".oe_linkedin_pop_c")); + }); IN.API.PeopleSearch().fields(commonPeopleFields). params({"keywords": this.text, "count": this.limit}).result(function(result) { pdef.resolve(result); }); - return $.when(cdef, pdef).then(function(companies, people) { - var lst = companies.companies.values || []; + var def2 = pdef.pipe(function(people) { var plst = people.people.values || []; - lst = _.initial(lst, _.min([self.limit / 2, plst.length])); - _.map(lst, function(el) { - el.__type = "company"; - return el; - }); - plst = _.first(plst, self.limit - lst.length) - _.map(plst, function(el) { + plst = _.first(plst, self.limit); + plst = _.map(plst, function(el) { el.__type = "people"; return el; }); - lst = plst.concat(lst); - console.log("Linkedin search found:", lst.length, lst); - self.result = lst; - self.display_result(); + console.debug("Linkedin people found:", plst.length, plst); + return self.display_result(plst, self.$(".oe_linkedin_pop_p")); }); + return $.when(def, def2); }, - display_result: function() { + display_result: function(result, $elem) { var self = this; var i = 0; var $row; - _.each(self.result, function(el) { + _.each(result, function(el) { var pc = new instance.web_linkedin.EntityWidget(self, el); if (i % 5 === 0) { $row = $("<div style='display: table-row;width:100%'/>"); - $row.appendTo(self.$(">div")); + $row.appendTo($elem); } pc.appendTo($row); pc.$element.css("display", "table-cell"); @@ -239,8 +242,8 @@ openerp.web_linkedin = function(instance) { }); i++; }); - if (self.result.length === 0) { - self.$(">div").text(_t("No results found")); + if (result.length === 0) { + $elem.text(_t("No results found")); } }, }); diff --git a/addons/web_linkedin/static/src/xml/linkedin.xml b/addons/web_linkedin/static/src/xml/linkedin.xml index 998918a174c..30a7abb3443 100644 --- a/addons/web_linkedin/static/src/xml/linkedin.xml +++ b/addons/web_linkedin/static/src/xml/linkedin.xml @@ -10,7 +10,10 @@ <div> <script type="in/Login"> </script> - <div style='display: table;width:100%'/> + <h2 style="margin-top: -10px;">People</h2> + <div class="oe_linkedin_pop_p" style='display: table;width:100%'/> + <h2>Companies</h2> + <div class="oe_linkedin_pop_c" style='display: table;width:100%'/> </div> </t> <t t-name="Linkedin.EntityWidget"> |
