Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gy4443
chemotion_eln_server
Commits
26e944dc
Commit
26e944dc
authored
Sep 18, 2017
by
jasonych99
Browse files
remove additional space between observation & Rf
parent
3986067a
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/components/report/SectionSiSynthesis.js
View file @
26e944dc
...
...
@@ -7,8 +7,8 @@ import ArrayUtils from '../utils/ArrayUtils';
import
{
Alphabet
}
from
'
../utils/ElementUtils
'
;
import
_
from
'
lodash
'
;
const
insert
Blank
=
(
target
)
=>
{
if
(
target
.
length
===
0
)
return
true
;
const
only
Blank
=
(
target
)
=>
{
if
(
target
.
length
===
0
)
return
true
;
const
content
=
target
.
map
(
t
=>
t
.
insert
).
join
(
''
).
replace
(
/
\s
+/
,
''
);
return
!
content
;
};
...
...
@@ -145,8 +145,7 @@ const obsvTlcContent = (el) => {
let
content
=
[];
content
=
[...
el
.
observation
.
ops
,
...
tlcContent
(
el
)];
content
=
rmOpsRedundantSpaceBreak
(
content
);
if
(
content
.
length
===
0
)
return
[];
if
(
insertBlank
)
return
[];
if
(
onlyBlank
(
content
))
return
[];
return
frontBreak
(
content
);
}
...
...
@@ -168,7 +167,7 @@ const rmHeadSpace = (content) => {
if
(
!
head
)
els
=
[...
els
.
slice
(
1
)];
return
head
;
});
if
(
els
.
length
===
0
||
!
head
)
return
[];
if
(
onlyBlank
(
els
)
||
!
head
)
return
[];
els
[
0
].
insert
=
head
;
return
els
;
...
...
@@ -182,7 +181,7 @@ const rmTailSpace = (content) => {
if
(
!
tail
)
els
=
[...
els
.
slice
(
1
)];
return
tail
;
});
if
(
els
.
length
===
0
||
!
tail
)
return
[];
if
(
onlyBlank
(
els
)
||
!
tail
)
return
[];
els
.
reverse
();
els
[
els
.
length
-
1
].
insert
=
tail
;
...
...
@@ -194,12 +193,12 @@ const opsTailWithSymbol = (els, symbol) => {
};
const
endingSymbol
=
(
content
,
symbol
)
=>
{
if
(
c
on
tent
.
length
===
0
)
return
[];
if
(
on
lyBlank
(
content
)
)
return
[];
let
els
=
rmHeadSpace
(
content
);
els
=
rmTailSpace
(
els
);
if
(
els
.
length
===
0
)
return
[];
if
(
onlyBlank
(
els
)
)
return
[];
return
opsTailWithSymbol
(
els
,
symbol
);
};
...
...
@@ -217,7 +216,7 @@ const analysesContent = (products) => {
content
=
[...
content
,
...
endingSymbol
(
data
.
ops
,
'
;
'
)];
});
});
if
(
c
on
tent
.
length
===
0
)
return
[];
if
(
on
lyBlank
(
content
)
)
return
[];
content
=
rmOpsRedundantSpaceBreak
(
content
);
content
=
[...
content
.
slice
(
0
,
-
1
),
{
insert
:
'
.
'
}];
return
frontBreak
(
content
);
...
...
@@ -239,7 +238,7 @@ const dangContent = (el) => {
const
DangerBlock
=
({
el
})
=>
{
const
block
=
dangContent
(
el
);
return
<
QuillViewer
value
=
{{
ops
:
block
}}
/
>
return
block
.
length
>
0
?
<
QuillViewer
value
=
{{
ops
:
block
}}
/>
: null
;
};
const
ContentBlock
=
({
el
})
=>
{
...
...
lib/reporter/docx/detail.rb
View file @
26e944dc
...
...
@@ -81,7 +81,7 @@ module Reporter
end
end
def
remove_redundant_space_break
(
ops
)
def
remove_redundant_space_break
(
ops
)
# ensure one line
ops
.
map
.
with_index
do
|
op
,
i
|
op
[
"insert"
]
=
op
[
"insert"
].
gsub
(
/[\u00A0\s]{2,}/
,
" "
)
op
[
"insert"
]
=
op
[
"insert"
].
lstrip
if
i
==
0
...
...
lib/reporter/docx/detail_reaction.rb
View file @
26e944dc
...
...
@@ -310,7 +310,8 @@ module Reporter
def
observation
delta_obs
=
obj
.
observation
.
deep_stringify_keys
[
'ops'
]
clean_obs
=
{
'ops'
=>
remove_redundant_space_break
(
delta_obs
)
}
one_line_obs
=
remove_redundant_space_break
(
delta_obs
)
clean_obs
=
{
'ops'
=>
rm_head_tail_space
(
one_line_obs
)
}
Sablon
.
content
(
:html
,
Delta
.
new
(
clean_obs
,
@font_family
).
getHTML
)
end
...
...
@@ -343,13 +344,15 @@ module Reporter
def
observation_delta
delta_obs
=
obj
.
observation
.
deep_stringify_keys
[
'ops'
]
clean_obs
=
remove_redundant_space_break
(
delta_obs
)
clean_obs
one_line_obs
=
remove_redundant_space_break
(
delta_obs
)
rm_head_tail_space
(
one_line_obs
)
end
def
obsv_tlc_delta
observation_delta
+
[{
"insert"
=>
" "
}]
+
tlc_delta
+
obsv_tlc_break_delta
tlc_delta_arr
=
tlc_delta
return
[]
if
obsv_blank
&&
tlc_delta_arr
.
blank?
observation_delta
+
[{
"insert"
=>
"."
}]
+
[{
"insert"
=>
" "
}]
+
tlc_delta_arr
+
[{
"insert"
=>
"
\n
"
}]
end
def
tlc_delta
...
...
@@ -364,11 +367,6 @@ module Reporter
obsv_arr
.
join
(
''
).
gsub
(
/\s+/
,
''
).
blank?
end
def
obsv_tlc_break_delta
return
[]
if
obsv_blank
&&
tlc_delta
.
blank?
[{
"insert"
=>
"
\n
"
}]
end
def
product_analyses_delta
delta
=
[]
obj
.
products
.
each
do
|
product
|
...
...
spec/lib/report/docx/detail_reaction_spec.rb
View file @
26e944dc
...
...
@@ -8,7 +8,8 @@ describe 'Reporter::Docx::DetailReaction instance' do
let
(
:rf
)
{
'correct tlc_rf'
}
let
(
:t_sol
)
{
'correct tlc_solvents'
}
let
(
:t_des
)
{
'correct tlc_description'
}
let
(
:obs
)
{
{
"ops"
=>
[{
"insert"
=>
"correct observation"
}]
}
}
let!
(
:correct_obsv
)
{
"correct observation"
}
let
(
:obs
)
{
{
"ops"
=>
[{
"insert"
=>
"
#{
correct_obsv
}
\n
"
}]
}
}
let
(
:des
)
{
{
"ops"
=>
[{
"insert"
=>
"correct description"
}]
}
}
let
(
:prev_index
)
{
5
}
let
(
:equiv
)
{
0.88
}
...
...
@@ -197,7 +198,8 @@ describe 'Reporter::Docx::DetailReaction instance' do
{
"insert"
=>
"} =
#{
(
equiv
*
100
).
to_i
}
% (0.000 g, 0.000 mmol)"
},
{
"insert"
=>
"."
},
{
"insert"
=>
"
\n
"
},
{
"insert"
=>
"correct observation"
},
{
"insert"
=>
"
#{
correct_obsv
}
"
},
{
"insert"
=>
"."
},
{
"insert"
=>
" "
},
{
"attributes"
=>
{
"italic"
=>
true
},
"insert"
=>
"R"
},
{
"attributes"
=>
{
"italic"
=>
true
,
"script"
=>
"sub"
},
"insert"
=>
"f"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment