'use strict';
|
|
define(['app'],
|
function (app) {
|
app.directive('jsInformation', ["$rootScope", "$log", "SystemEmail", "$resourceProvider", "SweetAlert", "$filter",
|
function ($rootScope, $log, SystemEmail, $resourceProvider, SweetAlert, $filter) {
|
return {
|
restrict : 'E',
|
scope : {},
|
templateUrl : 'custom_components/js-information/js-information.html',
|
link : function ($scope, $element, $attrs) {
|
|
$scope.fn = {
|
formSubmit : formSubmit, // 폼 전송
|
formCheck : formCheck, // 폼 체크
|
initForm : initForm // 폼 초기화
|
};
|
|
$scope.vm = {
|
form : {
|
email : "", // 이메일
|
description : "" // 내용
|
}
|
};
|
|
// 폼 체크
|
function formCheck(formInvalid) {
|
if (formInvalid) {
|
return true;
|
}
|
|
return false;
|
}
|
|
// 폼 전송
|
function formSubmit() {
|
$rootScope.spinner = true;
|
$rootScope.information = false;
|
|
SystemEmail.information($resourceProvider.getContent(
|
$scope.vm.form,
|
$resourceProvider.getPageContent(0, 0))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
SweetAlert.success($filter("translate")("inquiry.contactCompleted"), $filter("translate")("inquiry.asap"));
|
}
|
else {
|
SweetAlert.error($filter("translate")("inquiry.failedToReceiveEnquiry"), result.data.message.message);
|
}
|
|
$rootScope.spinner = false;
|
});
|
|
}
|
|
// 폼 초기화
|
function initForm() {
|
if ($rootScope.isDefined($rootScope.user)) {
|
$scope.vm.form.email = $rootScope.user.account;
|
}
|
else {
|
$scope.vm.form.email = "";
|
}
|
|
$scope.vm.form.description = "";
|
|
$rootScope.information = !$rootScope.information;
|
}
|
|
}
|
};
|
}])
|
});
|