diff options
| author | Antonin Bourguignon <abo@openerp.com> | 2012-08-22 19:57:56 +0200 |
|---|---|---|
| committer | Antonin Bourguignon <abo@openerp.com> | 2012-08-22 19:57:56 +0200 |
| commit | 121b351b59c013beb421830a39af3ddffb0bdb5b (patch) | |
| tree | 4bd1166c8708defec0995bb1b18d7ffda567acb8 /addons/web_linkedin/static/src | |
| parent | 095843797c3f89f0e81dbc77d049c9a277d64e9e (diff) | |
| parent | e459388304ac4d7fcbc2d5cf387af0c0b87f64d8 (diff) | |
[MERGE] latest trunk
bzr revid: abo@openerp.com-20120822175756-ypym270e6cklpbds
Diffstat (limited to 'addons/web_linkedin/static/src')
| -rw-r--r-- | addons/web_linkedin/static/src/css/linkedin.css | 11 | ||||
| -rw-r--r-- | addons/web_linkedin/static/src/js/linkedin.js | 63 | ||||
| -rw-r--r-- | addons/web_linkedin/static/src/xml/linkedin.xml | 9 |
3 files changed, 52 insertions, 31 deletions
diff --git a/addons/web_linkedin/static/src/css/linkedin.css b/addons/web_linkedin/static/src/css/linkedin.css index 16eea9f04d5..992dc48aeb8 100644 --- a/addons/web_linkedin/static/src/css/linkedin.css +++ b/addons/web_linkedin/static/src/css/linkedin.css @@ -32,4 +32,13 @@ .openerp .oe_linkedin_entity img { max-width: 70px; max-height: 70px; -}
\ No newline at end of file +} + +.openerp .oe_linkedin_entity h3 { + margin-bottom: 5px; +} + +.openerp .oe_linkedin_entity .oe_linkedin_entity_headline { + color: grey; + margin-bottom: 10px; +} diff --git a/addons/web_linkedin/static/src/js/linkedin.js b/addons/web_linkedin/static/src/js/linkedin.js index c15b995bff9..575a4cf9a85 100644 --- a/addons/web_linkedin/static/src/js/linkedin.js +++ b/addons/web_linkedin/static/src/js/linkedin.js @@ -102,11 +102,11 @@ openerp.web_linkedin = function(instance) { if (entity.__type === "company") { to_change.is_company = true; to_change.name = entity.name; - to_change.photo = false; + to_change.image = false; if (entity.logoUrl) { defs.push(self.rpc('/web_linkedin/binary/url2binary', {'url': entity.logoUrl}).pipe(function(data){ - to_change.photo = data; + to_change.image = data; })); } to_change.website = entity.websiteUrl; @@ -123,7 +123,10 @@ openerp.web_linkedin = function(instance) { children_def.resolve(result); }); defs.push(children_def.pipe(function(result) { - var defs = _.map(result.people.values || [], function(el) { + result = _.reject(result.people.values || [], function(el) { + return ! el.formattedName; + }); + var defs = _.map(result, function(el) { el.__type = "people"; return self.create_on_change(el); }); @@ -138,23 +141,24 @@ openerp.web_linkedin = function(instance) { } else { // people to_change.is_company = false; to_change.name = entity.formattedName; - to_change.photo = false; + to_change.image = false; if (entity.pictureUrl) { defs.push(self.rpc('/web_linkedin/binary/url2binary', {'url': entity.pictureUrl}).pipe(function(data){ - to_change.photo = data; + to_change.image = data; })); } to_change.mobile = false; to_change.phone = false; - _.each(entity.phoneNumbers.values || [], function(el) { + _.each((entity.phoneNumbers || {}).values || [], function(el) { if (el.phoneType === "mobile") { to_change.mobile = el.phoneNumber; } else { to_change.phone = el.phoneNumber; } }); - to_change.function = entity.headline; + var positions = (entity.positions || {}).values || []; + to_change.function = positions.length > 0 ? positions[0].title : false; /* TODO to_change.linkedinUrl = entity.publicProfileUrl; */ @@ -169,14 +173,14 @@ openerp.web_linkedin = function(instance) { var commonPeopleFields = ["id", "picture-url", "public-profile-url", "formatted-name", "location", "phone-numbers", "im-accounts", - "main-address", "headline"]; + "main-address", "headline", "positions"]; instance.web_linkedin.LinkedinPopup = instance.web.Dialog.extend({ template: "Linkedin.popup", init: function(parent, text) { this._super(parent, {title:_t("LinkedIn search")}); this.text = text; - this.limit = 15; + this.limit = 5; }, start: function() { this._super(); @@ -196,38 +200,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"); @@ -238,8 +245,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")); } }, }); @@ -261,6 +268,7 @@ openerp.web_linkedin = function(instance) { } else { // people this.$("h3").text(this.data.formattedName); self.$("img").attr("src", this.data.pictureUrl); + self.$(".oe_linkedin_entity_headline").text(this.data.headline); } }, }); @@ -270,6 +278,7 @@ openerp.web_linkedin = function(instance) { template: "LinkedIn.KeyWizard", init: function(parent, text) { this._super(parent, {title:_t("LinkedIn API Key")}); + this.api_domain = window.location.origin; }, start: function() { this._super(); diff --git a/addons/web_linkedin/static/src/xml/linkedin.xml b/addons/web_linkedin/static/src/xml/linkedin.xml index 0d062e6fd8c..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"> @@ -21,6 +24,7 @@ </span> </span> <h3/> + <div class="oe_linkedin_entity_headline" /> </div> </t> <t t-name="LinkedIn.DisabledWarning"> @@ -41,8 +45,7 @@ <li>Log into LinkedIn.</li> <li>Add a new application and fill the form: <ul> - <li>JavaScript API Domain is Your domain name (e.g. https://yourcompany.my.openerp.com)</li> - <li>You can give multiple domain (e.g. yourcompany.my.openerp.com)</li> + <li>JavaScript API Domain: <t t-esc="widget.api_domain"/></li> <li>The programming tool is Javascript</li> </ul> </li> |
