diff --git a/_restxq/synopsx.xqm b/_restxq/synopsx.xqm
index 2e4245f..72074ac 100644
--- a/_restxq/synopsx.xqm
+++ b/_restxq/synopsx.xqm
@@ -115,14 +115,42 @@ declare
%rest:query-param("project", "{$project}")
%updating
function config($project) {
- db:create-backup('synopsx'),
- (: supprimer tout attribut défault préexistant :)
- delete node db:open('synopsx', 'config.xml')//@default,
- (: si le projet existe, lui ajouter l'attribut default=true :)
- if (db:open('synopsx', 'config.xml')//dbName/text() = $project) then insert node (attribute { 'default' } { 'true' }) into db:open('synopsx', 'config.xml')//project[dbName/text()=$project]
- else insert node
- {$project}
- {$project}
- into db:open('synopsx', 'config.xml')//projects,
- db:output(web:redirect("/synopsx/config"))
+ db:create-backup('synopsx'),
+ delete node db:open('synopsx', 'config.xml')//@default, (: supprimer tout attribut défault préexistant :)
+ insert node (attribute { 'default' } { 'true' }) into db:open('synopsx', 'config.xml')//project[resourceName/text()=$project],
+ db:output(web:redirect("/synopsx/config"))
+};
+
+
+declare
+ %rest:GET
+ %restxq:path('/synopsx/create-project')
+ %output:method('html')
+ %output:html-version('5.0')
+function create_project() as element(html) {
+ let $queryParams := map {
+
+ }
+ let $outputParams :=map {
+ 'lang' : 'fr',
+ 'layout' : 'create-project.xhtml'
+ }
+ return synopsx.models.synopsx:htmlDisplay($queryParams, $outputParams)
+};
+
+declare
+ %rest:POST
+ %restxq:path('/synopsx/create-project')
+ %output:method('html')
+ %rest:query-param("project", "{$project}")
+ %updating
+function create_project($project) {
+ db:create($project, (), (), map { 'chop': fn:true(), 'textindex': fn:true(),'attrindex': fn:true() }),
+ insert node
+
+ {$project}
+ {$project}
+
+ into db:open('synopsx', 'config.xml')//projects,
+ db:output(web:redirect("/synopsx/config"))
};
diff --git a/models/synopsx.xqm b/models/synopsx.xqm
index 587f38c..b7d7b24 100644
--- a/models/synopsx.xqm
+++ b/models/synopsx.xqm
@@ -41,24 +41,25 @@ declare default function namespace "synopsx.models.synopsx";
: @rmq for testing with new htmlWrapping
:)
declare function getProjectsList($queryParams as map(*)) as map(*) {
- let $databases := db:list()
+ let $projects := db:open('synopsx', 'config.xml')//project
let $meta := map{
- 'title' : 'Liste des bases de données',
- 'count' : fn:string(fn:count($databases)),
+ 'title' : 'Liste des projets',
+ 'count' : fn:string(fn:count($projects)),
'defaultProject' : getDefaultProject()
}
- let $content := for $database in $databases return
- getSynopsxStatus($queryParams, $database)
+ let $content := for $project in $projects return
+ getSynopsxStatus($project)
return map{
'meta' : $meta,
'content' : $content
}
};
-declare function getSynopsxStatus($queryParams as map(*), $database) as map(*) {
- let $isProject := fn:exists(synopsx.models.synopsx:getDb($queryParams)//project[/dbName=$queryParams('database')])
- let $isDefault := $isProject and fn:exists(synopsx.models.synopsx:getDb($queryParams)//project[@default="true"])
- return map {'database':$database,'isProject':fn:string($isProject), 'isDefault':fn:string($isDefault)}
+declare function getSynopsxStatus($project) as map(*) {
+ let $isDefault := if (fn:exists($project/@default) and $project/@default=fn:true())
+ then "checked"
+ else ""
+ return fn:trace(map {'project':fn:string($project/resourceName/text()), 'isDefault':$isDefault})
};
(:~
diff --git a/templates/config.xhtml b/templates/config.xhtml
index 4493f0d..447c4a9 100644
--- a/templates/config.xhtml
+++ b/templates/config.xhtml
@@ -30,31 +30,23 @@
{title}
- {count} bases
- Projet par défaut : {defaultProject}
- Séléctionnez la base de données du projet par défault
- Si votre base n'existe pas encore, créez-la dans le module d'administration puis cliquez ici
-
+
+
+
+ Create new project
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+