git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
aaa2eea
)
word edit: flags in language selection
author
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 30 May 2020 20:30:57 +0000
(22:30 +0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 6 Jun 2020 01:49:20 +0000
(
03:49
+0200)
writer.plp
patch
|
blob
|
history
diff --git
a/writer.plp
b/writer.plp
index 0e1058221ad4dc984c28c03b77d3fa15e3109968..ef377a0afb0db329026956ff5548ed68c012e4ba 100644
(file)
--- a/
writer.plp
+++ b/
writer.plp
@@
-105,9
+105,16
@@
my $db = eval {
});
} or Abort('Database error', 501, $@);
});
} or Abort('Database error', 501, $@);
+my %lang = (
+ nld => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'dutch'],
+ eng => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'],
+ epo => ['<span style="color:green">★</span>', 'esperanto'],
+);
my @wordcols = pairkeys
my %wordcol = (
my @wordcols = pairkeys
my %wordcol = (
- lang => 'Language',
+ lang => {-label => 'Language', -select => {
+ map { $_ => "@{$lang{$_}}" } keys %lang
+ }},
cat => [{-label => 'Category'}, 'ref'],
ref => {-label => 'Reference'},
prio => [
cat => [{-label => 'Category'}, 'ref'],
ref => {-label => 'Reference'},
prio => [
@@
-124,11
+131,6
@@
my %wordcol = (
source => 'Image',
thumb => 'Convert options',
);
source => 'Image',
thumb => 'Convert options',
);
-my %langflag = (
- nld => "\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}",
- eng => "\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}",
- epo => '<span style="color:green">★</span>',
-);
my ($find) = map {{id => $_}} $fields{id} || $Request || ();
my $row;
my ($find) = map {{id => $_}} $fields{id} || $Request || ();
my $row;
@@
-220,11
+222,14
@@
package Shiar_Sheet::FormRow {
$html .= qq( $_="$attr->{$_}") for sort grep {!/^-/} keys %{$attr // {}};
if (my $options = $attr->{-select}) {
$html .= qq( $_="$attr->{$_}") for sort grep {!/^-/} keys %{$attr // {}};
if (my $options = $attr->{-select}) {
+ $options = { map {$_ => $options->[$_]} 0 .. $#{$options} }
+ if ref $options eq 'ARRAY';
+ $options->{$val} //= "unknown ($val)"; # preserve current
return (
sprintf('<select id="%s" name="%1$s">', $col),
(map { sprintf('<option value="%s"%s>%s</option>',
return (
sprintf('<select id="%s" name="%1$s">', $col),
(map { sprintf('<option value="%s"%s>%s</option>',
- $_, $val eq $_ && ' selected', $options->
[$_]
- ) }
0 .. $#
{$options}),
+ $_, $val eq $_ && ' selected', $options->
{$_}
+ ) }
sort keys %
{$options}),
'</select>',
);
}
'</select>',
);
}
@@
-288,9
+293,12
@@
if ($row->{id}) {
my $children = $db->select(word => '*', {ref => $row->{id}}, 'lang, id');
printf '<li><label>%s</label><div><ul class="inline">', 'Translations';
while (my $row = $children->hash) {
my $children = $db->select(word => '*', {ref => $row->{id}}, 'lang, id');
printf '<li><label>%s</label><div><ul class="inline">', 'Translations';
while (my $row = $children->hash) {
- printf '<li><label for="%s">%s</label> <a id="%1$s" href="%s">%s</a></li>',
- "trans-$row->{lang}", $langflag{$row->{lang}},
- "/writer/$row->{id}", Entity($row->{form});
+ printf(
+ '<li><label for="%1$s" title="%5$s">%4$s</label>' .
+ ' <a id="%s" href="%s">%s</a></li>',
+ "trans-$row->{lang}", "/writer/$row->{id}", Entity($row->{form}),
+ @{$lang{ $row->{lang} }}, # flag, name
+ );
}
say '</ul></div></li>';
}
}
say '</ul></div></li>';
}