Skip to content

Commit 6ebd806

Browse files
committed
MOBILE-2178 database: Don't use directive for approvalstatus action
1 parent 7dd7efc commit 6ebd806

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ angular.module('mm.addons.mod_data')
108108

109109
var actions = $mmaModDataHelper.getActions(data, access, $scope.entry);
110110

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ angular.module('mm.addons.mod_data')
254254

255255
var actions = $mmaModDataHelper.getActions(data, $scope.access, entry);
256256

257-
entriesHTML += $mmaModDataHelper.displayShowFields(data.listtemplate, $scope.fields, entry.id, 'list', actions);
257+
entriesHTML += $mmaModDataHelper.displayShowFields(data.listtemplate, $scope.fields, entry, 'list', actions);
258258
});
259259
entriesHTML += data.listtemplatefooter;
260260

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ angular.module('mm.addons.mod_data')
2222
* @name $mmaModDataHelper
2323
*/
2424
.factory('$mmaModDataHelper', function($mmaModData, $mmaModDataFieldsDelegate, $q, mmaModDataComponent, $mmFileUploader, $mmSite,
25-
$mmaModDataOffline, $mmFS, $mmFileUploaderHelper, $mmSitesManager) {
25+
$mmaModDataOffline, $mmFS, $mmFileUploaderHelper, $mmSitesManager, $translate) {
2626

2727
var self = {
2828
searchOther: {
@@ -39,12 +39,12 @@ angular.module('mm.addons.mod_data')
3939
* @name $mmaModDataHelper#displayShowFields
4040
* @param {String} template Template HMTL.
4141
* @param {Array} fields Fields that defines every content in the entry.
42-
* @param {Number} entryId Entry ID.
42+
* @param {Object} entry Entry.
4343
* @param {String} mode Mode list or show.
4444
* @param {Object} actions Actions that can be performed to the record.
4545
* @return {String} Generated HTML.
4646
*/
47-
self.displayShowFields = function(template, fields, entryId, mode, actions) {
47+
self.displayShowFields = function(template, fields, entry, mode, actions) {
4848
if (!template) {
4949
return "";
5050
}
@@ -58,19 +58,21 @@ 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 field="fields['+ field.id + ']" value="entries['+ entryId +'].contents['+ field.id +
62-
']" mode="'+mode+'" database="data" view-action="gotoEntry('+ entryId +')"></mma-mod-data-field>';
61+
render = '<mma-mod-data-field field="fields['+ field.id + ']" value="entries['+ entry.id +'].contents['+ field.id +
62+
']" mode="'+mode+'" database="data" view-action="gotoEntry('+ entry.id +')"></mma-mod-data-field>';
6363
template = template.replace(replace, render);
6464
});
6565

6666
angular.forEach(actions, function(enabled, action) {
6767
replace = new RegExp("##" + action + "##", 'gi');
6868
if (enabled) {
69-
if (action == "moreurl") {
69+
if (action == 'moreurl') {
7070
// Render more url directly because it can be part of an HTML attribute.
71-
render = $mmSite.getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entryId;
71+
render = $mmSite.getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entry.id;
72+
} else if (action == 'approvalstatus') {
73+
render = $translate.instant('mma.mod_data.' + (entry.approved ? 'approved' : 'notapproved'));
7274
} else {
73-
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entryId +
75+
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entry.id +
7476
']" mode="'+mode+'" database="data"></mma-mod-data-action>';
7577
}
7678
template = template.replace(replace, render);

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77

88
<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

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

14-
<span ng-if="action == 'approvalstatus'">
15-
<span ng-if="entry.approved">{{ 'mma.mod_data.approved' | translate }}</span>
16-
<span ng-if="!entry.approved">{{ 'mma.mod_data.notapproved' | translate }}</span>
17-
</span>
18-
1913
<a ng-if="action == 'userpicture'" mm-user-link courseid="{{database.courseid}}" userid="{{entry.userid}}" title="{{entry.fullname}}">
2014
<img ng-if="userpicture" ng-src="{{userpicture}}" class="avatar-round" alt="{{ 'mm.core.pictureof' | translate:{$a: entry.fullname} }}" role="presentation" mm-external-content>
2115
<img ng-if="!userpicture" class="avatar-round" src="img/user-avatar.png" alt="{{ 'mm.core.pictureof' | translate:{$a: entry.fullname} }}" role="presentation">

0 commit comments

Comments
 (0)