/** * Created by wisestone on 2018-05-08. */ 'use strict'; define([ 'app' ], function (app) { app.controller('noticeModifyController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'Notice', 'parameter', 'SweetAlert', '$filter', function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, Notice, parameter, SweetAlert, $filter) { $scope.fn = { cancel : cancel, // 팝업 창 닫기 formSubmit : formSubmit, // 폼 전송 formCheck : formCheck, // 폼 체크 detail : detail // 상세 정보 }; $scope.vm = { search : { id : parameter.id }, form : { id : parameter.id, title : "", // 제목 description : "" // 내용 }, options : { callbacks : { onImageUpload : function (data) { data.pop(); } }, disableDragAndDrop : true, shortcuts : true, toolbar : [ ['headline', ['style']], ['style', ['bold', 'italic', 'underline', 'clear', 'strikethrough', 'superscript', 'subscript']], ['fontface', ['fontname', 'fontsize']], ['insert', ['link', 'video']], ['fontclr', ['color']], ['alignment', ['ul', 'ol', 'paragraph', 'lineheight', 'height']], ['table', ['table']], ['view', ['redo', 'undo']] ], keyMap : { pc : { 'ENTER' : 'insertParagraph', 'CTRL+Z' : 'undo', 'CTRL+Y' : 'redo', /*'TAB': 'tab',*/ 'SHIFT+TAB' : 'untab', 'CTRL+B' : 'bold', 'CTRL+I' : 'italic', 'CTRL+U' : 'underline', 'CTRL+SHIFT+S' : 'strikethrough', 'CTRL+BACKSLASH' : 'removeFormat', 'CTRL+SHIFT+L' : 'justifyLeft', 'CTRL+SHIFT+E' : 'justifyCenter', 'CTRL+SHIFT+R' : 'justifyRight', 'CTRL+SHIFT+J' : 'justifyFull', 'CTRL+SHIFT+NUM7' : 'insertUnorderedList', 'CTRL+SHIFT+NUM8' : 'insertOrderedList', 'CTRL+LEFTBRACKET' : 'outdent', 'CTRL+RIGHTBRACKET' : 'indent', 'CTRL+NUM0' : 'formatPara', 'CTRL+NUM1' : 'formatH1', 'CTRL+NUM2' : 'formatH2', 'CTRL+NUM3' : 'formatH3', 'CTRL+NUM4' : 'formatH4', 'CTRL+NUM5' : 'formatH5', 'CTRL+NUM6' : 'formatH6', 'CTRL+ENTER' : 'insertHorizontalRule', 'CTRL+K' : 'linkDialog.show' } } } }; function formCheck(formInvalid) { if (formInvalid) { return true; } return false; } function formSubmit() { $rootScope.spinner = true; var content = { id : parameter.id, title : $rootScope.preventXss($scope.vm.form.title), description : $rootScope.preventXss($scope.vm.form.description) }; Notice.modify($resourceProvider.getContent( content, $resourceProvider.getPageContent(0, 0))).then(function (result) { if (result.data.message.status === "success") { $scope.fn.cancel(); // 목록 화면 갱신 $rootScope.$broadcast("getNoticeList", {}); } else { SweetAlert.error($filter("translate")("notice.failedToModifyNotice"), result.data.message.message); //공지 사항 수정 실패 } $rootScope.spinner = false; }); } // 팝업 창 닫기 function cancel() { $rootScope.$broadcast("closeLayer"); // 팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정 $uibModalInstance.dismiss('cancel'); $(document).unbind("keydown"); // 단축키 이벤트 제거 } // 상세 조회 function detail() { Notice.detail($resourceProvider.getContent( $scope.vm.search, $resourceProvider.getPageContent(0, 1))).then(function (result) { if (result.data.message.status === "success") { if ($rootScope.isDefined(result.data.data)) { $scope.vm.form.title = result.data.data.title; $scope.vm.form.description = result.data.data.description; } } else { SweetAlert.error($filter("translate")("notice.failedToLookupNotificationDetails"), result.data.message.message); //공지사항 상세 정보 조회 실패 } }); } // 공지사항 상세 조회 $scope.fn.detail(); }]); });