Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/issue-1528
Browse files Browse the repository at this point in the history
  • Loading branch information
hansmorb authored Jan 24, 2025
2 parents 103c085 + 9cb2c50 commit 6a19529
Show file tree
Hide file tree
Showing 71 changed files with 4,975 additions and 4,315 deletions.
3 changes: 2 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ phpunit
project.json
README.md
tsconfig.*
webpack.config.js
webpack.config.js
phpstan.neon
47 changes: 47 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PHPStan

on:
push:
branches:
- 'master'
- 'release/**'
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
branches:
- 'master'

jobs:
phpstan:
name: 'WP latest on PHP 8.3'

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4

# TODO Use the composer action below
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: uopz

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies (other PHP versions)
run: |
composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Run static suite
run: |
composer dump-autoload -o
#- uses: actions/checkout@v4
#- uses: php-actions/composer@v6

- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
configuration: phpstan.neon
8 changes: 6 additions & 2 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https:
<exclude name="Wordpress.PHP.YodaConditions" />
<exclude name="WordPress.NamingConventions.ValidVariableName" />
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid" />

<!-- Too much false positives in our codebase, but please reactivate if necessary -->

<!-- Excludes Short Array Syntax sniffs entirely -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>

<!-- Too much false positives in our codebase, but please reactivate if necessary -->
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow" />

Expand Down
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ module.exports = function (grunt) {
],
tasks: [
'dart-sass:adminDev', 'dart-sass:publicDev'
]
],
options: {
livereload: true
}
},
js: {
files: [
Expand Down
40 changes: 37 additions & 3 deletions assets/admin/css/admin.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@charset "UTF-8";
/*
* Admin styles
*
Expand Down Expand Up @@ -3176,15 +3177,15 @@
*
*/
/* -------------------- Boxes -------------------- */
.cb-box {
.cb-box, .cb-admin-page .cb-admin-cols div ul li {
background: var(--commonsbooking-color-gray-background);
overflow: hidden;
border-radius: var(--commonsbooking-radius);
margin-bottom: var(--commonsbooking-spacer);
padding: var(--commonsbooking-spacer-small)/2 var(--commonsbooking-spacer-small);
}
@media (min-width: 37.5em) {
.cb-box {
.cb-box, .cb-admin-page .cb-admin-cols div ul li {
padding: var(--commonsbooking-spacer) var(--commonsbooking-spacer-big);
}
}
Expand Down Expand Up @@ -3507,7 +3508,40 @@ a.disabled {
display: none;
}

/* Booking form */
/* Map creation */
/*
* The CPT creation form map
*/
#cmb2-metabox-cb_map-custom-fields .map-organizer .cmb2-metabox-title {
font-size: x-large;
}
#cmb2-metabox-cb_map-custom-fields .map-organizer .cmb2-metabox-title:before {
/* arrow to right */
content: "→ ";
}
#cmb2-metabox-cb_map-custom-fields .cmb-group-name {
font-size: x-large;
font-weight: bold;
}
#cmb2-metabox-cb_map-custom-fields .cmb-group-name:before {
content: "→ ";
}
#cmb2-metabox-cb_map-custom-fields #shortcode-field {
display: flex;
align-items: center;
flex-wrap: nowrap;
gap: 10px;
}
#cmb2-metabox-cb_map-custom-fields #shortcode-field code {
white-space: nowrap;
margin-right: 10px;
}
#cmb2-metabox-cb_map-custom-fields #shortcode-field .button {
padding: 5px 10px;
line-height: 1.5;
}

/* Plugin update page */
/**
* Plugin list update message
*
Expand Down
75 changes: 71 additions & 4 deletions assets/admin/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
let startTimeInput = $("#repetition-start_time");
let endTimeInput = $("#repetition-end_time");
let preserveManualCode = false;
let itemInput = $("#item-id");
let locationInput = $("#location-id");
let startDateInput = $("#repetition-start_date");
let bookingCodeInput = $("#_cb_bookingcode");
let allExist = [ fullDayCheckbox, startTimeInput, endTimeInput, itemInput, locationInput, startDateInput, bookingCodeInput ].every(domElement => domElement.length === 1);
if (!allExist) {
return;
}
fullDayCheckbox.on("change", function(event) {
if (fullDayCheckbox.is(":checked")) {
startTimeInput.val("00:00");
Expand All @@ -17,10 +25,6 @@
}
});
fullDayCheckbox.trigger("change");
let itemInput = $("#item-id");
let locationInput = $("#location-id");
let startDateInput = $("#repetition-start_date");
let bookingCodeInput = $("#_cb_bookingcode");
itemInput.on("change", function(event) {
let data = {
itemID: itemInput.val()
Expand Down Expand Up @@ -377,6 +381,69 @@
});
})(jQuery);

(function($) {
"use strict";
$(function() {
const mapSettingsForm = $("#cmb2-metabox-cb_map-custom-fields");
const hideFieldset = function(set) {
$.each(set, function() {
$(this).parents(".cmb-row").hide();
});
};
const showFieldset = function(set) {
$.each(set, function() {
$(this).parents(".cmb-row").show();
});
};
const copyToClipboard = function(element) {
let code = $(element).find("code")[0];
let text = code.innerText;
navigator.clipboard.writeText(text).then(function() {
let button = $(element).find(".button");
let buttonText = button.text();
button.text("✓");
button.disabled = true;
setTimeout(function() {
button.text(buttonText);
button.disabled = false;
}, 2e3);
});
};
const copyToClipboardButton = $("#shortcode-field").find(".button");
copyToClipboardButton.on("click", function() {
copyToClipboard($("#shortcode-field"));
});
function handleCustomFileInput(fileSelectorID, fileInputFields) {
const markerFileSelect = document.querySelector(fileSelectorID);
const handleSelectCustomMarker = function() {
showFieldset(fileInputFields);
if (markerFileSelect.value === "") {
hideFieldset(fileInputFields);
}
};
handleSelectCustomMarker();
const observerConfig = {
attributes: true,
childList: false,
subtree: false
};
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === "value") {
handleSelectCustomMarker();
}
});
});
observer.observe(markerFileSelect, observerConfig);
}
if (mapSettingsForm.length) {
handleCustomFileInput("#custom_marker_media", [ $("#marker_icon_width"), $("#marker_icon_height"), $("#marker_icon_anchor_x"), $("#marker_icon_anchor_y") ]);
handleCustomFileInput("#custom_marker_cluster_media", [ $("#marker_cluster_icon_width"), $("#marker_cluster_icon_height") ]);
handleCustomFileInput("#marker_item_draft_media", [ $("#marker_item_draft_icon_width"), $("#marker_item_draft_icon_height"), $("#marker_item_draft_icon_anchor_x"), $("#marker_item_draft_icon_anchor_y") ]);
}
});
})(jQuery);

(function($) {
"use strict";
$(function() {
Expand Down
2 changes: 1 addition & 1 deletion assets/admin/js/admin.min.js

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions assets/admin/js/src/booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
let startTimeInput = $('#repetition-start_time');
let endTimeInput = $('#repetition-end_time');
let preserveManualCode = false;
let itemInput = $('#item-id');
let locationInput = $('#location-id');
let startDateInput = $('#repetition-start_date');
let bookingCodeInput = $('#_cb_bookingcode');

// check if this is loaded on right kind of backend page
let allExist = [
fullDayCheckbox, startTimeInput, endTimeInput, itemInput, locationInput, startDateInput, bookingCodeInput
].every(domElement => domElement.length === 1);

if (!allExist) {
// return early to prevent ajax calls with incorrect parameters
return;
}

fullDayCheckbox.on('change', function (event) {
if (fullDayCheckbox.is(':checked')) {
startTimeInput.val('00:00');
Expand All @@ -18,12 +33,6 @@
});
fullDayCheckbox.trigger('change');


let itemInput = $('#item-id');
let locationInput = $('#location-id');
let startDateInput = $('#repetition-start_date');
let bookingCodeInput = $('#_cb_bookingcode');

itemInput.on('change', function (event) {
let data = {
itemID: itemInput.val(),
Expand Down
91 changes: 91 additions & 0 deletions assets/admin/js/src/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
(function ($) {
'use strict';
$(function () {
const mapSettingsForm = $("#cmb2-metabox-cb_map-custom-fields");

const hideFieldset = function (set) {
$.each(set, function () {
$(this).parents('.cmb-row').hide();
});
};

/**
* Show set-elements.
* @param set
*/
const showFieldset = function (set) {
$.each(set, function () {
$(this).parents('.cmb-row').show();
});
};

const copyToClipboard = function (element) {
let code = $(element).find('code')[0];
let text = code.innerText;
navigator.clipboard.writeText(text).then(function () {
let button = $(element).find('.button');
let buttonText = button.text();
button.text('✓');
button.disabled = true;
setTimeout(function () {
button.text(buttonText);
button.disabled = false;
}, 2000);
});
}

const copyToClipboardButton = $('#shortcode-field').find('.button');
copyToClipboardButton.on('click', function () {
copyToClipboard($('#shortcode-field'));
});

function handleCustomFileInput(fileSelectorID, fileInputFields) {
const markerFileSelect = document.querySelector(fileSelectorID);
const handleSelectCustomMarker = function () {
showFieldset(fileInputFields);
if (markerFileSelect.value === '') {
hideFieldset(fileInputFields);
}
};

handleSelectCustomMarker();

const observerConfig = {attributes: true, childList: false, subtree: false};
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === 'value') {
handleSelectCustomMarker();
}
});
});
observer.observe(markerFileSelect, observerConfig);
}

if (mapSettingsForm.length) {
handleCustomFileInput(
'#custom_marker_media',
[
$('#marker_icon_width'),
$('#marker_icon_height'),
$('#marker_icon_anchor_x'),
$('#marker_icon_anchor_y')
]);
handleCustomFileInput(
'#custom_marker_cluster_media',
[
$('#marker_cluster_icon_width'),
$('#marker_cluster_icon_height')
]
);
handleCustomFileInput(
'#marker_item_draft_media',
[
$('#marker_item_draft_icon_width'),
$('#marker_item_draft_icon_height'),
$('#marker_item_draft_icon_anchor_x'),
$('#marker_item_draft_icon_anchor_y')
]
);
}
});
})(jQuery);
5 changes: 4 additions & 1 deletion assets/admin/sass/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
/* Booking form */
@use "./partials/form-booking";

/* Booking form */
/* Map creation */
@use "./partials/form-map";

/* Plugin update page */
@use "./partials/plugin_update";

/* Edit Screens Backend */
Expand Down
Loading

0 comments on commit 6a19529

Please sign in to comment.