Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
validata-ui
Commits
81f84faa
Commit
81f84faa
authored
Oct 04, 2018
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Template refactoring
parent
938ccb79
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
97 deletions
+109
-97
validata_ui_next/templates/table_macros.html
validata_ui_next/templates/table_macros.html
+68
-0
validata_ui_next/templates/table_preview.html
validata_ui_next/templates/table_preview.html
+0
-23
validata_ui_next/templates/validation_report.html
validata_ui_next/templates/validation_report.html
+20
-51
validata_ui_next/views.py
validata_ui_next/views.py
+21
-23
No files found.
validata_ui_next/templates/table_macros.html
0 → 100644
View file @
81f84faa
{% macro preview(source_data) %}
<p
class=
"text"
>
Affichage de {{ source_data.preview_rows_nb }} lignes sur {{ source_data.rows_nb }} au total
</p>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-bordered table-sm table-hover"
>
<thead
class=
"thead-light"
>
<tr>
{% for col in source_data.header %}
<th
scope=
"col"
>
{{ col }}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in source_data.preview_rows %}
<tr>
{% for val in row %}
<td>
{{ val }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro body_errors(report, source_data) %}
<h3>
Problèmes de contenu
</h3>
<div
class=
"table-responsive-sm"
>
<table
class=
"table-sm table-bordered table-striped table-hover"
>
<thead
class=
"thead-light"
>
<th
scope=
"col"
>
1
</th>
{% for h in report.table.headers %}
<th
scope=
"col"
data-toggle=
"tooltip"
title=
"{{ report.table.headers_title[loop.index - 1]}}"
>
{{ h }}
</th>
{% endfor %}
</thead>
<tbody>
{% for row in report.table.errors.by_rows %}
<tr>
{% if 'row' in row.errors %}
<th
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
>
{{
row.row_id
}}
</th>
{% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
{% for _ in report.table.headers %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
></td>
{% endfor %}
{% endif %}
{% else %}
<th>
{{ row.row_id }}
</th>
{% endif %}
{% for d in source_data.data_rows[row.row_id - 2] %}
{% if loop.index in row.errors %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors[loop.index].message }}"
>
{% elif 'row' in row.errors %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
>
{% else %}
<td>
{% endif %}
{{ d }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
\ No newline at end of file
validata_ui_next/templates/table_preview.html
deleted
100644 → 0
View file @
938ccb79
<p
class=
"text"
>
Affichage de {{ source_data.preview_rows_nb }} lignes sur {{ source_data.rows_nb }} au total
</p>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-bordered table-sm table-hover"
>
<thead
class=
"thead-light"
>
<tr>
{% for col in source_data.header %}
<th
scope=
"col"
>
{{ col }}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in source_data.preview_rows %}
<tr>
{% for val in row %}
<td>
{{ val }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
\ No newline at end of file
validata_ui_next/templates/validation_report.html
View file @
81f84faa
...
@@ -26,12 +26,13 @@
...
@@ -26,12 +26,13 @@
</div>
</div>
</div>
</div>
{% import 'table_macros.html' as tables %}
{% if report.error_count == 0 %}
{% if report.error_count == 0 %}
<h2>
La table est valide
</h2>
<h2>
La table est valide
</h2>
<p>
Aucune erreur détectée
</p>
<p>
Aucune erreur détectée
</p>
{
% include '
table
_
preview
.html' %
}
{
{
table
s.
preview
(source_data) }
}
{% else %}
{% else %}
...
@@ -58,53 +59,21 @@
...
@@ -58,53 +59,21 @@
{% if report.table.errors.body %}
{% if report.table.errors.body %}
{% if not report.table.display_body_errors %}
{% if not report.table.display_body_errors %}
Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
<p
class=
"text"
>
Veuillez corriger ce(s) erreur(s) pour visualiser les problèmes de contenu.
<br
/>
<a
href=
"#"
id=
"show_body_errors"
title=
"Attention, en cas de problème sur les colonnes, certains messages d'errur ne seront pas pertinents"
>
Affichez
tout de même les erreurs de valeur
</a>
</p>
<div
id=
"body_errors"
style=
"display: none"
>
{{ tables.body_errors(report, source_data) }}
</div>
{% else %}
{% else %}
<div>
<div>
<h3>
Problèmes de contenu
</h3>
{{ tables.body_errors(report, source_data) }}
<div
class=
"table-responsive-sm"
>
<table
class=
"table-sm table-bordered table-striped table-hover"
>
<thead
class=
"thead-light"
>
<th
scope=
"col"
>
1
</th>
{% for h in report.table.headers %}
<th
scope=
"col"
data-toggle=
"tooltip"
title=
"{{ report.table.headers_title[loop.index - 1]}}"
>
{{ h }}
</th>
{% endfor %}
</thead>
<tbody>
{% for row in report.table.errors.by_rows %}
<tr>
{% if 'row' in row.errors %}
<th
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
>
{{
row.row_id
}}
</th>
{% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
{% for _ in report.table.headers %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
></td>
{% endfor %}
{% endif %}
{% else %}
<th>
{{ row.row_id }}
</th>
{% endif %}
{% for d in source_data.data_rows[row.row_id - 2] %}
{% if loop.index in row.errors %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors[loop.index].message }}"
>
{% elif 'row' in row.errors %}
<td
class=
"table-danger"
data-toggle=
"tooltip"
title=
"{{ row.errors.row.message }}"
>
{% else %}
<td>
{% endif %}
{{ d }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
...
@@ -112,12 +81,12 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
...
@@ -112,12 +81,12 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
<script>
<script>
$
(
function
()
{
$
(
function
()
{
// Errors tooltip activate
// Errors tooltip activate
$
(
'
[data-toggle="tooltip"]
'
).
tooltip
()
$
(
'
[data-toggle="tooltip"]
'
).
tooltip
()
;
//
Reload to re-validate
//
Show body errors
$
(
'
#
btn-reload
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#
show_body_errors
'
).
on
(
'
click
'
,
function
()
{
$
(
this
).
prop
(
'
disabled
'
,
true
)
$
(
'
#body_errors
'
).
show
();
window
.
location
.
reload
(
true
);
$
(
this
).
remove
(
);
})
})
})
})
</script>
</script>
...
@@ -127,4 +96,4 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
...
@@ -127,4 +96,4 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
{{ report.table.errors.body|length }} erreur(s) détectée(s)
{{ report.table.errors.body|length }} erreur(s) détectée(s)
#}
#}
{% endblock %}
{% endblock %}
\ No newline at end of file
validata_ui_next/views.py
View file @
81f84faa
...
@@ -156,32 +156,30 @@ def create_validata_report(goodtables_report, schema):
...
@@ -156,32 +156,30 @@ def create_validata_report(goodtables_report, schema):
else
:
else
:
report
[
'table'
][
'errors'
][
'body'
].
append
(
err
)
report
[
'table'
][
'errors'
][
'body'
].
append
(
err
)
# If there are structure errors different to invalid-column-delimiter
# Checks if there are structure errors different to invalid-column-delimiter
# => don't display body errors
report
[
'table'
][
'display_body_errors'
]
=
all
(
err
[
'code'
]
==
'invalid-column-delimiter'
report
[
'table'
][
'display_body_errors'
]
=
all
(
err
[
'code'
]
==
'invalid-column-delimiter'
for
err
in
report
[
'table'
][
'errors'
][
'structure'
])
for
err
in
report
[
'table'
][
'errors'
][
'structure'
])
if
report
[
'table'
][
'display_body_errors'
]:
# Group body errors by row id
# and group body errors by row id
rows
=
[]
rows
=
[]
current_row_id
=
0
current_row_id
=
0
for
err
in
report
[
'table'
][
'errors'
][
'body'
]:
for
err
in
report
[
'table'
][
'errors'
][
'body'
]:
if
not
'row-number'
in
err
:
if
not
'row-number'
in
err
:
print
(
'ERR'
,
err
)
print
(
'ERR'
,
err
)
row_id
=
err
[
'row-number'
]
row_id
=
err
[
'row-number'
]
del
err
[
'row-number'
]
del
err
[
'row-number'
]
del
err
[
'context'
]
del
err
[
'context'
]
if
row_id
!=
current_row_id
:
if
row_id
!=
current_row_id
:
current_row_id
=
row_id
current_row_id
=
row_id
rows
.
append
({
'row_id'
:
current_row_id
,
'errors'
:
{}})
rows
.
append
({
'row_id'
:
current_row_id
,
'errors'
:
{}})
column_id
=
err
.
get
(
'column-number'
)
column_id
=
err
.
get
(
'column-number'
)
if
column_id
is
not
None
:
if
column_id
is
not
None
:
del
err
[
'column-number'
]
del
err
[
'column-number'
]
rows
[
-
1
][
'errors'
][
column_id
]
=
err
rows
[
-
1
][
'errors'
][
column_id
]
=
err
else
:
else
:
rows
[
-
1
][
'errors'
][
'row'
]
=
err
rows
[
-
1
][
'errors'
][
'row'
]
=
err
report
[
'table'
][
'errors'
][
'by_rows'
]
=
rows
report
[
'table'
][
'errors'
][
'by_rows'
]
=
rows
return
report
return
report
...
...
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