O2Identity.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  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. }.bind(this), null, false);
  404. // this.action = new o2.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
  405. // this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
  406. // this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  407. // this.data = json.data;
  408. // }.bind(this)});
  409. }
  410. }
  411. });
  412. o2.widget.O2Process = new Class({
  413. Extends: o2.widget.O2Group,
  414. getPersonData: function(){
  415. if (!this.data.name){
  416. this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  417. this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
  418. this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  419. this.data = json.data;
  420. }.bind(this)});
  421. }
  422. },
  423. createInforNode: function(){
  424. this.inforNode = new Element("div", {
  425. "styles": this.style.identityInforNode
  426. });
  427. var nameNode = new Element("div", {
  428. "styles": this.style.identityInforNameNode,
  429. "text": this.data.name || this.data.applicationName || this.data.appName
  430. }).inject(this.inforNode);
  431. this.tooltip = new mBox.Tooltip({
  432. content: this.inforNode,
  433. setStyles: {content: {padding: 15, lineHeight: 20}},
  434. attach: this.node,
  435. transition: 'flyin'
  436. });
  437. },
  438. open : function (e) {
  439. debugger;
  440. if( this.data.id && this.data.application ){
  441. var appId = "process.ProcessManager" + this.data.application;
  442. if (layout.desktop.apps[appId]){
  443. layout.desktop.apps[appId].setCurrent();
  444. }else {
  445. var options = { "application": {
  446. "id": this.data.application,
  447. "name": this.data.applicationName || ""
  448. }};
  449. layout.desktop.openApplication(e, "process.ProcessManager", options);
  450. }
  451. }
  452. }
  453. });
  454. o2.widget.O2CMSCategory = new Class({
  455. Extends: o2.widget.O2Group,
  456. getPersonData: function(){
  457. if (!this.data.name){
  458. o2.Actions.get("x_cms_assemble_control").getCategory((this.data.id || this.data.name), function(json){
  459. this.data = json.data;
  460. this.data.name = this.data.categoryName;
  461. }.bind(this), null, false);
  462. }
  463. },
  464. createInforNode: function(){
  465. this.inforNode = new Element("div", {
  466. "styles": this.style.identityInforNode
  467. });
  468. var nameNode = new Element("div", {
  469. "styles": this.style.identityInforNameNode,
  470. "text": this.data.applicationName || this.data.appName
  471. }).inject(this.inforNode);
  472. this.tooltip = new mBox.Tooltip({
  473. content: this.inforNode,
  474. setStyles: {content: {padding: 15, lineHeight: 20}},
  475. attach: this.node,
  476. transition: 'flyin'
  477. });
  478. },
  479. open : function (e) {
  480. debugger;
  481. if( this.data.id && this.data.appId ){
  482. // var appId = "cms.ColumnManager" + this.data.id;
  483. // if (layout.desktop.apps[appId]){
  484. // layout.desktop.apps[appId].setCurrent();
  485. // }else {
  486. var options = {
  487. "navi":"categoryConfig",
  488. "column":{
  489. "id" : this.data.appId,
  490. "appName": this.data.appName || ""
  491. },
  492. "currentCategoryId":this.data.id
  493. };
  494. layout.desktop.openApplication(e, "cms.ColumnManager", options);
  495. // }
  496. }
  497. }
  498. });
  499. o2.widget.O2View = new Class({
  500. Extends: o2.widget.O2Group,
  501. getPersonData: function(){
  502. if (!this.data.query && this.data.id){
  503. var data = null;
  504. o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  505. data = json.data
  506. }, null, false);
  507. this.data = data;
  508. return data;
  509. }else{
  510. return this.data;
  511. }
  512. },
  513. createInforNode: function(){
  514. this.inforNode = new Element("div", {
  515. "styles": this.style.identityInforNode
  516. });
  517. var nameNode = new Element("div", {
  518. "styles": this.style.identityInforNameNode,
  519. "text": this.data.applicationName || this.data.appName || this.data.name
  520. }).inject(this.inforNode);
  521. this.tooltip = new mBox.Tooltip({
  522. content: this.inforNode,
  523. setStyles: {content: {padding: 15, lineHeight: 20}},
  524. attach: this.node,
  525. transition: 'flyin'
  526. });
  527. }
  528. });
  529. o2.widget.O2CMSView = new Class({
  530. Extends: o2.widget.O2View
  531. });
  532. o2.widget.O2QueryView = new Class({
  533. Extends: o2.widget.O2View,
  534. getPersonData: function(){
  535. if (!this.data.query && this.data.id){
  536. var data = null;
  537. o2.Actions.get("x_query_assemble_surface").getViewById(this.data.id, function(json){
  538. data = json.data;
  539. }, function(){
  540. data = {};
  541. return true;
  542. }, false);
  543. this.data = data;
  544. return data;
  545. }else{
  546. return this.data;
  547. }
  548. },
  549. open : function (e) {
  550. if( this.data.id && this.data.query ){
  551. var appId = "query.ViewDesigner" + this.data.id;
  552. if (layout.desktop.apps[appId]){
  553. layout.desktop.apps[appId].setCurrent();
  554. }else {
  555. var options = {
  556. "id": this.data.id,
  557. "application": {
  558. "id": this.data.query,
  559. "name": this.data.name || this.data.queryName || ""
  560. },
  561. "appId": appId
  562. };
  563. layout.desktop.openApplication(e, "query.ViewDesigner", options);
  564. }
  565. }
  566. }
  567. });
  568. o2.widget.O2QueryStatement = new Class({
  569. Extends: o2.widget.O2View,
  570. getPersonData: function(){
  571. if (!this.data.query && this.data.id){
  572. var data = null;
  573. o2.Actions.load("x_query_assemble_designer").StatementAction.get(this.data.id, function(json){
  574. data = json.data;
  575. }, function () {
  576. data = {};
  577. return true;
  578. }, false);
  579. this.data = data;
  580. return data;
  581. }else{
  582. return this.data;
  583. }
  584. },
  585. open : function (e) {
  586. if( this.data.id && this.data.query ){
  587. var appId = "query.StatementDesigner" + this.data.id;
  588. if (layout.desktop.apps[appId]){
  589. layout.desktop.apps[appId].setCurrent();
  590. }else {
  591. var options = {
  592. "id": this.data.id,
  593. "application": {
  594. "id": this.data.query,
  595. "name": this.data.name || this.data.queryName || ""
  596. },
  597. "appId": appId};
  598. layout.desktop.openApplication(e, "query.StatementDesigner", options);
  599. }
  600. }
  601. }
  602. });
  603. o2.widget.O2QueryStat = new Class({
  604. Extends: o2.widget.O2View,
  605. getPersonData: function(){
  606. if (!this.data.query && this.data.id){
  607. var data = null;
  608. o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
  609. data = json.data
  610. }, null, false);
  611. this.data = data;
  612. return data;
  613. }else{
  614. return this.data;
  615. }
  616. },
  617. open : function (e) {
  618. if( this.data.id && this.data.query){
  619. var appId = "query.StatDesigner" + this.data.id;
  620. if (layout.desktop.apps[appId]){
  621. layout.desktop.apps[appId].setCurrent();
  622. }else {
  623. var options = {
  624. "id": this.data.id,
  625. "application": {
  626. "id": this.data.query,
  627. "name": this.data.name || this.data.queryName
  628. },
  629. "appId": appId
  630. };
  631. layout.desktop.openApplication(e, "query.StatDesigner", options);
  632. }
  633. }
  634. }
  635. });
  636. o2.widget.O2QueryTable = new Class({
  637. Extends: o2.widget.O2View,
  638. getPersonData: function(){
  639. if (!this.data.query && this.data.id){
  640. var data = null;
  641. o2.Actions.get("x_query_assemble_surface").getTableById(this.data.id, function(json){
  642. data = json.data
  643. }, null, false);
  644. this.data = data;
  645. return data;
  646. }else{
  647. return this.data;
  648. }
  649. },
  650. open : function (e) {
  651. if( this.data.id && this.data.query){
  652. var appId = "query.TableDesigner" + this.data.id;
  653. if (layout.desktop.apps[appId]){
  654. layout.desktop.apps[appId].setCurrent();
  655. }else {
  656. var options = {
  657. "id": this.data.id,
  658. "application": {
  659. "id": this.data.query,
  660. "name": this.data.name || this.data.queryName
  661. },
  662. "appId": appId};
  663. layout.desktop.openApplication(e, "query.TableDesigner", options);
  664. }
  665. }
  666. }
  667. });
  668. o2.widget.O2QueryImportModel = new Class({
  669. Extends: o2.widget.O2View,
  670. getPersonData: function(){
  671. if (!this.data.query && this.data.id){
  672. var data = null;
  673. o2.Actions.get("x_query_assemble_surface").getImportModelById(this.data.id, function(json){
  674. data = json.data
  675. }, null, false);
  676. this.data = data;
  677. return data;
  678. }else{
  679. return this.data;
  680. }
  681. },
  682. open : function (e) {
  683. if( this.data.id && this.data.query){
  684. var appId = "query.ImporterDesigner" + this.data.id;
  685. if (layout.desktop.apps[appId]){
  686. layout.desktop.apps[appId].setCurrent();
  687. }else {
  688. var options = {
  689. "id": this.data.id,
  690. "application": {
  691. "id": this.data.query,
  692. "name": this.data.name || this.data.queryName || ""
  693. },
  694. "appId": appId};
  695. layout.desktop.openApplication(e, "query.ImporterDesigner", options);
  696. }
  697. }
  698. }
  699. });
  700. o2.widget.O2FormField = new Class({
  701. Extends: o2.widget.O2Group,
  702. getPersonData: function(){
  703. return this.data;
  704. }
  705. });
  706. o2.widget.O2Role = new Class({
  707. Extends: o2.widget.O2Group,
  708. getPersonData: function(){
  709. if (!this.data.distinguishedName){
  710. this.action.actions = {"getRole": {"uri": "/jaxrs/role/{id}"}};
  711. this.action.invoke({"name": "getRole", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  712. this.data = json.data;
  713. }.bind(this)});
  714. }
  715. }
  716. });
  717. o2.widget.O2File = new Class({
  718. Extends: o2.widget.O2Group,
  719. createInforNode: function(){
  720. this.inforNode = new Element("div", {
  721. "styles": this.style.identityInforNode
  722. });
  723. var extName = this.data.fileName.substring(this.data.fileName.lastIndexOf(".")+1, this.data.fileName.length).toLowerCase();
  724. if (["png","jpg","bmp","gif","jpeg","jpe"].indexOf(extName)!==-1){
  725. var url;
  726. if(this.data.portal) {
  727. url = MWF.xDesktop.getPortalFileUr(this.data.id, this.data.portal);
  728. }else if( this.data.appId ){
  729. url = MWF.xDesktop.getCMSFileUr(this.data.id, this.data.appId);
  730. }else{
  731. url = MWF.xDesktop.getProcessFileUr(this.data.id, this.data.application)
  732. };
  733. var img = new Element("img", {"src": url, "styles": {"max-width": "280px", "max-height": "140px"}}).inject(this.inforNode);
  734. }else{
  735. var nameNode = new Element("div", {
  736. "styles": this.style.identityInforNameNode,
  737. "text": this.data.applicationName || this.data.appName || this.data.name
  738. }).inject(this.inforNode);
  739. }
  740. this.tooltip = new mBox.Tooltip({
  741. content: this.inforNode,
  742. setStyles: {content: {padding: 15, lineHeight: 20}},
  743. attach: this.node,
  744. transition: 'flyin'
  745. });
  746. },
  747. getPersonData: function(){
  748. return this.data;
  749. }
  750. });
  751. o2.widget.O2Script = new Class({
  752. Extends: o2.widget.O2Group,
  753. getPersonData: function(){
  754. return this.data;
  755. },
  756. createInforNode: function(){
  757. if( !this.data.appType )return false;
  758. this.inforNode = new Element("div", {
  759. "styles": this.style.identityInforNode
  760. });
  761. var nameNode = new Element("div", {
  762. "text": o2.LP[this.data.appType+"Name"]
  763. }).inject(this.inforNode);
  764. var nameTextNode = new Element("div", {
  765. "text": this.data.applicationName || this.data.appName
  766. }).inject(this.inforNode);
  767. this.tooltip = new mBox.Tooltip({
  768. content: this.inforNode,
  769. setStyles: {content: {padding: 15, lineHeight: 20}},
  770. attach: this.node,
  771. transition: 'flyin'
  772. });
  773. },
  774. open: function(e){
  775. if( this.data.id && this.data.appId && this.data.appType) {
  776. this._open();
  777. }else{
  778. var app = this.data.appId || this.data.application || this.data.appName || this.data.applicationName;
  779. var name = this.data.id || this.data.name;
  780. if( this.data.appType === "service" )app = "service";
  781. if( name && app && this.data.appType ){
  782. var p, type = this.data.appType;
  783. if( type === "process" ){
  784. p = o2.Actions.load("x_processplatform_assemble_surface").ScriptAction.getImported(this.data.name, app);
  785. }else if( type === "portal" ){
  786. p = o2.Actions.load("x_portal_assemble_surface").ScriptAction.getImported(app, this.data.name);
  787. }else if( type === "cms" ){
  788. p = o2.Actions.load("x_cms_assemble_control").ScriptAction.load(this.data.name, app);
  789. }else if( type === "service" ){
  790. p = o2.Actions.load("x_program_center").ScriptAction.getImported(this.data.name);
  791. }
  792. p.then(function (json) {
  793. if( json.data.importedList && json.data.importedList.length ){
  794. this.data.id = json.data.importedList[0];
  795. this._open(e);
  796. }
  797. }.bind(this))
  798. }
  799. }
  800. },
  801. _open : function (e) {
  802. var appName;
  803. if( this.data.appType === "cms" ){
  804. appName = "cms.ScriptDesigner";
  805. }else if( this.data.appType === "portal" ){
  806. appName = "portal.ScriptDesigner";
  807. }else if( this.data.appType === "process" ) {
  808. appName = "process.ScriptDesigner";
  809. }else if( this.data.appType === "service" ) {
  810. appName = "service.ScriptDesigner";
  811. }
  812. var appId = appName + this.data.id;
  813. if (layout.desktop.apps[appId]){
  814. layout.desktop.apps[appId].setCurrent();
  815. }else {
  816. var options = {
  817. "id": this.data.id,
  818. "appId": appId,
  819. "application":{
  820. "name": this.data.appName || this.data.applicationName || "",
  821. "id": this.data.appId
  822. }
  823. };
  824. layout.desktop.openApplication(e, appName, options);
  825. }
  826. }
  827. });
  828. o2.widget.O2FormStyle = new Class({
  829. Extends: o2.widget.O2Group,
  830. getPersonData: function(){
  831. return this.data;
  832. },
  833. open : function (e) {
  834. if( typeOf(this.data)==="object" && this.data.id && this.data.appId && this.data.type === "script"){
  835. var appName;
  836. if( this.data.appType === "cms" ){
  837. appName = "cms.ScriptDesigner";
  838. }else{
  839. appName = "process.ScriptDesigner";
  840. }
  841. var appId = appName + this.data.id;
  842. if (layout.desktop.apps[appId]){
  843. layout.desktop.apps[appId].setCurrent();
  844. }else {
  845. var options = {
  846. "id": this.data.id,
  847. "appId": appId,
  848. "application":{
  849. "name": this.data.appName || this.data.applicationName || "",
  850. "id": this.data.appId
  851. }
  852. };
  853. layout.desktop.openApplication(e, appName, options);
  854. }
  855. }
  856. }
  857. });
  858. o2.widget.O2Dictionary = new Class({
  859. Extends: o2.widget.O2Group,
  860. getPersonData: function(){
  861. return this.data;
  862. },
  863. createInforNode: function(){
  864. if( !this.data.appType )return false;
  865. this.inforNode = new Element("div", {
  866. "styles": this.style.identityInforNode
  867. });
  868. var nameNode = new Element("div", {
  869. "text": o2.LP[this.data.appType+"Name"]
  870. }).inject(this.inforNode);
  871. var nameTextNode = new Element("div", {
  872. "text": this.data.applicationName || this.data.appName
  873. }).inject(this.inforNode);
  874. this.tooltip = new mBox.Tooltip({
  875. content: this.inforNode,
  876. setStyles: {content: {padding: 15, lineHeight: 20}},
  877. attach: this.node,
  878. transition: 'flyin'
  879. });
  880. },
  881. open : function (e) {
  882. if( this.data.id && this.data.appId && this.data.appType){
  883. var appName;
  884. switch (this.data.appType) {
  885. case "cms":
  886. appName = "cms.DictionaryDesigner"; break;
  887. case "process":
  888. appName = "process.DictionaryDesigner"; break;
  889. case "portal":
  890. appName = "portal.DictionaryDesigner"; break;
  891. default:
  892. appName = "service.DictionaryDesigner"; break;
  893. }
  894. var appId = appName + this.data.id;
  895. if (layout.desktop.apps[appId]){
  896. layout.desktop.apps[appId].setCurrent();
  897. }else {
  898. var options = {
  899. "id": this.data.id
  900. };
  901. if( this.data.appType !== "service" ){
  902. options.appId = appId;
  903. options.application = {
  904. "id": this.data.appId,
  905. "name": this.data.appName || this.data.applicationName || ""
  906. };
  907. }
  908. layout.desktop.openApplication(e, appName, options);
  909. }
  910. }
  911. }
  912. });
  913. o2.widget.O2Other = new Class({
  914. Extends: o2.widget.O2Group,
  915. getPersonData: function(){
  916. return this.data;
  917. }
  918. });
  919. /**
  920. * @return {null}
  921. */
  922. o2.widget.O2Org = function(value, container, options){
  923. var v = (o2.typeOf(value)==="string") ? {"name": value} : value.distinguishedName;
  924. var t = v.distinguishedName || v.name || "";
  925. if (t) {
  926. var flag = t.substr(t.length - 1, 1);
  927. switch (flag.toLowerCase()) {
  928. case "i":
  929. return new o2.widget.O2Identity(v, container, options);
  930. case "p":
  931. return new o2.widget.O2Person(v, container, options);
  932. case "u":
  933. return new o2.widget.O2Unit(v, container, options);
  934. case "g":
  935. return new o2.widget.O2Group(v, container, options);
  936. case "r":
  937. return new o2.widget.O2Role(v, container, options);
  938. case "d":
  939. return new o2.widget.O2Duty(v, container, options);
  940. default:
  941. return new o2.widget.O2Other(v, container, options);
  942. }
  943. }
  944. return null;
  945. };
  946. // o2.widget.O2Identity.iditems = o2.widget.O2Identity.iditems || [];
  947. // o2.widget.O2Identity.intervalId = window.setInterval(function(){
  948. // if (o2.widget.O2Identity.iditems && o2.widget.O2Identity.iditems.length){
  949. // o2.widget.O2Identity.iditems.each(function(item){
  950. // if (item.tooltip){
  951. // debugger;
  952. // if (item.tooltip.options.attach){
  953. //
  954. // }
  955. // }
  956. // });
  957. // }
  958. // }, 10000);