<?php $pageTitle='Create a crystal score';
include realpath(__DIR__).'/../../core/_common/header.php'; ?>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded',function(){

	ui.grid();


	const detailsBox=grid.box({
		classes:'r1 c1 h3 w1',
		title:'Details'
	});
	const frm=detailsBox.form({
		action:'/api/crystalscore/',
		method:'post'
	});
    let scoringSystemField=frm.roleField({
        label:"Scoring system",
        name:'crystalscoringsystemid',
        otherType:'crystalscoringsystem',
        headers:['Scoring system'],
        cellTemplates:['{{name}}']
    });
    let labelField=frm.textField({ label:"Name", name:'label', value:'' }); //Human-friendly name, not database name
    frm.colorField({value:'ff7733'});
    frm.textField({ label:'Score index', name:'scoreindex', value:'' });
    frm.textField({ label:'Hotkey', name:'hotkey', value:'' });
    frm.createButton({
        beforeSubmit:function (){
            let scoringSystemName=scoringSystemField.querySelector("a").innerHTML;
            nameField.value=scoringSystemName+"_"+labelField.querySelector("input").value;
        }
    });
    let nameField=frm.hiddenField('name','');

});


</script>
<?php include realpath(__DIR__).'/../../core/_common/footer.php';