SettingExplorer.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.require("MWF.widget.Identity", null,false);
  5. MWF.xApplication.Execution.SettingExplorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default"
  10. },
  11. initialize: function (node, app, actions, options) {
  12. this.setOptions(options);
  13. this.app = app;
  14. this.lp = app.lp;
  15. this.path = "/x_component_Execution/$SettingExplorer/";
  16. this.loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_Execution/$SettingExplorer/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. this.middleContent = this.app.middleContent;
  26. //this.middleContent.setStyles({"margin-top":"0px","border":"0px solid #f00"});
  27. this.createNaviContent();
  28. this.createContentDiv();
  29. this.resizeWindow();
  30. this.app.addEvent("resize", function(){
  31. this.resizeWindow();
  32. }.bind(this));
  33. },
  34. resizeWindow: function(){
  35. var size = this.app.middleContent.getSize();
  36. this.naviDiv.setStyles({"height":(size.y-40)+"px"});
  37. this.naviContentDiv.setStyles({"height":(size.y-180)+"px"});
  38. this.contentDiv.setStyles({"height":(size.y-40)+"px"});
  39. },
  40. createNaviContent: function(){
  41. this.naviDiv = new Element("div.naviDiv",{
  42. "styles":this.css.naviDiv
  43. }).inject(this.middleContent);
  44. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  45. "styles":this.css.naviTitleDiv,
  46. "text": this.lp.systemSetting
  47. }).inject(this.naviDiv);
  48. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  49. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  50. var jsonUrl = this.path+"navi.json";
  51. MWF.getJSON(jsonUrl, function(json){
  52. json.each(function(data, i){
  53. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  54. naviContentLi.addEvents({
  55. "mouseover" : function(ev){
  56. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  57. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }) ,
  58. "mouseout" : function(ev){
  59. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  60. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  61. "click" : function(ev){
  62. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  63. this.node.setStyles( this.styles );
  64. this.bindObj.currentNaviItem = this.node;
  65. if( this.action && this.bindObj[this.action] )this.bindObj[this.action]();
  66. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action })
  67. });
  68. var naviContentImg = new Element("img.naviContentImg",{
  69. "styles":this.css.naviContentImg,
  70. "src":"/x_component_Execution/$Main/"+this.options.style+"/icon/"+data.icon
  71. }).inject(naviContentLi);
  72. var naviContentSpan = new Element("span.naviContentSpan",{
  73. "styles":this.css.naviContentSpan,
  74. "text":data.title
  75. }).inject(naviContentLi);
  76. if( i == 0 )naviContentLi.click();
  77. }.bind(this));
  78. }.bind(this));
  79. },
  80. createContentDiv: function(){
  81. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleContent);
  82. },
  83. openSystemConfig: function(){
  84. if( this.contentDiv )this.contentDiv.empty();
  85. if( this.explorer ){
  86. this.explorer.destroy();
  87. delete this.explorer;
  88. }
  89. this.explorer = new MWF.xApplication.Execution.SettingExplorer.SystemConfigExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  90. this.explorer.load();
  91. },
  92. openSecretarySetting: function(){
  93. if( this.contentDiv )this.contentDiv.empty();
  94. if( this.explorer ){
  95. this.explorer.destroy();
  96. delete this.explorer;
  97. }
  98. this.explorer = new MWF.xApplication.Execution.SettingExplorer.SecretarySettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  99. this.explorer.load();
  100. },
  101. openCategorySetting: function(){
  102. if( this.contentDiv )this.contentDiv.empty();
  103. if( this.explorer ){
  104. this.explorer.destroy();
  105. delete this.explorer;
  106. }
  107. this.explorer = new MWF.xApplication.Execution.SettingExplorer.CategorySettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  108. this.explorer.load();
  109. }
  110. });
  111. MWF.xApplication.Execution.SettingExplorer.SystemConfigExplorer = new Class({
  112. Extends: MWF.widget.Common,
  113. Implements: [Options, Events],
  114. options: {
  115. "style": "default"
  116. },
  117. initialize: function (container, app, parent, options) {
  118. this.container = container;
  119. this.parent = parent;
  120. this.app = app;
  121. this.css = this.parent.css;
  122. this.lp = this.app.lp;
  123. },
  124. load: function () {
  125. this.container.empty();
  126. //this.loadToolbar();
  127. this.loadView();
  128. },
  129. destroy : function(){
  130. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  131. this.view.destroy();
  132. },
  133. aa:function(){
  134. if(d.configValue && d.configValue!=''){vl=''}else {var v = d.configValue.split(',');v1 = '';for (i = 0; i < v.length; i++) {if (v1 == '') {v1 = v[i].split('@')[0];} else {v1 = v1 + ',' + v[i].split('@')[0];};}} return v1
  135. },
  136. loadToolbar: function(){
  137. this.toolbar = new Element("div",{
  138. styles : this.css.toolbar
  139. }).inject(this.container);
  140. this.createActionNode = new Element("div",{
  141. styles : this.css.toolbarActionNode,
  142. text: this.lp.createConfig
  143. }).inject(this.toolbar);
  144. this.createActionNode.addEvent("click",function(){
  145. var form = new MWF.xApplication.Execution.SettingExplorer.SystemConfigForm(this, {}, {
  146. onPostOk : function(){
  147. this.view.reload();
  148. }.bind(this)});
  149. form.create();
  150. }.bind(this));
  151. this.fileterNode = new Element("div",{
  152. styles : this.css.fileterNode
  153. }).inject(this.toolbar);
  154. },
  155. loadView : function(){
  156. this.viewContainer = Element("div",{
  157. "styles" : this.css.viewContainer
  158. }).inject(this.container);
  159. this.resizeWindow();
  160. this.resizeWindowFun = this.resizeWindow.bind(this);
  161. this.app.addEvent("resize", this.resizeWindowFun );
  162. this.view = new MWF.xApplication.Execution.SettingExplorer.SystemConfigView( this.viewContainer, this.app, this, {
  163. templateUrl : this.parent.path+"listItem_config.json",
  164. scrollEnable : true
  165. } );
  166. this.view.load();
  167. },
  168. resizeWindow: function(){
  169. var size = this.app.content.getSize();
  170. this.viewContainer.setStyles({"height":(size.y-65)+"px"});
  171. }
  172. });
  173. MWF.xApplication.Execution.SettingExplorer.SystemConfigView = new Class({
  174. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  175. _createDocument: function(data){
  176. return new MWF.xApplication.Execution.SettingExplorer.SystemConfigDocument(this.viewNode, data, this.explorer, this);
  177. },
  178. _getCurrentPageData: function(callback, count){
  179. if (!count)count = 20;
  180. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  181. //var filter = this.filterData || {};
  182. this.actions.listConfigAll( function (json) {
  183. if (callback)callback(json);
  184. }.bind(this))
  185. },
  186. _removeDocument: function(documentData, all){
  187. this.actions.deleteConfig(documentData.id, function(json){
  188. this.reload();
  189. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  190. }.bind(this));
  191. },
  192. _create: function(){
  193. },
  194. _openDocument: function( documentData ){
  195. var form = new MWF.xApplication.Execution.SettingExplorer.SystemConfigForm(this, documentData, {
  196. onPostOk : function(){
  197. this.reload();
  198. }.bind(this)
  199. });
  200. form.edit();
  201. },
  202. _queryCreateViewNode: function(){
  203. },
  204. _postCreateViewNode: function( viewNode ){
  205. },
  206. _queryCreateViewHead:function(){
  207. },
  208. _postCreateViewHead: function( headNode ){
  209. }
  210. });
  211. MWF.xApplication.Execution.SettingExplorer.SystemConfigDocument = new Class({
  212. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  213. _queryCreateDocumentNode:function( itemData ){
  214. },
  215. _postCreateDocumentNode: function( itemNode, itemData ){
  216. }
  217. });
  218. MWF.xApplication.Execution.SettingExplorer.SystemConfigForm = new Class({
  219. Extends: MPopupForm,
  220. Implements: [Options, Events],
  221. options: {
  222. "style": "default",
  223. "width": "600",
  224. "height": "290",
  225. "hasTop": true,
  226. "hasIcon": false,
  227. "hasTopIcon" : true,
  228. "hasTopContent" : true,
  229. "hasBottom": true,
  230. "title": MWF.xApplication.Execution.LP.categoryFormTitle,
  231. "draggable": true,
  232. "closeAction": true
  233. },
  234. _createTableContent: function () {
  235. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  236. "<tr><td styles='formTableTitle' lable='configName' width='20%'></td>" +
  237. " <td styles='formTableValue' item='configName' width='80%'></td></tr>" +
  238. "<tr><td styles='formTableTitle' lable='configValue'></td>" +
  239. " <td styles='formTableValue' item='configValue'></td></tr>" +
  240. "<tr><td styles='formTableTitle' lable='orderNumber'></td>" +
  241. " <td styles='formTableValue' item='orderNumber'></td></tr>" +
  242. "<tr><td styles='formTableTitle' lable='description'></td>" +
  243. " <td styles='formTableValue' item='description'></td></tr>" +
  244. "</table>";
  245. this.formTableArea.set("html", html);
  246. var configValueSetting = {text: this.lp.configValue };
  247. //alert(JSON.stringify(this.data))
  248. //alert(this.data.valueType)
  249. //if( this.data.configCode == "REPORT_WORKFLOW_TYPE" ){
  250. // configValueSetting.type = "select";
  251. // configValueSetting.selectValue = ["ADMIN_AND_ALLLEADER","DEPLOYER"];
  252. //}else if( this.data.configCode == "REPORT_SUPERVISOR" ){
  253. // configValueSetting.tType = "identity";
  254. // configValueSetting.count = 1;
  255. //}else if( this.data.configCode == "REPORT_AUDIT_LEADER" ){
  256. // configValueSetting.tType = "identity";
  257. // configValueSetting.count = 0;
  258. //}else if( this.data.configCode == "COMPANY_WORK_ADMIN" ){
  259. // configValueSetting.tType = "identity";
  260. // configValueSetting.count = 0;
  261. //}else if( this.data.configCode == "ARCHIVEMANAGER" ){
  262. // configValueSetting.tType = "identity";
  263. // configValueSetting.count = 0;
  264. //}else if( this.data.configCode == "REPORT_AUDIT_LEVEL" ){
  265. // configValueSetting.tType = "number";
  266. //}
  267. //alert(this.data.valueType)
  268. configValueSetting.tType = this.data.valueType;
  269. if(configValueSetting.tType=="select"){
  270. configValueSetting.type = "select";
  271. configValueSetting.selectValue = this.data.selectContent.split("|")
  272. }else if(configValueSetting.tType=="identity"){
  273. configValueSetting.type="org";
  274. configValueSetting.orgType = "identity";
  275. if(this.data.isMultiple){
  276. configValueSetting.count = 0
  277. }
  278. }else if(configValueSetting.tType == "workflow"){
  279. configValueSetting.type="org";
  280. configValueSetting.orgType = "process";
  281. }else{
  282. }
  283. MWF.xDesktop.requireApp("Template", "MForm", function () {
  284. this.form = new MForm(this.formTableArea, this.data, {
  285. style: "execution",
  286. isEdited: this.isEdited || this.isNew,
  287. itemTemplate: {
  288. configName: {text: this.lp.configName, type : "innerText" },
  289. configValue : configValueSetting,
  290. orderNumber: {text: this.lp.orderNumber, type : "innerText" },
  291. description: {text: this.lp.description, type : "innerText" }
  292. }
  293. }, this.app);
  294. this.form.load();
  295. }.bind(this), true);
  296. },
  297. _ok: function (data, callback) {
  298. //if(this.data.configCode == "APPRAISE_WORKFLOW_ID"){
  299. if(this.data.valueType == "workflow"){
  300. if(this.form.getItem("configValue").orgObject){
  301. this.data.configValue = this.form.getItem("configValue").orgObject[0].data.id
  302. }else if(this.form.getItem("configValue").dom.orgData){
  303. this.data.configValue = this.form.getItem("configValue").dom.orgData[0]
  304. }else{
  305. this.data.configValue = ""
  306. }
  307. }
  308. this.app.restActions.saveConfig( data, function(json){
  309. if( callback )callback(json);
  310. this.fireEvent("postOk")
  311. }.bind(this));
  312. }
  313. });
  314. MWF.xApplication.Execution.SettingExplorer.SecretarySettingExplorer = new Class({
  315. Extends: MWF.widget.Common,
  316. Implements: [Options, Events],
  317. options: {
  318. "style": "default"
  319. },
  320. initialize: function (container, app, parent, options) {
  321. this.container = container;
  322. this.parent = parent;
  323. this.app = app;
  324. this.css = this.parent.css;
  325. this.lp = this.app.lp;
  326. },
  327. load: function () {
  328. this.container.empty();
  329. this.loadToolbar();
  330. this.loadView();
  331. },
  332. destroy : function(){
  333. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  334. this.view.destroy();
  335. },
  336. loadToolbar: function(){
  337. this.toolbar = new Element("div",{
  338. styles : this.css.toolbar
  339. }).inject(this.container);
  340. this.createActionNode = new Element("div",{
  341. styles : this.css.toolbarActionNode,
  342. text: this.lp.createSecretary
  343. }).inject(this.toolbar);
  344. this.createActionNode.addEvent("click",function(){
  345. var form = new MWF.xApplication.Execution.SettingExplorer.SecretarySettingForm(this, {}, {
  346. onPostOk : function(){
  347. this.view.reload();
  348. }.bind(this)});
  349. form.create();
  350. }.bind(this));
  351. this.fileterNode = new Element("div",{
  352. styles : this.css.fileterNode
  353. }).inject(this.toolbar);
  354. },
  355. loadView : function(){
  356. this.viewContainer = Element("div",{
  357. "styles" : this.css.viewContainer
  358. }).inject(this.container);
  359. this.resizeWindow();
  360. this.resizeWindowFun = this.resizeWindow.bind(this);
  361. this.app.addEvent("resize", this.resizeWindowFun );
  362. this.view = new MWF.xApplication.Execution.SettingExplorer.SecretarySettingView( this.viewContainer, this.app, this, {
  363. templateUrl : this.parent.path+"listItem_secretary.json",
  364. scrollEnable : true
  365. } );
  366. this.view.load();
  367. },
  368. resizeWindow: function(){
  369. var size = this.app.content.getSize();
  370. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  371. }
  372. });
  373. MWF.xApplication.Execution.SettingExplorer.SecretarySettingView = new Class({
  374. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  375. _createDocument: function(data){
  376. return new MWF.xApplication.Execution.SettingExplorer.SecretarySettingDocument(this.viewNode, data, this.explorer, this);
  377. },
  378. _getCurrentPageData: function(callback, count){
  379. if (!count)count = 20;
  380. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  381. var filter = this.filterData || {};
  382. this.actions.listSecretaryNext(id, count, filter, function (json) {
  383. if (callback)callback(json);
  384. }.bind(this))
  385. },
  386. _removeDocument: function(documentData, all){
  387. this.actions.deleteSecretary(documentData.id, function(json){
  388. this.reload();
  389. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  390. }.bind(this));
  391. },
  392. _create: function(){
  393. },
  394. _openDocument: function( documentData ){
  395. var form = new MWF.xApplication.Execution.SettingExplorer.SecretarySettingForm(this, documentData, {
  396. onPostOk : function(){
  397. this.reload();
  398. }.bind(this)
  399. });
  400. form.edit();
  401. },
  402. _queryCreateViewNode: function(){
  403. },
  404. _postCreateViewNode: function( viewNode ){
  405. },
  406. _queryCreateViewHead:function(){
  407. },
  408. _postCreateViewHead: function( headNode ){
  409. }
  410. });
  411. MWF.xApplication.Execution.SettingExplorer.SecretarySettingDocument = new Class({
  412. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  413. _queryCreateDocumentNode:function( itemData ){
  414. },
  415. _postCreateDocumentNode: function( itemNode, itemData ){
  416. }
  417. });
  418. MWF.xApplication.Execution.SettingExplorer.SecretarySettingForm = new Class({
  419. Extends: MPopupForm,
  420. Implements: [Options, Events],
  421. options: {
  422. "style": "default",
  423. "width": "600",
  424. "height": "260",
  425. "hasTop": true,
  426. "hasIcon": false,
  427. "hasTopIcon" : true,
  428. "hasTopContent" : true,
  429. "hasBottom": true,
  430. "title": MWF.xApplication.Execution.LP.secretaryFormTitle,
  431. "draggable": true,
  432. "closeAction": true
  433. },
  434. _createTableContent: function () {
  435. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  436. "<tr><td styles='formTableTitle' lable='secretaryIdentity'></td>" +
  437. " <td styles='formTableValue' item='secretaryIdentity'></td></tr>" +
  438. "<tr><td styles='formTableTitle' lable='leaderIdentity'></td>" +
  439. " <td styles='formTableValue' item='leaderIdentity'></td></tr>" +
  440. "<tr><td styles='formTableTitle' lable='description'></td>" +
  441. " <td styles='formTableValue' item='description'></td></tr>" +
  442. "</table>";
  443. this.formTableArea.set("html", html);
  444. MWF.xDesktop.requireApp("Template", "MForm", function () {
  445. this.form = new MForm(this.formTableArea, this.data, {
  446. style: "execution",
  447. isEdited: this.isEdited || this.isNew,
  448. itemTemplate: {
  449. secretaryIdentity: {text: this.lp.secretaryIdentity, type:"org",orgType: "identity", notEmpty: true},
  450. leaderIdentity: {text: this.lp.leaderIdentity, type:"org",orgType: "identity", notEmpty: true},
  451. description: {text: this.lp.description, type: "textarea"}
  452. }
  453. }, this.app);
  454. this.form.load();
  455. }.bind(this), true);
  456. },
  457. _ok: function (data, callback) {
  458. this.app.restActions.saveSecretary( data, function(json){
  459. if( callback )callback(json);
  460. this.fireEvent("postOk")
  461. }.bind(this));
  462. }
  463. });
  464. MWF.xApplication.Execution.SettingExplorer.CategorySettingExplorer = new Class({
  465. Extends: MWF.widget.Common,
  466. Implements: [Options, Events],
  467. options: {
  468. "style": "default"
  469. },
  470. initialize: function (container, app, parent, options) {
  471. this.container = container;
  472. this.parent = parent;
  473. this.app = app;
  474. this.css = this.parent.css;
  475. this.lp = this.app.lp;
  476. },
  477. load: function () {
  478. this.container.empty();
  479. this.loadToolbar();
  480. this.loadView();
  481. },
  482. destroy : function(){
  483. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  484. this.view.destroy();
  485. },
  486. loadToolbar: function(){
  487. this.toolbar = new Element("div",{
  488. styles : this.css.toolbar
  489. }).inject(this.container);
  490. this.createActionNode = new Element("div",{
  491. styles : this.css.toolbarActionNode,
  492. text: this.lp.createCategory
  493. }).inject(this.toolbar);
  494. this.createActionNode.addEvent("click",function(){
  495. var form = new MWF.xApplication.Execution.SettingExplorer.CategorySettingForm(this, {}, {
  496. onPostOk : function(){
  497. this.view.reload();
  498. }.bind(this)});
  499. form.create();
  500. }.bind(this));
  501. this.fileterNode = new Element("div",{
  502. styles : this.css.fileterNode
  503. }).inject(this.toolbar);
  504. },
  505. loadView : function(){
  506. this.viewContainer = Element("div",{
  507. "styles" : this.css.viewContainer
  508. }).inject(this.container);
  509. this.resizeWindow();
  510. this.resizeWindowFun = this.resizeWindow.bind(this);
  511. this.app.addEvent("resize", this.resizeWindowFun );
  512. this.view = new MWF.xApplication.Execution.SettingExplorer.CategorySettingView( this.viewContainer, this.app, this, {
  513. templateUrl : this.parent.path+"listItem_category.json",
  514. scrollEnable : true
  515. } );
  516. this.view.load();
  517. },
  518. resizeWindow: function(){
  519. var size = this.app.content.getSize();
  520. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  521. }
  522. });
  523. MWF.xApplication.Execution.SettingExplorer.CategorySettingView = new Class({
  524. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  525. _createDocument: function(data){
  526. return new MWF.xApplication.Execution.SettingExplorer.CategorySettingDocument(this.viewNode, data, this.explorer, this);
  527. },
  528. _getCurrentPageData: function(callback, count){
  529. if (!count)count = 20;
  530. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  531. //var filter = this.filterData || {};
  532. this.actions.listCategoryAll( function (json) {
  533. if (callback)callback(json);
  534. }.bind(this))
  535. },
  536. _removeDocument: function(documentData, all){
  537. this.actions.deleteCategory(documentData.id, function(json){
  538. this.reload();
  539. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  540. }.bind(this));
  541. },
  542. _create: function(){
  543. },
  544. _openDocument: function( documentData ){
  545. var form = new MWF.xApplication.Execution.SettingExplorer.CategorySettingForm(this, documentData, {
  546. onPostOk : function(){
  547. this.reload();
  548. }.bind(this)
  549. });
  550. form.edit();
  551. },
  552. _queryCreateViewNode: function(){
  553. },
  554. _postCreateViewNode: function( viewNode ){
  555. },
  556. _queryCreateViewHead:function(){
  557. },
  558. _postCreateViewHead: function( headNode ){
  559. }
  560. });
  561. MWF.xApplication.Execution.SettingExplorer.CategorySettingDocument = new Class({
  562. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  563. _queryCreateDocumentNode:function( itemData ){
  564. },
  565. _postCreateDocumentNode: function( itemNode, itemData ){
  566. }
  567. });
  568. MWF.xApplication.Execution.SettingExplorer.CategorySettingForm = new Class({
  569. Extends: MPopupForm,
  570. Implements: [Options, Events],
  571. options: {
  572. "style": "default",
  573. "width": "600",
  574. "height": "260",
  575. "hasTop": true,
  576. "hasIcon": false,
  577. "hasTopIcon" : true,
  578. "hasTopContent" : true,
  579. "hasBottom": true,
  580. "title": MWF.xApplication.Execution.LP.categoryFormTitle,
  581. "draggable": true,
  582. "closeAction": true
  583. },
  584. _createTableContent: function () {
  585. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  586. "<tr><td styles='formTableTitle' lable='workTypeName'></td>" +
  587. " <td styles='formTableValue' item='workTypeName'></td></tr>" +
  588. "<tr><td styles='formTableTitle' lable='orderNumber'></td>" +
  589. " <td styles='formTableValue' item='orderNumber'></td></tr>" +
  590. "<tr><td styles='formTableTitle' lable='description'></td>" +
  591. " <td styles='formTableValue' item='description'></td></tr>" +
  592. "</table>";
  593. this.formTableArea.set("html", html);
  594. MWF.xDesktop.requireApp("Template", "MForm", function () {
  595. this.form = new MForm(this.formTableArea, this.data, {
  596. style: "execution",
  597. isEdited: this.isEdited || this.isNew,
  598. itemTemplate: {
  599. workTypeName: {text: this.lp.workTypeName, notEmpty: true},
  600. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  601. description: {text: this.lp.description, type: "textarea"}
  602. }
  603. }, this.app);
  604. this.form.load();
  605. }.bind(this), true);
  606. },
  607. _ok: function (data, callback) {
  608. this.app.restActions.saveCategory( data, function(json){
  609. if( callback )callback(json);
  610. this.fireEvent("postOk")
  611. }.bind(this));
  612. }
  613. });