Form.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
  3. MWF.require("MWF.widget.Common", null, false);
  4. MWF.require("MWF.xAction.org.express.RestActions", null, false);
  5. MWF.xDesktop.requireApp("Selector", "package", null, false);
  6. MWF.xDesktop.requireApp("process.Xform", "Form", null, false);
  7. MWF.require("MWF.widget.O2Identity", null, false);
  8. MWF.xDesktop.requireApp("cms.Xform", "Package", null, false);
  9. MWF.xApplication.cms.Xform.Form = MWF.CMSForm = new Class({
  10. Implements: [Options, Events],
  11. Extends: MWF.APPForm,
  12. options: {
  13. "style": "default",
  14. "readonly": false,
  15. "cssPath": "",
  16. "autoSave": false,
  17. "saveOnClose": false,
  18. "showAttachment": true,
  19. "moduleEvents": ["queryLoad",
  20. "beforeLoad",
  21. "postLoad",
  22. "afterLoad",
  23. "beforeSave",
  24. "postSave",
  25. "afterSave",
  26. "beforeClose",
  27. "beforePublish",
  28. "postPublish",
  29. "afterPublish",
  30. "beforeDelete",
  31. "afterDelete",
  32. "beforeModulesLoad",
  33. "resize",
  34. "afterModulesLoad"]
  35. },
  36. initialize: function (node, data, options) {
  37. this.setOptions(options);
  38. this.container = $(node);
  39. this.container.setStyle("-webkit-user-select", "text");
  40. this.data = data;
  41. this.json = data.json;
  42. this.html = data.html;
  43. this.path = "../x_component_cms_Xform/$Form/";
  44. this.cssPath = this.options.cssPath || "../x_component_cms_Xform/$Form/" + this.options.style + "/css.wcss";
  45. this._loadCss();
  46. this.modules = [];
  47. this.all = {};
  48. this.forms = {};
  49. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  50. },
  51. load: function (callback) {
  52. if (this.app) {
  53. if (this.app.formNode) this.app.formNode.setStyles(this.json.styles);
  54. if (this.app.addEvent) this.app.addEvent("resize", function () {
  55. this.fireEvent("resize");
  56. }.bind(this))
  57. }
  58. //if (!this.businessData.control.allowSave) this.setOptions({"readonly": true});
  59. this.Macro = new MWF.CMSMacro.CMSFormContext(this);
  60. this.container.set("html", this.html);
  61. this.node = this.container.getFirst();
  62. this._loadEvents();
  63. if (this.fireEvent("queryLoad")) {
  64. MWF.xDesktop.requireApp("cms.Xform", "lp." + MWF.language, null, false);
  65. // this.container.setStyles(this.css.container);
  66. this._loadBusinessData();
  67. this.fireEvent("beforeLoad");
  68. if (this.app) if (this.app.fireEvent) this.app.fireEvent("beforeLoad");
  69. this.loadContent(callback)
  70. }
  71. },
  72. loadContent: function (callback) {
  73. this.subformCount = 0;
  74. this.subformLoadedCount = 0;
  75. this.subformLoaded = [this.json.id];
  76. this._loadHtml();
  77. this._loadForm();
  78. this.fireEvent("beforeModulesLoad");
  79. this._loadModules(this.node);
  80. if (!this.options.readonly) {
  81. if (this.options.autoSave) this.autoSave();
  82. this.app.addEvent("queryClose", function () {
  83. if (this.options.saveOnClose && this.businessData.document.docStatus == "draft") this.saveDocument(null, true);
  84. //if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  85. Object.each(this.forms, function (module, id) {
  86. if (module.json.type == "Htmleditor" && module.editor) {
  87. //if(CKEDITOR.currentImageDialog)CKEDITOR.currentImageDialog.destroy();
  88. //CKEDITOR.currentImageDialog = null;
  89. CKEDITOR.remove(module.editor);
  90. delete module.editor
  91. }
  92. });
  93. }.bind(this));
  94. }
  95. this.fireEvent("afterModulesLoad");
  96. this.fireEvent("postLoad");
  97. this.fireEvent("afterLoad");
  98. if (this.app && this.app.fireEvent) {
  99. this.app.fireEvent("afterModulesLoad");
  100. this.app.fireEvent("postLoad");
  101. this.app.fireEvent("afterLoad");
  102. }
  103. // 告诉移动端表单加载完成
  104. if (this.app && this.app.mobile) {
  105. if (callback) callback();
  106. }
  107. },
  108. autoSave: function () {
  109. //this.autoSaveTimerID = window.setInterval(function(){
  110. // this.saveDocument();
  111. //}.bind(this), 300000);
  112. },
  113. _loadBusinessData: function () {
  114. if (!this.businessData) {
  115. this.businessData = {
  116. "data": {}
  117. };
  118. }
  119. },
  120. _loadEvents: function () {
  121. Object.each(this.json.events, function (e, key) {
  122. if (e.code) {
  123. if (this.options.moduleEvents.indexOf(key) != -1) {
  124. this.addEvent(key, function (event) {
  125. return this.Macro.fire(e.code, this, event);
  126. }.bind(this));
  127. } else {
  128. if (key == "load") {
  129. this.addEvent("postLoad", function () {
  130. return this.Macro.fire(e.code, this);
  131. }.bind(this));
  132. } else if (key == "submit") {
  133. this.addEvent("beforePublish", function () {
  134. return this.Macro.fire(e.code, this);
  135. }.bind(this));
  136. } else {
  137. this.node.addEvent(key, function (event) {
  138. return this.Macro.fire(e.code, this, event);
  139. }.bind(this));
  140. }
  141. }
  142. }
  143. }.bind(this));
  144. },
  145. _loadModules: function (dom) {
  146. //var subDom = this.node.getFirst();
  147. //while (subDom){
  148. // if (subDom.get("MWFtype")){
  149. // var json = this._getDomjson(subDom);
  150. // var module = this._loadModule(json, subDom);
  151. // this.modules.push(module);
  152. // }
  153. // subDom = subDom.getNext();
  154. //}
  155. var moduleNodes = this._getModuleNodes(dom);
  156. moduleNodes.each(function (node) {
  157. var json = this._getDomjson(node);
  158. if (!this.options.showAttachment && json.type == "Attachment") {
  159. return;
  160. }
  161. //移动端去掉操作栏
  162. if (this.app.mobile && json.type === "Actionbar") {
  163. return;
  164. }
  165. var module = this._loadModule(json, node);
  166. this.modules.push(module);
  167. }.bind(this));
  168. },
  169. _loadModule: function (json, node, beforeLoad) {
  170. if (!json) return;
  171. if (!MWF["CMS" + json.type]) {
  172. MWF.xDesktop.requireApp("cms.Xform", json.type, null, false);
  173. }
  174. var module = new MWF["CMS" + json.type](node, json, this);
  175. if (beforeLoad) beforeLoad.apply(module);
  176. if (!this.all[json.id]) this.all[json.id] = module;
  177. if (module.field) {
  178. if (!this.forms[json.id]) this.forms[json.id] = module;
  179. }
  180. module.readonly = this.options.readonly;
  181. module.load();
  182. return module;
  183. },
  184. //getData: function(){
  185. // var data= Object.clone(this.businessData.data);
  186. // Object.each(this.forms, function(module, id){
  187. // debugger;
  188. // if (module.json.section=="yes"){
  189. // data[id] = this.getSectionData(module, data[id]);
  190. // }else{
  191. // data[id] = module.getData();
  192. // }
  193. // }.bind(this));
  194. //
  195. // this.businessData.data = data;
  196. // this.Macro.environment.setData(this.businessData.data);
  197. // return data;
  198. //},
  199. trim: function (array) {
  200. var arr = [];
  201. array.each(function (v) {
  202. if (v) arr.push(v);
  203. });
  204. return arr;
  205. },
  206. transportPermissionData: function (array, t) {
  207. var result = [];
  208. array.each(function (data) {
  209. var dn = typeOf(data) === "string" ? data : data.distinguishedName;
  210. if (dn) {
  211. var flag = dn.substr(dn.length - 1, 1);
  212. var type;
  213. switch (flag.toLowerCase()) {
  214. case "i":
  215. type = "人员"; //"身份";
  216. break;
  217. case "p":
  218. type = "人员";
  219. break;
  220. case "u":
  221. type = "组织";
  222. break;
  223. case "g":
  224. type = "群组";
  225. break;
  226. case "r":
  227. type = "角色";
  228. break;
  229. default:
  230. type = "";
  231. //result.push( data );
  232. }
  233. if (type) {
  234. var name;
  235. if( typeOf(data) === "object" && data.name ){
  236. name = data.name;
  237. }else if( MWF.name && MWF.name.cn ){
  238. name = MWF.name.cn( dn );
  239. }else{
  240. name = dn.split("@")[0];
  241. }
  242. result.push({
  243. permission: t == "author" ? "作者" : "阅读",
  244. permissionObjectType: type,
  245. permissionObjectName: name,
  246. permissionObjectCode: dn
  247. })
  248. }
  249. }
  250. });
  251. return result.length > 0 ? result : null;
  252. },
  253. getSpecialData: function () {
  254. var data = this.businessData.data;
  255. var readers = [];
  256. var authors = [];
  257. var pictures = [];
  258. var cloudPictures = [];
  259. var summary = "";
  260. Object.each(this.forms, function (module, id) {
  261. if (module.json.type == "Readerfield" || module.json.type == "Reader") {
  262. if (module.json.section == "yes") {
  263. readers = readers.concat(this.getSectionData(module, data[id]));
  264. } else {
  265. readers = readers.concat(module.getData());
  266. }
  267. }
  268. if (module.json.type == "Authorfield" || module.json.type == "Author") {
  269. if (module.json.section == "yes") {
  270. authors = authors.concat(this.getSectionData(module, data[id]));
  271. } else {
  272. authors = authors.concat(module.getData());
  273. }
  274. }
  275. if (module.json.type == "ImageClipper") {
  276. var d = module.getData();
  277. if (d) pictures.push(d);
  278. }
  279. if (module.json.type == "Htmleditor") {
  280. var text = module.getText();
  281. summary = text.substr(0, 80);
  282. cloudPictures = cloudPictures.concat(module.getImageIds());
  283. }
  284. });
  285. if (data.processOwnerList && typeOf(data.processOwnerList) == "array") { //如果是流程中发布的
  286. var owner = { personValue: [] };
  287. data.processOwnerList.each(function (p) {
  288. owner.personValue.push({
  289. name: p,
  290. type: "person"
  291. });
  292. });
  293. readers = readers.concat(owner);
  294. }
  295. return {
  296. readers: this.transportPermissionData(readers, "reader"),
  297. authors: this.transportPermissionData(authors, "author"),
  298. pictures: pictures,
  299. summary: summary,
  300. cloudPictures: cloudPictures
  301. };
  302. },
  303. getDocumentData: function (formData) {
  304. var data = Object.clone(this.businessData.document);
  305. if (formData.subject) {
  306. data.title = formData.subject;
  307. data.subject = formData.subject;
  308. this.businessData.document.title = formData.subject;
  309. this.businessData.document.subject = formData.subject;
  310. }
  311. data.isNewDocument = false;
  312. return data;
  313. },
  314. saveDocument: function (callback, sync) {
  315. this.fireEvent("beforeSave");
  316. if (this.businessData.document.docStatus == "published") {
  317. if (!this.formValidation("publish")) {
  318. this.app.content.unmask();
  319. //if (callback) callback();
  320. return false;
  321. }
  322. }
  323. if (!this.formSaveValidation()) {
  324. this.app.content.unmask();
  325. if (callback) callback();
  326. return false;
  327. }
  328. var data = this.getData();
  329. var specialData = this.getSpecialData();
  330. var documentData = this.getDocumentData(data);
  331. documentData.readerList = specialData.readers;
  332. documentData.authorList = specialData.authors;
  333. documentData.pictureList = specialData.pictures;
  334. documentData.summary = specialData.summary;
  335. documentData.cloudPictures = specialData.cloudPictures;
  336. documentData.docData = data;
  337. delete documentData.attachmentList;
  338. this.fireEvent("postSave", [documentData]);
  339. if (this.officeList) {
  340. this.officeList.each(function (module) {
  341. module.save(history);
  342. });
  343. }
  344. this.documentAction.saveDocument(documentData, function () {
  345. //this.documentAction.saveData(function(json){
  346. this.app.notice(MWF.xApplication.cms.Xform.LP.dataSaved, "success");
  347. this.businessData.data.isNew = false;
  348. this.fireEvent("afterSave");
  349. if (callback) callback();
  350. //}.bind(this), null, this.businessData.document.id, data, !sync );
  351. }.bind(this), null, !sync);
  352. },
  353. closeDocument: function () {
  354. this.fireEvent("beforeClose");
  355. if (this.app) {
  356. this.app.close();
  357. }
  358. },
  359. printDocument: function (form) {
  360. var form = form;
  361. if (!form) {
  362. form = this.json.id;
  363. if (this.json.printForm && this.json.printForm !== "none") form = this.json.printForm;
  364. }
  365. window.open(o2.filterUrl("../x_desktop/printcmsdoc.html?documentid=" + this.businessData.document.id + "&form=" + form));
  366. },
  367. formValidation: function (status) {
  368. if (this.options.readonly) return true;
  369. var flag = true;
  370. //flag = this.validation();
  371. Object.each(this.forms, function (field, key) {
  372. field.validationMode();
  373. if (!field.validation(status)) {
  374. flag = false;
  375. }
  376. }.bind(this));
  377. return flag;
  378. },
  379. formSaveValidation: function () {
  380. if (!this.json.validationSave) return true;
  381. if (!this.json.validationSave.code) return true;
  382. var flag = this.Macro.exec(this.json.validationSave.code, this);
  383. if (!flag) flag = MWF.xApplication.cms.Xform.LP.notValidation;
  384. if (typeOf(flag) === "string") {
  385. if (flag !== "true") {
  386. this.app.notice(flag, "error");
  387. return false;
  388. }
  389. } else if (flag.toString() != "true") {
  390. return false;
  391. }
  392. return true;
  393. },
  394. formPublishValidation: function () {
  395. if (!this.json.validationPublish) return true;
  396. if (!this.json.validationPublish.code) return true;
  397. var flag = this.Macro.exec(this.json.validationPublish.code, this);
  398. if (!flag) flag = MWF.xApplication.cms.Xform.LP.notValidation;
  399. if (typeOf(flag) === "string") {
  400. if (flag !== "true") {
  401. this.app.notice(flag, "error");
  402. return false;
  403. }
  404. } else if (flag.toString() != "true") {
  405. return false;
  406. }
  407. return true;
  408. },
  409. publishDocument: function (callback) {
  410. this.fireEvent("beforePublish");
  411. this.app.content.mask({
  412. "destroyOnHide": true,
  413. "style": this.app.css.maskNode
  414. });
  415. if (!this.formValidation("publish")) {
  416. this.app.content.unmask();
  417. //if (callback) callback();
  418. return false;
  419. }
  420. if (!this.formPublishValidation()) {
  421. this.app.content.unmask();
  422. if (callback) callback();
  423. return false;
  424. }
  425. var data = this.getData();
  426. var specialData = this.getSpecialData();
  427. //this.documentAction.saveData(function(json){
  428. var documentData = this.getDocumentData(data);
  429. documentData.readerList = specialData.readers;
  430. documentData.authorList = specialData.authors;
  431. documentData.pictureList = specialData.pictures;
  432. documentData.summary = specialData.summary;
  433. documentData.cloudPictures = specialData.cloudPictures;
  434. documentData.docData = data;
  435. delete documentData.attachmentList;
  436. //this.documentAction.saveDocument(documentData, function(){
  437. this.fireEvent("postPublish", [documentData]);
  438. if (this.app) if (this.app.fireEvent) this.app.fireEvent("postPublish",[documentData]);
  439. if (this.officeList) {
  440. this.officeList.each(function (module) {
  441. module.save(history);
  442. });
  443. }
  444. this.documentAction.publishDocumentComplex(documentData, function (json) {
  445. this.businessData.data.isNew = false;
  446. this.fireEvent("afterPublish", [this, json.data]);
  447. if (this.app) if (this.app.fireEvent) this.app.fireEvent("afterPublish",[this, json.data]);
  448. if (callback) callback();
  449. if (this.app.mobile) {
  450. this.app.content.unmask();
  451. console.log('这里是移动端');
  452. } else {
  453. if (this.businessData.document.title) {
  454. this.app.notice(MWF.xApplication.cms.Xform.LP.documentPublished + ": “" + this.businessData.document.title + "”", "success");
  455. } else {
  456. this.app.notice(MWF.xApplication.cms.Xform.LP.documentPublished, "success");
  457. }
  458. this.options.saveOnClose = false;
  459. }
  460. this.app.close();
  461. }.bind(this));
  462. //}.bind(this))
  463. //}.bind(this), null, this.businessData.document.id, data);
  464. },
  465. //publishDocument_bak: function(callback){
  466. // this.fireEvent("beforePublish");
  467. // this.app.content.mask({
  468. // "destroyOnHide": true,
  469. // "style": this.app.css.maskNode
  470. // });
  471. // if (!this.formValidation("publish")){
  472. // this.app.content.unmask();
  473. // if (callback) callback();
  474. // return false;
  475. // }
  476. //
  477. // var data = this.getData();
  478. // var specialData = this.getSpecialData();
  479. // this.documentAction.saveData(function(json){
  480. // this.businessData.data.isNew = false;
  481. // var documentData = this.getDocumentData(data);
  482. // documentData.permissionList = specialData.readers;
  483. // documentData.pictureList = specialData.pictures;
  484. // documentData.summary = specialData.summary;
  485. // delete documentData.attachmentList;
  486. // this.documentAction.saveDocument(documentData, function(){
  487. // this.documentAction.publishDocument(documentData, function(json){
  488. // this.fireEvent("afterPublish");
  489. // this.fireEvent("postPublish");
  490. // if (callback) callback();
  491. // this.app.notice(MWF.xApplication.cms.Xform.LP.documentPublished+": “"+this.businessData.document.title+"”", "success");
  492. // this.options.saveOnClose = false;
  493. // this.app.close();
  494. // //this.close();
  495. // }.bind(this) );
  496. // }.bind(this))
  497. // }.bind(this), null, this.businessData.document.id, data);
  498. //},
  499. deleteDocumentForMobile: function () {
  500. if (this.app.mobile) {
  501. this.app.content.mask({
  502. "style": {
  503. "background-color": "#999",
  504. "opacity": 0.6
  505. }
  506. });
  507. this.fireEvent("beforeDelete");
  508. if (this.app && this.app.fireEvent) this.app.fireEvent("beforeDelete");
  509. this.documentAction.removeDocument(this.businessData.document.id, function (json) {
  510. this.fireEvent("afterDelete");
  511. if (this.app && this.app.fireEvent) this.app.fireEvent("afterDelete");
  512. this.app.notice(MWF.xApplication.cms.Xform.LP.documentDelete + ": “" + this.businessData.document.title + "”", "success");
  513. this.options.autoSave = false;
  514. this.options.saveOnClose = false;
  515. this.fireEvent("postDelete");
  516. this.app.close();
  517. }.bind(this));
  518. }
  519. },
  520. deleteDocument: function () {
  521. var _self = this;
  522. var p = MWF.getCenterPosition(this.app.content, 380, 150);
  523. var event = {
  524. "event": {
  525. "x": p.x,
  526. "y": p.y - 200,
  527. "clientX": p.x,
  528. "clientY": p.y - 200
  529. }
  530. };
  531. this.app.confirm("infor", event, MWF.xApplication.cms.Xform.LP.deleteDocumentTitle, MWF.xApplication.cms.Xform.LP.deleteDocumentText, 380, 120, function () {
  532. _self.app.content.mask({
  533. "style": {
  534. "background-color": "#999",
  535. "opacity": 0.6
  536. }
  537. });
  538. _self.fireEvent("beforeDelete");
  539. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("beforeDelete");
  540. _self.documentAction.removeDocument(_self.businessData.document.id, function (json) {
  541. _self.fireEvent("afterDelete");
  542. if (_self.app && _self.app.fireEvent) _self.app.fireEvent("afterDelete");
  543. _self.app.notice(MWF.xApplication.cms.Xform.LP.documentDelete + ": “" + _self.businessData.document.title + "”", "success");
  544. _self.options.autoSave = false;
  545. _self.options.saveOnClose = false;
  546. _self.fireEvent("postDelete");
  547. _self.app.close();
  548. this.close();
  549. }.bind(this));
  550. //this.close();
  551. }, function () {
  552. this.close();
  553. });
  554. },
  555. editDocument: function () {
  556. if (this.app.inBrowser) {
  557. this.modules.each(function (module) {
  558. MWF.release(module);
  559. });
  560. //MWF.release(this);
  561. this.app.node.destroy();
  562. this.app.options.readonly = false;
  563. this.app.loadApplication();
  564. } else {
  565. var options = { "documentId": this.businessData.document.id, "readonly": false }; //this.explorer.app.options.application.allowControl};
  566. if (this.app.options.formEditId) options.formEditId = this.app.options.formEditId;
  567. this.app.desktop.openApplication(null, "cms.Document", options);
  568. this.app.close();
  569. }
  570. },
  571. //2019-11-29 移动端 开启编辑模式
  572. editDocumentForMobile: function () {
  573. if (this.app.mobile) {
  574. this.app.options.readonly = false;
  575. this.app.loadDocument(this.app.options);
  576. }
  577. },
  578. setPopularDocument: function () {
  579. this.app.setPopularDocument();
  580. },
  581. printWork: function (app, form) {
  582. var application = app || this.businessData.work.application;
  583. var form = form;
  584. if (!form) {
  585. form = this.json.id;
  586. if (this.json.printForm) form = this.json.printForm;
  587. }
  588. window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + this.businessData.work.application + "&form=" + form));
  589. },
  590. openWindow: function (form, app) {
  591. var form = form;
  592. if (!form) {
  593. form = this.json.id;
  594. }
  595. if (this.businessData.document) {
  596. //var application = app;
  597. //window.open("../x_desktop/printWork.html?workCompletedId="+this.businessData.workCompleted.id+"&app="+application+"&form="+form);
  598. }
  599. },
  600. uploadedAttachment: function (site, id) {
  601. this.documentAction.getAttachment(id, this.businessData.document.id, function (json) {
  602. var att = this.all[site];
  603. if (att) {
  604. if (json.data) att.attachmentController.addAttachment(json.data);
  605. att.attachmentController.checkActions();
  606. att.fireEvent("upload", [json.data]);
  607. }
  608. }.bind(this));
  609. },
  610. replacedAttachment: function (site, id) {
  611. this.documentAction.getAttachment(id, this.businessData.document.id, function (json) {
  612. var att = this.all[site];
  613. if (att) {
  614. var attachmentController = att.attachmentController;
  615. var attachment = null;
  616. for (var i = 0; i < attachmentController.attachments.length; i++) {
  617. if (attachmentController.attachments[i].data.id === id) {
  618. attachment = attachmentController.attachments[i];
  619. break;
  620. }
  621. }
  622. attachment.data = json.data;
  623. attachment.reload();
  624. attachmentController.checkActions();
  625. }
  626. }.bind(this))
  627. }
  628. });