Add support form feedback

This commit is contained in:
Johannes Zellner
2015-08-04 16:01:50 +02:00
parent d8ccc766b9
commit 88d905e8cc
2 changed files with 45 additions and 22 deletions

View File

@@ -27,16 +27,16 @@
We would love to hear any ideas, feature requests and overall feedback from your side.
<br/>
<br/>
<form ng-submit="submitFeedback()">
<div class="form-group">
<!-- <label for="feedbackSubject">Feedback</label> -->
<input type="text" class="form-control" id="feedbackSubject" ng-model="feedback.subject" placeholder="Enter your idea">
<form name="feedbackForm" ng-submit="submitFeedback()">
<div class="form-group" ng-class="{ 'has-error': (feedbackForm.subject.$dirty && feedbackForm.subject.$invalid) }">
<input type="text" class="form-control" name="subject" placeholder="Enter your idea" ng-model="feedback.subject" ng-maxlength="512" ng-minlength="1" required>
</div>
<div class="form-group">
<!-- <label for="feedbackDescription">Your Idea</label> -->
<textarea class="form-control" id="feedbackDescription" rows="3" ng-model="feedback.description" placeholder="Describe your idea"></textarea>
<div class="form-group" ng-class="{ 'has-error': (feedbackForm.description.$dirty && feedbackForm.description.$invalid) }">
<textarea class="form-control" name="description" rows="3" placeholder="Describe your idea" ng-model="feedback.description" ng-minlength="1" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary" ng-disabled="feedbackForm.$invalid || feedback.busy"><i class="fa fa-spinner fa-pulse" ng-show="feedback.busy"></i> Submit</button>
<span ng-show="feedback.error" class="text-danger text-bold">{{feedback.error}}</span>
<span ng-show="feedback.success" class="text-success text-bold">Thank You!</span>
</form>
</div>
</div>
@@ -53,19 +53,23 @@
If you found any issue or bugs, let us know, we will resolve that for you as soon as possible.
<br/>
<br/>
<form ng-submit="submitTicket()">
<div class="form-group">
<!-- <label for="feedbackSubject">Feedback</label> -->
<input type="text" class="form-control" id="feedbackSubject" ng-model="ticket.subject" placeholder="Enter your issue">
<form name="ticketForm" ng-submit="submitTicket()">
<div class="form-group" ng-class="{ 'has-error': (ticketForm.subject.$dirty && ticketForm.subject.$invalid) }">
<input type="text" class="form-control" name="subject" placeholder="Enter your issue" ng-model="ticket.subject" ng-maxlength="512" ng-minlength="1" required>
</div>
<div class="form-group">
<!-- <label for="feedbackDescription">Your Idea</label> -->
<textarea class="form-control" id="feedbackDescription" rows="3" ng-model="ticket.description" placeholder="Describe your issue"></textarea>
<div class="form-group" ng-class="{ 'has-error': (ticketForm.description.$dirty && ticketForm.description.$invalid) }">
<textarea class="form-control" name="description" rows="3" placeholder="Describe your issue" ng-model="ticket.description" ng-minlength="1" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary" ng-disabled="ticketForm.$invalid || ticket.busy"><i class="fa fa-spinner fa-pulse" ng-show="ticket.busy"></i> Submit</button>
<span ng-show="ticket.error" class="text-danger text-bold">{{ticket.error}}</span>
<span ng-show="ticket.success" class="text-success text-bold">Thank You!</span>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<br/>
<br/>
<br/>

View File

@@ -2,11 +2,11 @@
angular.module('Application').controller('SupportController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
$scope.busy = false;
$scope.feedback = {
error: null,
success: false,
busy: false,
subject: '',
description: ''
};
@@ -14,12 +14,29 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
$scope.ticket = {
error: null,
success: false,
busy: false,
subject: '',
description: ''
};
function resetFeedback() {
$scope.feedback.subject = '';
$scope.feedback.description = '';
$scope.feedbackForm.$setUntouched();
$scope.feedbackForm.$setPristine();
}
function resetTicket() {
$scope.ticket.subject = '';
$scope.ticket.description = '';
$scope.ticketForm.$setUntouched();
$scope.ticketForm.$setPristine();
}
$scope.submitFeedback = function () {
$scope.busy = true;
$scope.feedback.busy = true;
$scope.feedback.success = false;
$scope.feedback.error = null;
@@ -28,14 +45,15 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
$scope.feedback.error = error;
} else {
$scope.feedback.success = true;
resetFeedback();
}
$scope.busy = false;
$scope.feedback.busy = false;
});
};
$scope.submitTicket = function () {
$scope.busy = true;
$scope.ticket.busy = true;
$scope.ticket.success = false;
$scope.ticket.error = null;
@@ -44,9 +62,10 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
$scope.ticket.error = error;
} else {
$scope.ticket.success = true;
resetTicket();
}
$scope.busy = false;
$scope.ticket.busy = false;
});
};
}]);