Skip to content

Commit

Permalink
Dev: Show warning message after Cint tour
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 29, 2016
1 parent 9e67411 commit db5aff7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
32 changes: 22 additions & 10 deletions application/core/plugins/CintLink/CintLink.php
Expand Up @@ -172,18 +172,9 @@ public function actionIndex($surveyId)
}
*/

// Show tutorial if survey has no orders
// Show tour if survey has no orders
if (!CintLinkOrder::hasAnyOrders($surveyId))
{
/*
(new UniqueNotification(array(
'survey_id' => $surveyId,
'importance' => Notification::HIGH_IMPORTANCE,
'markAsNew' => false,
'title' => $this->gT('Welcome to CintLink LimeSurvey Integration'),
'message' => $this->renderPartial('tutorial', array(), true)
)))->save();
*/
$assetsUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/js');
App()->clientScript->registerScriptFile("$assetsUrl/bootstrap-tour.min.js");
App()->clientScript->registerScriptFile("$assetsUrl/tour.js");
Expand All @@ -194,6 +185,25 @@ public function actionIndex($surveyId)
return $content;
}

/**
* Set tutorial message after tour has ended
* Tutorial is for now only a warning message.
* @return void
*/
public function setTutorial(LSHttpRequest $request)
{
$surveyId = $request->getParam('surveyId');

(new UniqueNotification(array(
'survey_id' => $surveyId,
'importance' => Notification::HIGH_IMPORTANCE,
'markAsNew' => false,
'title' => $this->gT('Welcome to CintLink LimeSurvey Integration'),
'message' => $this->renderPartial('notifications.tutorial', array(), true)
)))->save();
return json_encode(array('result' => 'ok'));
}

/**
* Fetch the global variables from Cint, like number of children,
* personal income etc.
Expand All @@ -210,6 +220,7 @@ protected function fetchGlobalVariables()

/**
* Used from model
* Global variables are from Cint target group codes, e.g. number of children
* @return SimpleXmlElement
*/
public function getGlobalVariables()
Expand Down Expand Up @@ -1262,6 +1273,7 @@ public function newDirectRequest()
|| $functionToCall == "softDeleteOrder"
|| $functionToCall == "userTriedToPay"
|| $functionToCall == "updateAllOrders"
|| $functionToCall == "setTutorial"
|| $functionToCall == "getSurvey")
{
echo $this->$functionToCall($request);
Expand Down
11 changes: 10 additions & 1 deletion application/core/plugins/CintLink/js/tour.js
Expand Up @@ -11,9 +11,18 @@ $(document).ready(function() {
var texts = response.result;
LS.plugin.cintlink.tour = new Tour({
name: 'limesurvey-cintlink-tour',
//storage: false, // Enable this for debugging
storage: false, // Enable this for debugging
backdrop: true,
//debug: true,
onEnd: function() {
$.ajax({
url: LS.plugin.cintlink.pluginBaseUrl + '&method=setTutorial',
surveyId: LS.plugin.cintlink.surveyId,
success: function(response) {
LS.updateNotificationWidget(LS.plugin.cintlink.notificationUpdateUrl, false);
}
});
},
steps: [
{
element: '#cintlink-header',
Expand Down
4 changes: 2 additions & 2 deletions scripts/admin/notifications.js
Expand Up @@ -48,7 +48,7 @@ $(document).ready(function() {
/**
* Called from outside (update notifications when click
* @param {string} url
* @param {boolean} openAfter If notification widget should be opened after load; "default" to true
* @param {boolean} openAfter If notification widget should be opened after load; default to true
* @return
*/
LS.updateNotificationWidget = function(url, openAfter) {
Expand All @@ -60,7 +60,7 @@ $(document).ready(function() {
});

// Only update once
LS.updateNotificationWidget = function() {};
$('#notification-li').unbind('click');
}

/**
Expand Down

0 comments on commit db5aff7

Please sign in to comment.