feat: update NetworkMembership Protobuf version and add referral code functionality with UI enhancements
Build and Deploy to Production / build-and-deploy (push) Has been cancelled
Build and Deploy to Production / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -59,17 +59,27 @@ window.OrgChart = {
|
||||
const positionClass = data.position === 'Left' ? 'position-left' :
|
||||
data.position === 'Right' ? 'position-right' : 'position-root';
|
||||
const activeClass = data.isActive ? 'active' : 'inactive';
|
||||
const clubActiveClass = data.isClubActive ? 'club-active' : '';
|
||||
|
||||
// Avatar - first letter of name
|
||||
const firstChar = data.fullName ? data.fullName.charAt(0) : '?';
|
||||
|
||||
// نمایش کد معرف فقط برای کاربران فعال در باشگاه
|
||||
const referralCodeHtml = data.isClubActive && data.referralCode
|
||||
? `<div class="node-referral" onclick="event.stopPropagation(); OrgChart.copyReferralCode('${data.referralCode}');" title="کپی کد معرف">
|
||||
<span class="referral-icon">📋</span>
|
||||
<span class="referral-code">${data.referralCode}</span>
|
||||
</div>`
|
||||
: '';
|
||||
|
||||
return `
|
||||
<div class="org-node-card ${positionClass} ${activeClass}" data-user-id="${data.id}">
|
||||
<div class="org-node-card ${positionClass} ${activeClass} ${clubActiveClass}" data-user-id="${data.id}">
|
||||
<div class="node-header-compact ${isRoot ? 'root' : ''}">
|
||||
<div class="node-avatar-sm">${firstChar}</div>
|
||||
<div class="node-info">
|
||||
<div class="node-name-sm">${data.fullName || 'بدون نام'}</div>
|
||||
<div class="node-level-sm">L${data.level || 0}${!isRoot ? ' • ' + (data.position === 'Left' ? 'چپ' : 'راست') : ''}</div>
|
||||
${referralCodeHtml}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -187,6 +197,63 @@ window.OrgChart = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy referral code to clipboard
|
||||
* @param {string} code - The referral code to copy
|
||||
*/
|
||||
copyReferralCode: function(code) {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(code).then(() => {
|
||||
// Show toast notification
|
||||
this.showToast('کد معرف کپی شد: ' + code);
|
||||
}).catch(err => {
|
||||
console.error('Failed to copy:', err);
|
||||
this.fallbackCopy(code);
|
||||
});
|
||||
} else {
|
||||
this.fallbackCopy(code);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Fallback copy method for older browsers
|
||||
*/
|
||||
fallbackCopy: function(text) {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.left = '-999999px';
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
this.showToast('کد معرف کپی شد: ' + text);
|
||||
} catch (err) {
|
||||
console.error('Fallback copy failed:', err);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
},
|
||||
|
||||
/**
|
||||
* Show toast notification
|
||||
*/
|
||||
showToast: function(message) {
|
||||
// Remove existing toast
|
||||
const existingToast = document.querySelector('.org-chart-toast');
|
||||
if (existingToast) existingToast.remove();
|
||||
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'org-chart-toast';
|
||||
toast.textContent = message;
|
||||
document.body.appendChild(toast);
|
||||
|
||||
setTimeout(() => toast.classList.add('show'), 10);
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('show');
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
/**
|
||||
* Dispose the chart
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user