<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
              <form id="group-form">
                <div class="row g-3">
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="id"
                        >아이디</label
                      >
                      <div class="col-sm-10">
                        <input name="id" type="text" required data-map="GRP_ID" maxlength="50" class="form-control" placeholder="그룹 아이디" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="name"
                        >이름</label
                      >
                      <div class="col-sm-10">
                        <input name="name" type="text" required  data-map="GRP_NM" maxlength="60" class="form-control" placeholder="그룹 이름" />
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="description"
                        >설명</label
                      >
                      <div class="col-sm-10">
                        <input name="description" type="text" data-map="DSCRP" maxlength="200" class="form-control" placeholder="그룹 설명"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="createdBy"
                        >등록자</label
                      >
                      <div class="col-sm-10">
                        <input type="text" data-map="RGTR" readonly class="form-control" placeholder="등록자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="description"
                        >등록일자</label
                      >
                      <div class="col-sm-10">
                        <input type="text" data-map="REG_DT" readonly class="form-control" placeholder="등록일자"/>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="row">
                      <label class="col-sm-2 col-form-label text-sm-end" for="description"
                        >사용여부</label
                      >
                      <div class="col-sm-10" style="padding:.5em .7em;">
                      	<span id="groupInUse"></span>
                      </div>
                    </div>
                  </div>
                <div class="row mt-4 justify-content-end">
                      <div class="col-sm-12" style="text-align:right;">
                        <button onclick="saveGroup();" type="button" class="btn btn-primary">저장</button>
                      </div>
                </div>
              </form>
<script type="text/javascript">

var groupFields = new FormFields("#group-form");

codeControl.groups.setInfo = obj => {
	let info = obj.data;
	groupFields.set(obj);
	let create = isEmpty(info.GRP_ID);
	$("input[name='id']").prop("readonly", !create);
	$("#group-form input")
		.change(function() {
			let input = $(this),
				name = input.attr("data-map"),
				val = input.val();
			codeControl.groups.setValue(name, val);
		})
		.onEnterPress(saveGroup);
	$("#groupInUse").html(create ? "" : info.USE_YN == "Y" ? "사용 중" : "사용하지 않음");
	
	document.querySelector("input[name='" + (create ? "id" : "name") + "']").focus();
}

codeControl.groups.onModify = (changed) => {
	if (["GRP_NM"].filter(e => changed.includes(e)).length < 1)
		return;
	
	renderGroupList();
	codeControl.groups.dataset.setState();
}

function saveGroup() {
	if (!$("#group-form input").validInputs()) return;
	
	dialog.alert({
		content:"현재 그룹 정보를 저장하시겠습니까?",
		onOK:() => {
			codeControl.groups.save(groupFields.get());
		}
	});
}
//# sourceURL=group-info.jsp
</script>