O2Identity.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. o2.widget = o2.widget || {};
  2. o2.require("o2.widget.Common", null, false);
  3. o2.require("o2.xDesktop.Common", null, false);
  4. o2.require("o2.xDesktop.Actions.RestActions", null, false);
  5. o2.widget.O2Identity = new Class({
  6. Implements: [Options, Events],
  7. Extends: o2.widget.Common,
  8. options: {
  9. "style": "default",
  10. "canRemove": false,
  11. "lazy": false,
  12. "disableInfor" : false,
  13. "removeByClick": false,
  14. "styles": "",
  15. "delay": false
  16. },
  17. initialize: function(data, container, options){
  18. this.setOptions(options);
  19. this.loadedInfor = false;
  20. this.path = o2.session.path+"/widget/$O2Identity/";
  21. this.cssPath = o2.session.path+"/widget/$O2Identity/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.container = $(container);
  24. this.data = data;
  25. this.style = this.css;
  26. this.action = new o2.xDesktop.Actions.RestActions("", "x_organization_assemble_control", "x_component_Org");
  27. // this.explorer = explorer;
  28. // this.removeAction = removeAction;
  29. if(!this.options.delay)this.load();
  30. //o2.widget.O2Identity.iditems.push(this);
  31. },
  32. setText: function(){
  33. var disply;
  34. if( this.data.displayName ){
  35. disply = this.data.displayName;
  36. }else{
  37. var name = this.data.name || o2.name.cn(this.data.distinguishedName);
  38. var unit;
  39. if(this.data.unitName){
  40. unit = this.data.unitName;
  41. }else if( this.data.unitLevelName ){
  42. var list = this.data.unitLevelName.split("/");
  43. unit = list[ list.length - 1 ];
  44. }
  45. disply = name + (unit ? "("+unit+")" : "")
  46. }
  47. this.node.set("text", this.data.displayName || disply );
  48. },
  49. load: function(){
  50. this.fireEvent("queryLoad");
  51. var style = ( layout.mobile && this.style.identityNode_mobile ) ?
  52. this.style.identityNode_mobile : this.style.identityNode;
  53. if (!this.options.lazy && !this.options.disableInfor) this.getPersonData();
  54. this.node = new Element("div", {"styles": style }).inject(this.container);
  55. if( this.options.styles ){
  56. this.node.setStyles( this.options.styles );
  57. }
  58. this.setText();
  59. if( this.options.removeByClick ){
  60. this.node.addEvent("click", function(e){
  61. this.fireEvent("remove", [this, e]);
  62. e.stopPropagation();
  63. }.bind(this));
  64. }
  65. if (this.options.canRemove){
  66. this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
  67. this.removeNode.addEvent("click", function(e){
  68. this.fireEvent("remove", [this, e]);
  69. e.stopPropagation();
  70. }.bind(this));
  71. }
  72. if( !this.options.disableInfor && !layout.mobile){
  73. if (!this.options.lazy ){
  74. this.createInforNode(function(){
  75. this.fireEvent("loadedInfor", [this]);
  76. }.bind(this));
  77. }else{
  78. this.node.addEvents({
  79. "mouseover": function(){
  80. if (!this.loadedInfor){
  81. this.getPersonData();
  82. this.createInforNode(function(){
  83. this.fireEvent("loadedInfor", [this]);
  84. }.bind(this));
  85. }
  86. }.bind(this)
  87. });
  88. }
  89. }
  90. this.setEvent();
  91. if( !layout.mobile ){
  92. this.node.addEvents({
  93. "mouseover": function(){
  94. // var style_over = ( layout.mobile && this.style.identityNode_over_mobile ) ?
  95. // this.style.identityNode_over_mobile : this.style.identityNode_over;
  96. this.node.setStyles( this.style.identityNode_over ); //style_over
  97. if( this.options.styles ){
  98. this.node.setStyles( this.options.styles );
  99. }
  100. }.bind(this),
  101. "mouseout": function(){
  102. // var style = ( layout.mobile && this.style.identityNode_mobile ) ?
  103. // this.style.identityNode_mobile : this.style.identityNode;
  104. this.node.setStyles( this.style.identityNode ); //style
  105. if( this.options.styles ){
  106. this.node.setStyles( this.options.styles );
  107. }
  108. }.bind(this)
  109. });
  110. }
  111. this.fireEvent("postLoad");
  112. },
  113. setEvent: function(){
  114. if( this.open ){
  115. this.node.addEvents({
  116. "click": function(ev){
  117. this.open(ev);
  118. ev.stopPropagation();
  119. }.bind(this)
  120. });
  121. }
  122. },
  123. getPersonData: function(){
  124. if (!this.data.dutys){
  125. var action = o2.Actions.get("x_organization_assemble_control");
  126. var id = this.data.distinguishedName || this.data.id || this.data.unique;
  127. if (id) action.listUnitdutyByIdentity(id, function(json){
  128. this.data.dutys = json.data;
  129. }.bind(this), null, false);
  130. }
  131. if (!this.data.woPerson){
  132. // var uri = "/jaxrs/person/{flag}";
  133. // //uri = uri.replace("{flag}", this.data.person);
  134. // var uriIdentity = "/jaxrs/identity/{id}";
  135. this.action.actions = {
  136. "getPerson": {"uri": "/jaxrs/person/{flag}"},
  137. "getIdentity": {"uri": "/jaxrs/identity/{id}"}
  138. };
  139. var woPerson;
  140. if (this.data.person){
  141. this.action.invoke({"name": "getPerson", "async": false, "parameter": {"flag": this.data.person}, "success": function(json){
  142. this.data.woPerson = woPerson;
  143. woPerson = json.data;
  144. }.bind(this)});
  145. }else{
  146. this.action.invoke({"name": "getIdentity", "async": false, "parameter": {"id": this.data.distinguishedName || this.data.id || this.data.name}, "success": function(json){
  147. this.data = json.data;
  148. woPerson = json.data.woPerson;
  149. }.bind(this)});
  150. }
  151. return woPerson;
  152. }else{
  153. return this.data.woPerson;
  154. }
  155. //listDutyNameWithIdentity
  156. },
  157. createInforNode: function(callback){
  158. var person = this.getPersonData();
  159. if (person){
  160. this.inforNode = new Element("div", {
  161. "styles": this.style.identityInforNode
  162. });
  163. var nameNode = new Element("div", {
  164. "styles": this.style.identityInforNameNode
  165. }).inject(this.inforNode);
  166. var uri = "/jaxrs/person/{flag}/icon";
  167. uri = uri.replace("{flag}", person.id || person.unique || person.distinguishedName );
  168. this.action.getAddress();
  169. uri = this.action.address+uri;
  170. uri = o2.filterUrl(uri);
  171. img = "<img width='50' height='50' border='0' src='"+uri+"' style='border-radius:25px'/>";
  172. var picNode = new Element("div", {
  173. "styles": this.style.identityInforPicNode,
  174. "html": img
  175. }).inject(nameNode);
  176. var rightNode = new Element("div", {
  177. "styles": this.style.identityInforRightTextNode
  178. }).inject(nameNode);
  179. var nameTextNode = new Element("div", {
  180. "styles": this.style.identityInforNameTextNode,
  181. "text": person.name
  182. }).inject(rightNode);
  183. var employeeTextNode = new Element("div", {
  184. "styles": this.style.identityInforEmployeeTextNode,
  185. "text": person.employee || ""
  186. }).inject(rightNode);
  187. // var phoneNode = new Element("div", {
  188. // "styles": this.style.identityInforPhoneNode,
  189. // "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.personMobile+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mobile || "")+"</div>"
  190. // }).inject(this.inforNode);
  191. // var mailNode = new Element("div", {
  192. // "styles": this.style.identityInforPhoneNode,
  193. // "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.personMail+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mail || "")+"</div>"
  194. // }).inject(this.inforNode);
  195. var dutys = [];
  196. if (this.data.dutys && this.data.dutys.length){
  197. this.data.dutys.each(function(d){
  198. var n = d.name+"("+d.woUnit.levelName+")";
  199. dutys.push(n);
  200. });
  201. }
  202. var dutyNode = new Element("div", {
  203. "styles": this.style.identityInforPhoneNode,
  204. "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.duty+": </div><div style='width:160px; float:left; margin-left:10px'>"+(dutys.join(","))+"</div>"
  205. }).inject(this.inforNode);
  206. this.loadedInfor = true;
  207. this.tooltip = new mBox.Tooltip({
  208. content: this.inforNode,
  209. setStyles: {content: {padding: 15, lineHeight: 20}},
  210. attach: this.node,
  211. transition: 'flyin'
  212. });
  213. }
  214. if (callback) callback();
  215. },
  216. destroy: function(){
  217. if (this.tooltip) this.tooltip.destroy();
  218. this.node.destroy();
  219. o2.release(this);
  220. }
  221. });
  222. // o2.widget.Person = new Class({
  223. // Implements: [Options, Events],
  224. // Extends: o2.widget.Identity,
  225. // getPerson: function(callback){
  226. // if (this.data.name && this.data.id){
  227. // if (callback) callback({"data": this.data});
  228. // }else{
  229. // var key = this.data.name;
  230. // this.explorer.actions["getPerson"](function(json){
  231. // if (callback) callback(json);
  232. // }, null, key);
  233. // }
  234. // }
  235. // });
  236. o2.widget.O2Person = new Class({
  237. Extends: o2.widget.O2Identity,
  238. options: {
  239. "lazy": true
  240. },
  241. getPersonData: function(){
  242. if (!this.data.distinguishedName || !this.data.dutys ){
  243. this.action.actions = {"getPerson": {"uri": "/jaxrs/person/{id}"}};
  244. this.action.invoke({"name": "getPerson", "async": false, "parameter": {"id": (this.data.distinguishedName || this.data.id || this.data.name)}, "success": function(json){
  245. this.data = json.data;
  246. var dutyList = [];
  247. if( this.data.woIdentityList && this.data.woIdentityList.length ){
  248. this.data.woIdentityList.each(function (id) {
  249. if(id.woUnitDutyList && id.woUnitDutyList.length)dutyList = dutyList.concat(id.woUnitDutyList);
  250. })
  251. }
  252. this.data.dutys = dutyList;
  253. }.bind(this)});
  254. }
  255. return this.data;
  256. },
  257. setText: function(){
  258. var displayName;
  259. if(this.data.displayName){
  260. displayName = this.data.displayName;
  261. }else if(this.data.name && this.data.name.indexOf("@") > -1){
  262. displayName = this.data.name.split("@")[0];
  263. }else if( this.data.name && this.data.name.length === 36 ){
  264. this.data.id = this.data.name;
  265. this.getPersonData();
  266. displayName = this.data.name || this.data.distinguishedName.split("@")[0];
  267. }else{
  268. displayName = this.data.name || "";
  269. }
  270. this.node.set("text", displayName);
  271. }
  272. });
  273. o2.widget.O2Unit = new Class({
  274. Extends: o2.widget.O2Identity,
  275. getPersonData: function(){
  276. if (!this.data.distinguishedName || !this.data.levelName){
  277. this.action.actions = {"getUnit": {"uri": "/jaxrs/unit/{id}"}};
  278. this.action.invoke({"name": "getUnit", "async": false, "parameter": {"id": (this.data.id || this.data.distinguishedName || this.data.name)}, "success": function(json){
  279. this.data = json.data;
  280. }.bind(this)});
  281. }
  282. },
  283. createInforNode: function(){
  284. this.inforNode = new Element("div", {
  285. "styles": this.style.identityInforNode
  286. });
  287. var nameNode = new Element("div", {
  288. "styles": this.style.identityInforNameNode,
  289. "text": this.data.levelName
  290. }).inject(this.inforNode);
  291. this.tooltip = new mBox.Tooltip({
  292. content: this.inforNode,
  293. setStyles: {content: {padding: 15, lineHeight: 20}},
  294. attach: this.node,
  295. transition: 'flyin'
  296. });
  297. },
  298. setText: function(){
  299. this.node.set("text", this.data.displayName || this.data.name);
  300. }
  301. });
  302. o2.widget.O2Duty = new Class({
  303. Extends: o2.widget.O2Identity,
  304. getPersonData: function(){
  305. return this.data;
  306. // if (!this.data.woUnit){
  307. // this.action.actions = {"getUnitduty": {"uri": "/jaxrs/unitduty/{id}"}};
  308. // this.action.invoke({"name": "getUnitduty", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  309. // this.data = json.data;
  310. // }.bind(this)});
  311. // }
  312. },
  313. createInforNode: function(){
  314. if( this.options.showUnit && this.data.woUnit && this.data.woUnit.levelName ){
  315. this.inforNode = new Element("div", {
  316. "styles": this.style.identityInforNode
  317. });
  318. var nameNode = new Element("div", {
  319. "text": this.data.displayName || this.data.name
  320. }).inject(this.inforNode);
  321. var nameTextNode = new Element("div", {
  322. "text": this.data.woUnit.levelName
  323. }).inject(this.inforNode);
  324. this.tooltip = new mBox.Tooltip({
  325. content: this.inforNode,
  326. setStyles: {content: {padding: 15, lineHeight: 20}},
  327. attach: this.node,
  328. transition: 'flyin'
  329. });
  330. }else{
  331. return false;
  332. }
  333. // this.inforNode = new Element("div", {
  334. // "styles": this.style.identityInforNode
  335. // });
  336. // var nameNode = new Element("div", {
  337. // "styles": this.style.identityInforNameNode,
  338. // "text": this.data.woUnit.levelName
  339. // }).inject(this.inforNode);
  340. // this.tooltip = new mBox.Tooltip({
  341. // content: this.inforNode,
  342. // setStyles: {content: {padding: 15, lineHeight: 20}},
  343. // attach: this.node,
  344. // transition: 'flyin'
  345. // });
  346. },
  347. setText: function(){
  348. if( this.options.showUnit && this.data.woUnit ){
  349. var unit = this.data.woUnit.name ? ("("+this.data.woUnit.name+")") : "";
  350. this.node.set("text", (this.data.displayName || this.data.name)+unit);
  351. }else{
  352. this.node.set("text", this.data.displayName || this.data.name);
  353. }
  354. }
  355. });
  356. o2.widget.O2Group = new Class({
  357. Extends: o2.widget.O2Unit,
  358. getPersonData: function(){
  359. if (!this.data.distinguishedName){
  360. this.action.actions = {"getGroup": {"uri": "/jaxrs/group/{id}"}};
  361. this.action.invoke({"name": "getGroup", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  362. this.data = json.data;
  363. }.bind(this)});
  364. }
  365. },
  366. setText: function(){
  367. this.node.set("text", this.data.displayName || this.data.name);
  368. },
  369. createInforNode: function(){
  370. return false;
  371. }
  372. });
  373. o2.widget.O2Application = new Class({
  374. Extends: o2.widget.O2Group,
  375. getPersonData: function(){
  376. if (!this.data.name){
  377. this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  378. this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
  379. this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  380. this.data = json.data;
  381. }.bind(this)});
  382. }
  383. }
  384. });
  385. o2.widget.O2Portal = new Class({
  386. Extends: o2.widget.O2Group,
  387. getPersonData: function(){
  388. if (!this.data.name){
  389. this.action = new o2.xDesktop.Actions.RestActions("", "x_portal_assemble_surface", "");
  390. this.action.actions = {"getPortal": {"uri": "/jaxrs/portal/{id}"}};
  391. this.action.invoke({"name": "getPortal", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  392. this.data = json.data;
  393. }.bind(this)});
  394. }
  395. }
  396. });
  397. o2.widget.O2CMSApplication = new Class({
  398. Extends: o2.widget.O2Group,
  399. getPersonData: function(){
  400. if (!this.data.name){
  401. o2.Actions.get("x_cms_assemble_control").getApplication(this.data.id || this.data.name, function(json){
  402. this.data = json.data;
  403. if(!this.data.name)this.data.name = this.data.appName;
  404. if(!this.data.alias)this.data.alias = this.data.appAlias;
  405. }.bind(this), null, false);
  406. // this.action = new o2.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
  407. // this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
  408. // this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  409. // this.data = json.data;
  410. // }.bind(this)});
  411. }
  412. }
  413. });
  414. o2.widget.O2Process = new Class({
  415. Extends: o2.widget.O2Group,
  416. getPersonData: function(){
  417. if (!this.data.name){
  418. this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  419. this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
  420. this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  421. this.data = json.data;
  422. }.bind(this)});
  423. }
  424. },
  425. createInforNode: function(){
  426. this.inforNode = new Element("div", {
  427. "styles": this.style.identityInforNode
  428. });
  429. var nameNode = new Element("div", {
  430. "styles": this.style.identityInforNameNode,
  431. "text": this.data.name || this.data.applicationName || this.data.appName
  432. }).inject(this.inforNode);
  433. this.tooltip = new mBox.Tooltip({
  434. content: this.inforNode,
  435. setStyles: {content: {padding: 15, lineHeight: 20}},
  436. attach: this.node,
  437. transition: 'flyin'
  438. });
  439. },
  440. open : function (e) {
  441. debugger;
  442. if( this.data.id && this.data.application ){
  443. var appId = "process.ProcessManager" + this.data.application;
  444. if (layout.desktop.apps[appId]){
  445. layout.desktop.apps[appId].setCurrent();
  446. }else {
  447. var options = { "application": {
  448. "id": this.data.application,
  449. "name": this.data.applicationName || ""
  450. }};
  451. layout.desktop.openApplication(e, "process.ProcessManager", options);
  452. }
  453. }
  454. }
  455. });
  456. o2.widget.O2CMSCategory = new Class({
  457. Extends: o2.widget.O2Group,
  458. getPersonData: function(){
  459. if (!this.data.name){
  460. o2.Actions.get("x_cms_assemble_control").getCategory((this.data.id || this.data.name), function(json){
  461. this.data = json.data;
  462. this.data.name = this.data.categoryName;
  463. }.bind(this), null, false);
  464. }
  465. },
  466. createInforNode: function(){
  467. this.inforNode = new Element("div", {
  468. "styles": this.style.identityInforNode
  469. });
  470. var nameNode = new Element("div", {
  471. "styles": this.style.identityInforNameNode,
  472. "text": this.data.applicationName || this.data.appName
  473. }).inject(this.inforNode);
  474. this.tooltip = new mBox.Tooltip({
  475. content: this.inforNode,
  476. setStyles: {content: {padding: 15, lineHeight: 20}},
  477. attach: this.node,
  478. transition: 'flyin'
  479. });
  480. },
  481. open : function (e) {
  482. debugger;
  483. if( this.data.id && this.data.appId ){
  484. // var appId = "cms.ColumnManager" + this.data.id;
  485. // if (layout.desktop.apps[appId]){
  486. // layout.desktop.apps[appId].setCurrent();
  487. // }else {
  488. var options = {
  489. "navi":"categoryConfig",
  490. "column":{
  491. "id" : this.data.appId,
  492. "appName": this.data.appName || ""
  493. },
  494. "currentCategoryId":this.data.id
  495. };
  496. layout.desktop.openApplication(e, "cms.ColumnManager", options);
  497. // }
  498. }
  499. }
  500. });
  501. o2.widget.O2View = new Class({
  502. Extends: o2.widget.O2Group,
  503. getPersonData: function(){
  504. if (!this.data.query && this.data.id){
  505. var data = null;
  506. o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  507. data = json.data
  508. }, null, false);
  509. this.data = data;
  510. return data;
  511. }else{
  512. return this.data;
  513. }
  514. },
  515. createInforNode: function(){
  516. this.inforNode = new Element("div", {
  517. "styles": this.style.identityInforNode
  518. });
  519. var nameNode = new Element("div", {
  520. "styles": this.style.identityInforNameNode,
  521. "text": this.data.applicationName || this.data.appName || this.data.name
  522. }).inject(this.inforNode);
  523. this.tooltip = new mBox.Tooltip({
  524. content: this.inforNode,
  525. setStyles: {content: {padding: 15, lineHeight: 20}},
  526. attach: this.node,
  527. transition: 'flyin'
  528. });
  529. }
  530. });
  531. o2.widget.O2CMSView = new Class({
  532. Extends: o2.widget.O2View
  533. });
  534. o2.widget.O2QueryView = new Class({
  535. Extends: o2.widget.O2View,
  536. getPersonData: function(){
  537. if (!this.data.query && this.data.id){
  538. var data = null;
  539. o2.Actions.get("x_query_assemble_surface").getViewById(this.data.id, function(json){
  540. data = json.data;
  541. }, function(){
  542. data = {};
  543. return true;
  544. }, false);
  545. this.data = data;
  546. return data;
  547. }else{
  548. return this.data;
  549. }
  550. },
  551. open : function (e) {
  552. if( this.data.id && this.data.query ){
  553. var appId = "query.ViewDesigner" + this.data.id;
  554. if (layout.desktop.apps[appId]){
  555. layout.desktop.apps[appId].setCurrent();
  556. }else {
  557. var options = {
  558. "id": this.data.id,
  559. "application": {
  560. "id": this.data.query,
  561. "name": this.data.name || this.data.queryName || ""
  562. },
  563. "appId": appId
  564. };
  565. layout.desktop.openApplication(e, "query.ViewDesigner", options);
  566. }
  567. }
  568. }
  569. });
  570. o2.widget.O2QueryStatement = new Class({
  571. Extends: o2.widget.O2View,
  572. getPersonData: function(){
  573. if (!this.data.query && this.data.id){
  574. var data = null;
  575. o2.Actions.load("x_query_assemble_designer").StatementAction.get(this.data.id, function(json){
  576. data = json.data;
  577. }, function () {
  578. data = {};
  579. return true;
  580. }, false);
  581. this.data = data;
  582. return data;
  583. }else{
  584. return this.data;
  585. }
  586. },
  587. open : function (e) {
  588. if( this.data.id && this.data.query ){
  589. var appId = "query.StatementDesigner" + this.data.id;
  590. if (layout.desktop.apps[appId]){
  591. layout.desktop.apps[appId].setCurrent();
  592. }else {
  593. var options = {
  594. "id": this.data.id,
  595. "application": {
  596. "id": this.data.query,
  597. "name": this.data.name || this.data.queryName || ""
  598. },
  599. "appId": appId};
  600. layout.desktop.openApplication(e, "query.StatementDesigner", options);
  601. }
  602. }
  603. }
  604. });
  605. o2.widget.O2QueryStat = new Class({
  606. Extends: o2.widget.O2View,
  607. getPersonData: function(){
  608. if (!this.data.query && this.data.id){
  609. var data = null;
  610. o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  611. data = json.data
  612. }, null, false);
  613. this.data = data;
  614. return data;
  615. }else{
  616. return this.data;
  617. }
  618. },
  619. open : function (e) {
  620. if( this.data.id && this.data.query){
  621. var appId = "query.StatDesigner" + this.data.id;
  622. if (layout.desktop.apps[appId]){
  623. layout.desktop.apps[appId].setCurrent();
  624. }else {
  625. var options = {
  626. "id": this.data.id,
  627. "application": {
  628. "id": this.data.query,
  629. "name": this.data.name || this.data.queryName
  630. },
  631. "appId": appId
  632. };
  633. layout.desktop.openApplication(e, "query.StatDesigner", options);
  634. }
  635. }
  636. }
  637. });
  638. o2.widget.O2QueryTable = new Class({
  639. Extends: o2.widget.O2View,
  640. getPersonData: function(){
  641. if (!this.data.query && this.data.id){
  642. var data = null;
  643. o2.Actions.get("x_query_assemble_surface").getTableById(this.data.id, function(json){
  644. data = json.data
  645. }, null, false);
  646. this.data = data;
  647. return data;
  648. }else{
  649. return this.data;
  650. }
  651. },
  652. open : function (e) {
  653. if( this.data.id && this.data.query){
  654. var appId = "query.TableDesigner" + this.data.id;
  655. if (layout.desktop.apps[appId]){
  656. layout.desktop.apps[appId].setCurrent();
  657. }else {
  658. var options = {
  659. "id": this.data.id,
  660. "application": {
  661. "id": this.data.query,
  662. "name": this.data.name || this.data.queryName
  663. },
  664. "appId": appId};
  665. layout.desktop.openApplication(e, "query.TableDesigner", options);
  666. }
  667. }
  668. }
  669. });
  670. o2.widget.O2QueryImportModel = new Class({
  671. Extends: o2.widget.O2View,
  672. getPersonData: function(){
  673. if (!this.data.query && this.data.id){
  674. var data = null;
  675. o2.Actions.get("x_query_assemble_surface").getImportModelById(this.data.id, function(json){
  676. data = json.data
  677. }, null, false);
  678. this.data = data;
  679. return data;
  680. }else{
  681. return this.data;
  682. }
  683. },
  684. open : function (e) {
  685. if( this.data.id && this.data.query){
  686. var appId = "query.ImporterDesigner" + this.data.id;
  687. if (layout.desktop.apps[appId]){
  688. layout.desktop.apps[appId].setCurrent();
  689. }else {
  690. var options = {
  691. "id": this.data.id,
  692. "application": {
  693. "id": this.data.query,
  694. "name": this.data.name || this.data.queryName || ""
  695. },
  696. "appId": appId};
  697. layout.desktop.openApplication(e, "query.ImporterDesigner", options);
  698. }
  699. }
  700. }
  701. });
  702. o2.widget.O2FormField = new Class({
  703. Extends: o2.widget.O2Group,
  704. getPersonData: function(){
  705. return this.data;
  706. }
  707. });
  708. o2.widget.O2Role = new Class({
  709. Extends: o2.widget.O2Group,
  710. getPersonData: function(){
  711. if (!this.data.distinguishedName){
  712. this.action.actions = {"getRole": {"uri": "/jaxrs/role/{id}"}};
  713. this.action.invoke({"name": "getRole", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  714. this.data = json.data;
  715. }.bind(this)});
  716. }
  717. }
  718. });
  719. o2.widget.O2File = new Class({
  720. Extends: o2.widget.O2Group,
  721. createInforNode: function(){
  722. this.inforNode = new Element("div", {
  723. "styles": this.style.identityInforNode
  724. });
  725. var extName = this.data.fileName.substring(this.data.fileName.lastIndexOf(".")+1, this.data.fileName.length).toLowerCase();
  726. if (["png","jpg","bmp","gif","jpeg","jpe"].indexOf(extName)!==-1){
  727. var url;
  728. if(this.data.portal) {
  729. url = MWF.xDesktop.getPortalFileUr(this.data.id, this.data.portal);
  730. }else if( this.data.appId ){
  731. url = MWF.xDesktop.getCMSFileUr(this.data.id, this.data.appId);
  732. }else{
  733. url = MWF.xDesktop.getProcessFileUr(this.data.id, this.data.application)
  734. };
  735. var img = new Element("img", {"src": url, "styles": {"max-width": "280px", "max-height": "140px"}}).inject(this.inforNode);
  736. }else{
  737. var nameNode = new Element("div", {
  738. "styles": this.style.identityInforNameNode,
  739. "text": this.data.applicationName || this.data.appName || this.data.name
  740. }).inject(this.inforNode);
  741. }
  742. this.tooltip = new mBox.Tooltip({
  743. content: this.inforNode,
  744. setStyles: {content: {padding: 15, lineHeight: 20}},
  745. attach: this.node,
  746. transition: 'flyin'
  747. });
  748. },
  749. getPersonData: function(){
  750. return this.data;
  751. }
  752. });
  753. o2.widget.O2Script = new Class({
  754. Extends: o2.widget.O2Group,
  755. getPersonData: function(){
  756. return this.data;
  757. },
  758. createInforNode: function(){
  759. if( !this.data.appType )return false;
  760. this.inforNode = new Element("div", {
  761. "styles": this.style.identityInforNode
  762. });
  763. var nameNode = new Element("div", {
  764. "text": o2.LP[this.data.appType+"Name"]
  765. }).inject(this.inforNode);
  766. var nameTextNode = new Element("div", {
  767. "text": this.data.applicationName || this.data.appName
  768. }).inject(this.inforNode);
  769. this.tooltip = new mBox.Tooltip({
  770. content: this.inforNode,
  771. setStyles: {content: {padding: 15, lineHeight: 20}},
  772. attach: this.node,
  773. transition: 'flyin'
  774. });
  775. },
  776. open: function(e){
  777. if( this.data.id && this.data.appId && this.data.appType) {
  778. this._open();
  779. }else{
  780. var app = this.data.appId || this.data.application || this.data.appName || this.data.applicationName;
  781. var name = this.data.id || this.data.name;
  782. if( this.data.appType === "service" )app = "service";
  783. if( name && app && this.data.appType ){
  784. var p, type = this.data.appType;
  785. if( type === "process" ){
  786. p = o2.Actions.load("x_processplatform_assemble_surface").ScriptAction.getImported(this.data.name, app);
  787. }else if( type === "portal" ){
  788. p = o2.Actions.load("x_portal_assemble_surface").ScriptAction.getImported(app, this.data.name);
  789. }else if( type === "cms" ){
  790. p = o2.Actions.load("x_cms_assemble_control").ScriptAction.load(this.data.name, app);
  791. }else if( type === "service" ){
  792. p = o2.Actions.load("x_program_center").ScriptAction.getImported(this.data.name);
  793. }
  794. p.then(function (json) {
  795. if( json.data.importedList && json.data.importedList.length ){
  796. this.data.id = json.data.importedList[0];
  797. this._open(e);
  798. }
  799. }.bind(this))
  800. }
  801. }
  802. },
  803. _open : function (e) {
  804. var appName;
  805. if( this.data.appType === "cms" ){
  806. appName = "cms.ScriptDesigner";
  807. }else if( this.data.appType === "portal" ){
  808. appName = "portal.ScriptDesigner";
  809. }else if( this.data.appType === "process" ) {
  810. appName = "process.ScriptDesigner";
  811. }else if( this.data.appType === "service" ) {
  812. appName = "service.ScriptDesigner";
  813. }
  814. var appId = appName + this.data.id;
  815. if (layout.desktop.apps[appId]){
  816. layout.desktop.apps[appId].setCurrent();
  817. }else {
  818. var options = {
  819. "id": this.data.id,
  820. "appId": appId,
  821. "application":{
  822. "name": this.data.appName || this.data.applicationName || "",
  823. "id": this.data.appId
  824. }
  825. };
  826. layout.desktop.openApplication(e, appName, options);
  827. }
  828. }
  829. });
  830. o2.widget.O2FormStyle = new Class({
  831. Extends: o2.widget.O2Group,
  832. getPersonData: function(){
  833. return this.data;
  834. },
  835. open : function (e) {
  836. if( typeOf(this.data)==="object" && this.data.id && this.data.appId && this.data.type === "script"){
  837. var appName;
  838. switch (this.data.appType){
  839. case "service":
  840. appName = "service.ScriptDesigner";
  841. break;
  842. case "cms":
  843. appName = "cms.ScriptDesigner";
  844. break;
  845. default:
  846. appName = "process.ScriptDesigner";
  847. }
  848. var appId = appName + this.data.id;
  849. if (layout.desktop.apps[appId]){
  850. layout.desktop.apps[appId].setCurrent();
  851. }else {
  852. var options;
  853. if( this.data.appType === 'service' ){
  854. options = {
  855. "id": this.data.id
  856. };
  857. }else{
  858. options = {
  859. "id": this.data.id,
  860. "appId": appId,
  861. "application":{
  862. "name": this.data.appName || this.data.applicationName || "",
  863. "id": this.data.appId
  864. }
  865. };
  866. }
  867. layout.desktop.openApplication(e, appName, options);
  868. }
  869. }
  870. }
  871. });
  872. o2.widget.O2Dictionary = new Class({
  873. Extends: o2.widget.O2Group,
  874. getPersonData: function(){
  875. return this.data;
  876. },
  877. createInforNode: function(){
  878. if( !this.data.appType )return false;
  879. this.inforNode = new Element("div", {
  880. "styles": this.style.identityInforNode
  881. });
  882. var nameNode = new Element("div", {
  883. "text": o2.LP[this.data.appType+"Name"]
  884. }).inject(this.inforNode);
  885. var nameTextNode = new Element("div", {
  886. "text": this.data.applicationName || this.data.appName
  887. }).inject(this.inforNode);
  888. this.tooltip = new mBox.Tooltip({
  889. content: this.inforNode,
  890. setStyles: {content: {padding: 15, lineHeight: 20}},
  891. attach: this.node,
  892. transition: 'flyin'
  893. });
  894. },
  895. open : function (e) {
  896. if( this.data.id && this.data.appId && this.data.appType){
  897. var appName;
  898. switch (this.data.appType) {
  899. case "cms":
  900. appName = "cms.DictionaryDesigner"; break;
  901. case "process":
  902. appName = "process.DictionaryDesigner"; break;
  903. case "portal":
  904. appName = "portal.DictionaryDesigner"; break;
  905. default:
  906. appName = "service.DictionaryDesigner"; break;
  907. }
  908. var appId = appName + this.data.id;
  909. if (layout.desktop.apps[appId]){
  910. layout.desktop.apps[appId].setCurrent();
  911. }else {
  912. var options = {
  913. "id": this.data.id
  914. };
  915. if( this.data.appType !== "service" ){
  916. options.appId = appId;
  917. options.application = {
  918. "id": this.data.appId,
  919. "name": this.data.appName || this.data.applicationName || ""
  920. };
  921. }
  922. layout.desktop.openApplication(e, appName, options);
  923. }
  924. }
  925. }
  926. });
  927. o2.widget.O2Other = new Class({
  928. Extends: o2.widget.O2Group,
  929. getPersonData: function(){
  930. return this.data;
  931. }
  932. });
  933. /**
  934. * @return {null}
  935. */
  936. o2.widget.O2Org = function(value, container, options){
  937. var v = (o2.typeOf(value)==="string") ? {"name": value} : value.distinguishedName;
  938. var t = v.distinguishedName || v.name || "";
  939. if (t) {
  940. var flag = t.substr(t.length - 1, 1);
  941. switch (flag.toLowerCase()) {
  942. case "i":
  943. return new o2.widget.O2Identity(v, container, options);
  944. case "p":
  945. return new o2.widget.O2Person(v, container, options);
  946. case "u":
  947. return new o2.widget.O2Unit(v, container, options);
  948. case "g":
  949. return new o2.widget.O2Group(v, container, options);
  950. case "r":
  951. return new o2.widget.O2Role(v, container, options);
  952. case "d":
  953. return new o2.widget.O2Duty(v, container, options);
  954. default:
  955. return new o2.widget.O2Other(v, container, options);
  956. }
  957. }
  958. return null;
  959. };
  960. // o2.widget.O2Identity.iditems = o2.widget.O2Identity.iditems || [];
  961. // o2.widget.O2Identity.intervalId = window.setInterval(function(){
  962. // if (o2.widget.O2Identity.iditems && o2.widget.O2Identity.iditems.length){
  963. // o2.widget.O2Identity.iditems.each(function(item){
  964. // if (item.tooltip){
  965. // debugger;
  966. // if (item.tooltip.options.attach){
  967. //
  968. // }
  969. // }
  970. // });
  971. // }
  972. // }, 10000);