Skip to content

Commit

Permalink
Merge pull request #547 from PAWECOGmbH/development
Browse files Browse the repository at this point in the history
Dev to Staging
  • Loading branch information
ptruessel authored Nov 15, 2024
2 parents dabeda0 + f007e1e commit 956ef08
Show file tree
Hide file tree
Showing 44 changed files with 1,208 additions and 944 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/frontend/core/* merge=theirs
/frontend/default_theme/* merge=theirs
/frontend/index.cfm merge=ours
/frontend/custom_theme/* merge=ours
/backend/core/* merge=theirs
11 changes: 11 additions & 0 deletions config/db/core/V3__frontend-changes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

UPDATE frontend_mappings SET strPath = 'templates/login.cfm' WHERE strMapping = 'login';
UPDATE frontend_mappings SET strPath = 'templates/register.cfm' WHERE strMapping = 'register';
UPDATE frontend_mappings SET strPath = 'templates/password.cfm' WHERE strMapping = 'password';
UPDATE frontend_mappings SET strPath = 'templates/plans.cfm' WHERE strMapping = 'plans';
UPDATE frontend_mappings SET strPath = 'templates/mfa.cfm' WHERE strMapping = 'mfa';


SET FOREIGN_KEY_CHECKS = 1;
17 changes: 15 additions & 2 deletions www/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
application.errorMail = variables.errorEmail;
application.mainURL = variables.mainURL;
application.environment = variables.environment;
application.activeTheme = variables.activeTheme;

// Payrexx initialising
local.payrexxStruct = structNew();
Expand All @@ -55,6 +56,7 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
application.objNotifications = new backend.core.com.notifications();
application.objSysadmin = new backend.core.com.sysadmin();
application.objMeta = new backend.core.com.meta();
application.objCoreUtil = new frontend.core.com.coreutility();

// Save all choosable languages into a list
local.qLanguages = queryExecute(
Expand Down Expand Up @@ -244,12 +246,23 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp

// Protect the 'backend' folder excluding the pdf print page
if (listFirst(thiscontent.thisPath, "/") eq "backend" and !structKeyExists(session, "user_id")) {

if (structKeyExists(url, "pdf")) {

location url="#application.mainURL#/backend/core/views/invoices/print.cfm?pdf=#url.pdf#" addtoken="false";

} else {
getAlert('alertSessionExpired', 'warning');
location url="#application.mainURL#/login" addtoken="false";

// Redirect to the register form with plan redirect
if (structKeyExists(url, "plan")) {
location url="#application.mainURL#/register?redirect=book?plan=#url.plan#" addtoken="false";
} else {
getAlert('alertSessionExpired', 'warning');
location url="#application.mainURL#/login" addtoken="false";
}

}

}


Expand Down
13 changes: 13 additions & 0 deletions www/assets/img/payments/card_post-finance-pay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions www/backend/core/com/global.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ component displayname="globalFunctions" output="false" {
strMapping: {type: "nvarchar", value: local.sefString}
},
sql = "
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend
FROM system_mappings
WHERE strMapping = :strMapping
UNION
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend
FROM custom_mappings
WHERE strMapping = :strMapping
UNION
SELECT strPath, 0, 0, 0
SELECT strPath, 0, 0, 0, 1 as itsFrontend
FROM frontend_mappings
WHERE strMapping = :strMapping
UNION
Expand All @@ -47,15 +47,19 @@ component displayname="globalFunctions" output="false" {
SELECT strPath
FROM frontend_mappings
WHERE intFrontendMappingsID = frontend_mappings_trans.intFrontendMappingsID
) as strPath, 0, 0, 0
) as strPath, 0, 0, 0, 1 as itsFrontend
FROM frontend_mappings_trans
WHERE strMapping = :strMapping
LIMIT 1
"
)

if (local.qCheckSEF.recordCount) {
local.returnStruct['thisPath'] = local.qCheckSEF.strPath;
if (local.qCheckSEF.itsFrontend) {
local.returnStruct['thisPath'] = "frontend/" & application.activeTheme & "/" & local.qCheckSEF.strPath;
} else {
local.returnStruct['thisPath'] = local.qCheckSEF.strPath;
}
local.returnStruct['onlyAdmin'] = trueFalseFormat(local.qCheckSEF.blnOnlyAdmin);
local.returnStruct['onlySuperAdmin'] = trueFalseFormat(local.qCheckSEF.blnOnlySuperAdmin);
local.returnStruct['onlySysAdmin'] = trueFalseFormat(local.qCheckSEF.blnOnlySysAdmin);
Expand Down
3 changes: 1 addition & 2 deletions www/backend/core/com/translate.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ component displayname="translate" accessors="true" {
writeOutput("SELECT #variables.thisField# as myField FROM #variables.thisTable# WHERE #variables.thisPrimKey# = #variables.thisID#");
}

local.replacedCode = replaceList(local.qContent.myField, "<,>", "&lt;,&gt;");
local.replacedCode = replace(local.replacedCode, "#chr(13)#", "<br />", "all");
local.replacedCode = replace(local.qContent.myField, "#chr(13)#", "<br />", "all");
writeOutput(local.replacedCode);

return;
Expand Down
106 changes: 106 additions & 0 deletions www/backend/dist/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,52 @@ function generateUUID() {
}


// Constants for max pixels
const maxPixels = {
metatitle: 580,
metadescription: 1000
};

/**
* Calculates the pixel width of the given text based on the specified font settings.
* @param {string} text - The text to measure.
* @param {string} fontSettings - The font settings to apply (e.g., '400 14px Arial').
* @returns {number} - The width of the text in pixels.
*/
function getTextWidth(text, fontSettings) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.font = fontSettings;
return Math.round(context.measureText(text).width);
}

/**
* Updates the pixel count progress for a given input, progress bar, and max pixel threshold.
* @param {string} inputId - The ID of the input field.
* @param {string} progressId - The ID of the progress bar element.
* @param {string} progressBarId - The ID of the progress text element.
* @param {number} maxPixels - The maximum pixel width allowed.
* @param {string} fontSettings - The font settings for calculating pixel width.
*/
function updatePixelCount(inputId, progressId, progressBarId, maxPixels, fontSettings) {
const input = document.getElementById(inputId);
const progress = document.getElementById(progressId);
const progressbar = document.getElementById(progressBarId);
const text = input.value;
const pixels = getTextWidth(text, fontSettings);
const percentage = (pixels / maxPixels) * 100;

progress.style.width = `${percentage}%`;
progressbar.textContent = `${pixels} px / ${maxPixels} px`;

if (percentage <= 20) {
progress.style.backgroundColor = 'orange';
} else if (percentage > 100) {
progress.style.backgroundColor = 'red';
} else {
progress.style.backgroundColor = 'green';
}
}



Expand Down Expand Up @@ -660,6 +706,66 @@ $(document).ready(function() {
});


/**
* Initializes event bindings and DOM interactions for dynamic pixel counting.
* This section depends on the utility functions defined above (`updatePixelCount`, `getTextWidth`),
* which are set outside `$(document).ready()` as they do not require the DOM to be fully loaded.
*
* - Setting up pixel counters for inputs with IDs starting with 'input'
* - Adding event listeners for `input` and `shown.bs.modal` to update pixel counts and progress bars dynamically.
*/
$('[id^=input]').each(function () {
const id = $(this).attr('id').replace('input', '');
const maxPixelValue = id.includes('Desc') ? maxPixels.metadescription : maxPixels.metatitle;
const fontSettings = id.includes('Desc') ? '400 14px Arial, sans-serif' : '400 20px Roboto, HelveticaNeue, Arial, sans-serif';

updatePixelCount(`input${id}`, `progress${id}`, `progressbar${id}`, maxPixelValue, fontSettings);

$(this).on('input', function () {
updatePixelCount(`input${id}`, `progress${id}`, `progressbar${id}`, maxPixelValue, fontSettings);
});
});

// Event listener for modals being shown
$(document).on('shown.bs.modal', '.modal', function (e) {
const targetId = $(e.relatedTarget).data('bs-target');

// Check if modal target involves metatitle or metadescription
if (targetId && (targetId.includes('frontend_metatitle') || targetId.includes('frontend_metadescription'))) {
const modal = $(e.target);
const textareas = modal.find('textarea');

textareas.each(function () {
const textarea = $(this);
const textareaId = textarea.attr('id') || `textarea${Date.now() + Math.random().toString(36).substr(2, 9)}`;
textarea.attr('id', textareaId);
const progressId = `progress${textareaId}`;
const progressbarId = `progressbar${textareaId}`;
const maxPixelValue = targetId.includes('metadescription') ? maxPixels.metadescription : maxPixels.metatitle;
const fontSettings = targetId.includes('metadescription') ? '400 14px Arial, sans-serif' : '400 20px Roboto, HelveticaNeue, Arial, sans-serif';

// Add progress bar if not already present
if (!document.getElementById(progressId)) {
textarea.after(`
<div class="d-flex mt-2">
<div class="progress-bar" style="flex-grow: 1;">
<div id="${progressId}" class="progress"></div>
</div>
<div id="${progressbarId}" class="progress-text" style="margin-left: 10px;">0 px / ${maxPixelValue} px</div>
</div>
`);
}

updatePixelCount(textareaId, progressId, progressbarId, maxPixelValue, fontSettings);

textarea.on('input', function () {
updatePixelCount(textareaId, progressId, progressbarId, maxPixelValue, fontSettings);
});
});
}
});


});


Expand Down
Loading

0 comments on commit 956ef08

Please sign in to comment.