Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pixel Humain
survey
Commits
26896b3b
Commit
26896b3b
authored
Apr 09, 2020
by
Raph El
Browse files
Form : page config
parent
f1454983
Changes
2
Hide whitespace changes
Inline
Side-by-side
views/tpls/forms/config.php
0 → 100644
View file @
26896b3b
<?php
if
(
$canEditForm
===
true
){
$subFormIds
=
[];
if
(
isset
(
$form
[
"ids"
]))
$subFormIds
=
array_merge
(
$subFormIds
,
$form
[
"ids"
]
);
?>
<div
class=
"col-xs-12 padding-10 text-center bg-info"
>
<h4>
Admin Form
</h4>
<a
href=
'javascript:;'
data-id=
'
<?php
echo
(
String
)
$form
[
"_id"
];
?>
'
class=
"configBtn btn btn-danger bold"
>
<i
class=
'fa fa-cogs'
></i>
CONFIG
</a>
</div>
<?php
}
?>
<script
type=
"text/javascript"
>
var
tplCtx
=
{};
var
form
=
<?php
echo
(
!
empty
(
$form
))
?
json_encode
(
$form
)
:
"null"
;
?>
;
var
subForms
=
<?php
echo
json_encode
(
$subFormIds
)
?>
;
jQuery
(
document
).
ready
(
function
()
{
mylog
.
log
(
"
render
"
,
"
/modules/costum/views/tpls/forms/cplx/answers.php
"
);
$
(
'
.configBtn
'
).
off
().
on
(
"
click
"
,
function
()
{
tplCtx
.
id
=
$
(
this
).
data
(
"
id
"
);
mylog
.
log
(
"
configBtn
"
,
tplCtx
.
id
);
dyFObj
.
openForm
(
oformParams
,
null
,
form
)
});
});
var
oformParams
=
{
jsonSchema
:
{
title
:
"
Configurer le Questionnaire
"
,
description
:
"
lisez bien les options
"
,
icon
:
"
fa-question
"
,
properties
:
{
active
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Activé (Ouvert aux Réponses)
"
,
subLabel
:
"
Activer pour partagé et ouvrir le questionnaire aux réponses.
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Activé
"
},
checked
:
false
},
ids
:
{
inputType
:
"
array
"
,
label
:
"
Nommé chaque étape de votre questionnaire
"
,
//subLabel : "Vous remplirez les question de chaques étapes par la suite",
value
:
[]
},
private
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Privé
"
,
subLabel
:
"
Seul la communauté peut éditer ce questionnaire
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Privé
"
},
checked
:
false
},
canReadOtherAnswers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponses Ouvertes à la lecture
"
,
subLabel
:
"
Les réponses sont elles ouverte à la lecture public
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponses Ouvertes
"
},
checked
:
true
},
startDate
:
{
inputType
:
"
date
"
,
label
:
"
Date de début
"
,
},
endDate
:
{
inputType
:
"
date
"
,
label
:
"
Date de fin
"
},
oneAnswerPerPers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Bloquer à une réponse par personne
"
,
subLabel
:
"
Une personne ne pourra répondre qu'une seule fois
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse unique
"
},
checked
:
true
},
canModify
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponse Modifiable
"
,
subLabel
:
"
une fois soumise les réponses sont elles modifiables
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse Modifiable
"
},
checked
:
true
},
showAnswers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponse Affichés
"
,
subLabel
:
"
Les réponses sont elles affichés publiquement
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse Affichés
"
},
checked
:
true
},
},
beforeBuild
:
function
(){
dyFObj
.
setMongoId
(
'
forms
'
,
function
(){
uploadObj
.
gotoUrl
=
'
#page.type.forms.id.
'
+
uploadObj
.
id
;
});
},
save
:
function
(
formData
)
{
//mylog.log('save tplCtx formData', formData)
tplCtx
.
collection
=
"
forms
"
;
tplCtx
.
path
=
"
allToRoot
"
;
tplCtx
.
value
=
{};
$
.
each
(
oformParams
.
jsonSchema
.
properties
,
function
(
k
,
val
)
{
if
(
val
.
inputType
==
"
properties
"
)
tplCtx
.
value
[
k
]
=
getPairsObj
(
'
.
'
+
k
+
val
.
inputType
);
else
if
(
val
.
inputType
==
"
array
"
){
tplCtx
.
value
[
k
]
=
getArray
(
'
.
'
+
k
+
val
.
inputType
);
if
(
k
==
"
ids
"
){
$
.
each
(
tplCtx
.
value
[
k
],
function
(
ix
,
fName
)
{
if
(
!
$
.
inArray
(
fName
,
subForms
)
==
-
1
){
var
newFormId
=
"
<?php
echo
$el
[
"slug"
]
?>
"
+
subForms
.
length
;
tplCtx
.
value
[
k
][
ix
]
=
newFormId
;
var
newForm
=
{
collection
:
"
forms
"
,
value
:
{
id
:
newFormId
,
name
:
fName
,
type
:
"
openForm
"
,
inputs
:
{}
}
};
dataHelper
.
path2Value
(
newForm
,
function
()
{
}
);
countSubForms
++
;
}
})
}
}
else
tplCtx
.
value
[
k
]
=
$
(
"
#
"
+
k
).
val
();
mylog
.
log
(
"
value
"
,
'
.
'
+
k
+
val
.
inputType
,
tplCtx
.
value
[
k
]);
});
mylog
.
log
(
"
oformParams save tplCtx
"
,
tplCtx
);
if
(
typeof
tplCtx
.
value
==
"
undefined
"
)
toastr
.
error
(
'
value cannot be empty!
'
);
else
{
dataHelper
.
path2Value
(
tplCtx
,
function
(
params
)
{
urlCtrl
.
loadByHash
(
location
.
hash
);
}
);
}
}
}
};
</script>
\ No newline at end of file
views/tpls/forms/oforms.php
View file @
26896b3b
...
...
@@ -32,16 +32,16 @@ foreach ($forms as $fix => $f) {
echo
'<i class="fa fa-file-text-o"></i> '
.
$f
[
$i
][
'name'
]
.
"<br/>"
;
}
}
?>
<a
href=
'javascript:;'
data-id=
'
<?php
echo
$fix
?>
'
class=
"showAnswersBtn btn btn-xs btn-default col-
s
m-4 col-sm-12 bold"
>
<a
href=
'javascript:;'
data-id=
'
<?php
echo
$fix
?>
'
class=
"showAnswersBtn btn btn-xs btn-default col-m
d
-4 col-sm-12 bold"
>
<i
class=
'fa fa-comments'
></i>
(
<?php
echo
$f
[
"answers"
];
?>
)
<?php
echo
(
isset
(
$f
[
'what'
]))
?
$f
[
'what'
]
:
"RÉPONSES"
?>
</a>
<a
href=
'javascript:;'
data-id=
'
<?php
echo
$fix
?>
'
class=
"configBtn btn btn-xs btn-danger col-sm-4 col-sm-12 bold"
>
<!-- <a href='javascript:;' data-id='
<?php
//echo $fix ?>' class="configBtn btn btn-xs btn-danger col-sm-4 col-sm-12 bold">
<
i
class
=
'fa fa-cogs'
></
i
>
CONFIG
</
a
>
-->
<
a
target
=
'_blank'
href
=
'costum/co/index/slug/<?php echo $el["slug"] ?>#form.edit.id.<?php echo $fix ?>'
class
=
"btn btn-xs btn-danger col-md-4 col-sm-12 bold"
>
<
i
class
=
'fa fa-cogs'
></
i
>
CONFIG
</a>
<a
target=
'_blank'
href=
'costum/co/index/slug/
<?php
echo
$el
[
"slug"
]
?>
#form.edit.id.
<?php
echo
$fix
?>
'
class=
"btn btn-xs btn-primary col-sm-4 col-xs-12 bold"
>
<i
class=
'fa fa-file-text-o'
></i>
Edit Form
</
a
>
<a
target=
'_blank'
href=
'costum/co/index/slug/
<?php
echo
$el
[
"slug"
]
?>
#answer.index.id.new.form.
<?php
echo
$fix
?>
'
class=
"btn btn-xs btn-primary col-
s
m-4 col-
x
s-12 bold"
>
<
a
target
=
'_blank'
href
=
'costum/co/index/slug/<?php echo $el["slug"] ?>#answer.index.id.new.form.<?php echo $fix ?>'
class
=
"btn btn-xs btn-primary col-m
d
-4 col-s
m
-12 bold"
>
<
i
class
=
'fa fa-file-text-o'
></
i
>
RÉPONDRE
</
a
>
</
div
>
...
...
@@ -72,11 +72,11 @@ jQuery(document).ready(function() {
},"html");
});
$
(
'
.configBtn
'
).
off
().
on
(
"
click
"
,
function
()
{
tplCtx
.
id
=
$
(
this
).
data
(
"
id
"
);
mylog
.
log
(
"
configBtn
"
,
tplCtx
.
id
);
dyFObj
.
openForm
(
oformParams
,
null
,
formsData
[
$
(
this
).
data
(
"
id
"
)]
)
});
//
$('.configBtn').off().on("click",function() {
//
tplCtx.id = $(this).data("id");
//
mylog.log( "configBtn", tplCtx.id );
//
dyFObj.openForm( oformParams, null, formsData[$(this).data("id")] )
//
});
$('.editFormBtn').off().click( function(){
tplCtx.id = $(this).data("id");
dyFObj.openForm( oformParams, null, formsData[$(this).data("id")] )
...
...
@@ -164,123 +164,123 @@ var oform = {
}
};
var
oformParams
=
{
jsonSchema
:
{
title
:
"
Configurer le Questionnaire
"
,
description
:
"
lisez bien les options
"
,
icon
:
"
fa-question
"
,
properties
:
{
active
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Activé (Ouvert aux Réponses)
"
,
subLabel
:
"
Activer pour partagé et ouvrir le questionnaire aux réponses.
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Activé
"
},
checked
:
false
},
ids
:
{
inputType
:
"
array
"
,
label
:
"
Nommé chaque étape de votre questionnaire
"
,
//subLabel : "Vous remplirez les question de chaques étapes par la suite",
value
:
[]
},
private
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Privé
"
,
subLabel
:
"
Seul la communauté peut éditer ce questionnaire
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Privé
"
},
checked
:
false
},
canReadOtherAnswers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponses Ouvertes à la lecture
"
,
subLabel
:
"
Les réponses sont elles ouverte à la lecture public
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponses Ouvertes
"
},
checked
:
true
},
startDate
:
{
inputType
:
"
date
"
,
label
:
"
Date de début
"
,
},
endDate
:
{
inputType
:
"
date
"
,
label
:
"
Date de fin
"
},
oneAnswerPerPers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Bloquer à une réponse par personne
"
,
subLabel
:
"
Une personne ne pourra répondre qu'une seule fois
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse unique
"
},
checked
:
true
},
canModify
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponse Modifiable
"
,
subLabel
:
"
une fois soumise les réponses sont elles modifiables
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse Modifiable
"
},
checked
:
true
},
showAnswers
:
{
inputType
:
"
checkboxSimple
"
,
label
:
"
Réponse Affichés
"
,
subLabel
:
"
Les réponses sont elles affichés publiquement
"
,
params
:
{
onText
:
"
Oui
"
,
offText
:
"
Non
"
,
onLabel
:
"
Oui
"
,
offLabel
:
"
Non
"
,
labelText
:
"
Réponse Affichés
"
},
checked
:
true
},
},
beforeBuild
:
function
(){
dyFObj
.
setMongoId
(
'
forms
'
,
function
(){
uploadObj
.
gotoUrl
=
'
#page.type.forms.id.
'
+
uploadObj
.
id
;
});
},
save
:
function
(
formData
)
{
//mylog.log('save tplCtx formData', formData)
tplCtx
.
collection
=
"
forms
"
;
tplCtx
.
path
=
"
allToRoot
"
;
tplCtx
.
value
=
{};
//
var oformParams = {
//
jsonSchema : {
//
title : "Configurer le Questionnaire",
//
description : "lisez bien les options",
//
icon : "fa-question",
//
properties : {
//
active : {
//
inputType : "checkboxSimple",
//
label : "Activé (Ouvert aux Réponses)",
//
subLabel : "Activer pour partagé et ouvrir le questionnaire aux réponses.",
//
params : { onText : "Oui", offText : "Non", onLabel : "Oui", offLabel : "Non",
//
labelText : "Activé"},
//
checked : false },
//
ids : {
//
inputType : "array",
//
label : "Nommé chaque étape de votre questionnaire",
//
//subLabel : "Vous remplirez les question de chaques étapes par la suite",
//
value : []
//
},
//
private : {
//
inputType : "checkboxSimple",
//
label : "Privé",
//
subLabel : "Seul la communauté peut éditer ce questionnaire",
//
params : { onText : "Oui", offText : "Non", onLabel : "Oui", offLabel : "Non",
//
labelText : "Privé"},
//
checked : false },
//
canReadOtherAnswers: {
//
inputType : "checkboxSimple",
//
label : "Réponses Ouvertes à la lecture",
//
subLabel : "Les réponses sont elles ouverte à la lecture public",
//
params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
//
labelText : "Réponses Ouvertes"},
//
checked : true },
//
startDate: {
//
inputType : "date",
//
label : "Date de début",
//
},
//
endDate: {
//
inputType : "date",
//
label : "Date de fin"
//
},
//
oneAnswerPerPers: {
//
inputType : "checkboxSimple",
//
label : "Bloquer à une réponse par personne",
//
subLabel : "Une personne ne pourra répondre qu'une seule fois",
//
params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
//
labelText : "Réponse unique"},
//
checked : true },
//
canModify : {
//
inputType : "checkboxSimple",
//
label : "Réponse Modifiable",
//
subLabel : "une fois soumise les réponses sont elles modifiables",
//
params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
//
labelText : "Réponse Modifiable"},
//
checked : true },
//
showAnswers: {
//
inputType : "checkboxSimple",
//
label : "Réponse Affichés",
//
subLabel : "Les réponses sont elles affichés publiquement",
//
params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
//
labelText : "Réponse Affichés"},
//
checked : true },
//
},
//
beforeBuild : function(){
//
dyFObj.setMongoId('forms',function(){
//
uploadObj.gotoUrl = '#page.type.forms.id.'+uploadObj.id;
//
});
//
},
//
save : function (formData) {
//
//mylog.log('save tplCtx formData', formData)
//
tplCtx.collection = "forms";
//
tplCtx.path = "allToRoot";
//
tplCtx.value = {};
$
.
each
(
oformParams
.
jsonSchema
.
properties
,
function
(
k
,
val
)
{
if
(
val
.
inputType
==
"
properties
"
)
tplCtx
.
value
[
k
]
=
getPairsObj
(
'
.
'
+
k
+
val
.
inputType
);
else
if
(
val
.
inputType
==
"
array
"
){
tplCtx
.
value
[
k
]
=
getArray
(
'
.
'
+
k
+
val
.
inputType
);
if
(
k
==
"
ids
"
){
$
.
each
(
tplCtx
.
value
[
k
],
function
(
ix
,
fName
)
{
if
(
!
$
.
inArray
(
fName
,
subForms
)
==
-
1
){
var
newFormId
=
"
<?php
echo
$el
[
"slug"
]
?>
"
+
subForms
.
length
;
tplCtx
.
value
[
k
][
ix
]
=
newFormId
;
var
newForm
=
{
collection
:
"
forms
"
,
value
:
{
id
:
newFormId
,
name
:
fName
,
type
:
"
openForm
"
,
inputs
:
{}
}
};
dataHelper
.
path2Value
(
newForm
,
function
()
{
}
);
countSubForms
++
;
}
})
//
$.each( oformParams.jsonSchema.properties , function(k,val) {
//
if(val.inputType == "properties")
//
tplCtx.value[k] = getPairsObj('.'+k+val.inputType);
//
else if(val.inputType == "array"){
//
tplCtx.value[k] = getArray('.'+k+val.inputType);
//
if(k=="ids"){
//
$.each(tplCtx.value[k],function(ix,fName) {
//
if(!$.inArray(fName, subForms) == -1 ){
//
var newFormId = "
<?php
//
echo $el["slug"] ?>"+subForms.length;
//
tplCtx.value[k][ix] = newFormId;
//
var newForm ={
//
collection : "forms",
//
value : {
//
id : newFormId,
//
name : fName,
//
type : "openForm",
//
inputs : {}
//
}
//
};
//
dataHelper.path2Value( newForm, function() { } );
//
countSubForms++;
//
}
//
})
}
}
else
tplCtx
.
value
[
k
]
=
$
(
"
#
"
+
k
).
val
();
mylog
.
log
(
"
value
"
,
'
.
'
+
k
+
val
.
inputType
,
tplCtx
.
value
[
k
]);
});
mylog
.
log
(
"
oformParams save tplCtx
"
,
tplCtx
);
//
}
//
}
//
else
//
tplCtx.value[k] = $("#"+k).val();
//
mylog.log("value",'.'+k+val.inputType,tplCtx.value[k]);
//
});
//
mylog.log("oformParams save tplCtx",tplCtx);
if
(
typeof
tplCtx
.
value
==
"
undefined
"
)
toastr
.
error
(
'
value cannot be empty!
'
);
else
{
dataHelper
.
path2Value
(
tplCtx
,
function
(
params
)
{
urlCtrl
.
loadByHash
(
location
.
hash
);
}
);
}
//
if(typeof tplCtx.value == "undefined")
//
toastr.error('value cannot be empty!');
//
else {
//
dataHelper.path2Value( tplCtx, function(params) {
//
urlCtrl.loadByHash(location.hash);
//
} );
//
}
}
}
};
//
}
//
}
//
};
</
script
>
Write
Preview
Supports
Markdown
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