nodebb-plugin-onekite-calendar 2.0.59 → 2.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/public/client.js +114 -104
- package/nodebb-plugin-onekite-calendar-2.0.40.tgz +0 -0
package/package.json
CHANGED
package/plugin.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1676,11 +1676,14 @@ function toDatetimeLocalValue(date) {
|
|
|
1676
1676
|
const notes = String(p.notes || '').trim();
|
|
1677
1677
|
const participants = Array.isArray(p.participantsUsernames) ? p.participantsUsernames : [];
|
|
1678
1678
|
const eidPlain = escapeHtml(String(p.eid || '').replace(/^special:/, ''));
|
|
1679
|
+
// Participants can self-join/leave if they belong to the allowed group.
|
|
1680
|
+
// Use page capabilities as a fallback (details may be minimal in some edge cases).
|
|
1681
|
+
const canJoinHere = !!(p.canJoin || canCreateSpecial);
|
|
1679
1682
|
// Use real buttons with visible + / - text to avoid relying on icon fonts.
|
|
1680
|
-
const joinBtn = (
|
|
1683
|
+
const joinBtn = (canJoinHere && !p.isParticipant)
|
|
1681
1684
|
? `<button type="button" class="btn btn-sm btn-success ms-2 onekite-join-special" data-eid="${eidPlain}" title="S'ajouter" aria-label="S'ajouter">+</button>`
|
|
1682
1685
|
: '';
|
|
1683
|
-
const leaveBtn = (
|
|
1686
|
+
const leaveBtn = (canJoinHere && p.isParticipant)
|
|
1684
1687
|
? `<button type="button" class="btn btn-sm btn-danger ms-2 onekite-leave-special" data-eid="${eidPlain}" title="Se retirer" aria-label="Se retirer">−</button>`
|
|
1685
1688
|
: '';
|
|
1686
1689
|
const participantsHtml = `<div class="mb-2" id="onekite-participants-special"><strong>Participants</strong>${joinBtn}${leaveBtn}<br>` +
|
|
@@ -1738,60 +1741,63 @@ function toDatetimeLocalValue(date) {
|
|
|
1738
1741
|
} : {}),
|
|
1739
1742
|
},
|
|
1740
1743
|
});
|
|
1741
|
-
// Self-join handler
|
|
1744
|
+
// Self-join handler (event delegation so it keeps working after DOM updates)
|
|
1742
1745
|
try {
|
|
1743
|
-
dlg.
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1765
|
-
} catch (e3) {
|
|
1766
|
-
showAlert('error', "Impossible de s'ajouter.");
|
|
1746
|
+
dlg.off('click.onekiteParticipants');
|
|
1747
|
+
dlg.on('click.onekiteParticipants', '.onekite-join-special', async (e2) => {
|
|
1748
|
+
e2.preventDefault();
|
|
1749
|
+
const btn = e2.currentTarget;
|
|
1750
|
+
if (!btn) return;
|
|
1751
|
+
try {
|
|
1752
|
+
btn.classList.add('disabled');
|
|
1753
|
+
const eid = String(btn.getAttribute('data-eid') || '').trim();
|
|
1754
|
+
if (!eid) return;
|
|
1755
|
+
const r = await fetchJson(`/api/v3/plugins/calendar-onekite/special-events/${encodeURIComponent(eid)}/participants`, { method: 'POST' });
|
|
1756
|
+
const names = Array.isArray(r && r.participantsUsernames) ? r.participantsUsernames : [];
|
|
1757
|
+
const box = dlg.find('#onekite-participants-special');
|
|
1758
|
+
if (box && box.length) {
|
|
1759
|
+
const links = names.length
|
|
1760
|
+
? names.map((name) => {
|
|
1761
|
+
const u = String(name || '').trim();
|
|
1762
|
+
if (!u) return '';
|
|
1763
|
+
return `<a class="onekite-user-link me-2" href="${window.location.origin}/user/${encodeURIComponent(u)}">${escapeHtml(u)}</a>`;
|
|
1764
|
+
}).filter(Boolean).join('')
|
|
1765
|
+
: `<span class="text-muted">Aucun</span>`;
|
|
1766
|
+
box.html(`<strong>Participants</strong><button type="button" class="btn btn-sm btn-danger ms-2 onekite-leave-special" data-eid="${escapeHtml(eid)}" title="Se retirer" aria-label="Se retirer">−</button><br>${links}`);
|
|
1767
1767
|
}
|
|
1768
|
-
})
|
|
1768
|
+
} catch (e3) {
|
|
1769
|
+
showAlert('error', "Impossible de s'ajouter.");
|
|
1770
|
+
} finally {
|
|
1771
|
+
try { btn.classList.remove('disabled'); } catch (e4) {}
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1769
1774
|
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
}
|
|
1791
|
-
} catch (e3) {
|
|
1792
|
-
showAlert('error', "Impossible de se retirer.");
|
|
1775
|
+
dlg.on('click.onekiteParticipants', '.onekite-leave-special', async (e2) => {
|
|
1776
|
+
e2.preventDefault();
|
|
1777
|
+
const btn = e2.currentTarget;
|
|
1778
|
+
if (!btn) return;
|
|
1779
|
+
try {
|
|
1780
|
+
btn.classList.add('disabled');
|
|
1781
|
+
const eid = String(btn.getAttribute('data-eid') || '').trim();
|
|
1782
|
+
if (!eid) return;
|
|
1783
|
+
const r = await fetchJson(`/api/v3/plugins/calendar-onekite/special-events/${encodeURIComponent(eid)}/participants`, { method: 'DELETE' });
|
|
1784
|
+
const names = Array.isArray(r && r.participantsUsernames) ? r.participantsUsernames : [];
|
|
1785
|
+
const box = dlg.find('#onekite-participants-special');
|
|
1786
|
+
if (box && box.length) {
|
|
1787
|
+
const links = names.length
|
|
1788
|
+
? names.map((name) => {
|
|
1789
|
+
const u = String(name || '').trim();
|
|
1790
|
+
if (!u) return '';
|
|
1791
|
+
return `<a class="onekite-user-link me-2" href="${window.location.origin}/user/${encodeURIComponent(u)}">${escapeHtml(u)}</a>`;
|
|
1792
|
+
}).filter(Boolean).join('')
|
|
1793
|
+
: `<span class="text-muted">Aucun</span>`;
|
|
1794
|
+
box.html(`<strong>Participants</strong><button type="button" class="btn btn-sm btn-success ms-2 onekite-join-special" data-eid="${escapeHtml(eid)}" title="S'ajouter" aria-label="S'ajouter">+</button><br>${links}`);
|
|
1793
1795
|
}
|
|
1794
|
-
})
|
|
1796
|
+
} catch (e3) {
|
|
1797
|
+
showAlert('error', "Impossible de se retirer.");
|
|
1798
|
+
} finally {
|
|
1799
|
+
try { btn.classList.remove('disabled'); } catch (e4) {}
|
|
1800
|
+
}
|
|
1795
1801
|
});
|
|
1796
1802
|
} catch (e) {}
|
|
1797
1803
|
try {
|
|
@@ -1816,10 +1822,11 @@ function toDatetimeLocalValue(date) {
|
|
|
1816
1822
|
const participants = Array.isArray(p.participantsUsernames) ? p.participantsUsernames : [];
|
|
1817
1823
|
const oidPlain = escapeHtml(String(p.oid || '').replace(/^outing:/, ''));
|
|
1818
1824
|
// Use real buttons with visible + / - text to avoid relying on icon fonts.
|
|
1819
|
-
const
|
|
1825
|
+
const canJoinHere = !!(p.canJoin || canCreateOuting);
|
|
1826
|
+
const joinBtn = (canJoinHere && !p.isParticipant)
|
|
1820
1827
|
? `<button type="button" class="btn btn-sm btn-success ms-2 onekite-join-outing" data-oid="${oidPlain}" title="S'ajouter" aria-label="S'ajouter">+</button>`
|
|
1821
1828
|
: '';
|
|
1822
|
-
const leaveBtn = (
|
|
1829
|
+
const leaveBtn = (canJoinHere && p.isParticipant)
|
|
1823
1830
|
? `<button type="button" class="btn btn-sm btn-danger ms-2 onekite-leave-outing" data-oid="${oidPlain}" title="Se retirer" aria-label="Se retirer">−</button>`
|
|
1824
1831
|
: '';
|
|
1825
1832
|
const participantsHtml = `<div class="mb-2" id="onekite-participants-outing"><strong>Participants</strong>${joinBtn}${leaveBtn}<br>` +
|
|
@@ -1877,60 +1884,63 @@ function toDatetimeLocalValue(date) {
|
|
|
1877
1884
|
} : {}),
|
|
1878
1885
|
},
|
|
1879
1886
|
});
|
|
1880
|
-
// Self-join handler
|
|
1887
|
+
// Self-join handler (event delegation so it keeps working after DOM updates)
|
|
1881
1888
|
try {
|
|
1882
|
-
dlg.
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
} catch (e3) {
|
|
1905
|
-
showAlert('error', "Impossible de s'ajouter.");
|
|
1889
|
+
dlg.off('click.onekiteParticipantsOuting');
|
|
1890
|
+
dlg.on('click.onekiteParticipantsOuting', '.onekite-join-outing', async (e2) => {
|
|
1891
|
+
e2.preventDefault();
|
|
1892
|
+
const btn = e2.currentTarget;
|
|
1893
|
+
if (!btn) return;
|
|
1894
|
+
try {
|
|
1895
|
+
btn.classList.add('disabled');
|
|
1896
|
+
const oid = String(btn.getAttribute('data-oid') || '').trim();
|
|
1897
|
+
if (!oid) return;
|
|
1898
|
+
const r = await fetchJson(`/api/v3/plugins/calendar-onekite/outings/${encodeURIComponent(oid)}/participants`, { method: 'POST' });
|
|
1899
|
+
const names = Array.isArray(r && r.participantsUsernames) ? r.participantsUsernames : [];
|
|
1900
|
+
const box = dlg.find('#onekite-participants-outing');
|
|
1901
|
+
if (box && box.length) {
|
|
1902
|
+
const links = names.length
|
|
1903
|
+
? names.map((name) => {
|
|
1904
|
+
const u = String(name || '').trim();
|
|
1905
|
+
if (!u) return '';
|
|
1906
|
+
return `<a class="onekite-user-link me-2" href="${window.location.origin}/user/${encodeURIComponent(u)}">${escapeHtml(u)}</a>`;
|
|
1907
|
+
}).filter(Boolean).join('')
|
|
1908
|
+
: `<span class="text-muted">Aucun</span>`;
|
|
1909
|
+
box.html(`<strong>Participants</strong><button type="button" class="btn btn-sm btn-danger ms-2 onekite-leave-outing" data-oid="${escapeHtml(oid)}" title="Se retirer" aria-label="Se retirer">−</button><br>${links}`);
|
|
1906
1910
|
}
|
|
1907
|
-
})
|
|
1911
|
+
} catch (e3) {
|
|
1912
|
+
showAlert('error', "Impossible de s'ajouter.");
|
|
1913
|
+
} finally {
|
|
1914
|
+
try { btn.classList.remove('disabled'); } catch (e4) {}
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1908
1917
|
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
}
|
|
1930
|
-
} catch (e3) {
|
|
1931
|
-
showAlert('error', "Impossible de se retirer.");
|
|
1918
|
+
dlg.on('click.onekiteParticipantsOuting', '.onekite-leave-outing', async (e2) => {
|
|
1919
|
+
e2.preventDefault();
|
|
1920
|
+
const btn = e2.currentTarget;
|
|
1921
|
+
if (!btn) return;
|
|
1922
|
+
try {
|
|
1923
|
+
btn.classList.add('disabled');
|
|
1924
|
+
const oid = String(btn.getAttribute('data-oid') || '').trim();
|
|
1925
|
+
if (!oid) return;
|
|
1926
|
+
const r = await fetchJson(`/api/v3/plugins/calendar-onekite/outings/${encodeURIComponent(oid)}/participants`, { method: 'DELETE' });
|
|
1927
|
+
const names = Array.isArray(r && r.participantsUsernames) ? r.participantsUsernames : [];
|
|
1928
|
+
const box = dlg.find('#onekite-participants-outing');
|
|
1929
|
+
if (box && box.length) {
|
|
1930
|
+
const links = names.length
|
|
1931
|
+
? names.map((name) => {
|
|
1932
|
+
const u = String(name || '').trim();
|
|
1933
|
+
if (!u) return '';
|
|
1934
|
+
return `<a class="onekite-user-link me-2" href="${window.location.origin}/user/${encodeURIComponent(u)}">${escapeHtml(u)}</a>`;
|
|
1935
|
+
}).filter(Boolean).join('')
|
|
1936
|
+
: `<span class="text-muted">Aucun</span>`;
|
|
1937
|
+
box.html(`<strong>Participants</strong><button type="button" class="btn btn-sm btn-success ms-2 onekite-join-outing" data-oid="${escapeHtml(oid)}" title="S'ajouter" aria-label="S'ajouter">+</button><br>${links}`);
|
|
1932
1938
|
}
|
|
1933
|
-
})
|
|
1939
|
+
} catch (e3) {
|
|
1940
|
+
showAlert('error', "Impossible de se retirer.");
|
|
1941
|
+
} finally {
|
|
1942
|
+
try { btn.classList.remove('disabled'); } catch (e4) {}
|
|
1943
|
+
}
|
|
1934
1944
|
});
|
|
1935
1945
|
} catch (e) {}
|
|
1936
1946
|
try {
|
|
Binary file
|