33d071d63b7e033148cc91b1077d2b062d0d6811.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. BemsWebApplication.FloorPlan = function (params, viewInfo) {
  2. "use strict";
  3. var FloorInPopUpForSearch = ko.observableArray(),
  4. FloorInPopUp = ko.observableArray();
  5. var imagefileUrl = ko.observable(), uploadedFileInfo = {}, dropZone = null;
  6. var deferredForSearch = new $.Deferred();
  7. var floorplan = ko.observableArray();
  8. var isImageUpload = ko.observableArray();
  9. var enableDataBoxInPopup = ko.observable(false);
  10. var visibleEditButton = ko.observable(false); // 수정 버튼 활성화 여부 플래그
  11. var hasnotModificationPermission = ko.observable(true); // 수정버튼 비활성화 플래그
  12. var visibleDeleteButton = ko.observable(false); // 삭제버튼 활성화 플래그
  13. var visibleCancelButton = ko.observable(false); // 취소버튼 활성화 플래그
  14. var isEditModeInPopup = ko.observable(); // 저장버튼 활성화 플래그
  15. var isNotModifyMode = ko.observable(false); // 저장버튼 비활성화 플래그
  16. var backupDataViewModel = new BemsWebApplication.BemsFloorPlanViewModel();
  17. var backup_data;
  18. var floorAll;
  19. var endpointSelector = "";
  20. if (BemsWebApplication.config.mode == "production") {
  21. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  22. } else {
  23. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  24. }
  25. var floorplanPopupToolbarItems = [
  26. { location: 'before', text: '평면도 등록' },
  27. { location: 'after', widget: 'button', options: { text: $G('edit'), icon: 'edit', visible: visibleEditButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonEdit } },
  28. { location: 'after', widget: 'button', options: { text: $G('delete'), type: 'danger', icon: 'remove', visible: visibleDeleteButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonDelete } },
  29. { location: 'after', widget: 'button', options: { text: $G('cancel'), icon: 'cancel', visible: visibleCancelButton, clickAction: handlePopupButtonCancel } },
  30. { location: 'after', widget: 'button', options: { text: $G('save'), icon: 'save', visible: isEditModeInPopup, disabled: isNotModifyMode, clickAction: handlePopupButtonSave } },
  31. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: PopupButtonClose } }
  32. ];
  33. function setupDropZone(dataViewModel) {
  34. var timer = null;
  35. viewModel.isEditModeInPopup.subscribe(function (value) {
  36. if (value) {
  37. if (timer) {
  38. clearInterval(timer);
  39. }
  40. timer = setInterval(function () {
  41. if ($('#FloorPlanDropZone').length) {
  42. if (_.isNull(dropZone)) {
  43. dropZone = BWA.DropZone.create({
  44. id: '#FloorPlanDropZone',
  45. categoryId: $Code.FileCategory.FLOOR,
  46. uploadedFileInfo: uploadedFileInfo,
  47. handleRemoveBeforePromise: function () {
  48. var keys = BWA.db.extractKeysObject('BemsFloorPlan', dataViewModel);
  49. utils.toast.show($G('successDatabaseInsertionMsg'));
  50. PopupButtonClose();
  51. return BWA.db.BemsFloorPlan.update(keys, { ImageFileId: null });
  52. },
  53. handleSuccess: function (fileInfo) {
  54. if (uploadedFileInfo.FileId) {
  55. dataViewModel.ImageFileId(uploadedFileInfo.FileId);
  56. var keys = BWA.db.extractKeysObject('BemsFloorPlan', dataViewModel);
  57. var insert_data = {
  58. SiteId: BWA.UserInfo.SiteId(),
  59. FloorId: backup_data.FloorId,
  60. Name: dataViewModel.Name(),
  61. ImageFileId: uploadedFileInfo.FileId
  62. };
  63. if (keys.Name != null) {
  64. //update(insert_data, tmp_data);
  65. BemsWebApplication.db['BemsFloorPlan'].remove(backup_data).done(function () {
  66. var store = new DevExpress.data.ODataStore({
  67. url: endpointSelector + "/BemsFloorPlan",
  68. key: ["SiteId", "Name"],
  69. keyType: {
  70. SiteId: "Int32", Name: "String"
  71. }
  72. });
  73. store.insert(insert_data).done(function (key, result) {
  74. utils.toast.show($G('successDatabaseInsertionMsg'));
  75. PopupButtonClose();
  76. })
  77. .fail(function (error) {
  78. utils.toast.show(error);
  79. });
  80. viewModel.refreshList();
  81. setTimeout(function () {
  82. GetGridData();
  83. }, 500);
  84. });
  85. }
  86. }
  87. },
  88. handleRemovedFile: function () {
  89. dataViewModel.ImageFileId(null);
  90. }
  91. });
  92. }
  93. }
  94. }, 100);
  95. }
  96. else {
  97. if (timer) {
  98. clearInterval(timer);
  99. timer = null;
  100. }
  101. dropZone = null;
  102. }
  103. });
  104. }
  105. function update(postData, backupData) {
  106. var floorplanDataModel = new BemsWebApplication.BemsFloorPlanViewModel();
  107. if (FloorPlanDropZone.dropzone.files.length == 0) {
  108. utils.toast.show("첨부 파일을 업로드하여 주십시오.", 'error');
  109. return;
  110. }
  111. else if (_.isNull(dropZone) === false
  112. && (dropZone.files[0].type == 'image/jpeg'
  113. || dropZone.files[0].type == 'image/jpg'
  114. || dropZone.files[0].type == 'image/gif'
  115. || dropZone.files[0].type == 'image/png'
  116. || dropZone.files[0].type == 'image/bmp')) {
  117. dropZone.processQueue();
  118. }
  119. else {
  120. utils.toast.show("그림파일(jpeg, jpg, gif, png, bmp)만 등록 가능합니다.", 'error');
  121. return;
  122. }
  123. backup_data = {
  124. SiteId: BWA.UserInfo.SiteId(),
  125. FloorId: backupData.FloorId,
  126. Name: backupData.Name,
  127. ImageFileId: backupData.ImageFileId
  128. };
  129. var temp = {
  130. SiteId: BWA.UserInfo.SiteId(),
  131. FileId: backupData.ImageFileId
  132. }
  133. if (backupData.ImageFileId != null) {
  134. BWA.db.CmFile.byKey(temp).done(function (data) {
  135. dropZone.removeFile(data);
  136. });
  137. }
  138. dropZone.processQueue();
  139. }
  140. function insert(postData) {
  141. if (postData.Name == null || postData.FloorId == null) {
  142. utils.toast.show("층 정보가 입력되지 않았습니다.", 'error');
  143. return;
  144. }
  145. else if (FloorPlanDropZone.dropzone.files.length == 0) {
  146. utils.toast.show("첨부 파일을 업로드하여 주십시오.", 'error');
  147. return;
  148. }
  149. else if (_.isNull(dropZone) === false
  150. && viewModel.dataModel.ImageFileId() == null
  151. && (dropZone.files[0].type == 'image/jpeg'
  152. || dropZone.files[0].type == 'image/jpg'
  153. || dropZone.files[0].type == 'image/gif'
  154. || dropZone.files[0].type == 'image/png'
  155. || dropZone.files[0].type == 'image/bmp')) {
  156. dropZone.processQueue();
  157. }
  158. else {
  159. utils.toast.show("그림파일(jpeg, jpg, gif, png, bmp)만 등록 가능합니다.", 'error');
  160. return;
  161. }
  162. backup_data = {
  163. SiteId: BWA.UserInfo.SiteId(),
  164. FloorId: viewModel.dataModel.FloorId(),
  165. Name: viewModel.dataModel.Name(),
  166. ImageFileId: null
  167. };
  168. var store = new DevExpress.data.ODataStore({
  169. url: endpointSelector + "/BemsFloorPlan",
  170. key: ["SiteId", "Name"],
  171. keyType: {
  172. SiteId: "Int32", Name: "String"
  173. }
  174. });
  175. store.insert(postData).done(function (key, result) {
  176. utils.toast.show($G('successDatabaseInsertionMsg'));
  177. PopupButtonClose();
  178. })
  179. .fail(function (error) {
  180. utils.toast.show(error);
  181. });
  182. }
  183. //저장버튼
  184. function handlePopupButtonSave() {
  185. var dataViewModel = viewModel.dataModel;
  186. var postViewModel = new BemsWebApplication.BemsFloorPlanViewModel();
  187. postViewModel.SiteId(dataViewModel.SiteId());
  188. postViewModel.FloorId(dataViewModel.FloorId());
  189. postViewModel.Name(dataViewModel.Name());
  190. postViewModel.ImageFileId(dataViewModel.ImageFileId());
  191. var postData = postViewModel.toJS();
  192. if (viewModel.isNewInPopup())
  193. insert(postData);
  194. else
  195. update(postData, backupDataViewModel);
  196. //예외 처리(ImageFileId가 기존과 수정버전 모두 null인 경우)
  197. if (dataViewModel.ImageFileId() == null && backupDataViewModel.ImageFileId == null) {
  198. utils.toast.show($G('successDatabaseInsertionMsg'));
  199. PopupButtonClose();
  200. }
  201. //DB 저장에 시간이 걸리기때문에 딜레이 후 데이터 로드
  202. setTimeout(function () {
  203. UpdateSelectBoxInPopUp();
  204. GetGridData();
  205. }, 500);
  206. }
  207. function getBackupDataViewModel(model) {
  208. var object = {};
  209. $.each(model, function (name, value) {
  210. if (ko.isObservable(value)) {
  211. object[name] = value();
  212. }
  213. });
  214. return object;
  215. }
  216. function restoreDataViewModelFromBackup(model, backupModel) {
  217. $.each(backupModel, function (name, value) {
  218. model[name](value);
  219. });
  220. }
  221. // 수정버튼 클릭
  222. function handlePopupButtonEdit() {
  223. viewModel.isNewInPopup(false);
  224. viewModel.visibleEditButton(false);
  225. viewModel.visibleDeleteButton(false);
  226. viewModel.visibleCancelButton(true);
  227. viewModel.isEditModeInPopup(true);
  228. viewModel.isNotModifyMode(false);
  229. viewModel.enableDataBoxInPopup(false);
  230. viewModel.isImageUpload(true);
  231. backupDataViewModel = getBackupDataViewModel(viewModel.dataModel);
  232. dropZone = null;
  233. }
  234. //////
  235. // 삭제버튼 클릭
  236. function handlePopupButtonDelete() {
  237. DevExpress.ui.dialog.confirm($G('deleteConfirmMsg'), "삭제").then(function (result) {
  238. if (result) {
  239. var temp = {
  240. SiteId: BWA.UserInfo.SiteId(),
  241. FileId: viewModel.dataModel.ImageFileId()
  242. }
  243. if (viewModel.dataModel.ImageFileId() != null) {
  244. BWA.db.CmFile.byKey(temp).done(function (data) {
  245. if ($('#FloorPlanDropZone1').length) {
  246. if (_.isNull(dropZone)) {
  247. dropZone = BWA.DropZone.create({
  248. id: '#FloorPlanDropZone1',
  249. categoryId: $Code.FileCategory.FLOOR
  250. });
  251. dropZone.removeFile(data);
  252. dropZone = null;
  253. }
  254. }
  255. });
  256. }
  257. var selectedId = {};
  258. selectedId.SiteId = viewModel.dataModel.SiteId();
  259. selectedId.FloorId = viewModel.dataModel.FloorId();
  260. selectedId.Name = viewModel.dataModel.Name();
  261. selectedId.ImageFileId = viewModel.dataModel.ImageFileId();
  262. BemsWebApplication.db['BemsFloorPlan'].remove(selectedId).done(function () {
  263. viewModel.refreshList();
  264. setTimeout(function () {
  265. GetGridData();
  266. UpdateSelectBoxInPopUp();
  267. }, 500);
  268. PopupButtonClose();
  269. utils.toast.show('데이터베이스 항목 삭제 작업이 성공하였습니다.');
  270. }).fail(function () {
  271. utils.toast.show('데이터베이스 항목 삭제 작업이 실패하였습니다.', 'error');
  272. });
  273. //층별 관제점도 같이 지워준다
  274. var dataSource = new DevExpress.data.DataSource({
  275. store: {
  276. type: "odata",
  277. url: endpointSelector + "/BemsFloorStatus",
  278. },
  279. requireTotalCount: true
  280. });
  281. dataSource.filter([
  282. ["SiteId", "=", BWA.UserInfo.SiteId()],
  283. "and",
  284. ["FloorId", "=", viewModel.dataModel.FloorId()]
  285. ]);
  286. dataSource.load()
  287. .done(function (result) {
  288. for (var i = 0; i < result.length; i++) {
  289. var num = 0;
  290. var removeData = {
  291. SiteId: result[i].SiteId,
  292. FloorId: result[i].FloorId,
  293. FloorName: result[i].FloorName,
  294. ImageFileId: result[i].ImageFileId,
  295. Xvalue: result[i].Xvalue,
  296. Yvalue: result[i].Yvalue,
  297. ZoneId: result[i].ZoneId,
  298. FacilityTypeId: result[i].FacilityTypeId,
  299. FacilityCode: result[i].FacilityCode,
  300. PropertyId: result[i].PropertyId,
  301. FacilityName: result[i].FacilityName,
  302. };
  303. BemsWebApplication.db['BemsFloorStatus'].remove(removeData);
  304. }
  305. })
  306. }
  307. });
  308. }
  309. // 취소버튼
  310. function handlePopupButtonCancel() {
  311. viewModel.visibleEditButton(true);
  312. viewModel.visibleDeleteButton(true);
  313. viewModel.visibleCancelButton(false);
  314. viewModel.isEditModeInPopup(false);
  315. viewModel.isNotModifyMode(true);
  316. viewModel.isImageUpload(false);
  317. restoreDataViewModelFromBackup(viewModel.dataModel, backupDataViewModel);
  318. }
  319. // 닫기버튼
  320. function PopupButtonClose() {
  321. viewModel.isNewInPopup(false);
  322. viewModel.visibleEditButton(false);
  323. viewModel.visibleDeleteButton(false);
  324. viewModel.visibleCancelButton(false);
  325. viewModel.isEditModeInPopup(false);
  326. viewModel.isNotModifyMode(false);
  327. viewModel.dataModel.ImageFileId(null);
  328. viewModel.imagefileUrl(undefined);
  329. viewModel.popupVisible(false);
  330. dropZone = null;
  331. }
  332. function GetGridData() {
  333. var gridData = new Array();
  334. var dataSource = new DevExpress.data.DataSource({
  335. store: {
  336. type: "odata",
  337. url: endpointSelector + "/BemsFloorPlan",
  338. },
  339. requireTotalCount: true,
  340. pageSize: 9999,
  341. });
  342. dataSource.filter([
  343. ["SiteId", "=", BWA.UserInfo.SiteId()]
  344. ]);
  345. dataSource.sort({ getter: "Name", asc: true });
  346. dataSource.load()
  347. .done(function (result) {
  348. for (var i = 0; i < result.length; i++) {
  349. gridData[i] = {
  350. "SiteId": 0,
  351. "FloorId": 0,
  352. "Name": "",
  353. "ImageFileId": null
  354. };
  355. gridData[i].SiteId = result[i].SiteId;
  356. gridData[i].FloorId = result[i].FloorId;
  357. gridData[i].Name = result[i].Name;
  358. gridData[i].ImageFileId = result[i].ImageFileId;
  359. }
  360. $("#gridContainer").dxDataGrid("instance").option('dataSource', gridData);
  361. //$("#gridContainer").dxDataGrid("instance").refresh();
  362. })
  363. .fail(function (error) {
  364. utils.toast.show(error);
  365. });
  366. }
  367. function UpdateSelectBoxInPopUp() {
  368. var dataSource_GridData = new DevExpress.data.DataSource({
  369. store: {
  370. type: "odata",
  371. url: endpointSelector + "/BemsFloorPlan",
  372. },
  373. requireTotalCount: true,
  374. pageSize: 100
  375. });
  376. dataSource_GridData.filter([
  377. ["SiteId", "=", BWA.UserInfo.SiteId()]
  378. ]);
  379. dataSource_GridData.load()
  380. .done(function (gridData) {
  381. var tmp = new Array(floorAll.length);
  382. for (var i = 0; i < floorAll.length; i++) {
  383. tmp[i] = 0;
  384. for (var j = 0; j < gridData.length; j++) {
  385. if (floorAll[i].FloorId == gridData[j].FloorId) {
  386. tmp[i] = 1;
  387. break;
  388. }
  389. }
  390. }
  391. var dbfloor = new Array();
  392. var idx = 0;
  393. for (var i = 0; i < floorAll.length; i++) {
  394. if (tmp[i] == 0)
  395. dbfloor.push(floorAll[i]);
  396. }
  397. FloorInPopUp(dbfloor);
  398. FloorInPopUpForSearch($SearchView.createArrayOfSelectBox('FloorId', FloorInPopUp));
  399. });
  400. }
  401. function getImageSize(width, height) {
  402. var viewIndoor = $('#viewIndoor');
  403. var maxWidth = parseFloat(viewIndoor.css('width')), maxHeight = parseFloat(viewIndoor.css('height'));
  404. var widthRatio = width / maxWidth;
  405. var heightRatio = height / maxHeight;
  406. var maxRatio = max(widthRatio, heightRatio);
  407. if (maxRatio > 1) {
  408. return { width: width / maxRatio, height: height / maxRatio }
  409. }
  410. return { width: width, height: height }
  411. }
  412. function max(x, y) {
  413. if (x > y) return x;
  414. return y;
  415. }
  416. function loadImage(imageUrl) {
  417. $('#imageContext').find('text').remove();
  418. //var imageUrl = url;//'/Images/Blueprint/' + viewModel.dataModel.FloorId() + '.jpg';
  419. var image = document.getElementById("image");
  420. var newImage = new Image();
  421. newImage.onload = function () {
  422. var imageSize = getImageSize(newImage.width, newImage.height);
  423. $('#imageContext').css('width', imageSize.width).css('height', imageSize.height);
  424. $('#image').attr('width', imageSize.width).attr('height', imageSize.height); // 2016 05 30 추가, IE 문제해결, 종화
  425. }
  426. newImage.src = imageUrl;
  427. image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageUrl);
  428. }
  429. var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'BemsFloorPlan', {
  430. dataSourceOptions: {
  431. select: [
  432. 'SiteId',
  433. 'FloorId',
  434. 'Name',
  435. 'ImageFileId'
  436. ],
  437. filter: [
  438. ['SiteId', '=', BWA.UserInfo.SiteId()]
  439. ],
  440. extendOptions: {
  441. forceOriginalField: true
  442. },
  443. },
  444. columns: [
  445. { dataField: 'SiteId', caption: '번호', width: '30%', alignment: 'center' },
  446. { dataField: 'Name', caption: '층 명칭', width: '70%', alignment: 'center' },
  447. { dataField: 'FloorId', caption: '', width: '30%', alignment: 'center', visible: false },
  448. { dataField: 'ImageFileId', caption: '', width: '70%', alignment: 'center', visible: false }
  449. ],
  450. NoSearchView: true, // 2019.07.25 kgpark 검색버튼 삭제
  451. paging: {
  452. pageSize: 20,
  453. enabled: true
  454. },
  455. pager: {
  456. },
  457. handlePopupShowing: function (isNewInPopup, dataViewModel) {
  458. // 저장 버튼
  459. if (isNewInPopup() == false) {
  460. imagefileUrl(undefined);
  461. dropZone = null; // 신규등록인 경우
  462. } else {
  463. dataViewModel.Name('');
  464. dataViewModel.ImageFileId(null);
  465. viewModel.imagefileUrl(undefined);
  466. viewModel.isNewInPopup(true);
  467. viewModel.isEditModeInPopup(true);
  468. imagefileUrl('');
  469. loadImage(imagefileUrl());
  470. }
  471. // 탭으로 표시하지 않음
  472. isImageUpload(false);
  473. enableDataBoxInPopup(true);
  474. // tabsVisible(isNewInPopup() == false);
  475. $("#Floor_Info").dxSelectBox({
  476. onValueChanged: function () {
  477. if (isNewInPopup() == false) {
  478. // 이전 이미지 잔상 문제로 인한 방어코드
  479. // 이미지 경로 강제 초기화
  480. imagefileUrl(undefined);
  481. }
  482. isImageUpload(true);
  483. enableDataBoxInPopup(true);
  484. var floor = $("#Floor_Info").dxSelectBox('instance').option('value');
  485. var dataSource = new DevExpress.data.DataSource({
  486. store: {
  487. type: "odata",
  488. url: endpointSelector + "/CmFloor",
  489. },
  490. requireTotalCount: true
  491. });
  492. dataSource.filter([
  493. ["SiteId", "=", BWA.UserInfo.SiteId()]
  494. ]);
  495. dataSource.load()
  496. .done(function (result) {
  497. for (var i = 0; i < result.length; i++) {
  498. if (result[i].FloorId == floor) {
  499. viewModel.dataModel.Name(result[i].Name);
  500. break;
  501. }
  502. }
  503. });
  504. }
  505. });
  506. },
  507. handleViewShowing: function () {
  508. //권한설정
  509. hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
  510. var dataSource_FloorInfo = new DevExpress.data.DataSource({
  511. store: {
  512. type: "odata",
  513. url: endpointSelector + "/CmFloor",
  514. },
  515. requireTotalCount: true
  516. });
  517. dataSource_FloorInfo.filter([
  518. ["SiteId", "=", BWA.UserInfo.SiteId()]
  519. ]);
  520. dataSource_FloorInfo.load()
  521. .done(function (floorInfo) {
  522. floorAll = floorInfo;
  523. });
  524. UpdateSelectBoxInPopUp();
  525. GetGridData();
  526. enableDataBoxInPopup(true);
  527. },
  528. handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
  529. dataGrid.clearSelection();
  530. viewModel.visibleEditButton(true);
  531. viewModel.visibleDeleteButton(true);
  532. viewModel.isNotModifyMode(true);
  533. viewModel.enableDataBoxInPopup(false);
  534. viewModel.isImageUpload(false);
  535. viewModel.isNewInPopup(false);
  536. var data = clickRow.data;
  537. viewModel.dataModel.Name(data.Name);
  538. viewModel.dataModel.FloorId(data.FloorId);
  539. viewModel.dataModel.ImageFileId(data.ImageFileId);
  540. viewModel.dataModel.SiteId(data.SiteId);
  541. popupVisible(true);
  542. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, BWA.UserInfo.SiteId(), viewModel.dataModel.ImageFileId()));
  543. loadImage(imagefileUrl());
  544. },
  545. handleViewShown: function (dataViewModel, isEditModeInPopup) {
  546. setupDropZone(dataViewModel);
  547. },
  548. handleSaveSuccess: function () {
  549. if (_.isNull(dropZone) === false) {
  550. dropZone.resetUploadedFileInfo();
  551. }
  552. },
  553. handleAfterLoadingModelByKey: function (data, dataViewModel, isNewInPopup) {
  554. if (isNewInPopup() == false) {
  555. if (_.isNull(dataViewModel.ImageFileId()) === false) {
  556. imagefileUrl('{0}/CmFile(SiteId={1},FileId={2})/$value'.formati(BWA.db._url, dataViewModel.SiteId(), dataViewModel.ImageFileId()));
  557. }
  558. else {
  559. imagefileUrl("images/default.png");
  560. }
  561. }
  562. },
  563. });
  564. viewModel.floorplanPopupToolbarItems = floorplanPopupToolbarItems;
  565. viewModel.imagefileUrl = imagefileUrl;
  566. viewModel.FloorInPopUp = FloorInPopUp;
  567. viewModel.dataModel.FloorId = ko.observable();
  568. viewModel.isImageUpload = isImageUpload;
  569. viewModel.backupDataViewModel = backupDataViewModel;
  570. viewModel.enableDataBoxInPopup = enableDataBoxInPopup;
  571. viewModel.visibleEditButton = visibleEditButton;
  572. viewModel.hasnotModificationPermission = hasnotModificationPermission;
  573. viewModel.visibleDeleteButton = visibleDeleteButton;
  574. viewModel.visibleCancelButton = visibleCancelButton;
  575. viewModel.isEditModeInPopup = isEditModeInPopup;
  576. viewModel.isNotModifyMode = isNotModifyMode;
  577. return viewModel;
  578. };