Skip to content
Code-Schnipsel Gruppen Projekte
Commit a8ecb4a0 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: update variable declarations and cache handling

This commit involves refactoring code in Products.js by updating 'var' to 'let' or 'const' for
proper scoping and better readability. It also introduces a new variable 'inAdministration' to
handle specific conditions for QUIQQER's administrative state and modifies the condition for using
cached data, considering 'inAdministration'. Expect no changes in functionality or behavior of the
software with these changes.
Übergeordneter c18b0b9c
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!114Update 'next-3.x' with latest changes from 'main',!113fix: update variable declarations and cache handling
Pipeline-Nr. 16135 bestanden
......@@ -84,19 +84,19 @@ define('package/quiqqer/products/bin/classes/Products', [
*/
openProduct: function (productId) {
return this.getChild(productId).then(function (attributes) {
var panel = attributes.typePanel;
let panel = attributes.typePanel;
if (panel === '' || typeof panel === 'undefined') {
panel = 'package/quiqqer/products/bin/controls/products/Product';
}
return new Promise(function (resolve) {
var needles = [];
let needles = [];
needles.push(panel);
needles.push('utils/Panels');
require(needles, function (Panel, Utils) {
var Control = new Panel({
const Control = new Panel({
productId: productId
});
......@@ -175,7 +175,7 @@ define('package/quiqqer/products/bin/classes/Products', [
}
require(['Projects'], function (Projects) {
var Project = Projects.get(result.project),
const Project = Projects.get(result.project),
Media = Project.getMedia();
Media.get(result.id).then(resolve).catch(function () {
......@@ -231,8 +231,13 @@ define('package/quiqqer/products/bin/classes/Products', [
const jsonData = JSON.stringify({productId, fields});
const key = btoa(String.fromCharCode(...new TextEncoder().encode(jsonData))).slice(0, 32);
let inAdministration = false;
if (typeof QUIQQER.inAdministration !== 'undefined' && QUIQQER.inAdministration) {
inAdministration = !!QUIQQER.inAdministration;
}
return new Promise(function (resolve, reject) {
if (!forceCache && typeof requestCache[key] !== 'undefined') {
if (!forceCache && typeof requestCache[key] !== 'undefined' && !inAdministration) {
// JSON.parse(JSON.stringify because JS reference usage
return resolve(JSON.parse(JSON.stringify(requestCache[key])));
}
......@@ -489,7 +494,7 @@ define('package/quiqqer/products/bin/classes/Products', [
'package/quiqqer/products/bin/controls/products/Product',
'utils/Panels'
], function (ProductPanel, Panels) {
var PPanel = new ProductPanel({
const PPanel = new ProductPanel({
productId: productId,
'#id': productId
});
......@@ -504,7 +509,7 @@ define('package/quiqqer/products/bin/classes/Products', [
* @param {number} pid
*/
addToVisited: function (pid) {
var visited = this.getVisitedProductIds();
let visited = this.getVisitedProductIds();
visited.push(pid);
visited = visited.unique();
......@@ -522,7 +527,7 @@ define('package/quiqqer/products/bin/classes/Products', [
* @returns {Array}
*/
getVisitedProductIds: function () {
var visited = QUI.Storage.get('quiqqer-products-visited');
let visited = QUI.Storage.get('quiqqer-products-visited');
if (!visited) {
return [];
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren