[IMP] web_linkedin: changed way people and companies are presented
bzr revid: nicolas.vanhoren@openerp.com-20120822091013-dsfz80vn7b1r2kht
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user