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:
8f2b055
)
word/edit: hide unset story or keep existing
author
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 15 Aug 2021 02:38:21 +0000
(
04:38
+0200)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 25 Aug 2021 04:53:32 +0000
(06:53 +0200)
writer.js
patch
|
blob
|
history
writer.plp
patch
|
blob
|
history
diff --git
a/writer.js
b/writer.js
index 5d3ad5e782977c43e58213c03db6058f667a2015..6fc79ebcc19c8af97bd9e56164ff00154f0f49ee 100644
(file)
--- a/
writer.js
+++ b/
writer.js
@@
-40,8
+40,8
@@
document.addEventListener('DOMContentLoaded', () => {
// copy first paragraph to story
let wptext = json.parse.text['*'];
let storyinput = document.getElementById('story');
// copy first paragraph to story
let wptext = json.parse.text['*'];
let storyinput = document.getElementById('story');
- if (storyinput && wptext) {
- storyinput.
innerHTML
= wptext
+ if (storyinput &&
!storyinput.value &&
wptext) {
+ storyinput.
value
= wptext
.replace(/<h2.*/s, '') // prefix
.replace(/<table.*?<\/table>/sg, '') // ignore infobox
.match(/<p>(.*?)<\/p>/s)[0] // first paragraph
.replace(/<h2.*/s, '') // prefix
.replace(/<table.*?<\/table>/sg, '') // ignore infobox
.match(/<p>(.*?)<\/p>/s)[0] // first paragraph
diff --git
a/writer.plp
b/writer.plp
index a5aa431cf188dca558183c9aec9738c16b8944bd..c6d5898b77a93870ba9e3f1fbace448b44c13e89 100644
(file)
--- a/
writer.plp
+++ b/
writer.plp
@@
-105,7
+105,7
@@
my %wordcol = (
thumb => {-label => 'Convert options', -multiple => 1, -src => sub {
return "data/word/en/$_[0]->{id}.jpg";
}},
thumb => {-label => 'Convert options', -multiple => 1, -src => sub {
return "data/word/en/$_[0]->{id}.jpg";
}},
- story => {-label => 'Story', type => 'textarea'},
+ story => {-label => 'Story', type => 'textarea'
, hidden => 'hidden'
},
);
if (my $search = $fields{q}) {
);
if (my $search = $fields{q}) {
@@
-228,6
+228,7
@@
bless $row, 'Shiar_Sheet::FormRow';
for my $col (@wordcols) {
my $info = $wordcol{$col} or next;
my ($attr, @span) = ref $info eq 'ARRAY' ? @{$info} : $info;
for my $col (@wordcols) {
my $info = $wordcol{$col} or next;
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 '<li><label for="%s">%s</label><p>', $col, $title;
printf '<span class=inline>';
my $title = ref $attr ? delete $attr->{-label} : $attr;
printf '<li><label for="%s">%s</label><p>', $col, $title;
printf '<span class=inline>';