Fix form UI see #1478

pull/2487/head
jmontoyaa 9 years ago
parent 6094eee880
commit 3ee7a38cb8
  1. 13
      main/admin/grade_models.php
  2. 17
      main/inc/lib/grade_model.lib.php

@ -13,7 +13,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
if (api_get_setting('gradebook_enable_grade_model') != 'true') {
api_not_allowed();
api_not_allowed(true);
}
//Add the JS needed to use the jqgrid
@ -38,8 +38,8 @@ if ($action === 'add') {
}
$htmlHeadXtra[]= '<script>
function plusItem(item) {
console.log(item);
if (item != 1) {
document.getElementById(item).style.display = "inline";
document.getElementById("plus-"+item).style.display = "none";
@ -69,7 +69,6 @@ function minItem(item) {
}
</script>';
// The header.
Display::display_header();
//jqgrid will use this URL to do the selects
@ -113,10 +112,10 @@ $extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
?>
<script>
$(function() {

@ -83,8 +83,7 @@ class GradeModel extends Model
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->addText('name', get_lang('Name'));
$form->addHtmlEditor(
'description',
get_lang('Description'),
@ -97,14 +96,13 @@ class GradeModel extends Model
)
);
$form->addElement('label', get_lang('Components'));
$form->addLabel(get_lang('Components'), '');
// Get components
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
if ($defaults) {
$components = $this->get_components($defaults['id']);
@ -112,7 +110,7 @@ class GradeModel extends Model
if ($action == 'edit') {
if (!empty($components)) {
$nr_items = count($components) -1;
$nr_items = count($components);
}
}
@ -122,6 +120,7 @@ class GradeModel extends Model
$component_array = array();
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components['.$i.'][percentage]', null);
@ -130,10 +129,12 @@ class GradeModel extends Model
$form->addElement('hidden', 'components['.$i.'][id]', null);
$template_percentage =
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="form-group">
<p>
<label class="control-label">{label}</label>
<div class="controls">
<label for="" class="col-sm-2 control-label">
{label}
</label>
<div class="col-sm-8">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
{element} <!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --> % = ';

Loading…
Cancel
Save