|
|
Choosing A Webhost: |
[mb-commits] r8297 - mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit: msg#00300audio.musicbrainz.cvs
Author: keschte Date: 2006-07-31 16:43:29 +0000 (Mon, 31 Jul 2006) New Revision: 8297 Modified: mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/edit.html mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/form Log: preset language/script from stored values when editing one release. (fixes #1850) Modified: mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/edit.html =================================================================== --- mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/edit.html 2006-07-31 16:42:40 UTC (rev 8296) +++ mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/edit.html 2006-07-31 16:43:29 UTC (rev 8297) @@ -72,10 +72,15 @@ ++$artisthash{$release->GetArtist}; } - # convert empty values to internal int value (0). + # convert "i don't know" to 0. $script_new = 0 if (defined $script_new and $script_new eq ""); $language_new = 0 if (defined $language_new and $language_new eq ""); + + my @errors = (); + push @errors, "Please select the language of the selected releases." if (!MusicBrainz::IsNonNegInteger($language_new)); + push @errors, "Please select the script of the selected releases." if (!MusicBrainz::IsNonNegInteger($script_new)); + # we got a a form submission if ($submitvalue ne "") { @@ -87,6 +92,10 @@ { $script_new = undef; $language_new = undef; + + # clear errors after guessing, they'll be reshown again after + # the next submit, if there are still any. + @errors = (); } elsif ($submitvalue =~ /Cancel/i) { @@ -100,9 +109,7 @@ $m->comp("/comp/redirect", $url); } - elsif ($submitvalue =~ /Enter Edit/i - and MusicBrainz::IsNonNegInteger($language_new) - and MusicBrainz::IsNonNegInteger($script_new)) + elsif (@errors == 0) { # prepare url for enter mods redirct: # * only one release, redirect to the release @@ -143,6 +150,17 @@ die "Shouldn't get here"; } } + else + { + # if we are editing one release, load the current values from + # the database, else guess them from the list of releases. + if (@releaseobjs == 1) + { + my $release = $releaseobjs[0]; + $script_new = $release->GetScriptId; + $language_new = $release->GetLanguageId; + } + } # let's see if we have to guess language or script from # the title fields of this (or the first) release. @@ -150,9 +168,10 @@ # TODO: would it possibly make more sense to take all fields # of all releases into account? if (not defined $script_new - or not not defined $language_new) + or not defined $language_new) { my @text; + if (@releaseobjs) { my $release = $releaseobjs[0]; @@ -164,7 +183,7 @@ if (not defined $script_new) { $script_new = MusicBrainz::Server::Script->GuessFromText($mb->{DBH}, \@text); - $script_new = ($script_new ? $script_new->GetId : 0); + $script_new = ($script_new ? $script_new->GetId : -1); } # if the language is not set, guess it from the text and $script @@ -173,20 +192,20 @@ $language_new = MusicBrainz::Server::Language->GuessFromTextAndScript( $mb->{DBH}, \@text, $script_new ); - $language_new = ($language_new ? $language_new->GetId : 0); + $language_new = ($language_new ? $language_new->GetId : -1); } } # set the current values from the argument, or the first release handed in. - my $language_curr = $language_new || (@releaseobjs ? $releaseobjs[0]->GetLanguageId : "") || ""; - my $script_curr = $script_new || (@releaseobjs ? $releaseobjs[0]->GetScriptId : "") || ""; + my $language_curr = $language_new || (@releaseobjs ? $releaseobjs[0]->GetLanguageId : -1) || -1; + my $script_curr = $script_new || (@releaseobjs ? $releaseobjs[0]->GetScriptId : -1) || -1; # see if one of the releases has a modpending flag. my $mp = grep { $_->GetLanguageModPending } @releaseobjs; </%perl> -<& /comp/sidebar-notitle, pagetitle => "Edit Release Language/Script" &> +<& /comp/sidebar-notitle, pagetitle => "Edit release language/script" &> <!-- add editsuite for modnote resizer support --> <script type="text/javascript" src="/scripts/editsuite.js"></script> @@ -217,11 +236,27 @@ <td class="instructions" colspan="2"> <ul> <li> - Please choose the <& /comp/linkdoc, "ReleaseLanguage", "script and language" &> + Please choose the <& /comp/linkdoc, "ReleaseLanguage", "language/script" &> of the selected releases.</li> </ul> </td> </tr> + +% if (@errors) +% { + + <tr> + <td> </td> + <td> + <& /comp/form/feedbackbox, + "warning", "Your form submission contains errors:", + "<ul><li>" + . join ("</li><li>", @errors) + . "</li></ul>" &></td> + </tr> + +% } + <tr class="top"> <td class="label"> <label>Selected releases:</label></td> @@ -235,30 +270,30 @@ <%perl> - my $n = 0; - foreach my $release ( @releaseobjs ) - { - $m->out("<tr>"); + my $n = 0; + foreach my $release ( @releaseobjs ) + { + $m->out("<tr>"); - # TODO: load artist for this? - # $m->out(qq!<td style="padding-right: 40px">!); - # $m->comp("/comp/linkartist", artist => $release->GetArtist); - # $m->out(qq!</td><td style="padding-right: 40px">!); + # TODO: load artist for this? + # $m->out(qq!<td style="padding-right: 40px">!); + # $m->comp("/comp/linkartist", artist => $release->GetArtist); + # $m->out(qq!</td><td style="padding-right: 40px">!); - $m->out(qq!<td style="padding-right: 40px">!); - $m->comp("/comp/form/currentvalue", release => $release, mp_type => &ModDefs::MOD_EDIT_ALBUM_LANGUAGE); - $m->out(qq!</td><td style="padding-right: 40px">!); - $m->out( - defined $release->GetLanguage - ? $release->GetLanguage->GetName - : "Not Set"); - $m->out(qq!</td><td style="padding-right: 40px">!); - $m->out( - defined $release->GetScript - ? $release->GetScript->GetName - : "Not Set"); - $m->out("</td></tr>"); - } + $m->out(qq!<td style="padding-right: 40px">!); + $m->comp("/comp/form/currentvalue", release => $release, mp_type => &ModDefs::MOD_EDIT_ALBUM_LANGUAGE); + $m->out(qq!</td><td style="padding-right: 40px">!); + $m->out( + defined $release->GetLanguage + ? $release->GetLanguage->GetName + : "Not Set"); + $m->out(qq!</td><td style="padding-right: 40px">!); + $m->out( + defined $release->GetScript + ? $release->GetScript->GetName + : "Not Set"); + $m->out("</td></tr>"); + } </%perl> Modified: mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/form =================================================================== --- mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/form 2006-07-31 16:42:40 UTC (rev 8296) +++ mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/albumlanguage/form 2006-07-31 16:43:29 UTC (rev 8297) @@ -46,17 +46,21 @@ # Instantiate MusicBrainz object my $mb = $m->comp("/comp/dblogin"); - # load the list of languages from the database - my @languages_menu = MusicBrainz::Server::Language->Menu($mb->{DBH}, - minimum_frequency => ($expand_lists ? 1 : 2), - include => $language_curr + # compile list of scripts, be sure to include + # the current value (if compact list is shown) + my @scripts = MusicBrainz::Server::Script->Menu($mb->{DBH}, + minimum_frequency => ( $expand_lists ? 0 : 4 ), + include => $script_curr ); + unshift @scripts, [ "-1", "Select script..." ]; - # load the list of scripts from the database - my @scripts_menu = MusicBrainz::Server::Script->Menu($mb->{DBH}, - minimum_frequency => ($expand_lists ? 0 : 4), - include => $script_curr + # compile list of languages, be sure to include + # the current value (if collapsed) + my @languages = MusicBrainz::Server::Language->Menu($mb->{DBH}, + minimum_frequency => ( $expand_lists ? 1 : 2 ), + include => $language_curr ); + unshift @languages, [ "-1", "Select language..." ]; </%perl> @@ -74,7 +78,7 @@ <td class="field"> <select name="<% $language_fieldname %>" style="<% $expand_lists ? "" : "width: 200px" %>" id="id_<% $language_fieldname %>"> - <& /comp/options, \@languages_menu, $language_curr &> + <& /comp/options, \@languages, $language_curr &> </select></td> </tr> <tr> @@ -83,7 +87,7 @@ <td class="field"> <select name="<% $script_fieldname %>" style="<% $expand_lists ? "" : "width: 200px" %>" id="id_<% $script_fieldname %>"> - <& /comp/options, \@scripts_menu, $script_curr &> + <& /comp/options, \@scripts, $script_curr &> </select></td> </tr> <tr>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [mb-commits] r8296 - mb_server/branches/RELEASE_20060712-BRANCH/htdocs/comp/release_editor, root |
|---|---|
| Next by Date: | [mb-commits] r8298 - mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/album, root |
| Previous by Thread: | [mb-commits] r8296 - mb_server/branches/RELEASE_20060712-BRANCH/htdocs/comp/release_editor, root |
| Next by Thread: | [mb-commits] r8298 - mb_server/branches/RELEASE_20060712-BRANCH/htdocs/edit/album, root |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |