SettingModuleUI.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. MWF.xDesktop.requireApp("Selector", "package", null, false);
  2. MWF.require("MWF.widget.O2Identity", null,false);
  3. MWF.xApplication.Setting.UIModuleDocument = new Class({
  4. Extends: MWF.xApplication.Common.Main,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default"
  8. },
  9. initialize: function(explorer, content, options){
  10. this.setOptions(options);
  11. this.path = "../x_component_Setting/$SettingModuleUI/";
  12. this.cssPath =this.path+this.options.style+"/css.wcss";
  13. this._loadCss();
  14. this.content = content;
  15. this.explorer = explorer;
  16. this.app = this.explorer.app;
  17. this.lp = this.app.lp.module;
  18. this.actions = MWF.Actions.get("x_component_assemble_control");
  19. this.load();
  20. },
  21. "destroy": function(){
  22. this.appDeploymentContent.destroy();
  23. this.content.empty();
  24. if (this.setContentHeightFun) this.app.removeEvent("resize", this.setContentHeightFun);
  25. MWF.release(this);
  26. },
  27. load: function(){
  28. this.components = [];
  29. this.loadTitle();
  30. this.appDeploymentContent = new Element("div", {"styles": this.css.appDeploymentContent}).inject(this.content);
  31. this.componentsContent = new Element("div", {"styles": this.css.componentsContent}).inject(this.appDeploymentContent);
  32. MWF.require("MWF.widget.Tab", function(){
  33. this.tab = new MWF.widget.Tab(this.content, {"style": "processlayout"});
  34. this.tab.load();
  35. this.appPage = this.tab.addTab(this.appDeploymentContent, this.lp.moduleDeployed, false);
  36. this.appPage.showIm();
  37. this.setContentHeight();
  38. this.setContentHeightFun = this.setContentHeight.bind(this);
  39. this.app.addEvent("resize", this.setContentHeightFun);
  40. }.bind(this));
  41. this.loadApplicationContent();
  42. },
  43. loadTitle: function(){
  44. // this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
  45. // this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
  46. },
  47. loadApplicationContent: function(){
  48. this.loadApps(function(){
  49. if (MWF.AC.isAdministrator()) this.loadNewApp();
  50. }.bind(this));
  51. },
  52. getComponentCatalogue: function(callback){
  53. var url = MWF.defaultPath+"/xDesktop/$Layout/components.json";
  54. MWF.getJSON(url, function(json){
  55. if (callback) callback(json);
  56. }.bind(this));
  57. },
  58. loadApps: function(callback){
  59. this.getComponentCatalogue(function(json){
  60. json.each(function(value, key){
  61. //this.createComponentItem(value, key);
  62. this.components.push(new MWF.xApplication.Setting.UIModuleDocument.Component(value, this));
  63. }.bind(this));
  64. this.actions.listComponent(function(json){
  65. json.data.each(function(value, key){
  66. this.components.push(new MWF.xApplication.Setting.UIModuleDocument.UserComponent(value, this));
  67. }.bind(this));
  68. if (callback) callback();
  69. }.bind(this));
  70. }.bind(this));
  71. },
  72. loadNewApp: function(){
  73. var node = new Element("div", {"styles": this.css.componentItemNode}).inject(this.componentsContent);
  74. node.setStyles({
  75. "background-color": "#FFF"
  76. });
  77. var contentNode = new Element("div", {"styles": this.css.contentNode}).inject(node);
  78. var titleNode = new Element("div", {"styles": this.css.titleNode}).inject(contentNode);
  79. //contentNode.setStyles({"height": "30px"});
  80. var iconNode = new Element("div", {"styles": this.css.addIconNode}).inject(node);
  81. iconNode.addEvents({
  82. "mouseover": function(){iconNode.setStyles(this.css.addIconNode_over); titleNode.setStyle("color", "#3498db");}.bind(this),
  83. "mouseout": function(){iconNode.setStyles(this.css.addIconNode); titleNode.setStyle("color", "#999");}.bind(this),
  84. "click": function(e){
  85. this.createNewDeploy(e);
  86. }.bind(this)
  87. });
  88. var actionAreaNode = new Element("div", {"styles": this.css.actionAreaNode}).inject(node);
  89. titleNode.set("text", this.lp.add);
  90. titleNode.setStyle("color", "#999");
  91. },
  92. createNewDeploy: function(){
  93. new MWF.xApplication.Setting.UIModuleDocument.Deploy(this);
  94. },
  95. deployApp: function(){
  96. var inputs = this.appContentNode.getElements("input");
  97. var nameInput = inputs[0];
  98. var tileInput = inputs[1];
  99. var fileInput = inputs[2];
  100. var name = nameInput.get("value");
  101. var title = tileInput.get("value");
  102. if (!name || !title){
  103. this.app.notice( this.lp.inputAppNameNotice, "error", this.appContentNode);
  104. }else if (!fileInput.files.length){
  105. this.app.notice( this.lp.uploadZipFileNotice, "error", this.appContentNode);
  106. }else{
  107. var formData = new FormData();
  108. formData.append('file', fileInput.files[0]);
  109. formData.append('name', name);
  110. formData.append('title', title);
  111. formData.append('path', "/res/mwf4/package/xApplication");
  112. var xhr = new COMMON.Browser.Request();
  113. xhr.open("POST", "jaxrs/application", false);
  114. var onreadystatechange= function(){
  115. if (xhr.readyState != 4) return;
  116. var status = xhr.status;
  117. status = (status == 1223) ? 204 : status;
  118. if ((status >= 200 && status < 300)) {
  119. this.app.notice( this.lp.deploySuccess, "success", this.appContentNode);
  120. this.appListNode.empty();
  121. this.loadApps();
  122. };
  123. }.bind(this);
  124. xhr.onreadystatechange = onreadystatechange;
  125. xhr.send(formData);
  126. }
  127. },
  128. setContentHeight: function(node){
  129. var size = this.content.getSize();
  130. //var titleSize = this.titleBar.getSize();
  131. var tabSize = this.tab.tabNodeContainer.getSize();
  132. var height = size.y-tabSize.y;
  133. this.tab.pages.each(function(page){
  134. page.contentNodeArea.setStyles({"height": ""+height+"px", "overflow": "auto"})
  135. });
  136. //this.appDeploymentContent.setStyle("height", height);
  137. }
  138. });
  139. MWF.xApplication.Setting.UIModuleDocument.Component = new Class({
  140. initialize: function(value, deployment, inset){
  141. this.data = value;
  142. this.deployment = deployment;
  143. this.css = this.deployment.css;
  144. this.content = this.deployment.componentsContent;
  145. this.load(inset);
  146. },
  147. reload: function(data){
  148. this.data = data;
  149. this.node.empty();
  150. this.load();
  151. },
  152. load: function(inset){
  153. if (!this.node){
  154. this.node = new Element("div", {"styles": this.css.componentItemNode});
  155. if (inset){
  156. var tmpNode = this.content.getLast("div");
  157. this.node.inject(tmpNode, "before");
  158. }else{
  159. this.node.inject(this.content);
  160. }
  161. }
  162. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  163. this.titleNode = new Element("div", {"styles": this.css.titleNode}).inject(this.contentNode);
  164. this.nameNode = new Element("div", {"styles": this.css.nameNode}).inject(this.contentNode);
  165. this.iconNode = new Element("div", {"styles": this.css.iconNode}).inject(this.node);
  166. this.actionAreaNode = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.node);
  167. //var icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  168. var icon;
  169. if (this.data.path.substring(0, 4)==="@url"){
  170. if (this.data.iconPath){
  171. icon = this.data.iconPath;
  172. }else{
  173. icon = "../x_component_Setting/$Main/default/icon/site.png";
  174. }
  175. }else{
  176. icon = "../x_component_"+this.data.path.replace(/\./g, "_")+"/$Main/"+this.data.iconPath;
  177. }
  178. this.iconNode.setStyle("background-image", "url("+icon+")");
  179. this.titleNode.set("text", this.data.title);
  180. this.nameNode.set("text", this.data.name);
  181. this.addAction();
  182. this.loadSystemFlag();
  183. },
  184. addAction: function(){
  185. if (this.data.visible){
  186. var user = layout.session.user;
  187. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  188. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  189. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  190. var isAllow = true;
  191. if (this.data.allowList) isAllow = (this.data.allowList.length) ? (this.data.allowList.isIntersect(currentNames)) : true;
  192. var isDeny = false;
  193. if (this.data.denyList) isDeny = (this.data.denyList.length) ? (this.data.denyList.isIntersect(currentNames)) : false;
  194. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  195. this.openAction = new Element("div", {"styles": this.css.actionNode, "text": this.deployment.lp.open}).inject(this.actionAreaNode);
  196. this.openAction.addEvents({
  197. "mouseover": function(){this.openAction.setStyles(this.css.actionNode_over);}.bind(this),
  198. "mouseout": function(){this.openAction.setStyles(this.css.actionNode);}.bind(this),
  199. "click": function(e){
  200. this.deployment.app.desktop.openApplication(e, this.data.path);
  201. }.bind(this)
  202. });
  203. }
  204. }else{
  205. }
  206. },
  207. loadSystemFlag: function(){
  208. //this.flagNode = new Element("div", {"styles": this.css.flagNode}).inject(this.node);
  209. }
  210. });
  211. MWF.xApplication.Setting.UIModuleDocument.UserComponent = new Class({
  212. Extends: MWF.xApplication.Setting.UIModuleDocument.Component,
  213. createOpenAction: function(style){
  214. this.openAction = new Element("div", {"styles": this.css[style], "text": this.deployment.lp.open}).inject(this.actionAreaNode);
  215. this.openAction.addEvents({
  216. "mouseover": function(){this.openAction.setStyles(this.css.actionNode_over);}.bind(this),
  217. "mouseout": function(){this.openAction.setStyles(this.css[style]);}.bind(this),
  218. "click": function(e){
  219. this.deployment.app.desktop.openApplication(e, this.data.path);
  220. }.bind(this)
  221. });
  222. },
  223. createEditAction: function(style){
  224. this.editAction = new Element("div", {"styles": this.css[style], "text": this.deployment.lp.edit}).inject(this.actionAreaNode);
  225. this.editAction.addEvents({
  226. "mouseover": function(){this.editAction.setStyles(this.css.actionNode_over);}.bind(this),
  227. "mouseout": function(){this.editAction.setStyles(this.css[style]);}.bind(this),
  228. "click": function(e){
  229. this.editComponent();
  230. }.bind(this)
  231. });
  232. },
  233. createRemoveAction: function(style){
  234. this.removeAction = new Element("div", {"styles": this.css[style], "text": this.deployment.lp.remove}).inject(this.actionAreaNode);
  235. this.removeAction.addEvents({
  236. "mouseover": function(){this.removeAction.setStyles(this.css.actionNode_over);}.bind(this),
  237. "mouseout": function(){this.removeAction.setStyles(this.css[style]);}.bind(this),
  238. "click": function(e){
  239. var _self = this;
  240. var text = this.deployment.lp.removeComponent.replace(/{name}/, this.data.title);
  241. this.deployment.app.confirm("warn", e, this.deployment.lp.removeComponentTitle, text, 500, 170, function(){
  242. _self.removeComponent();
  243. this.close();
  244. }, function(){
  245. this.close();
  246. }, null, this.deployment.content);
  247. }.bind(this)
  248. });
  249. },
  250. addAction: function(){
  251. this.node.setStyles(this.css.userComponentItemNode);
  252. var user = layout.session.user;
  253. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  254. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  255. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  256. var isAdministrator = this.checkAdministrator();
  257. if (isAdministrator && this.data.visible){
  258. this.createOpenAction("action2Node");
  259. this.createEditAction("action2Node");
  260. this.createRemoveAction("action3Node");
  261. }else if (!isAdministrator && this.data.visible){
  262. var isAllow = (this.data.allowList.length) ? (this.data.allowList.isIntersect(currentNames)) : true;
  263. var isDeny = (this.data.denyList.length) ? (this.data.denyList.isIntersect(currentNames)) : false;
  264. if ((!isDeny && isAllow) || MWF.AC.isAdministrator()){
  265. this.createOpenAction("actionNode");
  266. }
  267. }else if (isAdministrator && !this.data.visible){
  268. this.createEditAction("action4Node");
  269. this.createRemoveAction("action5Node");
  270. }
  271. },
  272. checkAdministrator: function(){
  273. if (MWF.AC.isAdministrator()) return true;
  274. var user = this.deployment.desktop.session.user;
  275. var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
  276. if (user.roleList) currentNames = currentNames.concat(user.roleList);
  277. if (user.groupList) currentNames = currentNames.concat(user.groupList);
  278. if (this.data.controllerList.isIntersect(currentNames)) return true;
  279. return false;
  280. },
  281. loadSystemFlag: function(){},
  282. editComponent: function(){
  283. new MWF.xApplication.Setting.UIModuleDocument.DeployEdit(this.data, this, this.deployment);
  284. },
  285. removeComponent: function(){
  286. this.deployment.actions.removeComponent(this.data.id, function(){
  287. this.deployment.app.notice(this.deployment.lp.removeComponentOk, "success");
  288. this.deployment.components.erase(this);
  289. this.node.destroy();
  290. MWF.release(this);
  291. }.bind(this));
  292. }
  293. });
  294. MWF.xApplication.Setting.UIModuleDocument.Deploy = new Class({
  295. initialize: function(deployment){
  296. this.deployment = deployment;
  297. this.css = this.deployment.css;
  298. this.tab = this.deployment.tab;
  299. this.lp = this.deployment.lp;
  300. this.load(this.lp.add);
  301. },
  302. createLine: function(title){
  303. var lineNode = new Element("div", {"styles": this.css.deployLineNode}).inject(this.content);
  304. var titleNode = new Element("div", {"styles": this.css.deployTitleNode, "text": title}).inject(lineNode);
  305. var valueNode = new Element("div", {"styles": this.css.deployvalueNode}).inject(lineNode);
  306. return new Element("input", {"styles": this.css.deployInputNode, "type": "text"}).inject(valueNode);
  307. },
  308. createLineSelect: function(title, defaultValue){
  309. var lineNode = new Element("div", {"styles": this.css.deployLineNode}).inject(this.content);
  310. var titleNode = new Element("div", {"styles": this.css.deployTitleNode, "text": title}).inject(lineNode);
  311. var valueNode = new Element("div", {"styles": this.css.deployvalueNode}).inject(lineNode);
  312. var selectNode = new Element("select").inject(valueNode);
  313. new Element("option", {"text": this.lp.yes, "value":"yes"}).inject(selectNode);
  314. new Element("option", {"text": this.lp.no, "value":"no", "checked": ((defaultValue=="no") ? true : false)}).inject(selectNode);
  315. return selectNode;
  316. },
  317. load: function(title){
  318. this.node = new Element("div", {"styles": this.css.newDeployNode});
  319. this.content = new Element("div", {"styles": this.css.deployContentNode}).inject(this.node);
  320. this.nameInputNode = this.createLine(this.lp.name);
  321. this.titleInputNode = this.createLine(this.lp.componentTitle);
  322. this.pathInputNode = this.createLine(this.lp.path);
  323. // var p = this.pathInputNode.getParent();
  324. // p.setStyle("height", ""+h+"px");
  325. new Element("div", {"text": this.lp.urlInfor, "styles": this.css.deployLineNode}).inject( this.content);
  326. this.iconNode = new MWF.xApplication.Setting.UIModuleDocument.Deploy.Icon(this.deployment, this.content, this.lp.icon, this);
  327. this.pathInputNode.addEvent("change", function(){
  328. if (this.iconNode) this.iconNode.checkIcon();
  329. }.bind(this));
  330. this.visibleInputNode = this.createLineSelect(this.lp.isVisible);
  331. // this.widgetNameInputNode = this.createLine(this.lp.widgetName);
  332. // this.widgetTitleInputNode = this.createLine(this.lp.widgetTitle);
  333. // this.widgetStartInputNode = this.createLineSelect(this.lp.widgetStart, "no");
  334. // this.widgetVisibleInputNode = this.createLineSelect(this.lp.widgetVisible);
  335. this.allowList = new MWF.xApplication.Setting.UIModuleDocument.Deploy.Select(this.deployment, this.content, this.lp.allowList);
  336. this.denyList = new MWF.xApplication.Setting.UIModuleDocument.Deploy.Select(this.deployment, this.content, this.lp.denyList);
  337. //this.controllerList = new MWF.xApplication.Setting.UIModuleDocument.Deploy.Select(this.deployment, this.content, this.lp.controllerList);
  338. this.okAction = new Element("div", {"styles": this.css.deployOkAction, "text": this.lp.add}).inject(this.content);
  339. this.okAction.addEvent("click", function(){
  340. var data = this.getComponentData();
  341. if ((!data.name) || (!data.title) || (!data.path)){
  342. this.deployment.app.notice(this.lp.noInputInfor, "error");
  343. return false;
  344. }else{
  345. this.deployment.actions.createComponent(data, function(){
  346. this.deployment.app.notice(this.lp.deploySuccess, "success");
  347. this.page.closeTab();
  348. this.deployment.appPage.showTabIm();
  349. this.deployment.components.push(new MWF.xApplication.Setting.UIModuleDocument.UserComponent(data, this.deployment, true));
  350. }.bind(this));
  351. }
  352. }.bind(this));
  353. this.page = this.tab.addTab(this.node, title, true);
  354. this.page.showTabIm();
  355. },
  356. getComponentData: function(){
  357. var visible = this.visibleInputNode.options[this.visibleInputNode.selectedIndex].value;
  358. // var widgetStart = this.widgetStartInputNode.options[this.widgetStartInputNode.selectedIndex].value;
  359. // var widgetVisible = this.widgetVisibleInputNode.options[this.widgetVisibleInputNode.selectedIndex].value;
  360. // var data = {
  361. // "name": this.nameInputNode.get("value"),
  362. // "title": this.titleInputNode.get("value"),
  363. // "path": this.pathInputNode.get("value"),
  364. // "visible": (visible=="yes") ? true : false,
  365. // "iconPath": "appicon.png",
  366. // "widgetName": this.widgetNameInputNode.get("value"),
  367. // "widgetTitle": this.widgetTitleInputNode.get("value"),
  368. // "widgetIconPath": "widgeticon.png",
  369. // "widgetStart": (widgetStart=="yes") ? true : false,
  370. // "widgetVisible": (widgetVisible=="yes") ? true : false,
  371. //
  372. // "allowList": this.allowList.list,
  373. // "denyList": this.denyList.list,
  374. // "controllerList": this.controllerList.list
  375. // };
  376. var path = this.pathInputNode.get("value");
  377. var data = {
  378. "name": this.nameInputNode.get("value"),
  379. "title": this.titleInputNode.get("value"),
  380. "path": path,
  381. "visible": (visible==="yes") ? true : false,
  382. "iconPath": (path.substring(0, 4)==="@url") ? "../x_component_Setting/$Main/default/icon/site.png" : "appicon.png",
  383. "widgetName": "",
  384. "widgetTitle": "",
  385. "widgetIconPath": "",
  386. "widgetStart": false,
  387. "widgetVisible": false,
  388. "allowList": this.allowList.list,
  389. "denyList": this.denyList.list,
  390. "controllerList": []
  391. };
  392. return data;
  393. }
  394. });
  395. MWF.xApplication.Setting.UIModuleDocument.DeployEdit = new Class({
  396. Extends: MWF.xApplication.Setting.UIModuleDocument.Deploy,
  397. initialize: function(data, component, deployment){
  398. this.deployment = deployment;
  399. this.component = component;
  400. this.css = this.deployment.css;
  401. this.tab = this.deployment.tab;
  402. this.lp = this.deployment.lp;
  403. this.data = data;
  404. this.load(this.lp.modify);
  405. this.setValues();
  406. },
  407. setValues: function(){
  408. this.nameInputNode.set("value", this.data.name);
  409. this.titleInputNode.set("value", this.data.title);
  410. this.pathInputNode.set("value", this.data.path);
  411. if (this.data.visible){
  412. this.visibleInputNode.getFirst("option").set("selected", true);
  413. }else{
  414. this.visibleInputNode.getLast("option").set("selected", true);
  415. }
  416. // this.widgetNameInputNode.set("value", this.data.widgetName);
  417. // this.widgetTitleInputNode.set("value", this.data.widgetTitle);
  418. this.allowList.setList(this.data.allowList);
  419. this.denyList.setList(this.data.denyList);
  420. //this.controllerList.setList(this.data.controllerList);
  421. this.okAction.set("text", this.lp.modify);
  422. this.okAction.removeEvents("click");
  423. this.okAction.addEvent("click", function(){
  424. var data = this.getComponentData();
  425. data.iconPath = this.data.iconPath;
  426. if ((!data.name) || (!data.title) || (!data.path)){
  427. this.deployment.app.notice(this.lp.noInputInfor, "error");
  428. return false;
  429. }else{
  430. this.deployment.actions.updateComponent(this.data.id, data, function(){
  431. this.deployment.app.notice(this.lp.modifySuccess, "success");
  432. this.page.closeTab();
  433. this.deployment.appPage.showTabIm();
  434. data.id = this.data.id;
  435. this.component.reload(data);
  436. }.bind(this));
  437. }
  438. }.bind(this));
  439. }
  440. });
  441. MWF.xApplication.Setting.UIModuleDocument.Deploy.Select = new Class({
  442. initialize: function(deployment, content, title){
  443. this.deployment = deployment;
  444. this.css = this.deployment.css;
  445. this.list = [];
  446. var lineNode = new Element("div", {"styles": this.css.deployLineNode}).inject(content);
  447. lineNode.setStyle("height", "40px");
  448. var titleNode = new Element("div", {"styles": this.css.deployTitleNode, "text": title}).inject(lineNode);
  449. var valueNode = new Element("div", {"styles": this.css.deployvalueNode}).inject(lineNode);
  450. this.listNode = new Element("div", {"styles": {"float": "left"}}).inject(valueNode);
  451. var actionNode = new Element("div", {"styles": this.css.actionNode, "text": this.deployment.lp.selPerson}).inject(valueNode);
  452. actionNode.setStyles({"margin-top": "10px", "float": "left"});
  453. actionNode.addEvent("click", function(){
  454. var options = {
  455. "type": "",
  456. "types": ["person", "group", "role"],
  457. "values": this.list,
  458. "count": 0,
  459. "onComplete": function(items){
  460. this.list = [];
  461. items.each(function(item){
  462. this.list.push(item.data.distinguishedName);
  463. }.bind(this));
  464. this.listNode.empty();
  465. this.list.each(function(personName){
  466. if (personName){
  467. var t = personName.substr(personName.length-1, 1);
  468. switch (t){
  469. case "G":
  470. new MWF.widget.O2Group({"name": personName}, this.listNode, {"style": "application"});
  471. break;
  472. case "R":
  473. new MWF.widget.O2Role({"name": personName}, this.listNode, {"style": "application"});
  474. break;
  475. default:
  476. new MWF.widget.O2Person({"name": personName}, this.listNode, {"style": "application"});
  477. }
  478. }
  479. }.bind(this));
  480. }.bind(this)
  481. };
  482. var selector = new MWF.O2Selector(this.deployment.app.content, options);
  483. }.bind(this));
  484. },
  485. setList: function(data){
  486. this.list = data;
  487. this.list.each(function(personName){
  488. if (personName) {
  489. o2.widget.O2Org(personName, this.listNode, {"style": "application"});
  490. }
  491. }.bind(this));
  492. }
  493. });
  494. MWF.xApplication.Setting.UIModuleDocument.Deploy.Icon = new Class({
  495. initialize: function(deployment, content, title, deploy){
  496. this.deployment = deployment;
  497. this.css = this.deployment.css;
  498. this.deploy = deploy;
  499. this.list = [];
  500. var lineNode = new Element("div", {"styles": this.css.deployLineNode}).inject(content);
  501. lineNode.setStyle("height", "64px");
  502. var titleNode = new Element("div", {"styles": this.css.deployTitleNode, "text": title}).inject(lineNode);
  503. var valueNode = new Element("div", {"styles": this.css.deployvalueNode}).inject(lineNode);
  504. this.iconNode = new Element("div", {"styles": this.css.deployIconNode}).inject(valueNode);
  505. this.actionNode = new Element("div", {"styles": this.css.actionNode, "text": this.deployment.lp.selIcon}).inject(valueNode);
  506. this.actionNode.setStyles({"margin-top": "10px", "float": "left"});
  507. this.actionNode.addEvent("click", function(){
  508. if (!this.uploadFileAreaNode){
  509. this.createUploadFileAreaNode();
  510. }
  511. this.fileUploadNode.set("multiple", false);
  512. var fileNode = this.uploadFileAreaNode.getFirst();
  513. fileNode.set("accept", ".png,.jpg,.bmp,.gif,.jpeg,.jpe");
  514. fileNode.click();
  515. }.bind(this));
  516. this.checkIcon();
  517. },
  518. createUploadFileAreaNode: function(){
  519. this.uploadFileAreaNode = new Element("div");
  520. var html = "<input name=\"file\" type=\"file\" accept=\"images/*\" />";
  521. this.uploadFileAreaNode.set("html", html);
  522. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  523. this.fileUploadNode.addEvent("change", function(){
  524. //var fileId = attachment.data.id;
  525. var files = this.fileUploadNode.files;
  526. if (files.length){
  527. var count = files.length;
  528. for (var i = 0; i < files.length; i++) {
  529. var file = files.item(i);
  530. var formData = new FormData();
  531. formData.append('file', file);
  532. MWF.xDesktop.uploadImage(
  533. "component",
  534. "component",
  535. formData,
  536. file,
  537. function(json){
  538. debugger;
  539. var id = json.id;
  540. this.deploy.data.iconPath = MWF.xDesktop.getImageSrc(id);
  541. this.checkIcon();
  542. }.bind(this)
  543. );
  544. }
  545. }
  546. }.bind(this));
  547. },
  548. checkIcon: function(){
  549. var path = this.deploy.pathInputNode.get("value") || ((this.deploy.data) ? this.deploy.data.path : "");
  550. if (path.substring(0,4)==="@url"){
  551. if (!this.deploy.data || !this.deploy.data.iconPath){
  552. this.iconNode.setStyle("background", "url(../x_component_Setting/$Main/default/icon/site.png) no-repeat center center");
  553. }else{
  554. this.iconNode.setStyle("background", "url("+this.deploy.data.iconPath+") no-repeat center center");
  555. }
  556. if (this.actionNode) this.actionNode.show();
  557. }else{
  558. if (path){
  559. var p = path.replace(".", "_");
  560. this.iconNode.setStyle("background", "url(../x_component_"+p+"/$Main/appicon.png) no-repeat center center");
  561. }
  562. if (this.actionNode) this.actionNode.hide();
  563. }
  564. }
  565. });