Spaces:
Running
Running
Commit ·
85d90fc
1
Parent(s): 3dad87e
feat: implement styled collaborator list and multi-assignee face-pile support on canvas nodes
Browse filesFiles changed (3)
115 unmodified lines11611711811912012182 unmodified lines204205206207208209210211212213214215115 unmodified linesconst progressValue = data.progress !== undefined ? data.progress : 0;return (<divonDoubleClick={openConfigureModal}82 unmodified lines</span><div className="flex items-center gap-2">{data.ai && <Sparkles size={12} className="text-secondary animate-pulse" />}{data.assignee && (<divtitle={`${data.assignee.displayName || data.assignee.email || t('canvas.assignee', 'Assignee')}`}className="w-6 h-6 rounded-full border border-primary bg-secondary/10 text-primary flex items-center justify-center text-[9px] font-bold shadow-[1px_1px_0px_0px_var(--color-primary)] relative group cursor-help transition-transform hover:scale-105">{getInitials(data.assignee.displayName, data.assignee.email)}</div>)}</div>115 unmodified lines11611711811912012112212312412512612712812913013113213313413582 unmodified lines218219220221222223224225226227228229230231232233234235236237238239240241242243244115 unmodified linesconst progressValue = data.progress !== undefined ? data.progress : 0;const assignees = data.assignees && Array.isArray(data.assignees)? data.assignees: (data.assignee ? [data.assignee] : []);const tooltipText = assignees.map(a => {const name = a.displayName || t('canvas.collaborator', 'Collaborator');return a.email ? `${name} (${a.email})` : name;}).join(', ');const maxVisible = 3;const shouldTruncate = assignees.length > maxVisible;const visibleAssignees = shouldTruncate ? assignees.slice(0, 2) : assignees;const remainingCount = assignees.length - visibleAssignees.length;return (<divonDoubleClick={openConfigureModal}82 unmodified lines</span><div className="flex items-center gap-2">{data.ai && <Sparkles size={12} className="text-secondary animate-pulse" />}{assignees.length > 0 && (<divtitle={tooltipText}className="flex items-center -space-x-1.5 flex-row-reverse cursor-help">{shouldTruncate && (<divclassName="w-6 h-6 rounded-full border border-primary bg-secondary/20 text-primary flex items-center justify-center text-[8px] font-extrabold shadow-[1px_1px_0px_0px_var(--color-primary)] relative transition-transform hover:scale-105 z-0">+{remainingCount}</div>)}{visibleAssignees.slice().reverse().map((assignee, index) => (<divkey={assignee.sharedWithUserId || assignee.email || index}className="w-6 h-6 rounded-full border border-primary bg-secondary/10 text-primary flex items-center justify-center text-[9px] font-bold shadow-[1px_1px_0px_0px_var(--color-primary)] relative transition-transform hover:scale-105 hover:z-10"style={{ zIndex: index + 1 }}>{getInitials(assignee.displayName, assignee.email)}</div>))}</div>)}</div>
593 unmodified lines5945955965975985996001 unmodified line60260360460560660760815 unmodified lines624625626627628629630120 unmodified lines751752753754755756757593 unmodified lines}}} else if (n.type === 'sketch') {let assignee = null;if (n.decision && n.decision.startsWith('{')) {try {const parsed = JSON.parse(n.decision);1 unmodified lineprogress = parsed.progress || 0;showProgress = !!parsed.showProgress;decision = parsed.decision || 'bottom';assignee = parsed.assignee || null;} catch (e) {console.error('Failed to parse sketch decision JSON', e);}15 unmodified linesdescription: description || '',progress: progress,showProgress: showProgress,assignee,updateNodeData: updateNodeDataCallback}};120 unmodified linesprogress: n.data.progress || 0,showProgress: !!n.data.showProgress,decision: n.data.decision || 'bottom',assignee: n.data.assignee || null}): n.data.decision})),593 unmodified lines5945955965975985996001 unmodified line60260360460560660760860961061161215 unmodified lines628629630631632633634120 unmodified lines755756757758759760761593 unmodified lines}}} else if (n.type === 'sketch') {let assignees = [];if (n.decision && n.decision.startsWith('{')) {try {const parsed = JSON.parse(n.decision);1 unmodified lineprogress = parsed.progress || 0;showProgress = !!parsed.showProgress;decision = parsed.decision || 'bottom';if (parsed.assignees && Array.isArray(parsed.assignees)) {assignees = parsed.assignees;} else if (parsed.assignee) {assignees = [parsed.assignee];}} catch (e) {console.error('Failed to parse sketch decision JSON', e);}15 unmodified linesdescription: description || '',progress: progress,showProgress: showProgress,assignees,updateNodeData: updateNodeDataCallback}};120 unmodified linesprogress: n.data.progress || 0,showProgress: !!n.data.showProgress,decision: n.data.decision || 'bottom',assignees: n.data.assignees || []}): n.data.decision})),
56 unmodified lines57585960616263418 unmodified lines48248348448548648748811 unmodified lines50050150250350450550641 unmodified lines54854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962056 unmodified linesimport Sidebar from '../components/Sidebar';import { useAuth } from '../context/AuthContext';import { useTheme } from '../context/ThemeContext';import { Maximize2, Play, Settings, Save, ChevronLeft, ChevronDown, Loader2, Trash2, Target, GitFork, Image, X, Plus, Timer, Milestone, Share2, User, Copy, Scissors, Clipboard } from 'lucide-react';// Feature componentsimport SketchNode from '../features/canvas/components/nodes/SketchNode';418 unmodified linesconst [description, setDescription] = useState(node.data.description || '');const [showProgress, setShowProgress] = useState(!!node.data.showProgress);const [progress, setProgress] = useState(node.data.progress || 0);const [assignee, setAssignee] = useState(node.data.assignee || null);const handleSave = () => {let finalProgress = Number(progress);11 unmodified linesshowProgress,progress: finalProgress,status,assignee});};41 unmodified lines/></div>{/* Assignee Input */}<div><label className="block text-[11px] font-bold uppercase tracking-widest text-primary/60 mb-2">{t('canvas.assignee_label', 'Виконавець')}</label><div className="relative"><selectvalue={assignee ? (assignee.sharedWithUserId || 'owner') : 'none'}onChange={(e) => {const val = e.target.value;if (val === 'none') {setAssignee(null);} else {const selectedCollab = collaborators.find(c => (c.sharedWithUserId || 'owner') === val);if (selectedCollab) {setAssignee({email: selectedCollab.email,displayName: selectedCollab.displayName,sharedWithUserId: selectedCollab.sharedWithUserId});}}}}className="w-full px-4 py-3 bg-secondary/10 border-2 border-primary rounded-xl font-bold text-primary focus:outline-none focus:bg-surface-container-lowest transition-all shadow-[2px_2px_0px_0px_rgba(49,54,63,0.1)] appearance-none cursor-pointer pr-10 text-xs font-sans"><option value="none" className="bg-surface-container-lowest text-primary font-bold">{t('canvas.assignee_none', 'Не призначено')}</option>{collaborators.map((c) => {const labelStr = c.displayName? `${c.displayName} (${c.email})`: c.email;const val = c.sharedWithUserId || 'owner';return (<option key={val} value={val} className="bg-surface-container-lowest text-primary font-bold">{labelStr} {c.permission === 'Owner' ? `(${t('canvas.owner', 'Власник')})` : ''}</option>);})}</select><div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-4 text-primary"><ChevronDown size={16} /></div></div>{assignee && (<div className="mt-3 flex items-center gap-3 p-3 bg-success/5 border-2 border-success/30 rounded-xl animate-fade-in"><div className="w-8 h-8 rounded-full border-2 border-primary bg-secondary/15 text-primary flex items-center justify-center text-[10px] font-extrabold shadow-[2px_2px_0px_0px_var(--color-primary)] shrink-0">{getAssigneeInitials(assignee.displayName, assignee.email)}</div><div className="flex-1 min-w-0"><span className="block font-bold text-[11px] text-primary truncate">{assignee.displayName || t('canvas.collaborator', 'Співавтор')}</span><span className="block text-[9px] text-primary/60 truncate">{assignee.email}</span></div><buttononClick={() => setAssignee(null)}className="p-1 hover:bg-red-500/10 border-2 border-transparent hover:border-red-500/30 rounded-lg text-primary/60 hover:text-red-500 transition-all cursor-pointer shrink-0"title={t('common.remove', 'Видалити')}><X size={14} /></button></div>)}</div>{/* Show Progress Toggle */}56 unmodified lines57585960616263418 unmodified lines48248348448548648748811 unmodified lines50050150250350450550641 unmodified lines54854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561656 unmodified linesimport Sidebar from '../components/Sidebar';import { useAuth } from '../context/AuthContext';import { useTheme } from '../context/ThemeContext';import { Maximize2, Play, Settings, Save, ChevronLeft, ChevronDown, Loader2, Trash2, Target, GitFork, Image, X, Plus, Timer, Milestone, Share2, User, Copy, Scissors, Clipboard, Check } from 'lucide-react';// Feature componentsimport SketchNode from '../features/canvas/components/nodes/SketchNode';418 unmodified linesconst [description, setDescription] = useState(node.data.description || '');const [showProgress, setShowProgress] = useState(!!node.data.showProgress);const [progress, setProgress] = useState(node.data.progress || 0);const [assignees, setAssignees] = useState(node.data.assignees || []);const handleSave = () => {let finalProgress = Number(progress);11 unmodified linesshowProgress,progress: finalProgress,status,assignees});};41 unmodified lines/></div>{/* Assignees Input (Styled custom visual list) */}<div className="border-2 border-primary rounded-2xl p-4 bg-secondary/5 space-y-2"><label className="block text-[11px] font-bold uppercase tracking-widest text-primary/60">{t('canvas.assignees_label', 'Призначити виконавців')}</label><div className="space-y-1.5 max-h-[160px] overflow-y-auto pr-1">{collaborators.length === 0 ? (<p className="text-xs font-accent-note italic text-primary/50 text-center py-4">{t('canvas.no_collaborators_found', 'Немає доступних учасників')}</p>) : (collaborators.map((c) => {const collabVal = c.sharedWithUserId || 'owner';const isSelected = assignees.some(a => (a.sharedWithUserId || 'owner') === collabVal);return (<divkey={collabVal}onClick={() => {if (isSelected) {setAssignees(assignees.filter(a => (a.sharedWithUserId || 'owner') !== collabVal));} else {setAssignees([...assignees, {email: c.email,displayName: c.displayName,sharedWithUserId: c.sharedWithUserId}]);}}}className={`flex items-center justify-between p-2.5 rounded-xl border-2 transition-all cursor-pointer select-none ${isSelected? 'bg-success/10 border-success shadow-[2px_2px_0px_0px_rgba(34,197,94,0.3)]': 'bg-surface-container-lowest border-primary/20 hover:border-primary/50 hover:bg-secondary/5'}`}><div className="flex items-center gap-3 min-w-0"><div className={`w-8 h-8 rounded-full border-2 ${isSelected ? 'border-success bg-success/20 text-success' : 'border-primary bg-secondary/15 text-primary'} flex items-center justify-center text-[10px] font-extrabold shadow-[1.5px_1.5px_0px_0px_var(--color-primary)] shrink-0`}>{getAssigneeInitials(c.displayName, c.email)}</div><div className="min-w-0"><span className="block font-bold text-xs text-primary truncate leading-tight">{c.displayName || t('canvas.collaborator', 'Співавтор')}</span><span className="block text-[9px] text-primary/60 truncate leading-none mt-0.5">{c.email}</span></div></div><div className="shrink-0 flex items-center pr-1">{isSelected ? (<div className="w-5 h-5 rounded-md bg-success border-2 border-success flex items-center justify-center text-white"><Check size={12} strokeWidth={3} /></div>) : (<div className="w-5 h-5 rounded-md border-2 border-primary/30 bg-surface-container-lowest" />)}</div></div>);}))}</div></div>{/* Show Progress Toggle */}
src/features/canvas/components/nodes/SketchNode.jsx+33-4
src/features/canvas/hooks/useCanvasLogic.js+8-4
src/pages/CanvasPage.jsx+62-66