class CodeControl {
	constructor() {
		this.groups = new DatasetControl({
			prefix:"group",
			prefixName:"코드그룹",
			keymapper:info => info.GRP_ID,
			dataGetter:obj => obj.groupList,
			formats: {
				REG_DT:datetimeFormat
			},
			urls:{
				load:wctx.url("/code/group/list.do"),
				getInfo:wctx.url("/code/group/info.do"),
				create:wctx.url("/code/group/create.do"),
				update:wctx.url("/code/group/update.do"),
				remove:wctx.url("/code/group/remove.do")
			}
		});
		
		this.codes = new DatasetControl({
			prefix:"code",
			prefixName:"코드",
			keymapper:info => info.CODE,
			dataGetter:obj => obj.codeList,
			formats: {
				REG_DT:datetimeFormat
			}
		});
		
		this.groups.onDatasetChange = obj => this.onGroupListChange(obj);
		this.groups.onCurrentChange = item => {
			this.onCurrentGroupChange(item);
			
			let info = item ? item.data : null;
			if (info) {
				this.codes.query.groupIDs = info.GRP_ID;
				this.codes.load();
			} else
				this.codes.dataset.clear();
		};
		this.groups.onSelectionChange = selected => this.onGroupSelect(selected);

		this.codes.onDatasetChange = obj => this.onCodeListChange(obj);
		this.codes.onCurrentChange = item => this.onCurrentCodeChange(item);
		this.codes.onSelectionChange = selected => this.onCodeSelect(selected);
	}
	
	onGroupListChange(obj) {}
	
	onCurrentGroupChange(item) {}
	
	onGroupSelect(selected) {}
	
	newCode() {
		this.codes.newInfo({GRP_ID:this.groups.getCurrent().GRP_ID})
	}

	onCodeListChange(obj) {}
	
	onCurrentCodeChange(item) {}
	
	onCodeSelect(selected) {}
}