Skip to content

Commit c888284

Browse files
committed
Update utilities.js
WIP, mute translation render method; changing the way this works and probably will not need the method after rework...
1 parent 1d8f3a7 commit c888284

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

manager/assets/modext/util/utilities.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ MODx.util.UrlParams = {
6363
this.set({})
6464
},
6565
parse(str) {
66-
const params = new URLSearchParams(str)
67-
return Object.fromEntries(params.entries())
66+
const params = new URLSearchParams(str);
67+
return Object.fromEntries(params.entries());
6868
}
6969
}
7070

@@ -1178,3 +1178,37 @@ MODx.util.FileDownload = function (fields) {
11781178
me.isFinished(successCallback, failureCallback);
11791179
}
11801180
};
1181+
1182+
// MODx.util.Render = {
1183+
// /**
1184+
// * Get a translated field value from an object's record; primarily used
1185+
// * for core-installed objects
1186+
// * @param {String} fieldName The field's name or dataIndex
1187+
// * @param {Object} record The object's complete record
1188+
// * @param {Boolean} translateProtectedOnly Whether to translate only protected (typically core-installed) objects
1189+
// * @returns {String} The translated field or its default if not translation is available
1190+
// */
1191+
// translatedValue: function (fieldName, record, translateProtectedOnly = true) {
1192+
// const
1193+
// isGridRecord = Object.hasOwn(record, 'json'),
1194+
// dataObject = isGridRecord ? record.json : record
1195+
// ;
1196+
// if (MODx.cultureKey === 'en' || (translateProtectedOnly && !dataObject.isProtected)) {
1197+
// // console.log(`translatedValue :: do not translate ${record[fieldName]}...`);
1198+
// /*
1199+
// To update a grid's display of a single record after a successful
1200+
// edit without refreshing the entire grid (causing a new request
1201+
// and query to the back end), a call to the grid store's commit()
1202+
// method is made to update the row. This is only available in the
1203+
// data prop (the json prop is populated from the back end)
1204+
// */
1205+
// return isGridRecord ? record.data[fieldName] : record[fieldName] ;
1206+
// }
1207+
// // Return default value when no translation has been processed for this object
1208+
// // console.log(`translatedValue :: translating ${fieldName}...`);
1209+
// return Object.hasOwn(dataObject, `${fieldName}_trans`) && !dataObject[`${fieldName}_trans_missing`]
1210+
// ? dataObject[`${fieldName}_trans`]
1211+
// : dataObject[fieldName]
1212+
// ;
1213+
// }
1214+
// }

0 commit comments

Comments
 (0)