Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion www/addons/mod/data/controllers/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ angular.module('mm.addons.mod_data')

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

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

return $mmaModDataHelper.getPageInfoByEntry(data.id, entryId, $scope.selectedGroup).then(function(result) {
Expand Down
6 changes: 3 additions & 3 deletions www/addons/mod/data/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ angular.module('mm.addons.mod_data')

$scope.search = {
sortBy: "0",
sortDirection: "ASC",
sortDirection: "DESC",
page: 0,
text: "",
searching: false,
Expand Down Expand Up @@ -254,7 +254,7 @@ angular.module('mm.addons.mod_data')

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

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

Expand Down Expand Up @@ -386,7 +386,7 @@ angular.module('mm.addons.mod_data')
// Reset all search filters and closes the modal.
$scope.searchReset = function() {
$scope.search.sortBy = "0";
$scope.search.sortDirection = "ASC";
$scope.search.sortDirection = "DESC";
$scope.search.text = "";
$scope.search.advanced = {};
$scope.search.searchingAdvanced = false;
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/data/fields/url/template.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span ng-if="mode == 'edit'" mm-mark-required="{{field.required}}"></span>
<input ng-if="mode != 'show'" type="text" placeholder="{{field.name}}" name="f_{{field.id}}" ng-model="val">
<a ng-if="mode == 'show' && value && value.content" ng-href="{{value.content}}">{{field.name}}</a>
<a ng-if="mode == 'show' && value && value.content" ng-href="{{value.content}}" mm-link capture-link="true">{{field.name}}</a>
2 changes: 1 addition & 1 deletion www/addons/mod/data/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
padding: 0;
}

td {
td, th {
@extend .col;
}
}
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/data/services/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ angular.module('mm.addons.mod_data')
perpage: perPage || mmaModDataPerPage,
groupid: groupId || 0,
sort: sort || "0",
order: order || "ASC"
order: order || "DESC"
},
preSets = {
cacheKey: getEntriesCacheKey(dataId, groupId)
Expand Down
18 changes: 10 additions & 8 deletions www/addons/mod/data/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ angular.module('mm.addons.mod_data')
* @name $mmaModDataHelper
*/
.factory('$mmaModDataHelper', function($mmaModData, $mmaModDataFieldsDelegate, $q, mmaModDataComponent, $mmFileUploader, $mmSite,
$mmaModDataOffline, $mmFS, $mmFileUploaderHelper, $mmSitesManager) {
$mmaModDataOffline, $mmFS, $mmFileUploaderHelper, $mmSitesManager, $translate) {

var self = {
searchOther: {
Expand All @@ -39,12 +39,12 @@ angular.module('mm.addons.mod_data')
* @name $mmaModDataHelper#displayShowFields
* @param {String} template Template HMTL.
* @param {Array} fields Fields that defines every content in the entry.
* @param {Number} entryId Entry ID.
* @param {Object} entry Entry.
* @param {String} mode Mode list or show.
* @param {Object} actions Actions that can be performed to the record.
* @return {String} Generated HTML.
*/
self.displayShowFields = function(template, fields, entryId, mode, actions) {
self.displayShowFields = function(template, fields, entry, mode, actions) {
if (!template) {
return "";
}
Expand All @@ -58,19 +58,21 @@ angular.module('mm.addons.mod_data')
replace = new RegExp(replace, 'gi');

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

angular.forEach(actions, function(enabled, action) {
replace = new RegExp("##" + action + "##", 'gi');
if (enabled) {
if (action == "moreurl") {
if (action == 'moreurl') {
// Render more url directly because it can be part of an HTML attribute.
render = $mmSite.getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entryId;
render = $mmSite.getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entry.id;
} else if (action == 'approvalstatus') {
render = $translate.instant('mma.mod_data.' + (entry.approved ? 'approved' : 'notapproved'));
} else {
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entryId +
render = '<mma-mod-data-action action="' + action + '" entry="entries['+ entry.id +
']" mode="'+mode+'" database="data"></mma-mod-data-action>';
}
template = template.replace(replace, render);
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/data/services/prefetch_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ angular.module('mm.addons.mod_data')
files = [];

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

database = data;
return $mmGroups.getActivityGroupInfo(module.id, false, undefined, siteId).then(function(groupInfo) {
Expand Down
6 changes: 0 additions & 6 deletions www/addons/mod/data/templates/action.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@

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

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

<span ng-if="action == 'approvalstatus'">
<span ng-if="entry.approved">{{ 'mma.mod_data.approved' | translate }}</span>
<span ng-if="!entry.approved">{{ 'mma.mod_data.notapproved' | translate }}</span>
</span>

<a ng-if="action == 'userpicture'" mm-user-link courseid="{{database.courseid}}" userid="{{entry.userid}}" title="{{entry.fullname}}">
<img ng-if="userpicture" ng-src="{{userpicture}}" class="avatar-round" alt="{{ 'mm.core.pictureof' | translate:{$a: entry.fullname} }}" role="presentation" mm-external-content>
<img ng-if="!userpicture" class="avatar-round" src="img/user-avatar.png" alt="{{ 'mm.core.pictureof' | translate:{$a: entry.fullname} }}" role="presentation">
Expand Down