O2Identity.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. MWF.widget = MWF.widget || {};
  2. MWF.require("MWF.widget.Common", null, false);
  3. MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
  4. MWF.widget.O2Identity = new Class({
  5. Implements: [Options, Events],
  6. Extends: MWF.widget.Common,
  7. options: {
  8. "style": "default",
  9. "canRemove": false,
  10. "lazy": false
  11. },
  12. initialize: function(data, container, options){
  13. this.setOptions(options);
  14. this.loadedInfor = false;
  15. this.path = MWF.defaultPath+"/widget/$O2Identity/";
  16. this.cssPath = MWF.defaultPath+"/widget/$O2Identity/"+this.options.style+"/css.wcss";
  17. this._loadCss();
  18. this.container = $(container);
  19. this.data = data;
  20. this.style = this.css;
  21. this.action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_control", "x_component_Org");
  22. // this.explorer = explorer;
  23. // this.removeAction = removeAction;
  24. this.load();
  25. },
  26. setText: function(){
  27. this.node.set("text", this.data.name+"("+this.data.unitName+")");
  28. },
  29. load: function(){
  30. if (!this.options.lazy) this.getPersonData();
  31. this.node = new Element("div", {"styles": this.style.identityNode}).inject(this.container);
  32. this.setText();
  33. if (this.options.canRemove){
  34. this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
  35. this.removeNode.addEvent("click", function(e){
  36. this.fireEvent("remove", [this, e]);
  37. e.stopPropagation();
  38. }.bind(this));
  39. }
  40. if (!this.options.lazy){
  41. this.createInforNode(function(){
  42. this.fireEvent("loadedInfor", [this]);
  43. }.bind(this));
  44. }else{
  45. this.node.addEvents({
  46. "mouseover": function(){
  47. if (!this.loadedInfor){
  48. this.getPersonData();
  49. this.createInforNode(function(){
  50. this.fireEvent("loadedInfor", [this]);
  51. }.bind(this));
  52. }
  53. }.bind(this)
  54. });
  55. }
  56. this.setEvent();
  57. this.node.addEvents({
  58. "mouseover": function(){
  59. this.node.setStyles(this.style.identityNode_over);
  60. }.bind(this),
  61. "mouseout": function(){
  62. this.node.setStyles(this.style.identityNode);
  63. }.bind(this)
  64. });
  65. },
  66. setEvent: function(){},
  67. getPersonData: function(){
  68. if (!this.data.dutys){
  69. var action = MWF.Actions.get("x_organization_assemble_control");
  70. var id = this.data.distinguishedName || this.data.id || this.data.unique;
  71. if (id) action.listUnitdutyByIdentity(id, function(json){
  72. this.data.dutys = json.data;
  73. }.bind(this), null, false);
  74. }
  75. if (!this.data.woPerson){
  76. // var uri = "/jaxrs/person/{flag}";
  77. // //uri = uri.replace("{flag}", this.data.person);
  78. // var uriIdentity = "/jaxrs/identity/{id}";
  79. this.action.actions = {
  80. "getPerson": {"uri": "/jaxrs/person/{flag}"},
  81. "getIdentity": {"uri": "/jaxrs/identity/{id}"}
  82. };
  83. var woPerson;
  84. if (this.data.person){
  85. this.action.invoke({"name": "getPerson", "async": false, "parameter": {"flag": this.data.person}, "success": function(json){
  86. this.data.woPerson = woPerson;
  87. woPerson = json.data;
  88. }.bind(this)});
  89. }else{
  90. this.action.invoke({"name": "getIdentity", "async": false, "parameter": {"id": this.data.id || this.data.name}, "success": function(json){
  91. this.data = json.data;
  92. woPerson = json.data.woPerson;
  93. }.bind(this)});
  94. }
  95. return woPerson;
  96. }else{
  97. return this.data.woPerson;
  98. }
  99. listDutyNameWithIdentity
  100. },
  101. createInforNode: function(callback){
  102. debugger;
  103. var person = this.getPersonData();
  104. if (person){
  105. this.inforNode = new Element("div", {
  106. "styles": this.style.identityInforNode
  107. });
  108. var nameNode = new Element("div", {
  109. "styles": this.style.identityInforNameNode
  110. }).inject(this.inforNode);
  111. var uri = "/jaxrs/person/{flag}/icon";
  112. uri = uri.replace("{flag}", person.id);
  113. this.action.getAddress();
  114. uri = this.action.address+uri;
  115. img = "<img width='50' height='50' border='0' src='"+uri+"' style='border-radius:25px'/>";
  116. var picNode = new Element("div", {
  117. "styles": this.style.identityInforPicNode,
  118. "html": img
  119. }).inject(nameNode);
  120. var rightNode = new Element("div", {
  121. "styles": this.style.identityInforRightTextNode
  122. }).inject(nameNode);
  123. var nameTextNode = new Element("div", {
  124. "styles": this.style.identityInforNameTextNode,
  125. "text": person.name
  126. }).inject(rightNode);
  127. var employeeTextNode = new Element("div", {
  128. "styles": this.style.identityInforEmployeeTextNode,
  129. "text": person.employee || ""
  130. }).inject(rightNode);
  131. // var phoneNode = new Element("div", {
  132. // "styles": this.style.identityInforPhoneNode,
  133. // "html": "<div style='width:30px; float:left'>"+MWF.LP.desktop.person.personMobile+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mobile || "")+"</div>"
  134. // }).inject(this.inforNode);
  135. // var mailNode = new Element("div", {
  136. // "styles": this.style.identityInforPhoneNode,
  137. // "html": "<div style='width:30px; float:left'>"+MWF.LP.desktop.person.personMail+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mail || "")+"</div>"
  138. // }).inject(this.inforNode);
  139. debugger;
  140. var dutys = [];
  141. if (this.data.dutys && this.data.dutys.length){
  142. this.data.dutys.each(function(d){
  143. var n = d.name+"("+d.woUnit.levelName+")";
  144. dutys.push(n);
  145. });
  146. }
  147. var dutyNode = new Element("div", {
  148. "styles": this.style.identityInforPhoneNode,
  149. "html": "<div style='width:30px; float:left'>"+MWF.LP.desktop.person.duty+": </div><div style='width:160px; float:left; margin-left:10px'>"+(dutys.join(","))+"</div>"
  150. }).inject(this.inforNode);
  151. this.loadedInfor = true;
  152. this.tooltip = new mBox.Tooltip({
  153. content: this.inforNode,
  154. setStyles: {content: {padding: 15, lineHeight: 20}},
  155. attach: this.node,
  156. transition: 'flyin'
  157. });
  158. }
  159. if (callback) callback();
  160. },
  161. destroy: function(){
  162. if (this.tooltip) this.tooltip.destroy();
  163. this.node.destroy();
  164. MWF.release(this);
  165. }
  166. });
  167. // MWF.widget.Person = new Class({
  168. // Implements: [Options, Events],
  169. // Extends: MWF.widget.Identity,
  170. // getPerson: function(callback){
  171. // if (this.data.name && this.data.id){
  172. // if (callback) callback({"data": this.data});
  173. // }else{
  174. // var key = this.data.name;
  175. // this.explorer.actions["getPerson"](function(json){
  176. // if (callback) callback(json);
  177. // }, null, key);
  178. // }
  179. // }
  180. // });
  181. MWF.widget.O2Person = new Class({
  182. Extends: MWF.widget.O2Identity,
  183. getPersonData: function(){
  184. if (!this.data.distinguishedName){
  185. this.action.actions = {"getPerson": {"uri": "/jaxrs/person/{id}"}};
  186. this.action.invoke({"name": "getPerson", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  187. this.data = json.data;
  188. }.bind(this)});
  189. }
  190. return this.data;
  191. },
  192. setText: function(){
  193. this.node.set("text", this.data.name);
  194. }
  195. });
  196. MWF.widget.O2Unit = new Class({
  197. Extends: MWF.widget.O2Identity,
  198. getPersonData: function(){
  199. if (!this.data.distinguishedName){
  200. this.action.actions = {"getUnit": {"uri": "/jaxrs/unit/{id}"}};
  201. this.action.invoke({"name": "getUnit", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  202. this.data = json.data;
  203. }.bind(this)});
  204. }
  205. },
  206. createInforNode: function(){
  207. this.inforNode = new Element("div", {
  208. "styles": this.style.identityInforNode
  209. });
  210. var nameNode = new Element("div", {
  211. "styles": this.style.identityInforNameNode,
  212. "text": this.data.levelName
  213. }).inject(this.inforNode);
  214. this.tooltip = new mBox.Tooltip({
  215. content: this.inforNode,
  216. setStyles: {content: {padding: 15, lineHeight: 20}},
  217. attach: this.node,
  218. transition: 'flyin'
  219. });
  220. },
  221. setText: function(){
  222. this.node.set("text", this.data.name);
  223. }
  224. });
  225. MWF.widget.O2Duty = new Class({
  226. Extends: MWF.widget.O2Identity,
  227. getPersonData: function(){
  228. if (!this.data.woUnit){
  229. this.action.actions = {"getUnitduty": {"uri": "/jaxrs/unitduty/{id}"}};
  230. this.action.invoke({"name": "getUnitduty", "async": false, "parameter": {"id": (this.data.dutyId || this.data.name)}, "success": function(json){
  231. this.data = json.data;
  232. }.bind(this)});
  233. }
  234. },
  235. createInforNode: function(){
  236. this.inforNode = new Element("div", {
  237. "styles": this.style.identityInforNode
  238. });
  239. var nameNode = new Element("div", {
  240. "styles": this.style.identityInforNameNode,
  241. "text": this.data.woUnit.levelName
  242. }).inject(this.inforNode);
  243. this.tooltip = new mBox.Tooltip({
  244. content: this.inforNode,
  245. setStyles: {content: {padding: 15, lineHeight: 20}},
  246. attach: this.node,
  247. transition: 'flyin'
  248. });
  249. },
  250. setText: function(){
  251. this.node.set("text", this.data.name);
  252. }
  253. });
  254. MWF.widget.O2Group = new Class({
  255. Extends: MWF.widget.O2Unit,
  256. getPersonData: function(){
  257. if (!this.data.distinguishedName){
  258. this.action.actions = {"getGroup": {"uri": "/jaxrs/group/{id}"}};
  259. this.action.invoke({"name": "getGroup", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  260. this.data = json.data;
  261. }.bind(this)});
  262. }
  263. },
  264. setText: function(){
  265. this.node.set("text", this.data.name);
  266. },
  267. createInforNode: function(){
  268. return false;
  269. }
  270. });
  271. MWF.widget.O2Application = new Class({
  272. Extends: MWF.widget.O2Group,
  273. getPersonData: function(){
  274. if (!this.data.name){
  275. this.action = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  276. this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
  277. this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  278. this.data = json.data;
  279. }.bind(this)});
  280. }
  281. }
  282. });
  283. MWF.widget.O2CMSApplication = new Class({
  284. Extends: MWF.widget.O2Group,
  285. getPersonData: function(){
  286. if (!this.data.name){
  287. MWF.Actions.get("x_cms_assemble_control").getApplication((this.data.id || this.data.name), function(json){
  288. this.data = json.data;
  289. }.bind(this), null, false);
  290. // this.action = new MWF.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
  291. // this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
  292. // this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  293. // this.data = json.data;
  294. // }.bind(this)});
  295. }
  296. }
  297. });
  298. MWF.widget.O2Process = new Class({
  299. Extends: MWF.widget.O2Group,
  300. getPersonData: function(){
  301. if (!this.data.name){
  302. this.action = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  303. this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
  304. this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  305. this.data = json.data;
  306. }.bind(this)});
  307. }
  308. },
  309. createInforNode: function(){
  310. this.inforNode = new Element("div", {
  311. "styles": this.style.identityInforNode
  312. });
  313. var nameNode = new Element("div", {
  314. "styles": this.style.identityInforNameNode,
  315. "text": this.data.applicationName || this.data.appName
  316. }).inject(this.inforNode);
  317. this.tooltip = new mBox.Tooltip({
  318. content: this.inforNode,
  319. setStyles: {content: {padding: 15, lineHeight: 20}},
  320. attach: this.node,
  321. transition: 'flyin'
  322. });
  323. }
  324. });
  325. MWF.widget.O2CMSCategory = new Class({
  326. Extends: MWF.widget.O2Group,
  327. getPersonData: function(){
  328. if (!this.data.name){
  329. MWF.Actions.get("x_cms_assemble_control").getCategory((this.data.id || this.data.name), function(json){
  330. this.data = json.data;
  331. }.bind(this), null, false);
  332. }
  333. },
  334. createInforNode: function(){
  335. this.inforNode = new Element("div", {
  336. "styles": this.style.identityInforNode
  337. });
  338. var nameNode = new Element("div", {
  339. "styles": this.style.identityInforNameNode,
  340. "text": this.data.applicationName || this.data.appName
  341. }).inject(this.inforNode);
  342. this.tooltip = new mBox.Tooltip({
  343. content: this.inforNode,
  344. setStyles: {content: {padding: 15, lineHeight: 20}},
  345. attach: this.node,
  346. transition: 'flyin'
  347. });
  348. }
  349. });
  350. MWF.widget.O2View = new Class({
  351. Extends: MWF.widget.O2Group,
  352. getPersonData: function(){
  353. debugger;
  354. if (!this.data.query){
  355. var data = null;
  356. MWF.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  357. data = json.data
  358. }, null, false);
  359. this.data = data;
  360. return data;
  361. }else{
  362. return this.data;
  363. }
  364. },
  365. createInforNode: function(){
  366. this.inforNode = new Element("div", {
  367. "styles": this.style.identityInforNode
  368. });
  369. var nameNode = new Element("div", {
  370. "styles": this.style.identityInforNameNode,
  371. "text": this.data.applicationName || this.data.appName || this.data.name
  372. }).inject(this.inforNode);
  373. this.tooltip = new mBox.Tooltip({
  374. content: this.inforNode,
  375. setStyles: {content: {padding: 15, lineHeight: 20}},
  376. attach: this.node,
  377. transition: 'flyin'
  378. });
  379. }
  380. });
  381. MWF.widget.O2CMSView = new Class({
  382. Extends: MWF.widget.O2View
  383. });
  384. MWF.widget.O2QueryView = new Class({
  385. Extends: MWF.widget.O2View,
  386. getPersonData: function(){
  387. if (!this.data.query){
  388. var data = null;
  389. MWF.Actions.get("x_query_assemble_surface").getViewById(this.data.id, function(json){
  390. data = json.data
  391. }, null, false);
  392. this.data = data;
  393. return data;
  394. }else{
  395. return this.data;
  396. }
  397. }
  398. });
  399. MWF.widget.O2QueryStat = new Class({
  400. Extends: MWF.widget.O2View,
  401. getPersonData: function(){
  402. if (!this.data.query){
  403. var data = null;
  404. MWF.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  405. data = json.data
  406. }, null, false);
  407. this.data = data;
  408. return data;
  409. }else{
  410. return this.data;
  411. }
  412. }
  413. });
  414. MWF.widget.O2FormField = new Class({
  415. Extends: MWF.widget.O2Group,
  416. getPersonData: function(){
  417. return this.data;
  418. }
  419. });
  420. MWF.widget.O2Role = new Class({
  421. Extends: MWF.widget.O2Group,
  422. getPersonData: function(){
  423. if (!this.data.distinguishedName){
  424. this.action.actions = {"getRole": {"uri": "/jaxrs/role/{id}"}};
  425. this.action.invoke({"name": "getRole", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  426. this.data = json.data;
  427. }.bind(this)});
  428. }
  429. }
  430. });
  431. MWF.widget.O2Other = new Class({
  432. Extends: MWF.widget.O2Group,
  433. getPersonData: function(){
  434. return this.data;
  435. }
  436. });