diff --git a/www/addons/mod_forum/controllers/discussion.js b/www/addons/mod_forum/controllers/discussion.js index 388f5e82f3a..81ae46aef59 100644 --- a/www/addons/mod_forum/controllers/discussion.js +++ b/www/addons/mod_forum/controllers/discussion.js @@ -21,12 +21,12 @@ angular.module('mm.addons.mod_forum') * @ngdoc controller * @name mmaModForumDiscussionCtrl */ -.controller('mmaModForumDiscussionCtrl', function($q, $scope, $stateParams, $mmaModForum, $mmSite, $mmUtil, $ionicScrollDelegate, - mmaModForumComponent) { +.controller('mmaModForumDiscussionCtrl', function($q, $scope, $stateParams, $mmaModForum, $mmSite, $mmUtil, $translate, + $ionicScrollDelegate, mmaModForumComponent) { var discussionid = $stateParams.discussionid, courseid = $stateParams.courseid, - scrollView = $ionicScrollDelegate.$getByHandle('mmaModForumPostsScroll'); + scrollView; $scope.component = mmaModForumComponent; $scope.courseid = courseid; @@ -41,6 +41,12 @@ angular.module('mm.addons.mod_forum') return $mmaModForum.getDiscussionPosts(discussionid).then(function(posts) { $scope.discussion = $mmaModForum.extractStartingPost(posts); $scope.posts = posts; + + // Set default reply subject. + return $translate('mma.mod_forum.re').then(function(strReplyPrefix) { + $scope.defaultSubject = strReplyPrefix + ' ' + $scope.discussion.subject; + $scope.newpost.subject = $scope.defaultSubject; + }); }, function(message) { $mmUtil.showErrorModal(message); return $q.reject(); @@ -72,10 +78,13 @@ angular.module('mm.addons.mod_forum') // New post added. $scope.newPostAdded = function() { - scrollView.scrollTop(); + if (!scrollView) { + scrollView = $ionicScrollDelegate.$getByHandle('mmaModForumPostsScroll'); + } + scrollView && scrollView.scrollTop && scrollView.scrollTop(); $scope.newpost.replyingto = undefined; - $scope.newpost.subject = ''; + $scope.newpost.subject = $scope.defaultSubject; $scope.newpost.message = ''; $scope.discussionLoaded = false; diff --git a/www/addons/mod_forum/directives/discussionpost.js b/www/addons/mod_forum/directives/discussionpost.js index 3812305ec3f..e0ce7fe3841 100644 --- a/www/addons/mod_forum/directives/discussionpost.js +++ b/www/addons/mod_forum/directives/discussionpost.js @@ -20,6 +20,19 @@ angular.module('mm.addons.mod_forum') * @module mm.addons.mod_forum * @ngdoc directive * @name mmaForumDiscussionPost + * @description + * This directive will show a forum post if the right data is supplied. Attributes: + * + * @param {Object} post Post. + * @param {Number} courseid Post's course ID. + * @param {String} title Post's title. + * @param {String} subject Post's subject. + * @param {String} component Component this post belong to. + * @param {Object} newpost Object with the new post data. Usually shared between posts. + * @param {Boolean} showdivider True if it should have a list divider before the post. + * @param {Boolean} titleimportant True if title should be "important" (bold). + * @oaram {Function} [postadded] Function to call when a new post is added. + * @param {String} [defaultsubject] Default subject to set to new posts. */ .directive('mmaModForumDiscussionPost', function($mmaModForum, $mmUtil, $translate, $q) { return { @@ -33,7 +46,8 @@ angular.module('mm.addons.mod_forum') newpost: '=', showdivider: '=?', titleimportant: '=?', - postadded: '&?' + postadded: '&?', + defaultsubject: '=?' }, templateUrl: 'addons/mod_forum/templates/discussionpost.html', transclude: true, @@ -85,7 +99,7 @@ angular.module('mm.addons.mod_forum') promise.then(function() { scope.newpost.replyingto = undefined; - scope.newpost.subject = ''; + scope.newpost.subject = scope.defaultsubject || ''; scope.newpost.message = ''; }); }; diff --git a/www/addons/mod_forum/lang/en.json b/www/addons/mod_forum/lang/en.json index 5b76d919d50..10084c7dc29 100644 --- a/www/addons/mod_forum/lang/en.json +++ b/www/addons/mod_forum/lang/en.json @@ -15,6 +15,7 @@ "numdiscussions": "{{numdiscussions}} discussions", "numreplies": "{{numreplies}} replies", "posttoforum": "Post to forum", + "re": "Re:", "reply": "Reply", "subject": "Subject" } diff --git a/www/addons/mod_forum/templates/discussion.html b/www/addons/mod_forum/templates/discussion.html index efcd09c646c..d8cbd2a4b73 100644 --- a/www/addons/mod_forum/templates/discussion.html +++ b/www/addons/mod_forum/templates/discussion.html @@ -6,11 +6,11 @@
- +
- +