You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
5.1 KiB
PHTML

<div class="modal fade" id="modalBox" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-md modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">데이터 등록</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="panel-content border-faded border-left-0 border-right-0 border-top-0">
<form id="modal-form" method="post" action="{{ route('cms.setting.store') }}">
<input type="hidden" name="id" value="" />
<input type="hidden" name="mode" value="" />
<div class="form-group">
<label for="input-name">변수명</label>
<input type="text" name="name" id="input-name" value="" class="form-control" maxlength="30" required placeholder="변수명" />
</div>
<div class="form-group">
<label for="input-key">변수키</label>
<input type="text" name="key" id="input-key" value="" class="form-control" maxlength="20" placeholder="변수키" />
</div>
<div class="form-group">
<label for="input-value">변수값</label>
<textarea name="value" id="input-value" rows="3" class="form-control autosize" placeholder="변수값을 입력해 주세요."></textarea>
</div>
<div class="form-group">
<div class="form-group-box">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" name="system" id="system" class="custom-control-input" value="1" />
<label for="system" class="custom-control-label">시스템 변수</label>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-danger btn-save">저장</button>
<button type="button" class="btn btn-info" data-dismiss="modal">닫기</button>
</div>
</div>
</div>
</div>
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
var modal = $('#modalBox');
function initModalForm() {
modal.find('.modal-title').html('데이터 등록');
modal.find('input[name=id]').val('');
modal.find('input[name=mode]').val('add');
modal.find('input[type=text]').val('');
modal.find('#input-key').prop('readonly', false);
modal.find('textarea').val('');
modal.find('#system').prop('checked', true);
}
modal.on('shown.bs.modal', function (e) {
initModalForm();
var dataID = $(e.relatedTarget).data('id');
var mode = 'add';
var data = null;
$.get('{{ route('cms.setting.create') }}', { 'id': dataID }, function(result) {
if (result.code == 'success') {
data = result.data.data;
mode = result.data.mode;
modal.find('.modal-title').html(mode == 'modify' ? '데이터 변경' : '데이터 등록');
modal.find('input[name=id]').val(data.id);
modal.find('input[name=mode]').val(mode);
modal.find('#input-name').val(data.name);
modal.find('#input-key').val(data.key);
modal.find('#input-value').val(data.value);
if (data.system) {
if (mode != 'add') {
modal.find('#input-key').prop('readonly', true);
}
modal.find('#system').prop('checked', true);
} else {
modal.find('#input-key').prop('readonly', false);
modal.find('#system').prop('checked', false);
}
}
});
});
modal.on('hidden.bs.modal', function (e) {
initModalForm();
});
modal.find(".btn-save").click(function() {
modal.find("#modal-form").submit();
});
modal.find("#modal-form").submit(function() {
if (!$("#input-name").checkEmpty('변수명을 입력해 주세요.')) return false;
if (!$("#input-key").checkEmpty('변수키를 입력해 주세요.')) return false;
$.post($(this).attr('action'), $(this).serialize(), function(result) {
alert(result.message);
if (result.code == 'success') {
window.location.reload();
}
}).fail(function(result) {
console.log(result);
alert('시스템 오류가 발생했습니다!!');
});
return false;
});
});
</script>
@endpush