Skip to content

Commit ffa0b51

Browse files
authored
Merge pull request #1112 from dpalou/MOBILE-2178
Mobile 2178
2 parents ee69bd7 + 3f554c3 commit ffa0b51

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ angular.module('mm.addons.mod_data')
4848

4949
$scope.search = {
5050
sortBy: "0",
51-
sortDirection: "ASC",
51+
sortDirection: "DESC",
5252
page: 0,
5353
text: "",
5454
searching: false,
@@ -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

@@ -386,7 +386,7 @@ angular.module('mm.addons.mod_data')
386386
// Reset all search filters and closes the modal.
387387
$scope.searchReset = function() {
388388
$scope.search.sortBy = "0";
389-
$scope.search.sortDirection = "ASC";
389+
$scope.search.sortDirection = "DESC";
390390
$scope.search.text = "";
391391
$scope.search.advanced = {};
392392
$scope.search.searchingAdvanced = false;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<span ng-if="mode == 'edit'" mm-mark-required="{{field.required}}"></span>
22
<input ng-if="mode != 'show'" type="text" placeholder="{{field.name}}" name="f_{{field.id}}" ng-model="val">
3-
<a ng-if="mode == 'show' && value && value.content" ng-href="{{value.content}}">{{field.name}}</a>
3+
<a ng-if="mode == 'show' && value && value.content" ng-href="{{value.content}}" mm-link capture-link="true">{{field.name}}</a>

www/addons/mod/data/scss/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
padding: 0;
2626
}
2727

28-
td {
28+
td, th {
2929
@extend .col;
3030
}
3131
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ angular.module('mm.addons.mod_data')
315315
perpage: perPage || mmaModDataPerPage,
316316
groupid: groupId || 0,
317317
sort: sort || "0",
318-
order: order || "ASC"
318+
order: order || "DESC"
319319
},
320320
preSets = {
321321
cacheKey: getEntriesCacheKey(dataId, groupId)

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/services/prefetch_handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ angular.module('mm.addons.mod_data')
8181
files = [];
8282

8383
return $mmaModData.getDatabase(courseId, module.id, siteId, forceCache).then(function(data) {
84-
files = self.getIntroFilesFromInstance(module, database);
84+
files = self.getIntroFilesFromInstance(module, data);
8585

8686
database = data;
8787
return $mmGroups.getActivityGroupInfo(module.id, false, undefined, siteId).then(function(groupInfo) {

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)