// Copyright (c) 2021, JINGROW
// For license information, please see license.txt

jingrow.ui.form.on('App Release Approval Request', {
	refresh(frm) {
		if (['Open', 'Rejected'].includes(frm.pg.status)) {
			frm.add_custom_button('Approve Request', () => {
				frm.set_value('status', 'Approved');
				frm.save();
			});
		}

		if (!frm.pg.result && frm.pg.screening_status === 'Not Started') {
			let btn = frm.add_custom_button('Screen Release', () => {
				frm.call('start_screening');
				jingrow.msgprint('Started Screening');
			});
		}

		if (frm.pg.result_html) {
			let wrapper = frm.get_field('result_html_rendered').$wrapper;
			wrapper.html(frm.pg.result_html);
		}
	},
	status(frm) {
		frm.set_value('reviewed_by', jingrow.session.user);
	},
});
