Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jmvanel/semantic_forms
Browse files Browse the repository at this point in the history
  • Loading branch information
jmvanel committed May 30, 2017
2 parents 4a7982e + 7113908 commit 21fe7cc
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$model = $(this).parent().parent().find('.sf-value-block').first().children().first().children().first()
console.log('Clonage du champ :');
console.log($model);
cloneWidget($model)
cloneWidget($model,$(this))
});

$('.image-popup-vertical-fit').magnificPopup({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ trait UserTraceability[Rdf <: RDF, DATASET]
// field.timeMetadata = resultsTimestamp(field.property.toString)
} else field
}
// println(s"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX After add User Info\n${entries.mkString("\n")}")

formSyntax . fields = entries
formSyntax
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,18 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
hrefPrefix: String = config.hrefDisplayPrefix, lang: String = "en",
request: HTTPrequest = HTTPrequest())(implicit form: FormModule[NODE, URI]#FormSyntax): NodeSeq = {

val editableByUser = if (!field.metadata.isEmpty){
field.metadata == request.cookies.get("PLAY_SESSION").get.value.split("=")(1)
}
else true

// hack instead of true form separator in the form spec in RDF:
if (field.label.contains("----"))
return <hr class="sf-separator"/> // Text("----")

val xmlField = field match {
case l: formMod#LiteralEntry =>
if (editable)
if (editable && editableByUser)
createHTMLiteralEditableField(l)
else
createHTMLiteralReadonlyField(l)
Expand All @@ -230,13 +235,13 @@ private[html] trait Form2HTML[NODE, URI <: NODE]
* or (TODO) create a sub-form for a blank node of an ancillary type (like a street address),
* or just create a new resource with its type, given by range, or derived
* (like in N3Form in EulerGUI ) */
if (editable)
if (editable && editableByUser)
createHTMLResourceEditableField(r, lang)
else
createHTMLResourceReadonlyField(r, hrefPrefix, request)

case r: formMod#BlankNodeEntry =>
if (editable)
if (editable && editableByUser)
createHTMLBlankNodeEditableField(r)
else
createHTMLBlankNodeReadonlyField(r, hrefPrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private[html] trait Form2HTMLEdit[NODE, URI <: NODE]
}
<div class={ css.cssClasses.formAddDivCSSClass } > <!-- TODO : hidden="true" -->
<button type="button" class="btn btn-primary add-widget" readonly="yes" size="1" title={
"Add another value for " + field.label } >
"Add another value for " + field.label } input-class={css.cssClasses.formInputCSSClass} input-name={field.htmlName} input-title={ resourceOrBN_Placeholder(field) } >
<i class="glyphicon glyphicon-plus"></i>
</button>
</div>
Expand Down
52 changes: 37 additions & 15 deletions scala/forms_play/public/javascripts/formInteractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,50 @@
/*jslint browser: true*/

/** button with an action to duplicate the original HTML widget with an empty content */
function cloneWidget(widget) {
function cloneWidget(widget,button) {

var addedWidget = $("<input type='text' />"),
parent = widget.parent(),
cardinal = widget.parent().children().length;
console.log("nombre de widgets : "+cardinal);

var widgetName = decodeURIComponent(widget.attr("name")).split("+")
if (widgetName[2][0] == '<' )
widgetName = widgetName[0] +'+'+widgetName[1]+'+<>+.'
else
widgetName = widgetName[0] +'+'+widgetName[1]+'+""+.'
if(widgetName[0] !== 'undefined'){
if (widgetName[2][0] == '<' )
widgetName = widgetName[0] +'+'+widgetName[1]+'+<>+.'
else
widgetName = widgetName[0] +'+'+widgetName[1]+'+""+.'

addedWidget
.val('')
.attr('class',widget.attr('class'))
//.addClass( widget.attr('id'))
.attr('id', widget.attr('id')+'-'+cardinal)
.attr('name', widgetName)
.attr('title', widget.attr('title'))
.attr('hidden', 'false');
parent.prepend(addedWidget, widget);
addedWidget.focus();
}
else {
widgetName = decodeURIComponent(button.attr('input-name')).split("+")
if (widgetName[2][0] == '<' )
widgetName = widgetName[0] +'+'+widgetName[1]+'+<>+.'
else
widgetName = widgetName[0] +'+'+widgetName[1]+'+""+.'

addedWidget
.val('')
.attr('class',button.attr('input-class'))
//.addClass( widget.attr('id'))
.attr('id','new')
.attr('name', widgetName)
.attr('title', button.attr('input-title'))
.attr('hidden', 'false');
parent.prepend(addedWidget, widget);
addedWidget.focus();
}

addedWidget
.val('')
.attr('class',widget.attr('class'))
//.addClass( widget.attr('id'))
.attr('id', widget.attr('id')+'-'+cardinal)
.attr('name', widgetName)
.attr('title', widget.attr('title'))
.attr('hidden', 'false');
parent.prepend(addedWidget, widget);
addedWidget.focus();
return addedWidget;
}

Expand Down
15 changes: 15 additions & 0 deletions scala/scripts/rgraphmove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

OLDGRAPH=$1
NEWGRAPH=$2
if [ -z $3 ]; then SUBJECT="?S"; else SUBJECT="<$3>"; fi

echo "change le sujet $SUBJECT dans le graph <$OLDGRAPH> dans le nouveau graph <$NEWGRAPH>"
echo "DELETE { GRAPH <$OLDGRAPH> { $SUBJECT ?P ?O }} INSERT{ GRAPH <$NEWGRAPH> { $SUBJECT ?P ?O }} WHERE {GRAPH <$OLDGRAPH> { $SUBJECT ?P ?O}}" > /tmp/move_subject_graph.rq

# sbt "runMain tdb.tdbupdate --loc=TDB --verbose --update=/tmp/move_subject_graph.rq"
sbt <<EOF
project forms_play
runMain tdb.tdbupdate --loc=TDB --verbose --update=/tmp/move_subject_graph.rq
EOF
echo "Local SPARQL database in TDB/ : change le sujet $SUBJECT dans le graph <$OLDGRAPH> dans le nouveau graph <$NEWGRAPH>"

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class CreateData extends CornichonFeature {
When I get("http://localhost:9000/create-data")
Then assert status.is(200)
And assert body.path("subject").isPresent
//And assert body.path("fields").asArray.hasSize(3)

And assert body.path("title").isPresent
And assert body.path("formURI").isPresent
And assert body.path("formLabel").isPresent
And assert body.path("fields").asArray.isNotEmpty
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ import java.net.URLEncoder
import com.github.agourlay.cornichon.CornichonFeature

class FORM_DATA extends CornichonFeature {
lazy val url =
"""
http://jmvanel.free.fr/jmv.rdf#me
"""
lazy val url ="http://jmvanel.free.fr/jmv.rdf#me"

def feature = Feature("FORM_DATA") {

Scenario("FORM_DATA") {

get("http://localhost:9000/form-data").withParams(
"displayuri" -> URLEncoder.encode(url)
)
When I get("http://localhost:9000/form-data?displayuri=" + URLEncoder.encode(url))

Then assert status.is(200)
And assert body.path("subject").isPresent
//And assert body.path("form-label").is("Personne FOAF - court")
And assert body.path("formLabel").is("FOAF Person - short form")
And assert body.path("fields").asArray.isNotEmpty
And assert body.path("fields[0].subject").isPresent
//And assert body.path("fields[0].value").is("Jean-Marc")
And assert body.path("fields[0].value").is("Jean-Marc")

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LDP extends CornichonFeature {
When I get("http://localhost:9000/ldp/" + uri)
Then assert status.is(200)
And assert headers.name("Access-Control-Allow-Origin").isPresent

And assert body.path("@id").isPresent
}
}
}
Expand Down

0 comments on commit 21fe7cc

Please sign in to comment.