Skip to content

Commit

Permalink
Merge pull request #1356 from Pervanovo/pr-better-collectionlink-rend…
Browse files Browse the repository at this point in the history
…erer

Localize collectionlink renderer
  • Loading branch information
aheinze authored Oct 22, 2020
2 parents 8873145 + fee3b2c commit b7c826a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions assets/app/js/app.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@

App.Utils.renderer.textarea = App.Utils.renderer.text;

App.Utils.renderValue = function (renderer, v, meta) {
return (this.renderer[renderer] || this.renderer.default)(v, meta);
App.Utils.renderValue = function (renderer, v, meta, lang) {
return (this.renderer[renderer] || this.renderer.default)(v, meta, lang);
};

// riot enhancments
Expand Down
2 changes: 1 addition & 1 deletion modules/Collections/assets/field-collectionlink.tag
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<tr each="{entry,idx in entries}">
<td show="{parent.opts.multiple}"><input class="uk-checkbox" type="checkbox" onclick="{parent.toggleSelected}"></td>
<td class="uk-text-truncate" each="{field,idy in parent.fields}" if="{ field.name != '_modified' }">
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field) }"></raw>
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field, lang) }"></raw>
</td>
<td>{ App.Utils.dateformat( new Date( 1000 * entry._modified )) }</td>
<td show="{!parent.opts.multiple}">
Expand Down
6 changes: 3 additions & 3 deletions modules/Collections/assets/link-collectionitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

var linkCache = {};

App.Utils.renderer.collectionlink = function (v, field) {
App.Utils.renderer.collectionlink = function (v, field, lang) {

if (!v) {
if (!v || v.length === 0) {
return '<i class="uk-icon-eye-slash uk-text-muted"></i>';
}

Expand All @@ -19,7 +19,7 @@

linkCache[v._id] = new Promise(function (resolve) {

App.request('/collections/find', { collection: field.options.link, options: { filter: { _id: v._id } } }).then(function (data) {
App.request('/collections/find', { collection: field.options.link, options: { lang: lang, filter: { _id: v._id } } }).then(function (data) {

if (!data.entries || !data.entries.length) {
v.display = 'n/a';
Expand Down
4 changes: 2 additions & 2 deletions modules/Collections/views/partials/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<div class="uk-margin-small-bottom" each="{field,idy in parent.fields}" if="{ field.name != '_modified' && field.name != '_created' }">
<span class="uk-text-small uk-text-uppercase uk-text-muted">{ field.label || field.name }</span>
<a class="uk-link-muted uk-text-small uk-display-block uk-text-truncate" href="@route('/collections/entry/'.$collection['name'])/{ parent.entry._id }">
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field) }" if="{parent.entry[field.name] !== undefined}"></raw>
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field, lang) }" if="{parent.entry[field.name] !== undefined}"></raw>
<span class="uk-icon-eye-slash uk-text-muted" if="{parent.entry[field.name] === undefined}"></span>
</a>
</div>
Expand Down Expand Up @@ -226,7 +226,7 @@
<td><input class="uk-checkbox" type="checkbox" data-check data-id="{ entry._id }"></td>
<td class="uk-text-truncate" each="{field,idy in parent.fields}" if="{ field.name != '_modified' && field.name != '_created' }">
<a class="uk-link-muted" href="@route('/collections/entry/'.$collection['name'])/{ parent.entry._id }">
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field) }" if="{parent.entry[field.name] !== undefined}"></raw>
<raw content="{ App.Utils.renderValue(field.type, parent.entry[field.name], field, lang) }" if="{parent.entry[field.name] !== undefined}"></raw>
<span class="uk-icon-eye-slash uk-text-muted" if="{parent.entry[field.name] === undefined}"></span>
</a>
</td>
Expand Down

0 comments on commit b7c826a

Please sign in to comment.