From c2f197d735a5db030acef38cf948dff6e3e419c9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Vanel Date: Tue, 11 Dec 2018 17:45:19 +0100 Subject: [PATCH] FIX "summary sentences" #200 - div inside of span was causing HTML display problems - add XML comments --- .../runtime/html/Form2HTMLDisplay.scala | 2 +- .../deductions/runtime/html/TableView.scala | 48 +++++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/scala/html/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala b/scala/html/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala index 7928d6f00..7592fe236 100644 --- a/scala/html/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala +++ b/scala/html/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala @@ -38,7 +38,7 @@ with FormModule[NODE, URI] Unparsed(valueDisplayed) } { makeUserInfoOnTriples(literalEntry, request.getLanguage()) } -
{ if (literalEntry.lang =/= "" && literalEntry.lang =/= "No_language") " > " + literalEntry.lang }
+ { if (literalEntry.lang =/= "" && literalEntry.lang =/= "No_language") " > " + literalEntry.lang } } diff --git a/scala/html/src/main/scala/deductions/runtime/html/TableView.scala b/scala/html/src/main/scala/deductions/runtime/html/TableView.scala index d9665f06d..9df1f51f1 100644 --- a/scala/html/src/main/scala/deductions/runtime/html/TableView.scala +++ b/scala/html/src/main/scala/deductions/runtime/html/TableView.scala @@ -8,6 +8,8 @@ import scala.xml.NodeSeq import deductions.runtime.core.HTTPrequest import scala.xml.Unparsed import deductions.runtime.utils.I18NMessages +import scala.xml.Text +import scala.xml.Comment /** Table View; editable or not; usable one time, table data structures are never cleaned */ trait TableView[NODE, URI <: NODE] @@ -65,7 +67,7 @@ trait TableView[NODE, URI <: NODE] } /** generate HTML summary sentence of URI's à la Google search (#200) from triples in FormSyntax */ - def generateSummarySentences(form: formMod#FormSyntax, request: HTTPrequest): NodeSeq = { + private def generateSummarySentences(form: formMod#FormSyntax, request: HTTPrequest): NodeSeq = { populateTableStructures(form) generateSummarySentencesHTML(request) } @@ -106,14 +108,15 @@ trait TableView[NODE, URI <: NODE]

{ request.getHTTPparameterValue("label").getOrElse("") }

++ -

+

{ for (row <- rows.list) yield { -

+ Text("\n") ++ +

{ uriColumn(row) } { dataSentencesForRow(row, request) }

- } + } ++: Comment(s"""${rows.list.toSeq.size} items for "${rowsMap(row).subjectLabel.replaceAll("--", ",")}" """) }

} @@ -161,24 +164,27 @@ trait TableView[NODE, URI <: NODE] } } - /** data (triple objects) elements */ - private def dataSentencesForRow(row: NODE, request: HTTPrequest) = { - for (property <- properties.list) yield { - Seq( - { - val cellOption = cellsMap.get((row, property)) - cellOption match { - case Some(entriesList) => - for( entry <- entriesList) yield { -// println(s"dataColumns: isEditableFromRequest ${isEditableFromRequest(request)}, entry $entry") - createHTMLField(entry, - editable = isEditableFromRequest(request), - displayInTable = true, request=request )(nullFormSyntax) - } - case _ => "" + /** data (triple objects) elements */ + private def dataSentencesForRow(row: NODE, request: HTTPrequest): NodeSeq = { + val x = for (property <- properties.list.toSeq) yield { + val cellOption = cellsMap.get((row, property)) + val xx = cellOption match { + case Some(entriesList) => + for (entry <- entriesList) yield { + // println(s"dataColumns: isEditableFromRequest ${isEditableFromRequest(request)}, entry $entry") + Comment({entry.label}) ++ + { + createHTMLField( + entry, + editable = isEditableFromRequest(request), + displayInTable = true, request = request)(nullFormSyntax) + } } - }) - } + case _ => NodeSeq.Empty + } + xx . flatten ++ (if (xx.size >1) === else NodeSeq.Empty) + } + x .flatten } /** TODO also elsewhere */