X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/027a60ece8b12690c09b5e433339b03e55df065b..89cc73c8a0ee71ed9e85cbb7fcbf7e9e53fb1713:/word/edit.plp diff --git a/word/edit.plp b/word/edit.plp index 1aade3e..55fbeac 100644 --- a/word/edit.plp +++ b/word/edit.plp @@ -15,6 +15,7 @@ EOT use List::Util qw( pairs pairkeys ); use Shiar_Sheet::FormRow; +use SQL::Abstract '1.83'; use JSON; my $db = eval { @@ -72,6 +73,7 @@ my $user = eval { }; my %lang = ( + '' => ['(reference)'], nl => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'nederlands'], en => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'], eo => [qq'\N{BLACK STAR}', 'esperanto'], @@ -89,7 +91,9 @@ my %wordcol = ( prio => [ {-label => 'Level', -select => sub { my ($row) = @_; - my @enum = qw[ essential basic common distinctive optional invisible ]; + my @enum = qw[ + essential ubiquitous basic common distinctive specialised rare invisible + ]; return { ('' => 'parent') x (defined $row->{ref}), map { $_ => $enum[$_] } 0 .. $#enum @@ -106,13 +110,15 @@ my %wordcol = ( return "data/word/org/$_[0]->{id}.jpg"; }}, convert => {-label => 'Convert options', -json => 'image', -multiple => 1, -src => sub { - return "data/word/en/$_[0]->{id}.jpg"; + return "data/word/32/$_[0]->{id}.jpg"; }}, + crop32 => {-json => 'image', type => 'hidden'}, # set by javascript interface story => {-label => 'Story', type => 'textarea', hidden => 'hidden'}, ); if (my $search = $fields{q}) { - my %filter = (form => {ilike => '%'.$search.'%'}); + my %filter = $search eq '^' ? (cat => undef, ref => undef) : + (form => {ilike => '%'.parseinput($search).'%'}); my $results = $db->select(word => '*', \%filter); say '
delete." @@ -204,17 +216,17 @@ elsif (defined $post{form}) {{ require Shiar_Sheet::ImagePrep; my $image = Shiar_Sheet::ImagePrep->new($wordcol{source}->{-src}->($row)); my $reimage = eval { - ($imagecol->{source} // '') ne ($replace->{source} // '') or return; + ($imagecol->{source} // '') ne ($replace->{image}->{source} // '') or return; $image->download($imagecol->{source}); }; !$@ or Alert(["Source image not found", $@]); - $reimage ||= $row->{image} ~~ $replace->{image}; # different source - $reimage ||= $row->{cover} ~~ $replace->{cover}; # resize + $reimage ||= $row->{convert} ~~ $replace->{image}->{convert}; # different + $reimage ||= $row->{cover} ~~ $replace->{image}->{cover}; # resize $reimage++ if $fields{rethumb}; # force refresh if ($reimage) { eval { - $image->convert($wordcol{convert}->{-src}->($row), $imagecol->{convert}); + $image->generate($wordcol{convert}->{-src}->($row), $imagecol); } or do { my ($warn, @details) = ref $@ ? @{$@} : $@; Alert([ "Thumbnail image not generated", $warn ], @details); @@ -222,9 +234,9 @@ elsif (defined $post{form}) {{ } }} else { - $row->{lang} //= $user->{editlang}->[0]; + $row->{lang} //= $user->{editlang}->[0] unless exists $row->{lang}; $row->{$_} = $get{$_} for keys %get; - $row->{prio} = defined $row->{ref} ? undef : 1 unless exists $row->{prio}; + $row->{prio} = defined $row->{ref} ? undef : 4 unless exists $row->{prio}; } eval { @@ -251,17 +263,20 @@ for my $col (@wordcols) { my ($attr, @span) = ref $info eq 'ARRAY' ? @{$info} : $info; next if delete $attr->{hidden} and not $row->{$col}; my $title = ref $attr ? delete $attr->{-label} : $attr; - printf '
', $col, $title; + printf '