Commit ffed1181 authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic

Bug 1635503: Adjust the copy/edit selectors

So that we pass in the key as well as value to the template
then we can simplify the javascript around fetching the correct matrix

behatnotneeded

Change-Id: If4d2d47837de46fbbc5f6ecf6ec955687a264fa0
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent dd89f432
......@@ -141,13 +141,6 @@ else if ($upload) {
);
//set up variables for correct selection of framework from dropdowns
$fw_list = json_encode($fw);
$fwe = json_encode($fw_edit);
$fwe = preg_replace('/^\{(.*)\}$/', '[{$1}]', $fwe);
$fwe = preg_replace('/,/', '},{', $fwe );
$fw_list = preg_replace('/^\{(.*)\}$/', '[{$1}]', $fw_list);
$fw_list = preg_replace('/,/', '},{', $fw_list );
$inst_names = get_institutions();
$inst_stg = get_string('all', 'module.framework') . ',';
foreach ($inst_names as $inst) {
......@@ -155,9 +148,6 @@ else if ($upload) {
}
$inst_stg = preg_replace('/(.*)\,$/', '$1', $inst_stg);
$inlinejs = "var inst_names='{$inst_stg}';";
//want to have the id for the fw available to use because using name to save with causes problems
$inlinejs .= "var fws='{$fw_list}';";
$inlinejs .= "var fw_edit='{$fwe}';";
//2nd nav should be this.
$smarty = smarty(array('js/jsoneditor/src/dist/jsoneditor.js', 'module/framework/js/editor.js'), array(), $jsoneditor_strings);
......
......@@ -349,12 +349,7 @@ function refresh_editor() {
editor.destroy();
refresh_editor();
edit = true;
var fw = $('#edit_framework')[0];
var select_index = fw.children.edit.options.selectedIndex;
var fwe = JSON.parse(fw_edit);
//get the db index
index = Object.keys(fwe[select_index]);
index = index[0];
var index = $('#edit').val();
populate_editor(index, edit);
textarea_init();
......@@ -377,11 +372,7 @@ function refresh_editor() {
editor.destroy();
refresh_editor();
edit = false;
var fw = $('#copy_framework')[0];
var select_index = fw.children.copy.options.selectedIndex;
var fwc = JSON.parse(fws);
index = Object.keys(fwc[select_index]);
index = index[0];
var index = $('#copy').val();
populate_editor(index);
textarea_init();
set_editor_clean();
......
......@@ -8,12 +8,12 @@
<input type="submit" id='cancel' class="btn-default submitcancel cancel" name="cancel_submit" tabindex="0" value="{str tag='cancel'}">
</div>
<div id='edit_framework' class="select form-group"><label for=edit>Edit saved framework</label>
<select id='edit' class="select form-control">{foreach from=$fw_edit item=fw_ed}<option value={$fw_ed}>{$fw_ed}</option>{/foreach}</select>
<select id='edit' class="select form-control">{foreach from=$fw_edit key=fw_edk item=fw_ed}<option value={$fw_edk}>{$fw_ed}</option>{/foreach}</select>
<div class="description">
{$edit_desc}</div>
</div>
<div id='copy_framework' class="select form-group"><label for="copy">Copy existing framework</label>
<select id='copy' class="select form-control">{foreach from=$fw item=fw}<option value={$fw}>{$fw}</option>{/foreach}</select>
<select id='copy' class="select form-control">{foreach from=$fw key=fw_k item=fw}<option value={$fw_k}>{$fw}</option>{/foreach}</select>
<div class="description">
{$copy_desc}</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment