Add core data structures for Buildings and Rooms (v0.1.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m6s
All checks were successful
Create Release Package / build-release (push) Successful in 1m6s
Phase 1 implementation includes: - Custom Post Type: Buildings with address, contact, and details meta - Custom Post Type: Rooms with building relationship and gallery - Custom Taxonomy: Room Types (hierarchical) - Custom Taxonomy: Amenities (non-hierarchical with icons) - Admin columns, filters, and status badges - Gallery meta box with media library integration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,3 +79,115 @@
|
||||
.submit .button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Room Gallery */
|
||||
.bnb-gallery-container {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.bnb-gallery-images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.bnb-gallery-image {
|
||||
position: relative;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.bnb-gallery-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.bnb-gallery-image .bnb-remove-image {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.bnb-gallery-image:hover .bnb-remove-image {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.bnb-gallery-image .bnb-remove-image:hover {
|
||||
background: #d63638;
|
||||
}
|
||||
|
||||
/* Status Badge */
|
||||
.bnb-status-badge {
|
||||
display: inline-block;
|
||||
padding: 3px 8px;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Room Details Meta Box */
|
||||
#bnb_room_details .form-table td label {
|
||||
display: inline-block;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
/* Building Details Meta Box */
|
||||
#bnb_building_details p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
#bnb_building_details label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#bnb_building_details input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Admin Columns */
|
||||
.column-city,
|
||||
.column-country,
|
||||
.column-room_number,
|
||||
.column-capacity,
|
||||
.column-status {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.column-building {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.column-rooms {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
/* Dashicons in columns */
|
||||
.column-capacity .dashicons {
|
||||
color: #646970;
|
||||
font-size: 16px;
|
||||
vertical-align: middle;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,102 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize room gallery functionality.
|
||||
*/
|
||||
function initRoomGallery() {
|
||||
var $container = $('#bnb-room-gallery');
|
||||
var $addButton = $('#bnb-add-gallery-images');
|
||||
var $input = $('#bnb_room_gallery');
|
||||
var $imagesContainer = $container.find('.bnb-gallery-images');
|
||||
|
||||
if (!$addButton.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Media frame for selecting images.
|
||||
var mediaFrame;
|
||||
|
||||
// Add images button click.
|
||||
$addButton.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// If frame exists, reopen it.
|
||||
if (mediaFrame) {
|
||||
mediaFrame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create media frame.
|
||||
mediaFrame = wp.media({
|
||||
title: wpBnbAdmin.i18n.selectImages,
|
||||
button: {
|
||||
text: wpBnbAdmin.i18n.addToGallery
|
||||
},
|
||||
multiple: true,
|
||||
library: {
|
||||
type: 'image'
|
||||
}
|
||||
});
|
||||
|
||||
// Handle selection.
|
||||
mediaFrame.on('select', function() {
|
||||
var selection = mediaFrame.state().get('selection');
|
||||
selection.each(function(attachment) {
|
||||
var data = attachment.toJSON();
|
||||
var thumbnail = data.sizes.thumbnail ? data.sizes.thumbnail.url : data.url;
|
||||
|
||||
// Check if already in gallery.
|
||||
if ($imagesContainer.find('[data-id="' + data.id + '"]').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add image to gallery.
|
||||
var $image = $('<div class="bnb-gallery-image" data-id="' + data.id + '">' +
|
||||
'<img src="' + thumbnail + '" alt="">' +
|
||||
'<button type="button" class="bnb-remove-image">×</button>' +
|
||||
'</div>');
|
||||
$imagesContainer.append($image);
|
||||
});
|
||||
|
||||
updateGalleryInput();
|
||||
});
|
||||
|
||||
mediaFrame.open();
|
||||
});
|
||||
|
||||
// Remove image button click.
|
||||
$imagesContainer.on('click', '.bnb-remove-image', function(e) {
|
||||
e.preventDefault();
|
||||
$(this).closest('.bnb-gallery-image').remove();
|
||||
updateGalleryInput();
|
||||
});
|
||||
|
||||
// Make gallery sortable.
|
||||
$imagesContainer.sortable({
|
||||
items: '.bnb-gallery-image',
|
||||
cursor: 'move',
|
||||
update: function() {
|
||||
updateGalleryInput();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Update the hidden input with gallery image IDs.
|
||||
*/
|
||||
function updateGalleryInput() {
|
||||
var ids = [];
|
||||
$imagesContainer.find('.bnb-gallery-image').each(function() {
|
||||
ids.push($(this).data('id'));
|
||||
});
|
||||
$input.val(ids.join(','));
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize on document ready.
|
||||
$(document).ready(function() {
|
||||
initLicenseManagement();
|
||||
initRoomGallery();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user