Datatable.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Container", null, false);
  3. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Component", null, false);
  4. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Datatable$Data", null, false);
  5. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Datatable$Title", null, false);
  6. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Table$Td", null, false);
  7. MWF.xApplication.process.FormDesigner.Module.Datatable = MWF.FCDatatable = new Class({
  8. Extends: MWF.FC$Component,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "propertyPath": "../x_component_process_FormDesigner/Module/Datatable/datatable.html"
  13. },
  14. initialize: function(form, options){
  15. this.setOptions(options);
  16. this.path = "../x_component_process_FormDesigner/Module/Datatable/";
  17. this.cssPath = "../x_component_process_FormDesigner/Module/Datatable/"+this.options.style+"/css.wcss";
  18. this._loadCss();
  19. this.moduleType = "component";
  20. this.moduleName = "datatable";
  21. this.form = form;
  22. this.container = null;
  23. this.containerNode = null;
  24. this.containers = [];
  25. this.elements = [];
  26. this.selectedMultiTds = [];
  27. debugger;
  28. },
  29. clearTemplateStyles: function(styles){
  30. debugger;
  31. if (styles){
  32. if (styles.styles) this.removeStyles(styles.styles, "styles");
  33. if (styles.tableStyles) this.removeStyles(styles.tableStyles, "tableStyles");
  34. if (styles.titleStyles) this.removeStyles(styles.titleStyles, "titleStyles");
  35. if (styles.contentStyles) this.removeStyles(styles.contentStyles, "contentStyles");
  36. if (styles.actionStyles) this.removeStyles(styles.actionStyles, "actionStyles");
  37. if (styles.editStyles) this.removeStyles(styles.editStyles, "editStyles");
  38. if (styles.amountStyles) this.removeStyles(styles.amountStyles, "amountStyles");
  39. if (styles.sectionAmountStyles) this.removeStyles(styles.sectionAmountStyles, "sectionAmountStyles");
  40. if (styles.itemTitleStyles) this.removeStyles(styles.itemTitleStyles, "itemTitleStyles");
  41. if (styles.properties) this.removeStyles(styles.properties, "properties");
  42. if (styles.importActionStyles) this.removeStyles(styles.importActionStyles, "importActionStyles");
  43. if (styles.exportActionStyles) this.removeStyles(styles.exportActionStyles, "exportActionStyles");
  44. if (styles.sectionKeyStyles) this.removeStyles(styles.sectionKeyStyles, "sectionKeyStyles");
  45. if (styles.sectionKeyStyles) this.removeStyles(styles.sectionKeyStyles, "sectionByStyles");
  46. }
  47. },
  48. setTemplateStyles: function(styles){
  49. debugger;
  50. if (styles.styles) this.copyStyles(styles.styles, "styles");
  51. if (styles.tableStyles) this.copyStyles(styles.tableStyles, "tableStyles");
  52. if (styles.titleStyles) this.copyStyles(styles.titleStyles, "titleStyles");
  53. if (styles.contentStyles) this.copyStyles(styles.contentStyles, "contentStyles");
  54. if (styles.actionStyles) this.copyStyles(styles.actionStyles, "actionStyles");
  55. if (styles.editStyles) this.copyStyles(styles.editStyles, "editStyles");
  56. if (styles.amountStyles) this.copyStyles(styles.amountStyles, "amountStyles");
  57. if (styles.sectionAmountStyles) this.copyStyles(styles.sectionAmountStyles, "sectionAmountStyles");
  58. if (styles.itemTitleStyles) this.copyStyles(styles.itemTitleStyles, "itemTitleStyles");
  59. if (styles.properties) this.copyStyles(styles.properties, "properties");
  60. if (styles.importActionStyles) this.copyStyles(styles.importActionStyles, "importActionStyles");
  61. if (styles.exportActionStyles) this.copyStyles(styles.exportActionStyles, "exportActionStyles");
  62. if (styles.sectionKeyStyles) this.copyStyles(styles.sectionKeyStyles, "sectionKeyStyles");
  63. if (styles.sectionKeyStyles) this.copyStyles(styles.sectionKeyStyles, "sectionByStyles");
  64. },
  65. setImpExpTableStyles: function(){
  66. //设置导入导出表格样式
  67. if(this.form.templateStyles && this.form.templateStyles.table){
  68. this.json.impExpTableStyles = Object.merge(this.json.impExpTableStyles||{}, this.form.templateStyles.table.styles||{});
  69. this.json.impExpTableTitleStyles = Object.merge(this.json.impExpTableTitleStyles||{}, this.form.templateStyles.table.titleStyles||{});
  70. this.json.impExpTableContentStyles = Object.merge(this.json.impExpTableContentStyles||{}, this.form.templateStyles.table.contentStyles||{});
  71. this.json.impExpTableProperties = Object.merge(this.json.impExpTableProperties||{}, this.form.templateStyles.table.properties||{});
  72. }
  73. },
  74. _createMoveNode: function(){
  75. var tableHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" align=\"center\">";
  76. tableHTML += "<tr><th></th><th></th><th></th></tr>";
  77. tableHTML += "<tr><td></td><td></td><td></td></tr>";
  78. tableHTML += "</table>";
  79. this.moveNode = new Element("div", {
  80. "html": tableHTML
  81. }).inject(this.form.container);
  82. // this.moveNode = divNode.getFirst();
  83. // this.moveNode.inject(divNode, "after");
  84. // divNode.destroy();
  85. this.moveNode.setStyles(this.css.moduleNodeMove);
  86. this._setTableStyle();
  87. },
  88. _setTableStyle: function(){
  89. var tds = this.moveNode.getElements("td");
  90. tds.setStyles({
  91. "border": "1px dashed #999",
  92. "height": "20px"
  93. });
  94. var tds = this.moveNode.getElements("th");
  95. tds.setStyles({
  96. "background": "#C3CEEA",
  97. "border": "1px dashed #999",
  98. "height": "20px"
  99. });
  100. },
  101. _getContainers: function(){
  102. var tds = this.node.getElements("td");
  103. this.form.getTemplateData("Datatable$Data", function(data){
  104. tds.each(function(td){
  105. var json = this.form.getDomjson(td);
  106. var tdContainer = null;
  107. if (!json){
  108. var moduleData = Object.clone(data);
  109. tdContainer = new MWF.FCDatatable$Data(this.form);
  110. tdContainer.load(moduleData, td, this);
  111. }else{
  112. var moduleData = Object.clone(data);
  113. Object.merge(moduleData, json);
  114. Object.merge(json, moduleData);
  115. tdContainer = new MWF.FCDatatable$Data(this.form);
  116. tdContainer.load(json, td, this);
  117. }
  118. this.containers.push(tdContainer);
  119. }.bind(this));
  120. }.bind(this), false);
  121. },
  122. _getElements: function(){
  123. //this.elements.push(this);
  124. var ths = this.node.getElements("th");
  125. this.form.getTemplateData("Datatable$Title", function(data){
  126. ths.each(function(th){
  127. var json = this.form.getDomjson(th);
  128. var thElement = null;
  129. if (!json){
  130. var moduleData = Object.clone(data);
  131. thElement = new MWF.FCDatatable$Title(this.form);
  132. thElement.load(moduleData, th, this);
  133. }else{
  134. var moduleData = Object.clone(data);
  135. Object.merge(moduleData, json);
  136. Object.merge(json, moduleData);
  137. thElement = new MWF.FCDatatable$Title(this.form);
  138. thElement.load(json, th, this);
  139. }
  140. this.elements.push(thElement);
  141. }.bind(this));
  142. }.bind(this), false);
  143. },
  144. // _getDroppableNodes: function(){
  145. // var nodes = [this.form.node].concat(this.form.moduleElementNodeList, this.form.moduleContainerNodeList, this.form.moduleComponentNodeList);
  146. // this.form.moduleList.each( function(module){
  147. // //数据网格不能往数据模板里拖
  148. // if( module.moduleName === "datatemplate" ){
  149. // var subDoms = this.form.getModuleNodes(module.node);
  150. // nodes.erase( module.node );
  151. // subDoms.each(function (dom) {
  152. // nodes.erase( dom );
  153. // })
  154. // }
  155. // }.bind(this));
  156. // return nodes;
  157. // },
  158. _createNode: function(callback){
  159. var module = this;
  160. var url = this.path+"datatableCreate.html";
  161. MWF.require("MWF.widget.Dialog", function(){
  162. var size = $(document.body).getSize();
  163. var x = size.x/2-180;
  164. var y = size.y/2-130;
  165. var dlg = new MWF.DL({
  166. "title": "Create Datatable",
  167. "style": "property",
  168. "top": y,
  169. "left": x-40,
  170. "fromTop":size.y/2-65,
  171. "fromLeft": size.x/2,
  172. "width": 360,
  173. "height": 260,
  174. "url": url,
  175. "lp": MWF.xApplication.process.FormDesigner.LP.propertyTemplate,
  176. "buttonList": [
  177. {
  178. "text": MWF.APPFD.LP.button.ok,
  179. "action": function(){
  180. module._createTableNode();
  181. callback();
  182. this.close();
  183. }
  184. }
  185. ]
  186. });
  187. dlg.show();
  188. }.bind(this));
  189. },
  190. _createTableNode: function(){
  191. var cols = $("MWFNewTableColumn").get("value");
  192. var width = $("MWFNewTableWidth").get("value");
  193. var widthUnitNode = $("MWFNewTableWidthUnit");
  194. var widthUnit = widthUnitNode.options[widthUnitNode.selectedIndex].value;
  195. var border = $("MWFNewTableBorder").get("value");
  196. var cellpadding = $("MWFNewTableCellpadding").get("value");
  197. var cellspacing = $("MWFNewTableCellspacing").get("value");
  198. var w = "";
  199. if (widthUnit=="percent"){
  200. w = width+"%";
  201. }else{
  202. w = width+"px";
  203. }
  204. this.json.properties.width = w;
  205. this.json.properties.border = border;
  206. this.json.properties.cellpadding = cellpadding;
  207. this.json.properties.cellspacing = cellspacing;
  208. var tableHTML = "<table border=\""+border+"\" cellpadding=\""+cellpadding+"\" cellspacing=\""+cellspacing+"\" width=\""+w+"\" align=\"center\">";
  209. tableHTML += "<tr>";
  210. for (var j=0; j<cols.toInt(); j++){
  211. tableHTML += "<th></th>";
  212. }
  213. tableHTML += "</tr>";
  214. tableHTML += "<tr>";
  215. for (var j=0; j<cols.toInt(); j++){
  216. tableHTML += "<td></td>";
  217. }
  218. tableHTML += "</tr></table>";
  219. this.node = new Element("div", {
  220. "id": this.json.id,
  221. "MWFType": "datatable",
  222. "html": tableHTML,
  223. "styles": this.css.moduleNode,
  224. "events": {
  225. "selectstart": function(e){
  226. e.preventDefault();
  227. }
  228. }
  229. }).inject(this.form.node);
  230. this.table = this.node.getElement("table");
  231. },
  232. _dragComplete: function(){
  233. if (!this.node){
  234. this._createNode(function(){
  235. this._dragMoveComplete();
  236. }.bind(this));
  237. }else{
  238. this._dragMoveComplete();
  239. }
  240. },
  241. _dragMoveComplete: function(){
  242. this._resetTreeNode();
  243. this.node.inject(this.copyNode, "before");
  244. this._initModule();
  245. var thisDisplay = this.node.retrieve("thisDisplay");
  246. if (thisDisplay){
  247. this.node.setStyle("display", thisDisplay);
  248. }
  249. if (this.copyNode) this.copyNode.destroy();
  250. if (this.moveNode) this.moveNode.destroy();
  251. this.moveNode = null;
  252. this.copyNode = null;
  253. this.nextModule = null;
  254. this.form.moveModule = null;
  255. this.form.json.moduleList[this.json.id] = this.json;
  256. this.selected();
  257. if( this.operation && !this.historyAddDelay ){
  258. this.addHistoryLog( this.operation, null, this.fromLog );
  259. }
  260. if( !this.historyAddDelay ){
  261. this.operation = null;
  262. this.fromLog = null;
  263. }
  264. },
  265. _initModule: function(){
  266. if (!this.initialized){
  267. if (this.json.initialized!=="yes")this.setStyleTemplate();
  268. this.table = this.node.getElement("table");
  269. this._getElements();
  270. this._getContainers();
  271. this.setPropertiesOrStyles("styles");
  272. this.setPropertiesOrStyles("tableStyles");
  273. this.setPropertiesOrStyles("properties");
  274. if( !this.json.impExpTableStyles ){
  275. this.setImpExpTableStyles()
  276. }
  277. this._setNodeProperty();
  278. if (!this.form.isSubform) this._createIconAction();
  279. // this.checkSequenceShow();
  280. this._setNodeEvent();
  281. this.setDatatableStyles();
  282. this._setEditStyle_custom("impexpType");
  283. this.initialized = true;
  284. this.json.initialized = "yes";
  285. }
  286. },
  287. setPropertiesOrStyles: function(name){
  288. if (name=="styles"){
  289. try{
  290. this.setCustomStyles();
  291. }catch(e){}
  292. var border = this.node.getStyle("border");
  293. this.node.clearStyles();
  294. this.node.setStyles(this.css.moduleNode);
  295. this.node.setStyle("border", border);
  296. Object.each(this.json.styles, function(value, key){
  297. var reg = /^border\w*/ig;
  298. if (!key.test(reg)){
  299. this.node.setStyle(key, value);
  300. }
  301. }.bind(this));
  302. }
  303. if (name=="tableStyles"){
  304. this.table.clearStyles();
  305. Object.each(this.json.tableStyles, function(value, key){
  306. var reg = /^border\w*/ig;
  307. if (!key.test(reg)){
  308. this.table.setStyle(key, value);
  309. }
  310. }.bind(this));
  311. }
  312. if (name=="properties"){
  313. try{
  314. this.setCustomProperties();
  315. }catch(e){}
  316. var table = this.node.getElement("table");
  317. if(table)table.setProperties(this.json.properties);
  318. }
  319. },
  320. _setEditStyle_custom: function(name, obj, oldValue){
  321. if (name=="id"){
  322. if (oldValue && this.json.id!=oldValue){
  323. debugger;
  324. var reg = new RegExp("^"+oldValue, "i");
  325. this.containers.each(function(container){
  326. var id = container.json.id;
  327. var newId = id.replace(reg, this.json.id);
  328. container.json.id = newId;
  329. delete this.form.json.moduleList[id];
  330. this.form.json.moduleList[newId] = container.json;
  331. container._setEditStyle("id");
  332. if(container.property && container.property.propertyContent){
  333. var pid = container.property.data.pid;
  334. var input = container.property.propertyContent.getElement("input[name='"+pid+"id']");
  335. if(input)input.set("value", newId);
  336. }
  337. }.bind(this));
  338. this.elements.each(function(container){
  339. var id = container.json.id;
  340. var newId = id.replace(reg, this.json.id);
  341. container.json.id = newId;
  342. delete this.form.json.moduleList[id];
  343. this.form.json.moduleList[newId] = container.json;
  344. container._setEditStyle("id");
  345. if(container.property && container.property.propertyContent){
  346. var pid = container.property.data.pid;
  347. var input = container.property.propertyContent.getElement("input[name='"+pid+"id']");
  348. if(input)input.set("value", newId);
  349. }
  350. }.bind(this));
  351. }
  352. }
  353. if (name=="titleStyles"){
  354. var ths = this.table.getElements("th");
  355. ths.each(function(th){
  356. var opacity = th.getStyle("opacity");
  357. this.setCustomNodeStyles(th, this.json.titleStyles);
  358. if(opacity)th.setStyle("opacity", opacity);
  359. }.bind(this));
  360. }
  361. if (name=="contentStyles"){
  362. var tds = this.table.getElements("td");
  363. tds.each(function(td){
  364. var opacity = td.getStyle("opacity");
  365. this.setCustomNodeStyles(td, this.json.contentStyles);
  366. if(opacity)td.setStyle("opacity", opacity);
  367. }.bind(this));
  368. }
  369. var setImportExportAreaNodeWidth = function () {
  370. if( ["centerTop","centerBottom"].contains( this.json.impexpPosition ) ){
  371. var width = 2;
  372. if( this.exportActionNode ){
  373. width = width + this.exportActionNode.getSize().x +
  374. this.exportActionNode.getStyle("padding-left").toFloat() +
  375. + this.exportActionNode.getStyle("padding-right").toFloat() +
  376. + this.exportActionNode.getStyle("margin-left").toFloat() +
  377. + this.exportActionNode.getStyle("margin-right").toFloat()
  378. }
  379. if( this.importActionNode ){
  380. width = width + this.importActionNode.getSize().x +
  381. this.importActionNode.getStyle("padding-left").toFloat() +
  382. + this.importActionNode.getStyle("padding-right").toFloat() +
  383. + this.importActionNode.getStyle("margin-left").toFloat() +
  384. + this.importActionNode.getStyle("margin-right").toFloat()
  385. }
  386. this.importExportAreaNode.setStyle( "width", width+"px" );
  387. }else{
  388. this.importExportAreaNode.setStyle( "width", "auto" );
  389. }
  390. }.bind(this);
  391. if( name === "impexpType" ){
  392. debugger;
  393. //允许导入
  394. var importenable = this.json.impexpType === "impexp" || this.json.impexpType === "imp";
  395. //允许导出
  396. var exportenable = this.json.impexpType === "impexp" || this.json.impexpType === "exp";
  397. if( this.impexpNode )this.impexpNode.destroy();
  398. this.impexpNode = null;
  399. this.impexpNode = this.node.getElement("div.impexpNode");
  400. if( this.impexpNode )this.impexpNode.destroy();
  401. this.impexpNode = null;
  402. if( !exportenable && !importenable ){
  403. return;
  404. }
  405. var position = ["leftTop","centerTop","rightTop"].contains( this.json.impexpPosition || "" ) ? "top" : "bottom";
  406. this.impexpNode = new Element("div.impexpNode", { styles : { "width" : "100%", "overflow" : "hidden" } }).inject(this.node, position);
  407. var importExportAreaNode = new Element("div.importExportAreaNode").inject( this.impexpNode );
  408. if( ["leftTop","leftBottom"].contains( this.json.impexpPosition || "" ) ){
  409. importExportAreaNode.setStyles({ "float" : "left", "margin" : "0px" })
  410. }else if( ["rightTop","rightBottom"].contains( this.json.impexpPosition || "" ) ){
  411. importExportAreaNode.setStyles({ "float" : "right", "margin" : "0px" })
  412. }else{
  413. importExportAreaNode.setStyles({ "float" : "none", "margin" : "0px auto" })
  414. }
  415. this.importExportAreaNode = importExportAreaNode;
  416. var styles;
  417. var width = 0;
  418. if( exportenable ){
  419. var exportActionNode = new Element("div.exportActionStyles", { text : this.json.exportActionText }).inject( importExportAreaNode );
  420. if( this.json.exportActionStyles ){
  421. styles = Object.clone(this.json.exportActionStyles)
  422. }else{
  423. styles = {
  424. "color" : "#777",
  425. "border-radius": "5px",
  426. "border": "1px solid #ccc",
  427. "cursor": "pointer",
  428. "height": "26px",
  429. "float" : "left",
  430. "line-height": "26px",
  431. "padding": "0px 5px",
  432. "background-color": "#efefef",
  433. "margin" : "5px"
  434. }
  435. }
  436. exportActionNode.setStyles(styles);
  437. this.exportActionNode = exportActionNode;
  438. }
  439. if( importenable ){
  440. var importActionNode = new Element("div.importActionNode", { text : this.json.importActionText }).inject( importExportAreaNode );
  441. if( this.json.importActionStyles ){
  442. styles = Object.clone(this.json.importActionStyles);
  443. }else{
  444. styles = {
  445. "color" : "#777",
  446. "border-radius": "5px",
  447. "border": "1px solid #ccc",
  448. "cursor": "pointer",
  449. "height": "26px",
  450. "float" : "left",
  451. "line-height": "26px",
  452. "padding": "0px 5px",
  453. "background-color": "#efefef",
  454. "margin" : "5px"
  455. }
  456. }
  457. importActionNode.setStyles(styles);
  458. this.importActionNode = importActionNode;
  459. }
  460. setImportExportAreaNodeWidth();
  461. }
  462. if( name === "impexpPosition" && this.impexpNode && this.importExportAreaNode ){
  463. var position = ["leftTop","centerTop","rightTop"].contains( this.json.impexpPosition || "" ) ? "top" : "bottom";
  464. this.impexpNode.inject(this.node, position);
  465. var importExportAreaNode = this.importExportAreaNode;
  466. if( ["leftTop","leftBottom"].contains( this.json.impexpPosition || "" ) ){
  467. importExportAreaNode.setStyles({ "float" : "left", "margin" : "0px" })
  468. }else if( ["rightTop","rightBottom"].contains( this.json.impexpPosition || "" ) ){
  469. importExportAreaNode.setStyles({ "float" : "right", "margin" : "0px" })
  470. }else{
  471. importExportAreaNode.setStyles({ "float" : "none", "margin" : "0px auto" })
  472. }
  473. setImportExportAreaNodeWidth();
  474. }
  475. if( name === "importActionText" && this.importActionNode ){
  476. this.importActionNode.set("text", this.json.importActionText );
  477. setImportExportAreaNodeWidth();
  478. }
  479. if( name === "exportActionText" && this.exportActionNode ){
  480. this.exportActionNode.set("text", this.json.exportActionText );
  481. setImportExportAreaNodeWidth();
  482. }
  483. if( name === "importActionStyles" && this.importActionNode ){
  484. this.importActionNode.setStyles( this.json.importActionStyles || {} );
  485. setImportExportAreaNodeWidth();
  486. }
  487. if( name === "exportActionStyles" && this.exportActionNode ){
  488. this.exportActionNode.setStyles( this.json.exportActionStyles || {} );
  489. setImportExportAreaNodeWidth();
  490. }
  491. //if (name=="sequence") this.checkSequenceShow();
  492. },
  493. setDatatableStyles: function(){
  494. if (this.json.titleStyles){
  495. var ths = this.table.getElements("th");
  496. ths.each(function(th){
  497. var opacity = th.getStyle("opacity");
  498. this.setCustomNodeStyles(th, this.json.titleStyles);
  499. if(opacity)th.setStyle("opacity", opacity);
  500. }.bind(this));
  501. }
  502. if (this.json.contentStyles){
  503. var tds = this.table.getElements("td");
  504. tds.each(function(td){
  505. var opacity = td.getStyle("opacity");
  506. this.setCustomNodeStyles(td, this.json.contentStyles);
  507. if(opacity)td.setStyle("opacity", opacity);
  508. }.bind(this));
  509. }
  510. },
  511. setAllStyles: function(){
  512. this.setPropertiesOrStyles("styles");
  513. this.setPropertiesOrStyles("tableStyles");
  514. this.setPropertiesOrStyles("properties");
  515. this.setDatatableStyles();
  516. this.setImpExpTableStyles();
  517. this.reloadMaplist();
  518. },
  519. //checkSequenceShow: function(){
  520. // if (this.json.sequence=="yes"){
  521. // if (!this.sequenceTitleTd || !this.sequenceTd){
  522. // if (this.sequenceTitleTd){
  523. // this.sequenceTitleTd.destroy();
  524. // this.sequenceTitleTd = null;
  525. // }
  526. // if (this.sequenceTd){
  527. // this.sequenceTd.destroy();
  528. // this.sequenceTd = null;
  529. // }
  530. // var trs = this.node.getElements("tr");
  531. // if (trs[0]){
  532. // this.sequenceTitleTd = new Element("th", {"styles": this.css.sequenceTitleTd}).inject(trs[0], "top");
  533. // }
  534. // if (trs[1]){
  535. // this.sequenceTd = new Element("td", {"styles": this.css.sequenceTd, "text": "1"}).inject(trs[1], "top");
  536. // }
  537. // }
  538. // }else{
  539. // if (this.sequenceTitleTd){
  540. // this.sequenceTitleTd.destroy();
  541. // this.sequenceTitleTd = null;
  542. // }
  543. // if (this.sequenceTd){
  544. // this.sequenceTd.destroy();
  545. // this.sequenceTd = null;
  546. // }
  547. // }
  548. //},
  549. getContainerNodes: function(){
  550. return this.node.getElements("td");
  551. },
  552. copyComponentJsonData: function(newNode, pid){
  553. var tds = newNode.getElements("td");
  554. var ths = newNode.getElements("th");
  555. tds.each(function(td, idx){
  556. var newContainerJson = Object.clone(this.containers[idx].json);
  557. newContainerJson.id = this.containers[idx]._getNewId(pid);
  558. this.form.json.moduleList[newContainerJson.id] = newContainerJson;
  559. td.set("id", newContainerJson.id);
  560. }.bind(this));
  561. ths.each(function(th, idx){
  562. var newElementJson = Object.clone(this.elements[idx].json);
  563. newElementJson.id = this.elements[idx]._getNewId(pid);
  564. this.form.json.moduleList[newElementJson.id] = newElementJson;
  565. th.set("id", newElementJson.id);
  566. }.bind(this));
  567. },
  568. loadExistedNodeTh: function (cell, moduleData) {
  569. var thElement = new MWF.FCDatatable$Title(this.form);
  570. thElement.load(moduleData, cell, this);
  571. this.elements.push(thElement);
  572. },
  573. loadExistedNodeTd: function (cell, moduleData) {
  574. var tdContainer = new MWF.FCDatatable$Data(this.form);
  575. tdContainer.load(moduleData, cell, this);
  576. this.containers.push(tdContainer);
  577. },
  578. deleteThWithNode: function (cell) {
  579. var module = cell.retrieve("module");
  580. if (module){
  581. this.elements.erase(module);
  582. module.destroy();
  583. }
  584. },
  585. deleteTdWithNode: function (cell) {
  586. var module = cell.retrieve("module");
  587. if (module){
  588. this.containers.erase(module);
  589. module.destroy();
  590. }
  591. }
  592. });