Skip to content

Commit b02a850

Browse files
committed
MOBILE-2178 database: Show comments in single view
1 parent 8222b41 commit b02a850

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

www/addons/mod/data/controllers/entry.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ angular.module('mm.addons.mod_data')
109109
var actions = $mmaModDataHelper.getActions(data, access, $scope.entry);
110110

111111
$scope.entryRendered = $mmaModDataHelper.displayShowFields(data.singletemplate, $scope.fields, entryId, 'show', actions);
112+
$scope.showComments = actions.comments;
112113

113114
return $mmaModDataHelper.getPageInfoByEntry(data.id, entryId, $scope.selectedGroup).then(function(result) {
114115
$scope.previousId = result.previousId;

www/addons/mod/data/directives/action.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ angular.module('mm.addons.mod_data')
2828
scope: {
2929
action: '@',
3030
database: '=',
31-
entry: '=?'
31+
entry: '=?',
32+
mode: '@'
3233
},
3334
templateUrl: 'addons/mod/data/templates/action.html',
3435
link: function(scope) {

www/addons/mod/data/services/helper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ angular.module('mm.addons.mod_data')
5858
replace = new RegExp(replace, 'gi');
5959

6060
// Replace field by a generic directive.
61-
render = '<mma-mod-data-field mode="'+mode+'" field="fields['+ field.id + ']" value="entries['+ entryId +'].contents['+ field.id + ']" database="data" view-action="gotoEntry('+ entryId +')"></mma-mod-data-field>';
61+
render = '<mma-mod-data-field field="fields['+ field.id + ']" value="entries['+ entryId +'].contents['+ field.id +
62+
']" mode="'+mode+'" database="data" view-action="gotoEntry('+ entryId +')"></mma-mod-data-field>';
6263
template = template.replace(replace, render);
6364
});
6465

@@ -69,7 +70,8 @@ angular.module('mm.addons.mod_data')
6970
// Render more url directly because it can be part of an HTML attribute.
7071
render = $mmSite.getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entryId;
7172
} else {
72-
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entryId +']" database="data"></mma-mod-data-action>';
73+
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entryId +
74+
']" mode="'+mode+'" database="data"></mma-mod-data-action>';
7375
}
7476
template = template.replace(replace, render);
7577
} else {

www/addons/mod/data/templates/action.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a ng-if="action == 'approve'" class="button button-icon icon ion-thumbsup" ng-href="{{url}}/mod/data/view.php?d={{entry.dataid}}&approve={{entry.id}}" mm-link capture-link="true" title="{{ 'mma.mod_data.approve' | translate }}"></a>
66
<a ng-if="action == 'disapprove'" class="button button-icon icon ion-minus-circled" ng-href="{{url}}/mod/data/view.php?d={{entry.dataid}}&disapprove={{entry.id}}" mm-link capture-link="true" title="{{ 'mma.mod_data.disapprove' | translate }}"></a>
77

8-
<mm-comments ng-if="action == 'comments'" context-level="module" instance-id="{{database.coursemodule}}" component="mod_data" item-id="{{entry.id}}" area="database_entry"></mm-comments>
8+
<mm-comments ng-if="action == 'comments' && mode == 'list'" context-level="module" instance-id="{{database.coursemodule}}" component="mod_data" item-id="{{entry.id}}" area="database_entry"></mm-comments>
99

1010
<span ng-if="action == 'moreurl'">{{url}}/mod/data/view.php?d={{entry.dataid}}&amp;rid={{entry.id}}</span>
1111
<span ng-if="action == 'timeadded'">{{ entry.timecreated * 1000 | mmFormatDate:"dffulldate" }}</span>

www/addons/mod/data/templates/entry.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
{{ entryRendered }}
3131
</mm-format-text>
3232
</div>
33+
<mm-comments class="item" ng-if="showComments" context-level="module" instance-id="{{data.coursemodule}}" component="mod_data" item-id="{{entry.id}}" area="database_entry"></mm-comments>
3334
<div ng-if="previousId || nextId" class="item item-text-wrap row-buttons responsive-sm">
3435
<button ng-if="previousId" class="button button-block icon-left ion-chevron-left" ng-click="gotoEntry(previousId)">
3536
{{ 'mm.core.previous' | translate }}

www/core/components/comments/services/comments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ angular.module('mm.core.comments')
7575
return $mmSitesManager.getSite(siteId).then(function(site) {
7676
var params = {
7777
"contextlevel": contextLevel,
78-
"instanceid": instanceId,
78+
"instanceid": parseInt(instanceId, 10),
7979
"component": component,
80-
"itemid": itemId
80+
"itemid": parseInt(itemId, 10)
8181
},
8282
preSets = {};
8383

0 commit comments

Comments
 (0)