PersonExplorer_bak.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. MWF.require("MWF.xApplication.Organization.GroupExplorer", null, false);
  2. MWF.require("MWF.xApplication.Organization.OrgExplorer", null, false);
  3. MWF.xApplication.Organization.PersonExplorer = new Class({
  4. Extends: MWF.xApplication.Organization.GroupExplorer,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default"
  8. },
  9. initialize: function(node, actions, options){
  10. this.setOptions(options);
  11. this.path = "/x_component_Organization/$PersonExplorer/";
  12. this.cssPath = "/x_component_Organization/$PersonExplorer/"+this.options.style+"/css.wcss";
  13. this._loadCss();
  14. this.actions = actions;
  15. this.node = $(node);
  16. this.loaddingElement = false;
  17. this.groups = [];
  18. this.isElementLoaded = false;
  19. this.loadElementQueue = 0;
  20. this.deleteGroups = [];
  21. },
  22. loadElements: function(addToNext){
  23. if (!this.isElementLoaded){
  24. if (!this.loaddingElement){
  25. this.loaddingElement = true;
  26. this.actions.listPersonNext(this.getLastLoadedGroupId(), this.getPageNodeCount(), function(json){
  27. if (json.data.length){
  28. this.loadChartContent(json.data);
  29. this.loaddingElement = false;
  30. if (json.data.length<count){
  31. this.isElementLoaded = true;
  32. this.app.notice(this.app.lp.personLoaded, "ok", this.chartScrollNode, {"x": "center", "y": "bottom"});
  33. }else{
  34. if (this.loadElementQueue>0){
  35. this.loadElementQueue--;
  36. this.loadElements();
  37. }
  38. }
  39. }else{
  40. if (!this.groups.length){
  41. this.setNoGroupNoticeArea();
  42. }else{
  43. this.app.notice(this.app.lp.personLoaded, "ok", this.chartScrollNode, {"x": "center", "y": "bottom"});
  44. }
  45. this.isElementLoaded = true;
  46. this.loaddingElement = false;
  47. }
  48. }.bind(this));
  49. }else{
  50. if (addToNext) this.loadElementQueue++;
  51. }
  52. }
  53. },
  54. loadChartContent: function(data){
  55. data.each(function(itemData){
  56. var item = new MWF.xApplication.Organization.PersonExplorer.Person(itemData, this);
  57. this.groups.push(item);
  58. item.load();
  59. }.bind(this));
  60. },
  61. loadToolbar: function(){
  62. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode}).inject(this.chartAreaNode);
  63. this.addTopGroupNode = new Element("div", {"styles": this.css.addTopGroupNode}).inject(this.toolbarNode);
  64. this.addTopGroupNode.addEvent("click", function(){
  65. this.addTopGroup();
  66. }.bind(this));
  67. this.createSearchNode();
  68. },
  69. searchOrg: function(){
  70. var key = this.searchInputNode.get("value");
  71. if (key){
  72. if (key!=this.app.lp.searchText){
  73. var isSearchGroup = true;
  74. if (this.currentItem) isSearchGroup = this.currentItem.unSelected();
  75. if (isSearchGroup){
  76. this.actions.listPersonByKey(function(json){
  77. if (this.currentItem) this.currentItem.unSelected();
  78. this.clear();
  79. json.data.each(function(itemData){
  80. var item = new MWF.xApplication.Organization.PersonExplorer.Person(itemData, this);
  81. item.load();
  82. }.bind(this));
  83. }.bind(this), null, key);
  84. }else{
  85. this.app.notice(this.app.lp.groupSave, "error", this.propertyContentNode);
  86. }
  87. }else{
  88. if (this.currentItem) isSearchGroup = this.currentItem.unSelected();
  89. if (isSearchGroup){
  90. this.clear();
  91. this.loadElements();
  92. }else{
  93. this.app.notice(this.app.lp.groupSave, "error", this.propertyContentNode);
  94. }
  95. }
  96. }else{
  97. if (this.currentItem) isSearchGroup = this.currentItem.unSelected();
  98. if (isSearchGroup){
  99. this.clear();
  100. this.loadElements();
  101. }else{
  102. this.app.notice(this.app.lp.groupSave, "error", this.propertyContentNode);
  103. }
  104. }
  105. },
  106. addTopGroup: function(){
  107. var isNewGroup = true;
  108. if (this.currentItem) isNewGroup = this.currentItem.unSelected();
  109. if (isNewGroup){
  110. var newGroupData = {
  111. "employee": "",
  112. "password": "",
  113. "display": "",
  114. "qq": "",
  115. "mail": "",
  116. "weixin": "",
  117. "weibo": "",
  118. "mobile": "",
  119. "name": ""
  120. };
  121. var item = new MWF.xApplication.Organization.PersonExplorer.Person(newGroupData, this);
  122. item.load();
  123. item.selected();
  124. item.editBaseInfor();
  125. (new Fx.Scroll(this.chartScrollNode)).toElement(item.node);
  126. }else{
  127. this.app.notice(this.app.lp.groupSave, "error", this.propertyContentNode);
  128. }
  129. },
  130. deleteSelectedGroups: function(e){
  131. var _self = this;
  132. this.app.confirm("infor", e, this.app.lp.deleteGroupsTitle, this.app.lp.deleteGroupsConfirm, 300, 120, function(){
  133. var deleted = [];
  134. var doCount = 0;
  135. _self.deleteGroups.each(function(group){
  136. group["delete"](function(){
  137. deleted.push(group);
  138. doCount++;
  139. if (_self.deleteGroups.length==doCount){
  140. _self.deleteGroups = _self.deleteGroups.filter(function(item, index){
  141. return !deleted.contains(item);
  142. });
  143. _self.checkDeleteGroups();
  144. }
  145. }, function(){
  146. doCount++;
  147. if (_self.deleteGroups.length==doCount){
  148. _self.deleteGroups = _self.deleteGroups.filter(function(item, index){
  149. return !deleted.contains(item);
  150. });
  151. _self.checkDeleteGroups();
  152. }
  153. });
  154. });
  155. this.close();
  156. }, function(){
  157. this.close();
  158. });
  159. }
  160. });
  161. MWF.xApplication.Organization.PersonExplorer.Person = new Class({
  162. Extends: MWF.xApplication.Organization.GroupExplorer.Group,
  163. initialize: function(data, explorer){
  164. this.data = data;
  165. this.explorer = explorer;
  166. this.chartNode = this.explorer.chartNode;
  167. this.initStyle();
  168. this.selectedAttributes = [];
  169. this.isEdit = false;
  170. this.deleteSelected = false;
  171. },
  172. showItemProperty: function(){
  173. this.explorer.propertyTitleNode.set("text", this.data.name);
  174. this.showItemPropertyBase();
  175. this.showItemPropertyAttribute();
  176. this.showItemPropertyIdentity();
  177. },
  178. showItemPropertyBase: function(){
  179. this.propertyBaseNode = new Element("div", {
  180. "styles": this.style.propertyInforNode
  181. }).inject(this.explorer.propertyContentNode);
  182. this.baseActionNode = new Element("div", {
  183. "styles": this.style.propertyInforActionNode
  184. }).inject(this.propertyBaseNode);
  185. this.propertyBaseTextNode = new Element("div", {
  186. "styles": this.style.propertyInforTextNode,
  187. "text": this.explorer.app.lp.personBaseText
  188. }).inject(this.propertyBaseNode);
  189. this.createEditBaseNode();
  190. this.propertyBaseContentNode = new Element("div", {
  191. "styles": this.style.propertyInforContentNode
  192. }).inject(this.propertyBaseNode);
  193. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center'>";
  194. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personName+"</td><td id='formPersonName'></td></tr>";
  195. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personEmployee+"</td><td id='formPersonEmployee'></td></tr>";
  196. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personDisplay+"</td><td id='formPersonDisplay'></td></tr>";
  197. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personMobile+"</td><td id='formPersonMobile'></td></tr>";
  198. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personMail+"</td><td id='formPersonMail'></td></tr>";
  199. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personQQ+"</td><td id='formPersonQQ'></td></tr>";
  200. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personWeixin+"</td><td id='formPersonWeixin'></td></tr>";
  201. html += "<tr><td class='formTitle'>"+this.explorer.app.lp.personWeibo+"</td><td id='formPersonWeibo'></td></tr>";
  202. html += "</table>";
  203. this.propertyBaseContentNode.set("html", html);
  204. this.propertyBaseContentNode.getElements("td.formTitle").setStyles(this.style.propertyBaseContentTdTitle);
  205. this.personNameInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonName"), this.data.name, this.explorer.css.formInput);
  206. this.personEmployeeInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonEmployee"), this.data.employee, this.explorer.css.formInput);
  207. this.personDisplayInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonDisplay"), this.data.display, this.explorer.css.formInput);
  208. this.personMobileInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonMobile"), this.data.mobile, this.explorer.css.formInput);
  209. this.personMailInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonMail"), this.data.mail, this.explorer.css.formInput);
  210. this.personQQInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonQQ"), this.data.qq, this.explorer.css.formInput);
  211. this.personWeixinInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonWeixin"), this.data.weixin, this.explorer.css.formInput);
  212. this.personWeiboInput = new MWF.xApplication.Organization.GroupExplorer.Input(this.propertyBaseContentNode.getElement("#formPersonWeibo"), this.data.weibo, this.explorer.css.formInput);
  213. },
  214. editMode: function(){
  215. this.personNameInput.editMode();
  216. this.personEmployeeInput.editMode();
  217. this.personDisplayInput.editMode();
  218. this.personMobileInput.editMode();
  219. this.personMailInput.editMode();
  220. this.personQQInput.editMode();
  221. this.personWeixinInput.editMode();
  222. this.personWeiboInput.editMode();
  223. this.isEdit = true;
  224. },
  225. readMode: function(){
  226. this.personNameInput.readMode();
  227. this.personEmployeeInput.readMode();
  228. this.personDisplayInput.readMode();
  229. this.personMobileInput.readMode();
  230. this.personMailInput.readMode();
  231. this.personQQInput.readMode();
  232. this.personWeixinInput.readMode();
  233. this.personWeiboInput.readMode();
  234. this.isEdit = false;
  235. },
  236. saveBaseInfor: function(){
  237. if (!this.personNameInput.input.get("value") || !this.personEmployeeInput.input.get("value")){
  238. this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor, "error", this.explorer.propertyContentNode);
  239. return false;
  240. }
  241. if (this.personDisplayInput.input.get("value")) this.data.display = this.personNameInput.input.get("value");
  242. this.propertyBaseNode.mask({
  243. "style": {
  244. "opacity": 0.7,
  245. "background-color": "#999"
  246. }
  247. });
  248. this.save(function(){
  249. this.baseActionNode.empty();
  250. this.cancelBaseNode = null;
  251. this.saveBaseNode = null;
  252. this.createEditBaseNode();
  253. this.readMode();
  254. this.propertyBaseNode.unmask();
  255. }.bind(this), function(xhr, text, error){
  256. var errorText = error;
  257. if (xhr) errorText = xhr.responseText;
  258. this.explorer.app.notice("request json error: "+errorText, "error");
  259. this.propertyBaseNode.unmask();
  260. }.bind(this));
  261. },
  262. save: function(callback, cancel){
  263. this.data.name = this.personNameInput.input.get("value");
  264. this.data.employee = this.personEmployeeInput.input.get("value");
  265. this.data.display = this.personDisplayInput.input.get("value");
  266. this.data.mobile = this.personMobileInput.input.get("value");
  267. this.data.mail = this.personMailInput.input.get("value");
  268. this.data.qq = this.personQQInput.input.get("value");
  269. this.data.weixin = this.personWeixinInput.input.get("value");
  270. this.data.weibo = this.personWeiboInput.input.get("value");
  271. this.explorer.actions.savePerson(this.data, function(json){
  272. this.textNode.set("text", this.data.name);
  273. this.data.id = json.data.id;
  274. this.personNameInput.save();
  275. this.personEmployeeInput.save();
  276. this.personDisplayInput.save();
  277. this.personMobileInput.save();
  278. this.personMailInput.save();
  279. this.personQQInput.save();
  280. this.personWeixinInput.save();
  281. this.personWeiboInput.save();
  282. if (callback) callback();
  283. }.bind(this), function(xhr, text, error){
  284. if (cancel) cancel(xhr, text, error);
  285. }.bind(this));
  286. },
  287. showItemPropertyAttribute: function(){
  288. this.propertyAttributeNode = new Element("div", {
  289. "styles": this.style.propertyInforNode
  290. }).inject(this.explorer.propertyContentNode);
  291. this.attributeActionNode = new Element("div", {
  292. "styles": this.style.propertyInforActionNode
  293. }).inject(this.propertyAttributeNode);
  294. this.propertyAttributeTextNode = new Element("div", {
  295. "styles": this.style.propertyInforTextNode,
  296. "text": this.explorer.app.lp.personAttributeText
  297. }).inject(this.propertyAttributeNode);
  298. // this.createEditBaseNode();
  299. this.propertyAttributeContentNode = new Element("div", {
  300. "styles": this.style.propertyInforContentNode
  301. }).inject(this.propertyAttributeNode);
  302. this.createDeleteAttributeNode();
  303. this.createAddAttributeNode();
  304. this.listAttribute();
  305. },
  306. createAddAttributeNode: function(){
  307. this.addAttributeNode = new Element("button", {
  308. "styles": this.style.addDutyNode,
  309. "text": this.explorer.app.lp.add,
  310. "events": {"click": this.addAttribute.bind(this)}
  311. }).inject(this.attributeActionNode);
  312. },
  313. createDeleteAttributeNode: function(){
  314. this.deleteAttributeNode = new Element("button", {
  315. "styles": this.style.deleteDutyNode_desable,
  316. "text": this.explorer.app.lp["delete"],
  317. "disable": true
  318. }).inject(this.attributeActionNode);
  319. },
  320. addAttribute: function(){
  321. var data = this.getNewAttributeData();
  322. new MWF.xApplication.Organization.PersonAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
  323. },
  324. getNewAttributeData: function(){
  325. return {
  326. "person": this.data.id,
  327. "name": "",
  328. "attributeList":[]
  329. };
  330. },
  331. checkDeleteAttributeAction: function(){
  332. if (this.selectedAttributes.length){
  333. if (this.deleteAttributeNode.get("disable")){
  334. this.deleteAttributeNode.set({
  335. "styles": this.style.deleteDutyNode
  336. });
  337. this.deleteAttributeNode.removeProperty("disable");
  338. this.deleteAttributeNode.addEvent("click", function(e){this.deleteAttribute(e);}.bind(this));
  339. }
  340. }else{
  341. if (!this.deleteAttributeNode.get("disable")){
  342. this.deleteAttributeNode.set({
  343. "styles": this.style.deleteDutyNode_desable,
  344. "disable": true
  345. });
  346. this.deleteAttributeNode.removeEvents("click");
  347. }
  348. }
  349. },
  350. deleteAttribute: function(e){
  351. var _self = this;
  352. this.explorer.app.confirm("infor", e, this.explorer.app.lp.deleteAttributeTitle, this.explorer.app.lp.deleteAttribute, 300, 120, function(){
  353. this.close();
  354. _self.selectedAttributes.each(function(attribute){
  355. attribute.remove();
  356. });
  357. delete _self.selectedAttributes;
  358. _self.selectedAttribute = [];
  359. _self.checkDeleteAttributeAction();
  360. }, function(){this.close();});
  361. },
  362. listAttribute: function(){
  363. var html = "<table cellspacing='0' cellpadding='5' border='0' width='95%' align='center' style='line-height:normal'>";
  364. html += "<tr><th style='width:20px'></th>";
  365. html += "<th style='width: 30%; border-right: 1px solid #FFF'>"+this.explorer.app.lp.attributeName+"</th>";
  366. html += "<th>"+this.explorer.app.lp.attributeValue+"</th><th style='width:20px'></th></tr>";
  367. html += "</table>";
  368. this.propertyAttributeContentNode.set("html", html);
  369. this.propertyAttributeContentNode.getElements("th").setStyles(this.style.propertyDutyContentTdTitle);
  370. if (this.data.id){
  371. this.explorer.actions.listPersonAttribute(function(json){
  372. json.data.each(function(item){
  373. new MWF.xApplication.Organization.PersonAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), item, this, this.explorer.css.map);
  374. }.bind(this));
  375. }.bind(this), null, this.data.id);
  376. }
  377. },
  378. showItemPropertyIdentity:function(){
  379. this.propertyIdentityNode = new Element("div", {
  380. "styles": this.style.propertyInforNode
  381. }).inject(this.explorer.propertyContentNode);
  382. this.identityActionNode = new Element("div", {
  383. "styles": this.style.propertyInforActionNode
  384. }).inject(this.propertyIdentityNode);
  385. this.propertyIdentityTextNode = new Element("div", {
  386. "styles": this.style.propertyInforTextNode,
  387. "text": this.explorer.app.lp.personIdentityText
  388. }).inject(this.propertyIdentityNode);
  389. // this.createEditBaseNode();
  390. this.propertyIdentityContentNode = new Element("div", {
  391. "styles": this.style.propertyInforContentNode
  392. }).inject(this.propertyIdentityNode);
  393. this.listIdentity();
  394. },
  395. listIdentity: function(){
  396. if (this.data.id){
  397. this.explorer.actions.listIdentityByPerson(function(json){
  398. json.data.each(function(item){
  399. new MWF.xApplication.Organization.PersonExplorer.Identity(this.propertyIdentityContentNode, item, this, this.style);
  400. }.bind(this));
  401. }.bind(this), null, this.data.id);
  402. }
  403. },
  404. destroy: function(){
  405. this.explorer.currentItem = null;
  406. this.clearItemProperty();
  407. this.node.destroy();
  408. delete this;
  409. },
  410. "delete": function(success, failure){
  411. this.explorer.actions.deleteRole(this.data.id, function(){
  412. this.destroy();
  413. if (success) success();
  414. }.bind(this), function(xhr, text, error){
  415. var errorText = error;
  416. if (xhr) errorText = xhr.responseText;
  417. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  418. if (failure) failure();
  419. });
  420. }
  421. });
  422. MWF.xApplication.Organization.PersonAttribute = new Class({
  423. Extends: MWF.xApplication.Organization.CompanyAttribute,
  424. saveValue: function(value){
  425. var oldValue = this.data.attributeList;
  426. this.data.attributeList = value.split("/,\s*/");
  427. this.item.explorer.actions.savePersonAttribute(this.data, function(json){
  428. this.data.id = json.data.id;
  429. this.valueNode.empty();
  430. this.valueInput = null;
  431. this.valueNode.set("text", this.data.attributeList.join(","));
  432. }.bind(this), function(xhr, text, error){
  433. this.data.attributeList = oldValue;
  434. this.valueInput.focus();
  435. var errorText = error;
  436. if (xhr) errorText = xhr.responseText;
  437. this.item.explorer.app.notice("request json error: "+errorText, "error");
  438. }.bind(this));
  439. },
  440. save: function(name){
  441. var oldName = this.data.name;
  442. this.data.name = name;
  443. this.item.explorer.actions.savePersonAttribute(this.data, function(json){
  444. this.data.id = json.data.id;
  445. this.nameNode.empty();
  446. this.input = null;
  447. this.nameNode.set("text", this.data.name);
  448. }.bind(this), function(xhr, text, error){
  449. this.data.name = oldName;
  450. this.input.focus();
  451. var errorText = error;
  452. if (xhr) errorText = xhr.responseText;
  453. this.item.explorer.app.notice("request json error: "+errorText, "error");
  454. }.bind(this));
  455. },
  456. remove: function(){
  457. this.item.explorer.actions.deletePersonAttribute(this.data.id, function(){
  458. this.node.destroy();
  459. delete this;
  460. }.bind(this));
  461. }
  462. });
  463. MWF.xApplication.Organization.PersonExplorer.Identity = new Class({
  464. initialize: function(container, data, item, style){
  465. this.container = $(container);
  466. this.data = data;
  467. this.style = style;
  468. this.item = item;
  469. this.load();
  470. },
  471. load: function(){
  472. this.node = new Element("div", {
  473. "styles": this.style.identityNode
  474. }).inject(this.container);
  475. var nameNode = new Element("div", {
  476. "styles": this.style.identityInforNameNode
  477. }).inject(this.node);
  478. var picNode = new Element("div", {
  479. "styles": this.style.identityInforPicNode,
  480. "html": "<img width='50' height='50' border='0' src='"+"/x_component_Organization/$PersonExplorer/default/icon/head.png'></img>"
  481. }).inject(nameNode);
  482. var nameTextNode = new Element("div", {
  483. "styles": this.style.identityInforNameTextNode,
  484. "text": this.data.name
  485. }).inject(nameNode);
  486. var departmentNode = new Element("div", {"styles": this.style.identityDepartmentNode}).inject(this.node);
  487. var departmentTitleNode = new Element("div", {
  488. "styles": this.style.identityTitleNode,
  489. "text": this.item.explorer.app.lp.department
  490. }).inject(departmentNode);
  491. this.departmentTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(departmentNode);
  492. var companyNode = new Element("div", {"styles": this.style.identityCompanyNode}).inject(this.node);
  493. var companyTitleNode = new Element("div", {
  494. "styles": this.style.identityTitleNode,
  495. "text": this.item.explorer.app.lp.company
  496. }).inject(companyNode);
  497. this.companyTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(companyNode);
  498. var dutyNode = new Element("div", {"styles": this.style.identityDutyNode}).inject(this.node);
  499. var dutyTitleNode = new Element("div", {
  500. "styles": this.style.identityTitleNode,
  501. "text": this.item.explorer.app.lp.duty
  502. }).inject(dutyNode);
  503. this.dutyTextNode = new Element("div", {"styles": this.style.identityTextNode}).inject(dutyNode);
  504. this.item.explorer.actions.getDepartment(function(json){
  505. this.department = json.data;
  506. this.departmentTextNode.set({"text": this.department.name, "title": this.department.name});
  507. this.item.explorer.actions.getCompany(function(json){
  508. this.company = json.data;
  509. this.companyTextNode.set({"text": this.company.name, "text": this.company.name});
  510. }.bind(this), null, this.department.company);
  511. }.bind(this), null, this.data.department);
  512. this.item.explorer.actions.listCompanyDutyByIdentity(function(json){
  513. json.data.each(function(duty){
  514. var text = this.dutyTextNode.get("text");
  515. if (text){
  516. text = text+", "+duty.name;
  517. }else{
  518. text = duty.name;
  519. }
  520. this.dutyTextNode.set({"text": text, "title": text});
  521. }.bind(this));
  522. }.bind(this), null, this.data.id);
  523. this.item.explorer.actions.listDepartmentDutyByIdentity(function(json){
  524. json.data.each(function(duty){
  525. var text = this.dutyTextNode.get("text");
  526. if (text){
  527. text = text+", "+duty.name;
  528. }else{
  529. text = duty.name;
  530. }
  531. this.dutyTextNode.set({"text": text, "title": text});
  532. }.bind(this));
  533. }.bind(this), null, this.data.id);
  534. }
  535. });