EmilyMooreGlobal's picture
Add 1 files
a3701ff verified
Raw History Blame Contribute Delete
28.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Communication Preference Management</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.fade-in {
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.slide-up {
animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.file-input-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.file-input-wrapper input[type=file] {
position: absolute;
left: 0;
top: 0;
opacity: 0;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
animation: fadeIn 0.3s ease-in-out;
}
.tag {
display: inline-flex;
align-items: center;
background-color: #e2e8f0;
border-radius: 9999px;
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
margin-bottom: 0.5rem;
}
.tag-remove {
margin-left: 0.5rem;
cursor: pointer;
color: #64748b;
}
.criteria-section {
border-left: 3px solid #3b82f6;
padding-left: 1rem;
margin-bottom: 1.5rem;
}
</style>
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-4">
<button id="openModalBtn" class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200">
<i class="fas fa-plus mr-2"></i> Add Communication Preference
</button>
</div>
<!-- Modal -->
<div id="preferenceModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden">
<div class="bg-white rounded-xl shadow-2xl w-full max-w-3xl max-h-[90vh] overflow-y-auto slide-up">
<!-- Modal Header -->
<div class="border-b border-gray-200 p-6 sticky top-0 bg-white z-10">
<div class="flex justify-between items-center">
<h3 class="text-2xl font-semibold text-gray-800">Manage Communication Preference</h3>
<button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times text-xl"></i>
</button>
</div>
</div>
<!-- Modal Body -->
<div class="p-6 space-y-6">
<!-- Basic Information Section -->
<div>
<h4 class="text-lg font-medium text-gray-800 mb-4">Basic Information</h4>
<div class="space-y-4">
<div>
<label for="preferenceName" class="block text-sm font-medium text-gray-700 mb-1">Preference Name *</label>
<input type="text" id="preferenceName" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="description" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
</div>
<div>
<label for="tooltip" class="block text-sm font-medium text-gray-700 mb-1">Tooltip Text</label>
<input type="text" id="tooltip" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<p class="text-xs text-gray-500 mt-1">This will appear when users hover over the preference name</p>
</div>
<div class="flex items-center">
<input type="checkbox" id="isMandatory" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="isMandatory" class="ml-2 block text-sm text-gray-700">This preference is mandatory</label>
</div>
</div>
</div>
<!-- User Assignment Section -->
<div>
<h4 class="text-lg font-medium text-gray-800 mb-4">User Assignment</h4>
<div class="space-y-4">
<div class="space-y-2">
<div class="flex items-center space-x-4">
<div class="flex items-center">
<input type="radio" id="assignNone" name="assignmentType" value="none" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
<label for="assignNone" class="ml-2 block text-sm text-gray-700">None</label>
</div>
<div class="flex items-center">
<input type="radio" id="assignAll" name="assignmentType" value="all" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
<label for="assignAll" class="ml-2 block text-sm text-gray-700">All Network Members</label>
</div>
<div class="flex items-center">
<input type="radio" id="assignCriteria" name="assignmentType" value="criteria" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
<label for="assignCriteria" class="ml-2 block text-sm text-gray-700">Select assignment criteria</label>
</div>
</div>
</div>
<!-- Conditional Content for Criteria Assignment -->
<div id="criteriaAssignmentContent" class="hidden bg-gray-50 p-4 rounded-lg space-y-4">
<!-- Assignment Criteria Sections -->
<div class="criteria-section">
<h5 class="text-sm font-medium text-gray-700 mb-3">Assignment Criteria</h5>
<div class="space-y-4">
<!-- Region & Country -->
<div>
<div class="flex items-center mb-2">
<input type="checkbox" id="enableRegionCountry" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="enableRegionCountry" class="ml-2 block text-sm text-gray-700">Region & Country</label>
</div>
<div id="regionCountryContent" class="hidden pl-6 mt-2">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="region" class="block text-sm font-medium text-gray-700 mb-1">Region</label>
<select id="region" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">Select a region</option>
<option value="europe">Europe</option>
<option value="asia">Asia</option>
<option value="americas">Americas</option>
<option value="africa">Africa</option>
</select>
</div>
<div>
<label for="country" class="block text-sm font-medium text-gray-700 mb-1">Country</label>
<select id="country" disabled class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-gray-100">
<option value="">Select a region first</option>
</select>
</div>
</div>
</div>
</div>
<!-- User Tags -->
<div>
<div class="flex items-center mb-2">
<input type="checkbox" id="enableUserTags" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="enableUserTags" class="ml-2 block text-sm text-gray-700">User Tags</label>
</div>
<div id="userTagsContent" class="hidden pl-6 mt-2">
<div>
<label for="tagInput" class="block text-sm font-medium text-gray-700 mb-1">Add User Tags</label>
<div class="flex">
<input type="text" id="tagInput" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter tags separated by commas">
<button type="button" id="addTagsBtn" class="px-4 py-2 bg-blue-600 text-white rounded-r-md hover:bg-blue-700">Add</button>
</div>
<div id="tagsContainer" class="mt-2 flex flex-wrap"></div>
</div>
</div>
</div>
<!-- Key Contact Roles -->
<div>
<div class="flex items-center mb-2">
<input type="checkbox" id="enableContactRoles" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="enableContactRoles" class="ml-2 block text-sm text-gray-700">Key Contact Roles</label>
</div>
<div id="contactRolesContent" class="hidden pl-6 mt-2">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Select Key Contact Roles</label>
<div class="space-y-2">
<div class="flex items-center">
<input type="checkbox" id="roleAdmin" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="roleAdmin" class="ml-2 block text-sm text-gray-700">Administrator</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="roleManager" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="roleManager" class="ml-2 block text-sm text-gray-700">Manager</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="roleSupervisor" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="roleSupervisor" class="ml-2 block text-sm text-gray-700">Supervisor</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="roleCoordinator" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="roleCoordinator" class="ml-2 block text-sm text-gray-700">Coordinator</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Additional Users Upload -->
<div class="criteria-section">
<h5 class="text-sm font-medium text-gray-700 mb-3">Additional Users</h5>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Upload additional users (optional)</label>
<div class="file-input-wrapper">
<button type="button" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">
<i class="fas fa-upload mr-2"></i> Choose Excel/CSV File
</button>
<input type="file" id="userImportFile" accept=".xlsx,.xls,.csv" class="hidden">
</div>
<p class="text-xs text-gray-500 mt-2">Supported formats: .xlsx, .xls, .csv</p>
<div id="fileInfo" class="mt-2 text-sm text-gray-600 hidden">
<i class="fas fa-check-circle text-green-500 mr-1"></i>
<span id="fileName"></span> selected
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="border-t border-gray-200 p-6 sticky bottom-0 bg-white">
<div class="flex justify-end space-x-3">
<button type="button" id="cancelBtn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">Cancel</button>
<button type="button" id="saveBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">Save Preference</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Modal toggle
const modal = document.getElementById('preferenceModal');
const openModalBtn = document.getElementById('openModalBtn');
const closeModalBtn = document.getElementById('closeModalBtn');
const cancelBtn = document.getElementById('cancelBtn');
openModalBtn.addEventListener('click', () => {
modal.classList.remove('hidden');
});
[closeModalBtn, cancelBtn].forEach(btn => {
btn.addEventListener('click', () => {
modal.classList.add('hidden');
});
});
// Assignment type toggle
const assignmentRadios = document.querySelectorAll('input[name="assignmentType"]');
const criteriaAssignmentContent = document.getElementById('criteriaAssignmentContent');
assignmentRadios.forEach(radio => {
radio.addEventListener('change', function() {
if (this.value === 'criteria') {
criteriaAssignmentContent.classList.remove('hidden');
} else {
criteriaAssignmentContent.classList.add('hidden');
}
});
});
// Criteria toggles
const enableRegionCountry = document.getElementById('enableRegionCountry');
const regionCountryContent = document.getElementById('regionCountryContent');
const enableUserTags = document.getElementById('enableUserTags');
const userTagsContent = document.getElementById('userTagsContent');
const enableContactRoles = document.getElementById('enableContactRoles');
const contactRolesContent = document.getElementById('contactRolesContent');
enableRegionCountry.addEventListener('change', function() {
if (this.checked) {
regionCountryContent.classList.remove('hidden');
} else {
regionCountryContent.classList.add('hidden');
}
});
enableUserTags.addEventListener('change', function() {
if (this.checked) {
userTagsContent.classList.remove('hidden');
} else {
userTagsContent.classList.add('hidden');
}
});
enableContactRoles.addEventListener('change', function() {
if (this.checked) {
contactRolesContent.classList.remove('hidden');
} else {
contactRolesContent.classList.add('hidden');
}
});
// Region-country dependency
const regionSelect = document.getElementById('region');
const countrySelect = document.getElementById('country');
const countryOptions = {
europe: ['United Kingdom', 'Germany', 'France', 'Spain', 'Italy'],
asia: ['China', 'Japan', 'India', 'South Korea', 'Singapore'],
americas: ['United States', 'Canada', 'Brazil', 'Mexico', 'Argentina'],
africa: ['South Africa', 'Egypt', 'Nigeria', 'Kenya', 'Morocco']
};
regionSelect.addEventListener('change', function() {
if (this.value) {
countrySelect.disabled = false;
countrySelect.innerHTML = '<option value="">Select a country</option>';
countrySelect.classList.remove('bg-gray-100');
countryOptions[this.value].forEach(country => {
const option = document.createElement('option');
option.value = country.toLowerCase().replace(' ', '-');
option.textContent = country;
countrySelect.appendChild(option);
});
} else {
countrySelect.disabled = true;
countrySelect.innerHTML = '<option value="">Select a region first</option>';
countrySelect.classList.add('bg-gray-100');
}
});
// Tag management
const tagInput = document.getElementById('tagInput');
const addTagsBtn = document.getElementById('addTagsBtn');
const tagsContainer = document.getElementById('tagsContainer');
addTagsBtn.addEventListener('click', function() {
const tagsText = tagInput.value.trim();
if (tagsText) {
const tags = tagsText.split(',').map(tag => tag.trim()).filter(tag => tag);
tags.forEach(tag => {
const tagElement = document.createElement('div');
tagElement.className = 'tag';
tagElement.innerHTML = `
${tag}
<span class="tag-remove" onclick="this.parentElement.remove()">
<i class="fas fa-times"></i>
</span>
`;
tagsContainer.appendChild(tagElement);
});
tagInput.value = '';
}
});
// File upload display
const fileInput = document.getElementById('userImportFile');
const fileInfo = document.getElementById('fileInfo');
const fileName = document.getElementById('fileName');
fileInput.addEventListener('change', function() {
if (this.files.length > 0) {
fileName.textContent = this.files[0].name;
fileInfo.classList.remove('hidden');
} else {
fileInfo.classList.add('hidden');
}
});
// Save button
const saveBtn = document.getElementById('saveBtn');
saveBtn.addEventListener('click', function() {
// Validate form
const preferenceName = document.getElementById('preferenceName').value.trim();
if (!preferenceName) {
alert('Please enter a preference name');
return;
}
// Check if criteria is selected but no criteria options are chosen
const assignmentType = document.querySelector('input[name="assignmentType"]:checked').value;
if (assignmentType === 'criteria') {
const hasCriteria = enableRegionCountry.checked || enableUserTags.checked || enableContactRoles.checked;
if (!hasCriteria) {
alert('Please select at least one assignment criteria');
return;
}
// Validate region/country if enabled
if (enableRegionCountry.checked) {
const region = regionSelect.value;
const country = countrySelect.value;
if (!region) {
alert('Please select a region');
return;
}
if (!country) {
alert('Please select a country');
return;
}
}
// Validate tags if enabled
if (enableUserTags.checked && tagsContainer.children.length === 0) {
alert('Please add at least one user tag');
return;
}
// Validate roles if enabled
if (enableContactRoles.checked) {
const rolesSelected = document.querySelectorAll('#contactRolesContent input[type="checkbox"]:checked').length > 0;
if (!rolesSelected) {
alert('Please select at least one contact role');
return;
}
}
}
// Gather form data (in a real app, you would send this to a server)
const formData = {
name: preferenceName,
description: document.getElementById('description').value.trim(),
tooltip: document.getElementById('tooltip').value.trim(),
isMandatory: document.getElementById('isMandatory').checked,
assignmentType: assignmentType,
criteria: {
regionCountry: enableRegionCountry.checked ? {
region: regionSelect.value,
country: countrySelect.value
} : null,
userTags: enableUserTags.checked ?
Array.from(tagsContainer.children).map(tag => tag.textContent.trim().replace('×', '')) :
null,
contactRoles: enableContactRoles.checked ? {
admin: document.getElementById('roleAdmin').checked,
manager: document.getElementById('roleManager').checked,
supervisor: document.getElementById('roleSupervisor').checked,
coordinator: document.getElementById('roleCoordinator').checked
} : null,
additionalUsers: fileInput.files.length > 0 ? fileInput.files[0].name : null
}
};
console.log('Form data:', formData);
alert('Preference saved successfully!');
modal.classList.add('hidden');
// Reset form (in a real app, you might want to keep some values)
document.getElementById('preferenceName').value = '';
document.getElementById('description').value = '';
document.getElementById('tooltip').value = '';
document.getElementById('isMandatory').checked = false;
document.getElementById('assignAll').checked = true;
criteriaAssignmentContent.classList.add('hidden');
enableRegionCountry.checked = false;
regionCountryContent.classList.add('hidden');
enableUserTags.checked = false;
userTagsContent.classList.add('hidden');
enableContactRoles.checked = false;
contactRolesContent.classList.add('hidden');
tagsContainer.innerHTML = '';
fileInfo.classList.add('hidden');
fileInput.value = '';
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EmilyMooreGlobal/communication-preference" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>