Commit e0aa4ec0 authored by Chenu Denis's avatar Chenu Denis

[feature] Allow participant to ask help to other‘s

parent f1667624
#modal-create-partial-token-survey .modal-body {
overflow:auto;
}
#modal-create-partial-token-survey fieldset {
padding: .35em .625em .75em;
margin: 0 2px;
border: 1px solid #ccc;
}
#modal-create-partial-token-survey legend {
font-size: inherit;
line-height: inherit;
border-color:#ccc;
}
#modal-create-partial-token-survey ul.form-horizontal {
padding: 0 20px;
}
#modal-create-partial-token-survey .question-item{padding-top: 0}
/*
#modal-create-partial-token-survey .form-horizontal {
padding-left:15px;
padding-right:15px;
}
#modal-create-partial-token-survey .form-horizontal .form-group{position:relative}
#modal-create-partial-token-survey .checkbox-item input[type="checkbox"], #modal-create-partial-token-survey .checkbox-item input[type="radio"] {
opacity: 0;
z-index: -1;
position: absolute;
left: 0;
margin-left: 0;
top:50%;margin-top:-4px;
width:1.5em;height:1.5em;
}
#modal-create-partial-token-survey .checkbox-item input[type="checkbox"] {
border-radius: 3px;
}
#modal-create-partial-token-survey .checkbox-item label{
display:block;
}
#modal-create-partial-token-survey .checkbox-item label::after{
top:50%;margin-top:-4px;border-radius: 3px;padding:0;text-align:center;width:1.5em;height:1.5em;border: 1px solid #cccccc;font-size: 12px;
background-color: transparent;
color: #328637;
}
#modal-create-partial-token-survey .checkbox-item label::before{top:50%;margin-top:-4px;padding:0;width:1.5em;height:1.5em;font-size: 12px;}
#modal-create-partial-token-survey .checkbox-item label::before,
#modal-create-partial-token-survey .checkbox-item label::after {
margin-left: 0;
left: 0;
}
#modal-create-partial-token-survey .checkbox-item label::after {
border:0px none;
}
.checkbox-item input[type="checkbox"]:focus + label::before, .checkbox-item input[type="radio"]:focus + label::before,
.checkbox-item input[type="checkbox"]:focus + label::after, .checkbox-item input[type="radio"]:focus + label::after {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
*/
.form-horizontal .checkbox-item .control-label {
text-align: left;
}
#modal-create-partial-token-survey .form-horizontal .control-label {
font-weight:normal;
max-height:6em;
}
#modal-create-partial-token-survey .form-horizontal .checkbox-item {
padding-left: 0;
}
var partialTokenSurveyFill = {
init : function (options) {
if(!$('[data-showtokenfillmanagement]').length) {
$("#navigator-container").append("<div class='col-xs-12'><button type='button' data='showtokenfillmanagement' class='btn btn-default'>"+options.lang.buttonAction+"</button></div>");
}
$("[data='showtokenfillmanagement']").on("click",partialTokenSurveyFill.openTokenFillManagement);
$("#modal-create-partial-token-survey button:submit").on("click",partialTokenSurveyFill.createTokenFilterSurvey);
$("#modal-create-partial-token-survey").on("shown.bs.modal",function(e) {
if(e.target) {
partialTokenSurveyFill.updateHeightModalbody(e.target);
}
});
},
openTokenFillManagement : function(event) {
event.preventDefault();
$("#modal-create-partial-token-survey").modal('show');
},
createTokenFilterSurvey : function(event,data){
//~ event.preventDefault();
data = $.extend({source:null}, data);
if(data.source == 'control') {
return;
}
event.preventDefault();
var $form = $("#modal-create-partial-token-survey form")[0];
if (!$form.checkValidity()) {
$(event.target).trigger('click',{source:'control'});
return;
}
var url = $("#modal-create-partial-token-survey form").attr("action");
var params = $("#modal-create-partial-token-survey form").serializeArray();
$("#modal-create-partial-token-survey .ajax-result").html("");
$.ajax({
url : url,
type : 'POST',
data : params,
dataType : 'json'
})
.done(function(data) {
data = $.extend({}, {status:'warning'}, data);
if(data.status == "success" || data.status == "info") {
//$("#modal-create-partial-token-survey form").hide();
var htmlAlert = "<div class='alert alert-"+data.status+"'>"+data.html+"</div>";
$("#modal-create-partial-token-survey .ajax-result").html(htmlAlert);
$("#modal-create-partial-token-survey .modal-body").animate({
scrollTop: $("#modal-create-partial-token-survey .modal-body .ajax-result").position().top
}, 500);
$("#modal-create-partial-token-survey form").find("input[type='email'],input:text,textarea").each(function(){
$(this).val("");
if($(this).data("default")) {
$(this).val($(this).data("default"));
}
});
//~ if($("#emailbody").data("wysihtml5")) {
//~ $("#emailbody").data("wysihtml5").editor.setValue($("#emailbody").data("default"));
//~ }
//~ if($("#emailmessage").data("wysihtml5")) {
//~ $("#emailmessage").data("wysihtml5").editor.setValue($("#emailmessage").data("default"));
//~ }
return;
}
if(data.html) {
var className = data.status;
if(data.status == 'error') {
className = 'danger';
}
var htmlAlert = "<div class='alert alert-"+className+"'>"+data.html+"</div>";
$("#modal-create-partial-token-survey .ajax-result").html(htmlAlert);
$("#modal-create-partial-token-survey .modal-body").animate({
scrollTop: $("#modal-create-partial-token-survey .modal-body .ajax-result").position().top
}, 500);
return;
}
})
.fail(function( jqXHR, textStatus ) {
$("#modal-create-partial-token-survey .ajax-result").html("<div class='alert alert-danger'>"+jqXHR.responseText+"</div>");
$("#modal-create-partial-token-survey .modal-body").animate({
scrollTop: $("#modal-create-partial-token-survey .modal-body .ajax-result").position().top
}, 500);
});
return;
},
updateHeightModalbody : function (modal)
{
var navbarFixed=0;
if(false && (".navbar-fixed-top").length) {
navbarFixed=$(".navbar-fixed-top").outerHeight();
}
var modalHeader = 0;
if($(modal).find(".modal-header").length) {
modalHeader = $(modal).find(".modal-header").outerHeight();
}
var modalFooter = 0;
if($(modal).find(".modal-footer").length) {
modalFooter = $(modal).find(".modal-footer").outerHeight();
}
var finalHeight=Math.max(400,$(window).height()-(navbarFixed+modalHeader+modalFooter+38));// Not less than 150px
$(modal).find(".modal-lg").css("margin-top",navbarFixed+4).css("margin-bottom",4);
console.log([
$(window).height(),
modalHeader,
finalHeight,
]);
$(modal).find(".modal-body").height(finalHeight);
//$(modal).find(".modal-body > iframe").css("height",finalHeight);
}
}
/* html(parser rules */
var wysihtml5ParserRules = {
tags: {
strong: {},
b: {
rename_tag: "strong"
},
em: {},
i: {
rename_tag: "em"
},
br: {},
p: {},
div: {},
span: {},
ul: {},
ol: {},
li: {},
a: {
set_attributes: {
target: "_blank"
},
check_attributes: {
href: "url"
}
},
img: {
check_attributes: {
src: "url",
width : "numbers",
alt : "alt",
height : "numbers"
},
},
link: {
remove: 1
},
script: {
remove: 1
}
}
};
<?php
/**
* This file is part of reloadAnyResponse plugin
*/
namespace partialTokenSurveyFill\models;
use Yii;
use LSActiveRecord;
class tokenFilter extends LSActiveRecord
{
/**
* Class surveyChaining\models\chainingResponseLink
*
* @property integer $sid survey
* @property integer $srid : response id
* @property string $token : token
* @property string $filter (json string)
* @property string $sourcetoken : token that create the token
*/
/** @inheritdoc */
public static function model($className=__CLASS__) {
return parent::model($className);
}
/** @inheritdoc */
public function tableName()
{
// todo : find a way to use API
return '{{partialtokensurveyfill_tokenFilter}}';
}
/** @inheritdoc */
public function primaryKey()
{
return array('sid', 'token');
}
public function rules()
{
return array(
array('sid', 'numerical', 'integerOnly'=>true),
array('srid', 'numerical', 'integerOnly'=>true),
array('srid', 'required'),
array('token', 'length', 'min' => 1, 'max'=>50),
array('sourcetoken', 'length', 'min' => 1, 'max'=>50),
);
}
public function setFilters($filters)
{
$this->filter = json_encode($filters);
}
public function getFilter()
{
return json_decode($this->filter);
}
/**
* Return (or create) self
* @param integer $sid survey
* @param integer $srid : response id
* @param string $filters : filter to be set
* @return self::model()
*/
//~ public static function setFilter($sid,$token,$filters)
//~ {
//~ $oTokenFilter = self::model()->findByPk(['sid'=>$sid,'token'=>$token]);
//~ if(!$oTokenFilter) {
//~ $oTokenFilter = new self;
//~ $oTokenFilter->sid = $sid;
//~ $oTokenFilter->token = $token;
//~ }
//~ $oTokenFilter->filters = json_encode($filters);
//~ $oResponseLink->save();
//~ return $oResponseLink;
//~ }
/**
* Get filters
* @return null|array
*/
public function getSgqaFilters()
{
if(empty($this)) {
return null;
}
$filters = json_decode($this->filter);
if(empty($filters)) {
return array();
}
if(!is_array($filters)) {
return array();
}
$sgqaFilters = array();
foreach($filters as $qid) {
$oQuestion = \Question::model()->find('qid = :qid and sid = :sid',array(':qid'=>$qid,':sid'=>$this->sid));
if($oQuestion && !$oQuestion->parent_qid) {
$sgqaFilters = array_merge($sgqaFilters,\getQuestionInformation\helpers\surveyCodeHelper::getQuestionColumn($qid));
} else {
\Yii::log("Invalid question id $qid for {$this->token} in {$this->sid}", 'warning', 'plugin.partialTokenSurveyFill.models.tokenFilter.getSgqaFilters');
}
}
return $sgqaFilters;
}
}
This diff is collapsed.
<div class="modal fade" tabindex="-1" role="dialog" id="modal-create-token">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Create a new user and send an invite</h4>
</div>
<div class="modal-body">
<?php echo CHtml::beginForm($addUser['action'],'post',array('class'=>'form-horizontal')); ?>
<div id="create-token-errors"></div>
<fieldset>
<legend>User attribute</legend>
<ul class='list-unstyled'>
<li class="form-group"><?php echo CHtml::label(gT("First name"),'tokenattribute_firstname',array('class'=>"col-sm-4 control-label")) . CHtml::tag("div",array('class'=>"col-sm-7"),CHtml::textField('tokenattribute[firstname]','',array('class'=>'form-control','data-default'=>''))); ?></li>
<li class="form-group"><?php echo CHtml::label(gT("Last name"),'tokenattribute_lastname',array('class'=>"col-sm-4 control-label")) . CHtml::tag("div",array('class'=>"col-sm-7"),CHtml::textField('tokenattribute[lastname]','',array('class'=>'form-control','data-default'=>''))); ?></li>
<li class="form-group"><?php echo CHtml::label(gT("Email"),'tokenattribute_email',array('class'=>"col-sm-4 control-label")) . CHtml::tag("div",array('class'=>"col-sm-7"),CHtml::emailField('tokenattribute[email]','',array('class'=>'form-control','data-default'=>'','required'=>'required'))); ?></li>
<?php foreach($addUser['attributes'] as $attribute=>$aAttribute) {
echo CHtml::tag("li",array('class'=>"form-group"),
CHtml::label($aAttribute['caption'],'tokenattribute_'.$attribute,array('class'=>"col-sm-4 control-label"))
. CHtml::tag("div",array('class'=>"col-sm-7"),
CHtml::textField('tokenattribute['.$attribute.']','',array('class'=>'form-control','data-default'=>'','required'=>($aAttribute['mandatory'] == 'Y')))
)
);
}?>
<?php if($addUser["attributeGroup"]) {
$label = CHtml::label($addUser["attributeGroup"]["caption"],'tokenattribute_'.$addUser["attributeGroup"]["attribute"],array('class'=>"col-sm-4 control-label"));
$field = CHtml::textField('tokenattribute['.$addUser["attributeGroup"]["attribute"].']','',array('class'=>'form-control','data-default'=>'','required'=>($addUser["attributeGroup"]['mandatory'] == 'Y')));
echo CHtml::tag("hr");
echo CHtml::tag("li",array('class'=>"form-group"),
$label
. CHtml::tag("div",array('class'=>"col-sm-7"),
$field
)
);
}?>
<?php if($addUser["tokenAttributeGroupManager"]) {
//$field = CHtml::checkBox('tokenattribute['.$addUser["tokenAttributeGroupManager"]["attribute"].']',false,array('class'=>''));
$label = CHtml::label($addUser["tokenAttributeGroupManager"]["caption"],'tokenattribute_',array('class'=>"col-sm-4 control-label"));
$field = CHtml::textField('tokenattribute['.$addUser["tokenAttributeGroupManager"]["attribute"].']','',array('class'=>'form-control','data-default'=>''));
echo CHtml::tag("li",array('class'=>"form-group"),
$label
. CHtml::tag("div",array('class'=>"col-sm-7"),
$field
)
);
}?>
</ul>
</fieldset>
<fieldset>
<legend>Email to send</legend>
<ul class='list-unstyled'>
<li class="form-group"><?php
echo CHtml::label(gT("Subject"),'emailsubject',array('class'=>"col-sm-4 control-label"))
. CHtml::tag("div",
array('class'=>"col-sm-7"),
CHtml::textField('emailsubject',$addUser['email']['subject'],array('class'=>'form-control','data-default'=>$addUser['email']['subject']))
);
?></li>
<li class="form-group">
<?php
$textArea = Chtml::textArea('email[body]',$addUser['email']['body'],array('rows'=>20,'class'=> 'form-control','data-default'=>$addUser['email']['body']));
if($addUser['email']['html']) {
$textArea = Yii::app()->getController()->widget('yiiwheels.widgets.html5editor.WhHtml5Editor', array(
'name' => 'emailbody',
'value' => $addUser['email']['body'],
'pluginOptions' => array(
'html' => true,
'lists' => false,
'image'=>false,
'link'=>false,
'useLineBreaks'=>false,// False broke reading …
'autoLink'=>true,
'parserRules'=>'js:wysihtml5ParserRules'
),
'htmlOptions' => array(
'class'=> 'form-control',
'data-default'=>$addUser['email']['body'],
),
),true);
}
echo CHtml::label(gT("Body"),'emailbody',array('class'=>"col-sm-4 control-label")) .
CHtml::tag("div",array('class'=>"col-sm-7"),
$textArea . "<p class='help-block'>".$addUser['email']['help']."</p>");
?>
</li>
</ul>
</fieldset>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<?php echo CHtml::htmlButton("Create and send",array('type'=>'submit','class'=>"btn btn-primary")); ?>
</div>
</div>
<?php echo CHtml::endForm(); ?>
</div>
<div class="modal-footer">
<?php
echo CHtml::htmlButton($lang['Close'],array('type'=>'button','class'=>"btn btn-warning",'data-dismiss'=>"modal"));
?>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" tabindex="-1" role="dialog" id="modal-create-partial-token-survey">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><?php echo $lang["Select the question to send to an helper"]; ?></h4>
</div>
<div class="modal-body container-fluid">
<?php echo CHtml::beginForm($addUser['action'],'post',array('class'=>'form-horizontal')); ?>
<div class="ajax-result"></div>
<fieldset>
<legend><?php echo $lang["Select the question to send to an helper"]; ?></legend>
<?php foreach($aGroups as $group) {
$gid = $group['id'];
?>
<fieldset>
<legend><?php echo viewHelper::flatEllipsizeText($group['title'],1); ?></legend><ul class="list-unstyled form-horizontal">
<li class="checkbox-item group-item">
<input name="groups[]" id="groups-<?php echo $gid; ?>" value="<?php echo $gid; ?>" type="checkbox">
<label for="groups-<?php echo $gid; ?>" class="checkbox-label control-label"><strong><?php echo $lang['All question in this group']; ?></strong></label>
</li><ul>
<?php foreach($group['questions'] as $question) {
$qid = $question['id'];
?>
<li class="checkbox-item question-item">
<input name="questions[]" id="questions-<?php echo $qid; ?>" value="<?php echo $qid; ?>" type="checkbox">
<label for="questions-<?php echo $qid; ?>" class="checkbox-label control-label"><?php echo viewHelper::flatEllipsizeText($question['title'],1,160); ?></label>
</li>
<?php } ?>
</ul>
</fieldset>
<?php } ?>
</fieldset>
<fieldset>
<legend><?php echo $lang["Email and message"]; ?></legend>
<ul class='list-unstyled'>
<li class="form-group"><?php
echo CHtml::label(gT("Email"),'tokenattribute_email',array('class'=>"col-sm-4 control-label"))
. CHtml::tag("div",
array('class'=>"col-sm-7"),
CHtml::emailField('tokenattribute[email]',"",array('id'=>'tokenattribute_email','class'=>'form-control','data-default'=>"",'required'=>false))
);
?></li>
<li class="form-group">
<?php
$textArea = Chtml::textArea('emailmessage',$addUser['email']['message'],array('rows'=>20,'class'=> 'form-control','data-default'=>$addUser['email']['message']));
if($addUser['email']['html']) {
$textArea = Yii::app()->getController()->widget('yiiwheels.widgets.html5editor.WhHtml5Editor', array(
'name' => 'emailmessage',
'value' => $addUser['email']['message'],
'pluginOptions' => array(
'html' => true,
'lists' => false,
'image'=>false,
'link'=>false,
'useLineBreaks'=>false,// False broke reading …
'autoLink'=>true,
'parserRules'=>'js:wysihtml5ParserRules'
),
'htmlOptions' => array(
'class'=> 'form-control',
'data-default'=>$addUser['email']['body'],
),
),true);
}
echo CHtml::label(gT("Message"),'emailbody',array('class'=>"col-sm-4 control-label")) .
CHtml::tag("div",array('class'=>"col-sm-7"),
$textArea . "<p class='help-block'>".$addUser['email']['help']."</p>");
?>
</li>
</ul>
</fieldset>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<?php echo CHtml::htmlButton("Create and send",array('type'=>'submit','class'=>"btn btn-primary")); ?>
</div>
</div>
<?php echo CHtml::endForm(); ?>
</div>
<?php
//echo CHtml::htmlButton($lang['Close'],array('type'=>'button','class'=>"btn btn-warning",'data-dismiss'=>"modal"));
?>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment