aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorjpl2017-08-23 15:36:29 +0200
committerjpl2017-08-23 15:36:39 +0200
commitfd168f1aa111f915ba2a58e24617267fcb5cbe0c (patch)
tree812e7c8751df060e2ec90b6b5643f8ebd3ef25e9 /app
parent6fe3c8ac3f4120fcab85a593062a8c0785b50839 (diff)
downloadchouette-core-fd168f1aa111f915ba2a58e24617267fcb5cbe0c.tar.bz2
Refs #4258: adding overhead feature to table_builder, with static samples on imports#show
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/components/_tables.sass62
-rw-r--r--app/controllers/imports_controller.rb4
-rw-r--r--app/helpers/table_builder_helper.rb150
-rw-r--r--app/views/imports/show.html.slim134
-rw-r--r--app/views/networks/show.html.slim2
5 files changed, 322 insertions, 30 deletions
diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass
index 3fc92d348..b50721f27 100644
--- a/app/assets/stylesheets/components/_tables.sass
+++ b/app/assets/stylesheets/components/_tables.sass
@@ -85,6 +85,67 @@
border-top: 2px solid $darkgrey
margin-top: 15px
+ // Overhead
+ > thead > tr.overhead
+ > th
+ font-size: 1.4rem
+ text-align: center
+
+ &.overheaded-default
+ background-color: rgba($grey, 0.15)
+ background-clip: padding-box
+ border-left: 2px solid rgba($grey, 0.15)
+ border-right: 2px solid rgba($grey, 0.15)
+
+ &.overheaded-danger
+ background-color: $red
+ border-left: 2px solid $red
+ border-right: 2px solid $red
+ color: #fff
+
+ &.overheaded-warning
+ background-color: $orange
+ border-left: 2px solid $orange
+ border-right: 2px solid $orange
+ color: #fff
+
+ &.overheaded-success
+ background-color: $green
+ border-left: 2px solid $green
+ border-right: 2px solid $green
+ color: #fff
+
+ td, th
+ &.overheaded-default
+ border-left: 2px solid rgba($grey, 0.15)
+ border-right: 2px solid rgba($grey, 0.15)
+
+ &.overheaded-danger
+ border-left: 2px solid $red
+ border-right: 2px solid $red
+
+ &.overheaded-warning
+ border-left: 2px solid $orange
+ border-right: 2px solid $orange
+
+ &.overheaded-success
+ border-left: 2px solid $green
+ border-right: 2px solid $green
+
+ tr:last-child
+ td
+ &.overheaded-default
+ border-bottom: 2px solid rgba($grey, 0.15)
+
+ &.overheaded-danger
+ border-bottom: 2px solid $red
+
+ &.overheaded-warning
+ border-bottom: 2px solid $orange
+
+ &.overheaded-success
+ border-bottom: 2px solid $green
+
// Specific for tables displaying stop points
&.has-stoppoints
tbody
@@ -144,7 +205,6 @@
margin-top: -8px
-
// select_toolbox
.select_toolbox
padding: 10px
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 916e5ac23..979c9bfcf 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -6,6 +6,10 @@ class ImportsController < BreadcrumbController
def show
show! do
+ @import = @import.decorate(context: {
+ workbench: @workbench
+ })
+
build_breadcrumb :show
end
end
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index b5497b600..f15019458 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -42,7 +42,8 @@ require 'table_builder_helper/url'
# ),
# ],
# links: [:show, :edit],
-# cls: 'table has-search'
+# cls: 'table has-search',
+# overhead: [ {title: 'one', width: 1, cls: 'toto'}, {title: 'two <span class="test">Info</span>', width: 2, cls: 'default'} ]
# )
module TableBuilderHelper
# TODO: rename this after migration from `table_builder`
@@ -65,19 +66,36 @@ module TableBuilderHelper
links: [],
# A CSS class to apply to the <table>
- cls: ''
+ cls: '',
+
+ # A set of content, over the th line...
+ overhead: []
)
content_tag :table,
- thead(collection, columns, sortable, selectable, links.any?) +
- tbody(collection, columns, selectable, links),
+ thead(collection, columns, sortable, selectable, links.any?, overhead) +
+ tbody(collection, columns, selectable, links, overhead),
class: cls
end
private
- def thead(collection, columns, sortable, selectable, has_links)
+ def thead(collection, columns, sortable, selectable, has_links, overhead)
content_tag :thead do
- content_tag :tr do
+ # Inserts overhead content if any specified
+ over_head = ''
+
+ unless overhead.empty?
+ over_head = content_tag :tr, class: 'overhead' do
+ oh_cont = []
+
+ overhead.each do |h|
+ oh_cont << content_tag(:th, raw(h[:title]), colspan: h[:width], class: h[:cls])
+ end
+ oh_cont.join.html_safe
+ end
+ end
+
+ main_head = content_tag :tr do
hcont = []
if selectable
@@ -85,14 +103,58 @@ module TableBuilderHelper
end
columns.each do |column|
- hcont << content_tag(:th, build_column_header(
- column,
- sortable,
- collection.model,
- params,
- params[:sort],
- params[:direction]
- ))
+ if overhead.empty?
+ hcont << content_tag(:th, build_column_header(
+ column,
+ sortable,
+ collection.model,
+ params,
+ params[:sort],
+ params[:direction]
+ ))
+
+ else
+ i = columns.index(column)
+
+ if overhead[i].blank?
+ if (i > 0) && (overhead[i - 1][:width] > 1)
+ clsArrayH = overhead[i - 1][:cls].split
+
+ hcont << content_tag(:th, build_column_header(
+ column,
+ sortable,
+ collection.model,
+ params,
+ params[:sort],
+ params[:direction]
+ ), class: td_cls(clsArrayH))
+
+ else
+ hcont << content_tag(:th, build_column_header(
+ column,
+ sortable,
+ collection.model,
+ params,
+ params[:sort],
+ params[:direction]
+ ))
+ end
+
+ else
+ clsArrayH = overhead[i][:cls].split
+
+ hcont << content_tag(:th, build_column_header(
+ column,
+ sortable,
+ collection.model,
+ params,
+ params[:sort],
+ params[:direction]
+ ), class: td_cls(clsArrayH))
+
+ end
+
+ end
end
# Inserts a blank column for the gear menu
@@ -102,10 +164,12 @@ module TableBuilderHelper
hcont.join.html_safe
end
+
+ (over_head + main_head).html_safe
end
end
- def tbody(collection, columns, selectable, links)
+ def tbody(collection, columns, selectable, links, overhead)
content_tag :tbody do
collection.map do |item|
@@ -128,9 +192,53 @@ module TableBuilderHelper
item,
referential
)
- bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir')
+
+ if overhead.empty?
+ bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir')
+
+ else
+ i = columns.index(column)
+
+ if overhead[i].blank?
+ if (i > 0) && (overhead[i - 1][:width] > 1)
+ clsArrayAlt = overhead[i - 1][:cls].split
+
+ bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir', class: td_cls(clsArrayAlt))
+
+ else
+ bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir')
+ end
+
+ else
+ clsArray = overhead[columns.index(column)][:cls].split
+
+ bcont << content_tag(:td, link_to(value, polymorph_url), title: 'Voir', class: td_cls(clsArray))
+ end
+ end
+
else
- bcont << content_tag(:td, value)
+ if overhead.empty?
+ bcont << content_tag(:td, value)
+
+ else
+ i = columns.index(column)
+
+ if overhead[i].blank?
+ if (i > 0) && (overhead[i - 1][:width] > 1)
+ clsArrayAlt = overhead[i - 1][:cls].split
+
+ bcont << content_tag(:td, value, class: td_cls(clsArrayAlt))
+
+ else
+ bcont << content_tag(:td, value)
+ end
+
+ else
+ clsArray = overhead[i][:cls].split
+
+ bcont << content_tag(:td, value, class: td_cls(clsArray))
+ end
+ end
end
end
@@ -148,6 +256,14 @@ module TableBuilderHelper
end
end
+ def td_cls(a)
+ if a.include? 'full-border'
+ a.slice!(a.index('full-border'))
+
+ return a.join(' ')
+ end
+ end
+
def build_links(item, links)
trigger = content_tag(
:div,
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index b40e11ea4..65e3f33ff 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -1,14 +1,126 @@
-.title.row
- .col-md-8
- = title_tag job_status_title(@import)
+/ PageHeader
+= pageheader 'map-marker',
+ @import.name,
+ '',
+ t('last_update', time: l(@import.updated_at, format: :short)) do
+
+ / Below is secundary actions & optional contents (filters, ...)
+ .row
+ .col-lg-12.text-right.mb-sm
+ - @import.action_links.each do |link|
+ = link_to link.href,
+ method: link.method,
+ data: link.data,
+ class: 'btn btn-primary' do
+ = link.content
-.import_show
- .links
- = link_to font_awesome_classic_tag("fa-file-#{@import.file.file.extension}-o") + t("imports.show.imported_file"), @import.file.url
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = definition_list t('metadatas'), { 'Récupération des données' => '-', "Nom de l'archive" => @import.try(:file_identifier)}
-- content_for :sidebar do
- ul.actions
- li
- = link_to t('imports.actions.destroy'), workbench_import_path(@workbench, @import.id), method: :delete, data: {confirm: t('imports.actions.destroy_confirm')}, class: 'remove'
+ / .row
+ / .col-lg-12
+ / = table_builder_2 Import.all,
+ / [ \
+ / TableBuilderHelper::Column.new( \
+ / key: :status, \
+ / attribute: 'status' \
+ / ), \
+ / TableBuilderHelper::Column.new( \
+ / key: :started_at, \
+ / attribute: 'started_at' \
+ / ), \
+ / TableBuilderHelper::Column.new( \
+ / key: :name, \
+ / attribute: 'name' \
+ / ), \
+ / TableBuilderHelper::Column.new( \
+ / key: :creator, \
+ / attribute: 'creator' \
+ / ) \
+ / ],
+ / links: [],
+ / cls: 'table',
+ / overhead: [ \
+ / {}, \
+ / { \
+ / title: 'Lorem ipsum dolor sit amet', \
+ / width: 1, \
+ / cls: 'overheaded-danger full-border' \
+ / }, { \
+ / title: 'Toto <span title="Lorem ipsum..." class="fa fa-lg fa-info-circle text-info"></span>', \
+ / width: 2, \
+ / cls: 'overheaded-default' \
+ / } \
+ / ]
- = history_tag(@import)
+ .row
+ .col-lg-12
+ / TMP static table
+ table.table
+ thead
+ tr
+ th Nom du jeu de données
+ th Conformité Netex
+ th Contrôle STIF
+ th Contrôle organisation
+ th
+
+ tbody
+ tr
+ td Nom JDD #1
+ td.text-center
+ span.fa.fa-circle.text-success
+ td.text-center
+ span.fa.fa-circle.text-danger
+ td.text-center -
+ td.actions
+ .btn-group
+ .btn.dropdown-toggle data-toggle='dropdown'
+ span.fa.fa-cog
+
+ ul.dropdown-menu
+ li
+ = link_to 'Rapport de contrôle STIF', '#'
+ li
+ = link_to 'Rapport de contrôle Orga.', '#'
+
+ tr
+ td Nom JDD #2
+ td.text-center
+ span.fa.fa-circle.text-warning
+ td.text-center
+ span.fa.fa-circle.text-warning
+ td.text-center -
+ td.actions
+ .btn-group
+ .btn.dropdown-toggle data-toggle='dropdown'
+ span.fa.fa-cog
+
+ ul.dropdown-menu
+ li
+ = link_to 'Rapport de contrôle STIF', '#'
+ li
+ = link_to 'Rapport de contrôle Orga.', '#'
+
+ tr
+ td Nom JDD #3
+ td.text-center
+ span.fa.fa-circle.text-danger
+ td.text-center
+ span.fa.fa-circle.text-danger
+
+ td.text-center -
+ td.actions
+ .btn-group
+ .btn.dropdown-toggle data-toggle='dropdown'
+ span.fa.fa-cog
+
+ ul.dropdown-menu
+ li
+ = link_to 'Rapport de contrôle STIF', '#'
+ li
+ = link_to 'Rapport de contrôle Orga.', '#'
diff --git a/app/views/networks/show.html.slim b/app/views/networks/show.html.slim
index 09edbad2e..5726daa2b 100644
--- a/app/views/networks/show.html.slim
+++ b/app/views/networks/show.html.slim
@@ -1,7 +1,7 @@
/ PageHeader
= pageheader 'map-marker',
@network.name,
- 'Lorem ipsum dolor sit amet',
+ '',
t('last_update', time: l(@network.updated_at, format: :short)) do
/ Below is secundary actions & optional contents (filters, ...)