feat: add feature assignment to admin tier management UI

- Add slide-over panel for assigning features to subscription tiers
- Features grouped by category with select all/deselect all
- Add puzzle-piece icon button in tier table actions
- Add feature management methods to subscription-tiers.js
- Fix JS-006 by adding try/catch to init function

Documentation:
- Update feature-gating-system.md with Admin Tier Management UI section
- Update subscription-billing.md with tier management overview
- Add new admin user guide: subscription-tier-management.md
- Add guide to mkdocs.yml navigation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-01 12:58:09 +01:00
parent 71c66aa237
commit d803e1c911
6 changed files with 501 additions and 3 deletions

View File

@@ -144,6 +144,9 @@
</td>
<td class="px-4 py-3 text-right">
<div class="flex items-center justify-end gap-2">
<button @click="openFeaturePanel(tier)" class="p-2 text-gray-500 hover:text-blue-600 dark:hover:text-blue-400" title="Edit Features">
<span x-html="$icon('puzzle-piece', 'w-4 h-4')"></span>
</button>
<button @click="openEditModal(tier)" class="p-2 text-gray-500 hover:text-purple-600 dark:hover:text-purple-400" title="Edit">
<span x-html="$icon('pencil', 'w-4 h-4')"></span>
</button>
@@ -332,6 +335,143 @@
</div>
</div>
<!-- Feature Assignment Slide-over Panel -->
<div
x-show="showFeaturePanel"
x-cloak
@keydown.escape.window="closeFeaturePanel()"
class="fixed inset-0 z-50 overflow-hidden"
role="dialog"
aria-modal="true"
>
<!-- Backdrop -->
<div
x-show="showFeaturePanel"
x-transition:enter="ease-out duration-300"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="ease-in duration-200"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-gray-500/50 dark:bg-gray-900/80 backdrop-blur-sm"
@click="closeFeaturePanel()"
></div>
<!-- Panel -->
<div class="fixed inset-y-0 right-0 flex max-w-full pl-10">
<div
x-show="showFeaturePanel"
x-transition:enter="transform transition ease-in-out duration-300"
x-transition:enter-start="translate-x-full"
x-transition:enter-end="translate-x-0"
x-transition:leave="transform transition ease-in-out duration-300"
x-transition:leave-start="translate-x-0"
x-transition:leave-end="translate-x-full"
class="w-screen max-w-lg"
>
<div class="flex h-full flex-col bg-white dark:bg-gray-800 shadow-xl">
<!-- Header -->
<div class="flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700">
<div>
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">Edit Features</h2>
<p class="text-sm text-gray-500 dark:text-gray-400" x-text="selectedTierForFeatures?.name"></p>
</div>
<button
@click="closeFeaturePanel()"
class="p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
>
<span x-html="$icon('x', 'w-5 h-5')"></span>
</button>
</div>
<!-- Body -->
<div class="flex-1 overflow-y-auto px-6 py-4">
<!-- Loading State -->
<div x-show="loadingFeatures" class="flex items-center justify-center py-8">
<span x-html="$icon('refresh', 'w-6 h-6 animate-spin text-purple-600')"></span>
<span class="ml-2 text-gray-500 dark:text-gray-400">Loading features...</span>
</div>
<!-- Feature Categories -->
<div x-show="!loadingFeatures" class="space-y-6">
<template x-for="category in categories" :key="category">
<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden">
<!-- Category Header -->
<div class="flex items-center justify-between px-4 py-3 bg-gray-50 dark:bg-gray-700/50">
<h3 class="text-sm font-medium text-gray-900 dark:text-white" x-text="formatCategoryName(category)"></h3>
<div class="flex items-center gap-2">
<button
@click="selectAllInCategory(category)"
class="text-xs text-purple-600 dark:text-purple-400 hover:underline"
x-show="!allSelectedInCategory(category)"
>
Select all
</button>
<button
@click="deselectAllInCategory(category)"
class="text-xs text-gray-500 dark:text-gray-400 hover:underline"
x-show="allSelectedInCategory(category)"
>
Deselect all
</button>
</div>
</div>
<!-- Features List -->
<div class="divide-y divide-gray-100 dark:divide-gray-700">
<template x-for="feature in featuresGrouped[category]" :key="feature.code">
<label class="flex items-start px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/30 cursor-pointer">
<input
type="checkbox"
:checked="isFeatureSelected(feature.code)"
@change="toggleFeature(feature.code)"
class="mt-0.5 rounded border-gray-300 dark:border-gray-600 text-purple-600 focus:ring-purple-500"
>
<div class="ml-3">
<div class="text-sm font-medium text-gray-900 dark:text-white" x-text="feature.name"></div>
<div class="text-xs text-gray-500 dark:text-gray-400" x-text="feature.description"></div>
</div>
</label>
</template>
</div>
</div>
</template>
<!-- Empty State -->
<div x-show="categories.length === 0" class="text-center py-8 text-gray-500 dark:text-gray-400">
No features available.
</div>
</div>
</div>
<!-- Footer -->
<div class="flex items-center justify-between px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50">
<div class="text-sm text-gray-500 dark:text-gray-400">
<span x-text="selectedFeatures.length"></span> features selected
</div>
<div class="flex items-center gap-3">
<button
@click="closeFeaturePanel()"
type="button"
class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"
>
Cancel
</button>
<button
@click="saveFeatures()"
:disabled="savingFeatures"
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 disabled:opacity-50"
>
<span x-show="savingFeatures" x-html="$icon('refresh', 'w-4 h-4 mr-2 animate-spin')"></span>
<span x-text="savingFeatures ? 'Saving...' : 'Save Features'"></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block extra_scripts %}