mirror of https://github.com/akveo/blur-admin
fixes
parent
eacef1ca2f
commit
be628ea0ec
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,6 +7,26 @@
|
|||
<div class="panel-body">
|
||||
<p ng-model="survey.description" ng-attr-contenteditable="{{ editmode }}"></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="control-group">
|
||||
<span class="control-label" style="display: inline-block;position: relative;;margin-right: 25px;">Survey type : </span>
|
||||
<label class="radio-inline custom-radio nowrap">
|
||||
<input type="radio" name="surveyType" ng-model="survey.type" value="s_360">
|
||||
<span>360 Survey</span>
|
||||
</label>
|
||||
<label class="radio-inline custom-radio nowrap">
|
||||
<input type="radio" name="surveyType" ng-model="survey.type" value="s_regular">
|
||||
<span>Regular Survey</span>
|
||||
</label>
|
||||
<label class="radio-inline custom-radio nowrap">
|
||||
<input type="radio" name="surveyType" ng-model="survey.type" value="s_incognito">
|
||||
<span>Incognito Survey</span>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div id="newElem"></div>
|
||||
|
||||
<div class="control-group col-sm-12 col-xs-12 text-center new-question-container">
|
||||
|
@ -44,6 +64,7 @@
|
|||
|
||||
<div>
|
||||
<ui-select multiple ng-model="lists.selected"
|
||||
ng-change="selectedListsChange()"
|
||||
ng-disabled="false"
|
||||
search-enabled="true"
|
||||
append-to-body="true"
|
||||
|
@ -55,17 +76,14 @@
|
|||
{{multipleItem.name}}
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
<input type="text" class="form-control compose-input default-color" placeholder="Subject" ng-model="boxCtrl.subject">
|
||||
|
||||
<div class="control-group">
|
||||
<span class="control-label" style="display: block;float: left;margin: 7px;">360 Survey : </span>
|
||||
<div><ba-switcher switcher-style="primary" switcher-value="survey.s360"></ba-switcher></div>
|
||||
<input type="text" class="form-control compose-input default-color" placeholder="Subject" ng-model="survey.subject">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="compose-container">
|
||||
<text-angular-toolbar ta-toolbar-class="toolbarMain" name="toolbarMain" ta-toolbar="[['h1','h2','h3','bold','italics', 'underline', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],['userName', 'surveyLink']]"></text-angular-toolbar>
|
||||
<text-angular name="htmlcontent" ta-target-toolbars='toolbarMain,toolbarFooter' ng-model="boxCtrl.text"></text-angular>
|
||||
<text-angular-toolbar ta-toolbar-class="toolbarMain" name="toolbarMain" ta-toolbar="[['h1','h2','h3','bold','italics', 'underline', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],['userName', 'surveyLink'],['360Model', 'regularModel', 'incognitoModel']]"></text-angular-toolbar>
|
||||
<text-angular name="htmlcontent" ta-target-toolbars='toolbarMain,toolbarFooter' ng-model="survey.text"></text-angular>
|
||||
</div>
|
||||
</div>
|
||||
<div class="compose-footer clearfix">
|
||||
|
@ -95,7 +113,7 @@
|
|||
<div class="feed-messages-container" track-width="smallContainerWidth" min-width="360">
|
||||
<div class="feed-message" ng-repeat="l in lists.selected">
|
||||
<h3>{{l.name}}</h3>
|
||||
<img class="photo-icon roll-in-blurred-right" ng-src="{{m | profilePicture}}" ng-repeat="m in l.members">
|
||||
<img class="photo-icon roll-in-blurred-right" ng-src="{{m.id | profilePicture}}" ng-repeat="m in l.members">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('BlurAdmin.pages.surveys.create',['BlurAdmin.pages.surveys', 'ui.select', 'ngSanitize', 'textAngular', 'ngTagsInput'])
|
||||
.directive('tagInput', tagInput)
|
||||
.config(function($provide){
|
||||
$provide.decorator('taOptions', ['taRegisterTool', '$delegate', function(taRegisterTool, taOptions){
|
||||
// $delegate is the taOptions we are decorating
|
||||
|
@ -58,23 +57,39 @@
|
|||
return moveCaret(1);
|
||||
}
|
||||
});
|
||||
|
||||
taRegisterTool('360Model', {
|
||||
iconclass: "fa fa-circle-o-notch",
|
||||
tooltiptext: "Insert a 360 survey text model",
|
||||
action: function(){
|
||||
var model = "<p>Dear {{MEMBER_NAME}},<br><br>You have been selected to participate in a 360 Feedback Survey.<br><br>The purpose of a 360 Feedback Survey is to provide feedback to our leaders that will enable them to develop and improve.<br><br>To gain access to the site, please click on the link below.<br><br>{{SURVEY_LINK}}<br><br>We appreciate your assistance in this process and request that you complete the 360 feedback by .<br><br>Please be sure to answer all questions as honestly and as accurately as you can - all information received is kept strictly confidential. Thank you for taking the time to participate in this survey.<br><br>If you have any questions regarding the survey process or experience any technical difficulties, please contact .<br><br>Thank you for your participation<br></p>";
|
||||
return this.$editor().wrapSelection('insertHTML', model, true);
|
||||
}
|
||||
});
|
||||
|
||||
taRegisterTool('regularModel', {
|
||||
iconclass: "fa fa-file",
|
||||
tooltiptext: "Insert a regular survey text model",
|
||||
action: function(){
|
||||
insertTextAtCursor("REGULAR");
|
||||
return moveCaret(1);
|
||||
}
|
||||
});
|
||||
|
||||
taRegisterTool('incognitoModel', {
|
||||
iconclass: "fa fa-eye-slash",
|
||||
tooltiptext: "Insert an incognito survey text model",
|
||||
action: function(){
|
||||
insertTextAtCursor("INCOGNITO");
|
||||
return moveCaret(1);
|
||||
}
|
||||
});
|
||||
// add the button to the default toolbar definition
|
||||
taOptions.toolbar[1].push('colourRed');
|
||||
return taOptions;
|
||||
}]);
|
||||
});
|
||||
|
||||
function tagInput() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function( $scope, elem, attr) {
|
||||
console.log("tagInput", $scope);
|
||||
$(elem).tagsinput({
|
||||
tagClass: 'label label-' + attr.tagInput,
|
||||
val: 'test'
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
});
|
||||
|
||||
/** @ngInject */
|
||||
function CreateTabCtrl(SurveyService, ListService, $scope, $http, $compile, $timeout, $stateParams, $log, toastr) {
|
||||
function CreateTabCtrl(SurveyService, ListService,MemberService, $scope, $http, $compile, $timeout, $stateParams, $log, toastr, $uibModal, $state) {
|
||||
|
||||
$scope.editmode = true;
|
||||
|
||||
|
@ -45,15 +45,13 @@
|
|||
$scope.survey.name = 'Page Title';
|
||||
$scope.survey.description = 'Page Description';
|
||||
$scope.survey.elements = [];
|
||||
$scope.survey.type = "s_360";
|
||||
|
||||
$scope.display = {};
|
||||
$scope.display.survey = true;
|
||||
$scope.display.sidebar = false;
|
||||
$scope.display.surveySending = false;
|
||||
|
||||
$scope.emailsTexts = []
|
||||
$scope.emailsTexts["s_360"] = "<p>Dear {{MEMBER_NAME}},<br><br>You have been selected to participate in a 360 Feedback Survey.<br><br>The purpose of a 360 Feedback Survey is to provide feedback to our leaders that will enable them to develop and improve.<br><br>To gain access to the site, please click on the link below.<br><br>{{SURVEY_LINK}}<br><br>We appreciate your assistance in this process and request that you complete the 360 feedback by .<br><br>Please be sure to answer all questions as honestly and as accurately as you can - all information received is kept strictly confidential. Thank you for taking the time to participate in this survey.<br><br>If you have any questions regarding the survey process or experience any technical difficulties, please contact .<br><br>Thank you for your participation<br></p>"
|
||||
$scope.emailsTexts["s_default"] = "Normal"
|
||||
|
||||
$scope.progressFunction = function() {
|
||||
return $timeout(function() {}, 3000);
|
||||
|
@ -126,21 +124,38 @@
|
|||
|
||||
};
|
||||
|
||||
$scope.saveSurvey=function(){
|
||||
var survey = $scope.survey
|
||||
$scope.saveSurvey=function(process){
|
||||
|
||||
if(!process)
|
||||
$scope.survey.list = [];
|
||||
var survey = $scope.survey;
|
||||
|
||||
if($stateParams.survey_id) {
|
||||
SurveyService
|
||||
.update(survey)
|
||||
.then(
|
||||
function (data){
|
||||
console.log('Survey edited', data);
|
||||
toastr.info('The survey was edited successfuly :)', 'Surveys', {
|
||||
"autoDismiss": true,
|
||||
"positionClass": "toast-bottom-right",
|
||||
"type": "success",
|
||||
"timeOut": "5000",
|
||||
"extendedTimeOut": "2000"
|
||||
})
|
||||
if (process)
|
||||
$uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/pages/surveys/create/widgets/successModal.html',
|
||||
//size: size,
|
||||
/*resolve: {
|
||||
items: function () {
|
||||
return $scope.items;
|
||||
}
|
||||
}*/
|
||||
});
|
||||
else
|
||||
toastr.info('The survey was edited successfuly :)', 'Surveys', {
|
||||
"autoDismiss": true,
|
||||
"positionClass": "toast-bottom-right",
|
||||
"type": "success",
|
||||
"timeOut": "5000",
|
||||
"extendedTimeOut": "2000"
|
||||
})
|
||||
|
||||
},
|
||||
function (error){
|
||||
toastr.error('There were an error editing the survey', 'Surveys', {
|
||||
|
@ -187,7 +202,34 @@
|
|||
$scope.display.surveySending = true;
|
||||
};
|
||||
|
||||
$scope.selectedListsChange=function(){
|
||||
$log.info("selectedListsChange",$scope.lists.selected);
|
||||
angular.forEach($scope.lists.selected, function(list) {
|
||||
if(list.members.length > 0 && !list.members[0].name) {
|
||||
var params = {"ids" : list.members};
|
||||
MemberService
|
||||
.list(params)
|
||||
.then(
|
||||
function (data){
|
||||
list.members = data;
|
||||
},
|
||||
function (error){
|
||||
console.log("Error getting the members");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.sendSurvey=function(){
|
||||
$scope.survey.list = $scope.lists.selected;
|
||||
$scope.survey.status = "Sending";
|
||||
$log.info("sendSurvey",$scope.survey);
|
||||
$state.transitionTo('surveys.list'/*, {id: item.id}*/);
|
||||
|
||||
$scope.saveSurvey(true);
|
||||
|
||||
|
||||
/*$scope.saveSurvey();
|
||||
$("#sidebar").fadeIn();
|
||||
$("#survey-actions").fadeOut();*/
|
||||
|
@ -216,12 +258,9 @@
|
|||
SurveyService
|
||||
.get(id)
|
||||
.then(function (data){
|
||||
$log.info("data[0]",data[0].elements);
|
||||
angular.forEach(data[0].elements, function(elem) {
|
||||
elem.tagsJoined = elem.tags.join();
|
||||
});
|
||||
$log.info("data[0]",data);
|
||||
|
||||
$scope.survey = data[0];
|
||||
$scope.survey = data;
|
||||
$scope.updateBuilder();
|
||||
$log.info("Got the survey data",$scope.survey);
|
||||
}, function (error){
|
||||
|
@ -246,7 +285,7 @@
|
|||
|
||||
$scope.activate=function(){
|
||||
if($stateParams.survey_id) {
|
||||
$scope.loadSurvey($stateParams.member_id);
|
||||
$scope.loadSurvey($stateParams.survey_id);
|
||||
}
|
||||
$scope.loadLists();
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<div class="col-md-10 pull-right">
|
||||
<!--<div class="col-md-10 pull-right">
|
||||
<label class="checkbox-inline custom-checkbox nowrap">
|
||||
<input ng-model="element.multiAnswers" type="checkbox">
|
||||
<span>Allow more than one answer to this question (use checkboxes)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="col-md-10 pull-right">
|
||||
<label class="checkbox-inline custom-checkbox nowrap">
|
||||
|
@ -66,11 +66,19 @@
|
|||
</label>
|
||||
<div class="form-group" ng-show=element.comment>
|
||||
<label for="inputEmail3" class="col-sm-2 control-label">Label</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="col-sm-5">
|
||||
<input ng-model="element.commentLabel" type="text" class="form-control">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="checkbox-inline custom-checkbox nowrap">
|
||||
<input ng-model="element.commentIsRequired" type="checkbox">
|
||||
<span>Required ?</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<div class="modal-content">
|
||||
<div class="modal-header bg-success">
|
||||
<i class="ion-checkmark modal-icon"></i><span> Survey completed</span>
|
||||
</div>
|
||||
<div class="modal-body text-center">The survey is being sent to the members ...</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-success" ng-click="$dismiss()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
.controller('list', list);
|
||||
|
||||
/** @ngInject */
|
||||
function list( SurveyService, $scope, $rootScope, $log, $state, toastr) {
|
||||
function list( SurveyService, AnswerService, $scope, $rootScope, $log, $state, toastr, baConfig) {
|
||||
var vm = this;
|
||||
$rootScope.$state = $state;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
|||
.list()
|
||||
.then(function (data){
|
||||
vm.surveys = data;
|
||||
getSurveyCompletion();
|
||||
$log.info("Got the survey data",data);
|
||||
}, function (error){
|
||||
$log.error(error);
|
||||
|
@ -61,12 +62,66 @@
|
|||
}
|
||||
};
|
||||
|
||||
function getSurveyCompletion() {
|
||||
angular.forEach(vm.surveys, function(survey, key) {
|
||||
var totalMembers = 0
|
||||
var totalAnswers = survey.answers.length
|
||||
var totalQuestions = survey.elements.length
|
||||
var completion = 0
|
||||
|
||||
angular.forEach(survey.list, function(list, key) {
|
||||
totalMembers = totalMembers + list.members.length
|
||||
});
|
||||
|
||||
totalQuestions = survey.type == "s_360" ? totalQuestions * totalMembers : totalQuestions;
|
||||
|
||||
completion = (((totalAnswers) / (totalMembers * totalQuestions))*100).toFixed(0)
|
||||
|
||||
survey.completion = completion;
|
||||
//console.log('totalAnswers / TOTAL', totalAnswers, totalMembers * totalQuestions);
|
||||
|
||||
});
|
||||
|
||||
//console.log('getSurveyCompletion', vm.surveys);
|
||||
}
|
||||
|
||||
function analyzeSurvey(survey) {
|
||||
var params = {"survey":survey.id}
|
||||
AnswerService
|
||||
.analyze(params)
|
||||
.then(function (data){
|
||||
vm.analysis = data;
|
||||
vm.activeSurvey = survey;
|
||||
$log.info("Got answers analysis",data);
|
||||
}, function (error){
|
||||
$log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
function activate(){
|
||||
vm.surveys = [];
|
||||
vm.activeSurvey = {};
|
||||
vm.goToCreate = goToCreate;
|
||||
vm.analyzeSurvey = analyzeSurvey;
|
||||
vm.editSurvey = editSurvey;
|
||||
vm.removeSurvey = removeSurvey;
|
||||
|
||||
var layoutColors = baConfig.colors;
|
||||
vm.doughnutOptions = {
|
||||
elements: {
|
||||
arc: {
|
||||
borderWidth: 0
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'bottom',
|
||||
labels: {
|
||||
fontColor: layoutColors.defaultText
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loadSurveys();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,18 @@
|
|||
<td>
|
||||
{{ survey.updatedAt | date:'shortDate' }}
|
||||
</td>
|
||||
<td> {{ survey.responses || 0 }} </td>
|
||||
<td> {{ survey.status }} </td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="{{survey.completion}}" aria-valuemin="0" aria-valuemax="100" style="width: {{survey.completion}}%">
|
||||
<span class="sr-only">{{survey.completion}}% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td> <button class="status-button btn btn-xs btn-{{survey.status=='Draft'?'warning':''}}{{survey.status=='Sending'?'info':''}}{{survey.status=='Sent'?'primary':''}}{{survey.status=='Done'?'success':''}}">{{ survey.status }}</button> </td>
|
||||
<td>
|
||||
<button class="status-button btn btn-xs btn-primary" ng-click="vm.editSurvey(survey.id)">Edit</button>
|
||||
<button class="status-button btn btn-xs btn-info" ng-if="survey.status == 'Draft'" ng-click="vm.goToSend(survey.id)">Send</button>
|
||||
<button class="status-button btn btn-xs btn-info" ng-if="survey.status == 'Draft'" ng-click="vm.goToAnswers(survey.id)">Answers</button>
|
||||
<button class="status-button btn btn-xs btn-info" ng-if="survey.status == 'Sent'" ng-click="vm.analyzeSurvey(survey)">Analyse</button>
|
||||
<button class="status-button btn btn-xs btn-danger" ng-click="vm.removeSurvey(survey.id)">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -50,6 +56,20 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12" ng-show="vm.activeSurvey.id">
|
||||
|
||||
<div
|
||||
ba-panel
|
||||
ba-panel-class="horizontal-tabs tabs-panel">
|
||||
<div ng-include="'app/pages/surveys/list/surveyDetails.html'"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<uib-tabset active="$tabSetStatus.activeTab">
|
||||
<uib-tab heading="Question summaries">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{vm.analysis.completion}}" aria-valuemin="0" aria-valuemax="100" style="width: {{vm.analysis.completion}}%">
|
||||
{{vm.activeSurvey.completion}}% of question answred (Respondents : {{vm.analysis.respondents.length}} of {{vm.analysis.recipents}})
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="panel-group">
|
||||
|
||||
<div class="panel panel-default bootstrap-panel" ng-repeat="e in vm.activeSurvey.elements">
|
||||
<div class="panel-heading">{{ e.text }}</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
<div class="chartjs-canvas-holder-first-row" style="max-width: 300px;margin:0 auto;">
|
||||
<canvas id="doughnut" chart-options="vm.doughnutOptions" class="chart chart-doughnut"
|
||||
chart-data="vm.analysis.data[e._id]" chart-labels="vm.analysis.labels[e._id]">
|
||||
</canvas>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</uib-tab>
|
||||
<uib-tab heading="Individual responses">
|
||||
|
||||
</uib-tab>
|
||||
</uib-tabset>
|
|
@ -32,7 +32,7 @@
|
|||
function get(id) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get(endpoint)
|
||||
$http.get(endpoint + "/" + id)
|
||||
.success(function(data) {
|
||||
deferred.resolve(data);
|
||||
}).error(function(msg, code) {
|
||||
|
@ -42,7 +42,7 @@
|
|||
return deferred.promise;
|
||||
|
||||
|
||||
return $http.get(endpoint, id);
|
||||
return $http.get(endpoint + "/" + id);
|
||||
}
|
||||
|
||||
function create(survey) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
angular.module('BlurAdmin.pages.surveys', [
|
||||
'BlurAdmin.pages.surveys.create',
|
||||
'BlurAdmin.pages.surveys.list',
|
||||
]).config(routeConfig);
|
||||
]).config(routeConfig).config(chartJsConfig);
|
||||
|
||||
/** @ngInject */
|
||||
function routeConfig($stateProvider) {
|
||||
|
@ -45,4 +45,52 @@
|
|||
});
|
||||
}
|
||||
|
||||
function chartJsConfig(ChartJsProvider, baConfigProvider) {
|
||||
var layoutColors = baConfigProvider.colors;
|
||||
// Configure all charts
|
||||
ChartJsProvider.setOptions({
|
||||
chartColors: [
|
||||
layoutColors.primary, layoutColors.danger, layoutColors.warning, layoutColors.success, layoutColors.info, layoutColors.default, layoutColors.primaryDark, layoutColors.successDark, layoutColors.warningLight, layoutColors.successLight, layoutColors.primaryLight],
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
animation: {
|
||||
duration: 2500
|
||||
},
|
||||
scale: {
|
||||
gridLines: {
|
||||
color: layoutColors.border
|
||||
},
|
||||
scaleLabel: {
|
||||
fontColor: layoutColors.defaultText
|
||||
},
|
||||
ticks: {
|
||||
fontColor: layoutColors.defaultText,
|
||||
showLabelBackdrop: false
|
||||
}
|
||||
}
|
||||
});
|
||||
// Configure all line charts
|
||||
ChartJsProvider.setOptions('Line', {
|
||||
datasetFill: false
|
||||
});
|
||||
// Configure all radar charts
|
||||
ChartJsProvider.setOptions('radar', {
|
||||
scale: {
|
||||
pointLabels: {
|
||||
fontColor: layoutColors.defaultText
|
||||
},
|
||||
ticks: {
|
||||
maxTicksLimit: 5,
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
// Configure all bar charts
|
||||
ChartJsProvider.setOptions('bar', {
|
||||
tooltips: {
|
||||
enabled: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
params = params || {};
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get(endpoint)
|
||||
$http.get(endpoint, { params : params})
|
||||
.success(function(data) {
|
||||
deferred.resolve(data);
|
||||
}).error(function(msg, code) {
|
||||
|
@ -30,33 +30,46 @@
|
|||
}
|
||||
|
||||
function create(answer) {
|
||||
console.log("new Answer Object", answer);
|
||||
// return $http.post(endpoint, answer);
|
||||
}
|
||||
|
||||
function put(answer) {
|
||||
return $http.put(endpoint + "/" + answer.id, answer);
|
||||
return $http.post(endpoint, answer);
|
||||
}
|
||||
|
||||
function get(id) {
|
||||
return $http.get(endpoint + "/" + id);
|
||||
}
|
||||
|
||||
function edit(answer) {
|
||||
console.log("edit Answer Object", answer);
|
||||
function update(answer) {
|
||||
return $http.put(endpoint + "/"+answer.id, answer);
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
return $http.delete(endpoint + "/" + id);
|
||||
}
|
||||
|
||||
function analyze(params) {
|
||||
params = params || {};
|
||||
endpoint = endpoint + "/analyze"
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get(endpoint, { params : params})
|
||||
.success(function(data) {
|
||||
deferred.resolve(data);
|
||||
}).error(function(msg, code) {
|
||||
deferred.reject(msg);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
|
||||
|
||||
return $http.get(endpoint, params);
|
||||
}
|
||||
|
||||
return {
|
||||
list:list,
|
||||
create:create,
|
||||
edit:edit,
|
||||
update:update,
|
||||
get:get,
|
||||
put:put,
|
||||
remove:remove
|
||||
remove:remove,
|
||||
analyze:analyze
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -14,56 +14,69 @@
|
|||
|
||||
var vm = this;
|
||||
|
||||
function loadSurveys() {
|
||||
function loadSurvey(id) {
|
||||
SurveyService
|
||||
.list()
|
||||
.get(id)
|
||||
.then(function (data){
|
||||
vm.surveys = data;
|
||||
vm.survey = data;
|
||||
$log.info("Got the survey data",data);
|
||||
vm.survey = getSurvey();
|
||||
//building forms elements
|
||||
vm.forms = [];
|
||||
angular.forEach(vm.survey.elements, function(element, key) {
|
||||
|
||||
angular.forEach(vm.survey.list.members, function(member, key) {
|
||||
if(member._id != vm.activeMemberId) {
|
||||
vm.forms[member._id] = {};
|
||||
//vm.forms[member._id].$element_id = false;
|
||||
/*var form = [];
|
||||
form[element._id] = [];
|
||||
vm.forms.push(form);
|
||||
var input = [];
|
||||
input[element._id] = false;
|
||||
vm.forms[member._id].push(input);*/
|
||||
}
|
||||
//angular.forEach(vm.survey.elements, function(element, key) {
|
||||
// console.log("element",element);
|
||||
angular.forEach(vm.survey.list, function(list, key) {
|
||||
console.log("list",list);
|
||||
angular.forEach(list.members, function(member, key) {
|
||||
//console.log("member",member);
|
||||
vm.forms[member.id] = {};
|
||||
vm.forms[member.id].elements = vm.survey.elements;
|
||||
vm.forms[member.id].question = {};
|
||||
if(member.id != vm.activeMemberId) {
|
||||
vm.members.push(member);
|
||||
|
||||
} else
|
||||
vm.askedMember = member;
|
||||
|
||||
//.push(k + ': ' + member);
|
||||
});
|
||||
vm.members.push(vm.askedMember);
|
||||
//Thnak You message
|
||||
vm.members.push({"id": "none", "name" : ": )"});
|
||||
});
|
||||
});
|
||||
console.log(vm.survey);
|
||||
console.log(vm.forms);
|
||||
// });
|
||||
/*console.log("loadSurvey:vm.survey",vm.survey);
|
||||
console.log("loadSurvey:vm.survey.list.members",vm.survey.list.members);
|
||||
console.log("loadSurvey:vm.forms",vm.forms);*/
|
||||
}, function (error){
|
||||
$log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
function getSurvey() {
|
||||
$log.info("getSurvey",$stateParams.survey_id);
|
||||
return vm.surveys.filter(function(s){
|
||||
return s.id == $stateParams.survey_id;
|
||||
})[0];
|
||||
}
|
||||
|
||||
|
||||
function activate(){
|
||||
vm.surveys = [];
|
||||
vm.survey = [];
|
||||
vm.forms = [];
|
||||
vm.survey = {};
|
||||
vm.members = [];
|
||||
vm.askedMember = {};
|
||||
vm.activeMemberId = $stateParams.member_id;
|
||||
loadSurveys();
|
||||
loadSurvey($stateParams.survey_id);
|
||||
console.log(vm.activeMemberId)
|
||||
|
||||
|
||||
}
|
||||
|
||||
vm.getInitials = function(string) {
|
||||
var names = string.split(' '),
|
||||
initials = names[0].substring(0, 1).toUpperCase();
|
||||
|
||||
if (names.length > 1) {
|
||||
initials += names[names.length - 1].substring(0, 1).toUpperCase();
|
||||
}
|
||||
//console.log("getInitials", string, initials)
|
||||
return initials;
|
||||
};
|
||||
|
||||
vm.test = function(form){
|
||||
//$scope.submitted = true;
|
||||
alert("Angular is Awesome!!!");
|
||||
|
|
|
@ -11,13 +11,18 @@
|
|||
|
||||
<div class="separator"></div>
|
||||
<ba-wizard>
|
||||
<ba-wizard-step title="{{ m.name }}" ng-repeat="m in vm.survey.list.members" ng-if='m._id != vm.activeMemberId' ng-init="memberId = m._id" form="vm.forms[memberId]" >
|
||||
<form name="vm.forms[memberId]" novalidate>
|
||||
|
||||
<ba-wizard-step title="{{ m.id != vm.activeMemberId ? vm.getInitials(m.name) : 'ME' }}" ng-repeat="m in vm.members track by $index" ng-init="memberId = m.id" form="vm.forms[memberId]" mid="{{ m.id }}" elements="{{vm.survey.elements}}" evaluated="{{m}}" asked="{{vm.askedMember}}">
|
||||
<form name="vm.forms[memberId]" novalidate ng-if="m.id != 'none'">
|
||||
<ng-form name="innerForm">
|
||||
<div class="member-survey">
|
||||
<div class="separator"></div>
|
||||
<h3 class="member-full-name">{{ m.name }}</h3>
|
||||
<div class="separator"></div>
|
||||
<div id="{{e.id}}" class="form-group answer" ng-repeat="e in vm.survey.elements"
|
||||
ng-init="elementId = vm.survey.id+'_'+memberId+'_'+vm.activeMemberId+'_'+e._id" ng-class="{'has-error': innerForm[elementId].$invalid && (vm.forms[memberId].$submitted)}">
|
||||
<input type="hidden" name="{{ elementId }}_submitted" ng-model="vm.innerForm[elementId].submitted" ng-value="false"/>
|
||||
<!--<input type="hidden" name="{{ elementId }}_question" ng-model="vm.innerForm[elementId].question.$viewValue" ng-value="e"/>-->
|
||||
<p>{{ e.text }}</p>
|
||||
<label ng-class="el.multiple ? 'custom-checkbox radio-checkbox nowrap' : 'custom-radio radio-inline nowrap'" ng-repeat="el in e.items">
|
||||
<input ng-attr-type="{{el.multiple? 'checkbox' : 'radio'}}" name="{{elementId}}" ng-model="vm.innerForm[elementId].$viewValue" ng-value="el.value" ng-attr-required="{{el.required}}">
|
||||
|
@ -33,8 +38,16 @@
|
|||
</div>
|
||||
</ng-form>
|
||||
</form>
|
||||
<form class="form-horizontal" name="vm.finishForm" novalidate ng-if="m.id == 'none'">
|
||||
<div class="separator"></div>
|
||||
<h3 class="member-full-name">Congratulations! You have successfully filled the form!</h3>
|
||||
<div class="separator"></div>
|
||||
|
||||
</form>
|
||||
</ba-wizard-step>
|
||||
|
||||
|
||||
|
||||
</ba-wizard>
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<div class="ba-wizard">
|
||||
<div class="ba-wizard-navigation-container">
|
||||
<div ng-repeat="t in $baWizardController.tabs" class="ba-wizard-navigation {{$baWizardController.tabNum == $index ? 'active' : ''}}" ng-click="$baWizardController.selectTab($index)">
|
||||
{{t.title}}
|
||||
<div ng-repeat="t in $baWizardController.tabs" class="ba-wizard-navigation {{$baWizardController.tabNum == $index ? 'active heartbeat' : ''}}" ng-click="$baWizardController.selectTab($index)">
|
||||
{{ $baWizardController.tabNum != $index ? t.title : ''}}
|
||||
<img ng-if="$baWizardController.tabNum == $index" ng-src="{{t.mid | profilePicture}}" class="little-human-picture">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.directive('baWizardStep', baWizardStep);
|
||||
|
||||
/** @ngInject */
|
||||
function baWizardStep($http) {
|
||||
function baWizardStep($http, AnswerService, $filter) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
|
@ -14,7 +14,7 @@
|
|||
form: '='
|
||||
},
|
||||
templateUrl: 'app/theme/components/baWizard/baWizardStep.html',
|
||||
link: function($scope, $element, $attrs, wizard, AnswerService) {
|
||||
link: function($scope, $element, $attrs, wizard) {
|
||||
$scope.selected = true;
|
||||
|
||||
var tab = {
|
||||
|
@ -24,7 +24,8 @@
|
|||
isComplete: isComplete,
|
||||
isAvailiable: isAvailiable,
|
||||
prevTab: undefined,
|
||||
setPrev: setPrev
|
||||
setPrev: setPrev,
|
||||
mid: $attrs.mid
|
||||
};
|
||||
|
||||
wizard.addTab(tab);
|
||||
|
@ -38,34 +39,94 @@
|
|||
}
|
||||
|
||||
function submit() {
|
||||
var apiBaseUrl = "http://localhost:9000"
|
||||
var endpoint = apiBaseUrl + "/answers";
|
||||
|
||||
var elements = angular.fromJson($attrs.elements);
|
||||
var memberEvaluated = angular.fromJson($attrs.evaluated);
|
||||
var memberAsked = angular.fromJson($attrs.asked);
|
||||
|
||||
$scope.form && $scope.form.$setSubmitted(true);
|
||||
if($scope.form && $scope.form.$invalid == false) {
|
||||
|
||||
//console.log("inner", $scope.form.innerForm);
|
||||
console.log("$attrs.elements", elements);
|
||||
console.log("inner", $scope.form.innerForm);
|
||||
|
||||
angular.forEach($scope.form.innerForm, function(val, key) {
|
||||
if((key.indexOf("_") !== -1) && (key.indexOf("_comment") == -1)) {
|
||||
|
||||
if((key.indexOf("_") !== -1) && (key.indexOf("_comment") == -1) && (key.indexOf("_submitted") == -1) && (key.indexOf("_question") == -1)) {
|
||||
var res = key.split("_");
|
||||
//console.log("res", res);
|
||||
console.log("res", res);
|
||||
//console.log("val", val);
|
||||
var commentKey = key + "_comment";
|
||||
var submittedKey = key + "_submitted";
|
||||
//console.log("key", key);
|
||||
//console.log("commentKey", commentKey);
|
||||
//console.log("submittedKey", submittedKey);
|
||||
var element = $filter('filter')(elements, {'_id':res[3]})
|
||||
var answer = {
|
||||
"value" : val.$viewValue,
|
||||
"comment" : $scope.form.innerForm[commentKey].$viewValue,
|
||||
"comment" : ($scope.form.innerForm[commentKey]) ? $scope.form.innerForm[commentKey].$viewValue : '',
|
||||
"survey" : res[0],
|
||||
"memberEvaluated" : res[1],
|
||||
"memberAsked" : res[2]
|
||||
"evaluated" : memberEvaluated,
|
||||
"asked" : memberAsked,
|
||||
"question": element[0]
|
||||
}
|
||||
console.log($scope);
|
||||
//AnswerService.create(answer);
|
||||
/*$http.post(endpoint, answer).success(function(data) {
|
||||
console.log(data.data);
|
||||
//return response.data;
|
||||
}).error(function(msg, code) {
|
||||
//deferred.reject(msg);
|
||||
});*/
|
||||
console.log("$attrs",$attrs);
|
||||
console.log("submit:answer",answer);
|
||||
if ($scope.form.innerForm[submittedKey].$viewValue) {
|
||||
answer.id = $scope.form.innerForm[submittedKey].$viewValue;
|
||||
AnswerService
|
||||
.update(answer)
|
||||
.then(
|
||||
function (data){
|
||||
console.log("answer.update",data);
|
||||
$scope.form.innerForm[submittedKey].$viewValue = data.data.id;
|
||||
},
|
||||
function (error){
|
||||
console.log("Error updating the answer");
|
||||
}
|
||||
);
|
||||
} else {
|
||||
//checking if the answer already exist
|
||||
var params = {"survey":answer.survey, "asked":answer.asked.id, "evaluated":answer.evaluated.id, "question":answer.question._id}
|
||||
AnswerService
|
||||
.list(params)
|
||||
.then(
|
||||
function (data){
|
||||
console.log("answer.check",data);
|
||||
if(data.length > 0) {
|
||||
answer.id = data[0].id;
|
||||
AnswerService
|
||||
.update(answer)
|
||||
.then(
|
||||
function (data){
|
||||
console.log("answer.update",data);
|
||||
$scope.form.innerForm[submittedKey].$viewValue = data.data.id;
|
||||
},
|
||||
function (error){
|
||||
console.log("Error updating the answer");
|
||||
}
|
||||
);
|
||||
} else
|
||||
AnswerService
|
||||
.create(answer)
|
||||
.then(
|
||||
function (data){
|
||||
console.log("answer.create",data);
|
||||
$scope.form.innerForm[submittedKey].$viewValue = data.data.id;
|
||||
},
|
||||
function (error){
|
||||
console.log("Error creating the answer");
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
function (error){
|
||||
console.log("Error getting the answer");
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
|
@ -6,12 +6,12 @@
|
|||
}
|
||||
|
||||
.roll-in-blurred-right {
|
||||
-webkit-animation: roll-in-blurred-right 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1s both;
|
||||
animation: roll-in-blurred-right 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1s both;
|
||||
-webkit-animation: roll-in-blurred-right 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1500ms both;
|
||||
animation: roll-in-blurred-right 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1500ms both;
|
||||
}
|
||||
.roll-in-blurred-left {
|
||||
-webkit-animation: roll-in-blurred-left 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
|
||||
animation: roll-in-blurred-left 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
|
||||
-webkit-animation: roll-in-blurred-left 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1500ms both;
|
||||
animation: roll-in-blurred-left 0.65s cubic-bezier(0.230, 1.000, 0.320, 1.000) 1500ms both;
|
||||
}
|
||||
.slide-out-blurred-left {
|
||||
-webkit-animation: slide-out-blurred-left 0.45s cubic-bezier(0.755, 0.050, 0.855, 0.060) both;
|
||||
|
@ -21,6 +21,10 @@
|
|||
-webkit-animation: slide-out-blurred-right 0.45s cubic-bezier(0.755, 0.050, 0.855, 0.060) both;
|
||||
animation: slide-out-blurred-right 0.45s cubic-bezier(0.755, 0.050, 0.855, 0.060) both;
|
||||
}
|
||||
.heartbeat {
|
||||
-webkit-animation: heartbeat 1.5s ease-in-out infinite both;
|
||||
animation: heartbeat 1.5s ease-in-out infinite both;
|
||||
}
|
||||
|
||||
@-webkit-keyframes roll-in-blurred-right {
|
||||
0% {
|
||||
|
@ -175,4 +179,75 @@
|
|||
}
|
||||
|
||||
|
||||
@-webkit-keyframes heartbeat {
|
||||
from {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
-webkit-transform-origin: center center;
|
||||
transform-origin: center center;
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
10% {
|
||||
-webkit-transform: scale(0.91);
|
||||
transform: scale(0.91);
|
||||
-webkit-animation-timing-function: ease-in;
|
||||
animation-timing-function: ease-in;
|
||||
}
|
||||
17% {
|
||||
-webkit-transform: scale(0.98);
|
||||
transform: scale(0.98);
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
33% {
|
||||
-webkit-transform: scale(0.87);
|
||||
transform: scale(0.87);
|
||||
-webkit-animation-timing-function: ease-in;
|
||||
animation-timing-function: ease-in;
|
||||
}
|
||||
45% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
}
|
||||
@keyframes heartbeat {
|
||||
from {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
-webkit-transform-origin: center center;
|
||||
transform-origin: center center;
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
10% {
|
||||
-webkit-transform: scale(0.91);
|
||||
transform: scale(0.91);
|
||||
-webkit-animation-timing-function: ease-in;
|
||||
animation-timing-function: ease-in;
|
||||
}
|
||||
17% {
|
||||
-webkit-transform: scale(0.98);
|
||||
transform: scale(0.98);
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
33% {
|
||||
-webkit-transform: scale(0.87);
|
||||
transform: scale(0.87);
|
||||
-webkit-animation-timing-function: ease-in;
|
||||
animation-timing-function: ease-in;
|
||||
}
|
||||
45% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
-webkit-animation-timing-function: ease-out;
|
||||
animation-timing-function: ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -278,6 +278,12 @@ a {
|
|||
margin-right: 20px;
|
||||
}
|
||||
|
||||
#surveys #survey-sending .compose-container {
|
||||
background-color: white;
|
||||
}
|
||||
#surveys #survey-sending .compose-footer {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -334,3 +340,28 @@ a {
|
|||
color: #262626;
|
||||
background-color: #ffff00;
|
||||
}
|
||||
|
||||
.ba-wizard-navigation{
|
||||
display: inline-block !important;
|
||||
color: rgb(255, 255, 255); background-color: #60afdd;
|
||||
display: inline-block; font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;
|
||||
font-size: 36px !important; border-radius: 80px; width: 80px; height: 80px; line-height: 80px !important; margin: 3px; text-align: center;
|
||||
}
|
||||
|
||||
.ba-wizard-navigation-container {
|
||||
padding: 0px 0 !important;
|
||||
}
|
||||
.ba-wizard-navigation.active{
|
||||
background-color: white;
|
||||
}
|
||||
.ba-wizard-navigation .little-human-picture {
|
||||
border-radius: 80px; width: 80px; height: 80px;margin-top: -5px;
|
||||
}
|
||||
|
||||
.ng-invalid.form-control {
|
||||
border: 1px solid #ed7878;
|
||||
}
|
||||
|
||||
#surveys .progress{
|
||||
margin: 10px;
|
||||
}
|
Loading…
Reference in New Issue