/**
|
* Created by wisestone on 2018-05-08.
|
*/
|
'use strict';
|
|
define([
|
'app'
|
],
|
function (app) {
|
app.controller('eventAddController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'Event', 'SweetAlert', '$filter',
|
function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, Event, SweetAlert, $filter) {
|
|
$scope.fn = {
|
cancel : cancel, // 팝업 창 닫기
|
formSubmit : formSubmit, // 폼 전송
|
formCheck : formCheck // 폼 체크
|
};
|
|
$scope.vm = {
|
form : {
|
title : "", // 제목
|
description : "", // 내용
|
startEndDateRange : "", // 시작일, 종료일 정보
|
startDate : "",
|
endDate : "",
|
},
|
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;
|
}
|
|
if (!$rootScope.isDefined($scope.vm.form.startEndDateRange)) {
|
return true;
|
}
|
|
return false;
|
}
|
|
function formSubmit() {
|
$rootScope.spinner = true;
|
|
var content = {
|
title : $rootScope.preventXss($scope.vm.form.title),
|
description : $rootScope.preventXss($scope.vm.form.description),
|
startDate : "",
|
endDate : "",
|
};
|
|
if ($rootScope.isDefined($scope.vm.form.startEndDateRange)) {
|
var startEndDateRange = $scope.vm.form.startEndDateRange.split("~");
|
content.startDate = startEndDateRange[0].trim();
|
content.endDate = startEndDateRange[1].trim();
|
}
|
|
Event.add($resourceProvider.getContent(
|
content,
|
$resourceProvider.getPageContent(0, 10))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
$scope.fn.cancel();
|
// 목록 화면 갱신
|
$rootScope.$broadcast("getEventList", {});
|
}
|
else {
|
SweetAlert.error($filter("translate")("event.failedEventRegistration"), result.data.message.message);
|
}
|
|
$rootScope.spinner = false;
|
});
|
}
|
|
function cancel() {
|
$rootScope.$broadcast("closeLayer"); // 팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
|
$uibModalInstance.dismiss('cancel');
|
$(document).unbind("keydown"); // 단축키 이벤트 제거
|
}
|
}]);
|
});
|