diff --git a/src/addons/mod/data/components/search/search.ts b/src/addons/mod/data/components/search/search.ts index 954e944a9..ced4e44fe 100644 --- a/src/addons/mod/data/components/search/search.ts +++ b/src/addons/mod/data/components/search/search.ts @@ -125,6 +125,18 @@ export class AddonModDataSearchComponent implements OnInit { [placeholder]="\'addon.mod_data.authorlastname\' | translate" formControlName="lastname">'; template = template.replace(replaceRegex, render); + // Searching by otherfields. + const regex = new RegExp('##otherfields##', 'gi'); + + if (template.match(regex)) { + const unusedFields = this.fieldsArray.filter(field => !template.includes(`[field]="fields[${field.id}]`)).map((field) => + `
${field.name}
` + + ''); + + template = template.replace(regex, unusedFields.join('')); + } + // Searching by tags is not supported. replaceRegex = new RegExp('##tags##', 'gi'); const message = CoreTag.areTagsAvailableInSite() ? diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index 6509bc4a4..a53dc4559 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -440,6 +440,18 @@ export class AddonModDataEditPage implements OnInit { template = template.replace(replaceRegEx, 'field_' + field.id); }); + const regex = new RegExp('##otherfields##', 'gi'); + + if (template.match(regex)) { + const unusedFields = this.fieldsArray.filter(field => !template.includes(`[field]="fields[${field.id}]`)).map((field) => + `
${field.name}
` + + '');
+
+ template = template.replace(regex, unusedFields.join(''));
+ }
+
// Editing tags is not supported.
const replaceRegEx = new RegExp('##tags##', 'gi');
const message = CoreTag.areTagsAvailableInSite()
diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts
index 6de9d53f8..901416dc2 100644
--- a/src/addons/mod/data/services/data-helper.ts
+++ b/src/addons/mod/data/services/data-helper.ts
@@ -191,9 +191,10 @@ export class AddonModDataHelperProvider {
* @param template Template HMTL.
* @param fields Fields that defines every content in the entry.
* @param entry Entry.
- * @param offset Entry offset.
* @param mode Mode list or show.
* @param actions Actions that can be performed to the record.
+ * @param options Show fields options (sortBy, offset, etc).
+ *
* @returns Generated HTML.
*/
displayShowFields(
@@ -225,28 +226,54 @@ export class AddonModDataHelperProvider {
for (const action in actions) {
const replaceRegex = new RegExp('##' + action + '##', 'gi');
// Is enabled?
- if (actions[action]) {
- let render = '';
- if (action == AddonModDataAction.MOREURL) {
- // Render more url directly because it can be part of an HTML attribute.
- render = CoreSites.getRequiredCurrentSite().getURL() + '/mod/data/view.php?d={{database.id}}&rid=' + entry.id;
- } else if (action == 'approvalstatus') {
- render = Translate.instant('addon.mod_data.' + (entry.approved ? 'approved' : 'notapproved'));
- } else {
- render = `
${field.name}
` + + '