designflow-studio / script.js
jirashiran's picture
สร้างเว็บแอป "แบบฟอร์มสั่งงานออกแบบดีไซน์" ที่มีระบบฐานข้อมูล ง่ายๆ ด้วย React , tailwind
b7db777 verified
Raw
History Blame Contribute Delete
2.18 kB
// Initialize tooltips
document.addEventListener('DOMContentLoaded', function() {
// Initialize any tooltips or popovers
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Sample data fetch for jobs
fetchJobs();
});
function fetchJobs() {
// In a real app, this would fetch from your API
console.log("Fetching jobs data...");
// Mock data for demonstration
const mockJobs = [
{
id: "DES-2023-001",
title: "New Product Packaging",
department: "Marketing",
status: "in-progress",
date: "2023-11-15",
image: "http://static.photos/technology/320x240/1"
},
// More mock jobs...
];
// Process and display jobs
// This would be handled by your job-card web component
}
// Form validation for new job page
function validateJobForm() {
const form = document.getElementById('newJobForm');
if (form) {
form.addEventListener('submit', function(e) {
e.preventDefault();
// Validate required fields
const requiredFields = form.querySelectorAll('[required]');
let isValid = true;
requiredFields.forEach(field => {
if (!field.value.trim()) {
field.classList.add('border-red-500');
isValid = false;
} else {
field.classList.remove('border-red-500');
}
});
if (isValid) {
// Submit form or show confirmation
showConfirmationModal();
}
});
}
}
function showConfirmationModal() {
// Show a confirmation modal before submission
console.log("Showing confirmation modal...");
// In a real app, this would show a modal with the job summary
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
validateJobForm();
});