From ec6e8cf82de9d8aef36b4742a2a64cba41196a59 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Mon, 29 Dec 2014 01:48:26 -0600 Subject: [PATCH] Request work types/languages --- batch-add-recording-relationships.user.js | 462 +--------------------- 1 file changed, 18 insertions(+), 444 deletions(-) diff --git a/batch-add-recording-relationships.user.js b/batch-add-recording-relationships.user.js index d1c2d74..f3fea88 100644 --- a/batch-add-recording-relationships.user.js +++ b/batch-add-recording-relationships.user.js @@ -159,442 +159,8 @@ function batch_recording_rels() { ); }); - var work_type_options = '\ -'; - - var work_language_options = '\ -'; + var $work_type_options = $(''); + var $work_language_options = $(''); // Add button to manage performance ARs var $relate_table = table( @@ -609,9 +175,9 @@ function batch_recording_rels() { tr(td("Their suggested works"), td(goBtn(relate_to_suggested_works))), tr(td(label("Work type:").attr('for',"bpr-work-type")), - td(work_type_options)), + td($work_type_options)), tr(td(label("Lyrics language:").attr('for', "bpr-work-language")), - td(work_language_options))).hide(); + td($work_language_options))).hide(); var $works_table = table( $('').append( @@ -631,8 +197,16 @@ function batch_recording_rels() { .insertAfter($("div#content h2")[0]); $container.find("table").find("td").css("width", "auto"); - $container.children("tbody").children("tr").children("td") - .css({"padding": "0.5em", "vertical-align": "top"}); + $container.children("tbody").children("tr").children("td").css({ padding: "0.5em", "vertical-align": "top" }); + + // Get actual work types/languages + + $.get('/dialog?path=%2Fwork%2Fcreate', function (data) { + var nodes = $.parseHTML(data); + + $work_type_options.append($('#id-edit-work\\.type_id', nodes).children()).val(''); + $work_language_options.append($('#id-edit-work\\.language_id', nodes).children()).val(''); + }); var hide_performed_recs = $.cookie('hide_performed_recs') === 'true' ? true : false; var hide_pending_edits = $.cookie('hide_pending_edits') === 'true' ? true : false; @@ -1269,12 +843,12 @@ function batch_recording_rels() { // Edit creation - $("#bpr-work-type").val($.cookie("bpr_work_type") || 0) + $work_type_options.val($.cookie("bpr_work_type") || 0) .change(function () { $.cookie('bpr_work_type', this.value, { path: '/', expires: 1000 }); }); - $("#bpr-work-language").val($.cookie("bpr_work_language") || 0) + $work_language_options.val($.cookie("bpr_work_language") || 0) .change(function () { $.cookie('bpr_work_language', this.value, { path: '/', expires: 1000 }); }); @@ -1401,8 +975,8 @@ function batch_recording_rels() { function create_new_work(title, callback) { function post_edit() { var data = "edit-work.name=" + title; - var work_type = $("#bpr-work-type").val(); - var work_lang = $("#bpr-work-language").val(); + var work_type = $work_type_options.val(); + var work_lang = $work_language_options.val(); if (work_type) data += "&edit-work.type_id=" + work_type; if (work_lang) data += "&edit-work.language_id=" + work_lang;