Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9b19365
match-meme-comment: Show comment type
benloh Sep 26, 2024
670828e
match-meme-comment: Show simple "DELETED" for comment prompts
benloh Oct 3, 2024
191091a
match-meme-comment: Fix bug: `commenter_id` is inadvertently changed …
benloh Oct 3, 2024
3bc9697
match-meme-comment: Count only non-deleted comments. Add `commentCou…
benloh Oct 4, 2024
0c35f25
match-meme-comment: Ignore deleted comments in comment stats (unread,…
benloh Oct 4, 2024
44fbfaa
match-meme-comment: Backport URTable
benloh Dec 14, 2024
920dbb2
Merge branch 'dev-next' into dev-bl/match-meme-comment
benloh Dec 23, 2024
bc4b11a
Merge branch 'dev-next' into dev-bl/match-meme-comment -- missing NCT…
benloh Dec 23, 2024
e7dd1ec
fix-export: Fail gracefully if node type options or edge type options…
benloh Dec 31, 2024
7075a11
match-meme-comment: Match MEME URCommentPrompt
benloh Dec 31, 2024
10531e5
match-meme-comment: Match MEME URCommentStatus with UNISYS fixes
benloh Dec 31, 2024
2fa637f
match-meme-comment: Match MEME URCommentThread
benloh Dec 31, 2024
d5be36c
match-meme-comment: Match MEME URComment with UNISYS fix
benloh Dec 31, 2024
1b80c55
match-meme-comment: Match MEME ac-comments
benloh Dec 31, 2024
437bb7d
match-meme-comment: Match MEME dc-comments
benloh Dec 31, 2024
6003776
match-meme-comment: Port URCommentSVGBtn and URCommentCollectionMgr w…
benloh Dec 31, 2024
14ca2f0
match-meme-comment: Match URCommentVBtn with UNISYS fixes
benloh Dec 31, 2024
ef7bd60
match-meme-comment: Add svg comment icon to comment-mgr (replace svgj…
benloh Dec 31, 2024
d01f905
match-meme-comment: Match some of MEME comment-mgr calls
benloh Dec 31, 2024
15aa3e4
match-meme-comment: Update URCommentVBtn when cref changes so count i…
benloh Jan 1, 2025
f6ec4f4
match-meme-comment: Match MEME add URDialog from URCommentStatus
benloh Jan 3, 2025
7078916
match-meme-comment: Match MEME replace URCommentThreadMgr with URComm…
benloh Jan 3, 2025
4edd611
match-meme-comment: Convert NCNode, NCEdge, NCNodeTable, NCEdgeTable …
benloh Jan 3, 2025
9ed543f
match-meme-comment: Match MEME URComment css
benloh Jan 3, 2025
3348b9a
match-meme-comment: NC uses `comment.comment_id` where MEME uses `com…
benloh Jan 4, 2025
2035076
match-meme-comment: Match method name casing
benloh Jan 4, 2025
df9ff7f
match-meme-comment: Match MEME comment-mgr calls, especially support …
benloh Jan 4, 2025
0be591e
match-meme-comment: Deprecate toggle comment button. Currently handl…
benloh Jan 4, 2025
2ff5797
match-meme-comment: Refactor NCNodeTable and NCEdgeTable as functiona…
benloh Jan 5, 2025
e3893fe
match-meme-comment: Comment types are defined first in project templa…
benloh Jan 6, 2025
8815072
match-meme-comment: project template comment types should override an…
benloh Jan 7, 2025
7387c69
match-meme-comment: Tighten up comment spacing, add more gap between …
benloh Jan 7, 2025
5c2c352
lint cleanup debug
benloh Jan 7, 2025
18480b3
match-meme-comment: Wait for comment to open before trying to scroll …
benloh Jan 8, 2025
82d339b
lint rewrap
benloh Jan 8, 2025
7e39647
provenance: Honor `hidden=true` for created, updated, revision in edi…
benloh Jan 8, 2025
40876fe
provenance: Remove `isProvenance` from built in fields for _default.t…
benloh Jan 8, 2025
d7b6e2c
provenance: Add custom `infoOrigin` field that initially displays `Cr…
benloh Jan 8, 2025
a0ef4cf
lint rewrap
benloh Jan 8, 2025
c6d9873
provenance: Move `DeriveInfoOriginString` to `nc-utils` so importexpo…
benloh Jan 8, 2025
7efd86a
provenance: Generate `infoOrigin` during exports. #322
benloh Jan 9, 2025
f07e4a5
provenance: Fix _default.template.toml so "Label" is capitalized, and…
benloh Jan 10, 2025
cd19ade
provenance: URTable markdown sort show empty rows at bottom
benloh Jan 10, 2025
123ec76
provenance: Limit height of images in tables. CSS should be in URTab…
benloh Jan 10, 2025
f4f2f46
provenance: Show Provenance in Node and Edge Tables.
benloh Jan 10, 2025
d6b4343
provenance: Fail gracefully if provenance data is not yet defined
benloh Jan 10, 2025
934dc10
provenance: Add support for `hdate-short` and `timestamp-short` colum…
benloh Jan 10, 2025
95e9fc1
provenance: Add `infoOrigin` support to NCNodeTable and NCEdgeTable.
benloh Jan 11, 2025
4ed92da
provenance: Use "" for Comment column header. #325
benloh Jan 11, 2025
c989422
provenance: Don't show tabletips on View/Edit and Comment buttons #326
benloh Jan 11, 2025
74748e4
provenance: Use template labels for history columns. #327
benloh Jan 11, 2025
1935090
provenance: Show table popups in-line #324
benloh Jan 11, 2025
1460438
lint rewrap
benloh Jan 11, 2025
cdf28b2
provenance: Add rudimentary support for `infoOrigin` and `timestamp` …
benloh Jan 11, 2025
ff189ec
provenance: Add support for filtering timestamps (which are not Histo…
benloh Jan 12, 2025
6facf37
provenance: Restore hdate view in tables
benloh Jan 12, 2025
15487f5
provenance: Tables need to use `meta.created` when deriving `infoOrigin`
benloh Jan 12, 2025
1130eec
provenance: Style date fields to match other Node/Edge editor fields.…
benloh Jan 12, 2025
623021c
match-meme-comment: Match MEME backport of Comment Cancel. Fixes #329
benloh Jan 12, 2025
120cdc1
provenance: Catch missing `meta` parameters with new nodes and edges.…
benloh Jan 12, 2025
b2f422b
provenance: Clean up `revision` for older projects so that canceling …
benloh Jan 12, 2025
b625c8b
provenance: Optimize Node and Edge editor rendering
benloh Jan 12, 2025
4f7a1b1
provenance: Fix missing setState
benloh Jan 12, 2025
41dc1d2
provenance: Show larger images on table tip hover. #333
benloh Jan 13, 2025
a69b1c5
provenance: Case insensitive sorting for node labels in tables. Use …
benloh Jan 13, 2025
70e520b
provenance: Fix duplicate key warning in provenance tabs
benloh Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 72 additions & 37 deletions _ur_addons/comment/ac-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@

COMMENTCOLLECTION ccol
-----------------
A COMMENTCOLLECTION is the main data source for the CommentBtn.
A COMENTCOLLECTION is the main data source for the CommentBtn.
It primarily shows summary information for the three states of the button:
* has no comments
* has unread comments
* has read comments
* number of non-deleted comments in the collection
It passes on the collection_ref to the CommentThread components.

interface CommentCollection {
cref: any; // collection_ref
hasUnreadComments: boolean;
hasReadComments: boolean;
commentCount: number;
}


COMMENTUISTATE cui
--------------
COMMENTUISTATE keeps track of the `isOpen` state of currently selected/open
comment ui buttons.
Comments can be opened and closed from multiple UI elements.
A COMMENTUISTATE object can be opened and closed from multiple UI elements.
COMMENTUI keeps track of the `isOpen` status based on the UI element.
e.g. a comment button in a node can open a comment but the same comment can
be opened from the node table view.
be opeend from the node table view.

COMMENTUISTATE Map<uiref, {cref, isOpen}>


OPENCOMMENTS
---------------
OPENCOMMENTS keeps track of currently open comments. This is
------------
OPENCOMMENTS keeps track of currently open comment buttons. This is
used prevent two comment buttons from opening the same comment collection,
e.g. if the user opens a node and a node table comment at the same time.

Expand Down Expand Up @@ -68,8 +69,6 @@
isMarkedRead: boolean;
isReplyToMe: boolean;
allowReply: boolean;

markedRead: boolean;
}

\*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * /////////////////////////////////////*/
Expand All @@ -96,6 +95,7 @@ type TCommentCollection = {
collection_ref: TCollectionRef;
hasUnreadComments?: boolean;
hasReadComments?: boolean;
commentCount?: number;
};

type TCommentUIRef = string; // comment button id, e.g. `n32-isTable`, not just TCollectionRef
Expand All @@ -113,9 +113,8 @@ type TCommentVisualObject = {
isBeingEdited: boolean;
isEditable: boolean;
isMarkedRead: boolean;
isReplyToMe: boolean;
allowReply: boolean;
markedRead: boolean;
isReplyToMe?: boolean;
allowReply?: boolean;
};

type TCommentCollectionMap = Map<TCollectionRef, TCommentCollection>;
Expand Down Expand Up @@ -154,6 +153,12 @@ function LoadTemplate(commentTypes: Array<TCommentType>) {
* @param {any} data JSON data
*/
function LoadDB(data) {
COMMENTCOLLECTION.clear();
COMMENTUISTATE.clear();
OPENCOMMENTS.clear();
COMMENTS_BEING_EDITED.clear();
COMMENTVOBJS.clear();

if (DBG) console.log(PR, 'LoadDB', data);
DCCOMMENTS.LoadDB(data);
if (DBG) console.log('COMMENTCOLLECTION', COMMENTCOLLECTION);
Expand Down Expand Up @@ -203,6 +208,23 @@ function CloseCommentCollection(
DeriveThreadedViewObjects(cref, uid);
}

/**
* Close comment collections WITHOUT marking them read
* Used by comment status when user is quickly opening
* comments for review
*/
function CloseAllCommentCollections(uid: TUserID) {
COMMENTUISTATE.forEach((state, uiref) => {
if (state.isOpen) {
// Set isOpen status
COMMENTUISTATE.set(uiref, { cref: state.cref, isOpen: false });
OPENCOMMENTS.set(state.cref, undefined);
// Update Derived Lists to update Marked status
DeriveThreadedViewObjects(state.cref, uid);
}
});
}

function MarkRead(cref: TCollectionRef, uid: TUserID) {
// Mark Read
const commentVObjs = COMMENTVOBJS.get(cref);
Expand Down Expand Up @@ -232,14 +254,16 @@ function GetCommentStats(uid: TUserID): {
COMMENTVOBJS.forEach(cvobjs => {
cvobjs.forEach(cvobj => {
if (!cvobj.isMarkedRead) {
// count unread
countUnread++;
// count repliesToMe
const comment = DCCOMMENTS.GetComment(cvobj.comment_id);
if (rootCidsWithRepliesToMe.includes(comment.comment_id_parent)) {
// HACK: Update cvobj by reference!
cvobj.isReplyToMe = true;
countRepliesToMe++;
if (!comment.comment_isMarkedDeleted) {
// count unread
countUnread++;
// count repliesToMe
if (rootCidsWithRepliesToMe.includes(comment.comment_id_parent)) {
// HACK: Update cvobj by reference!
cvobj.isReplyToMe = true;
countRepliesToMe++;
}
}
}
});
Expand All @@ -265,16 +289,23 @@ function GetOpenComments(cref: TCollectionRef): TCommentUIRef {
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// EDITABLE COMMENTS

function m_RegisterCommentBeingEdited(cid: TCommentID) {
function RegisterCommentBeingEdited(cid: TCommentID) {
COMMENTS_BEING_EDITED.set(cid, cid);
}
function m_DeRegisterCommentBeingEdited(cid: TCommentID) {
function DeRegisterCommentBeingEdited(cid: TCommentID) {
COMMENTS_BEING_EDITED.delete(cid);
}

function GetCommentBeingEdited(cid: TCommentID): TCommentID {
return COMMENTS_BEING_EDITED.get(cid);
}
/// ANY comment is being edited
function GetCommentsAreBeingEdited(): boolean {
return COMMENTS_BEING_EDITED.size > 0;
}

function GetCommentsBeingEdited(): TCommentsBeingEditedMap {
return COMMENTS_BEING_EDITED;
}

/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// UNREAD COMMENTS
Expand Down Expand Up @@ -302,6 +333,8 @@ function GetUnreadComments(): TComment[] {
/// COMMENT THREAD VIEW OBJECTS

function DeriveAllThreadedViewObjects(uid: TUserID) {
COMMENTCOLLECTION.clear();
COMMENTVOBJS.clear();
const crefs = DCCOMMENTS.GetCrefs();
crefs.forEach(cref => DeriveThreadedViewObjects(cref, uid));
}
Expand All @@ -317,12 +350,14 @@ function DeriveThreadedViewObjects(
): TCommentVisualObject[] {
if (cref === undefined)
throw new Error(`m_DeriveThreadedViewObjects cref: "${cref}" must be defined!`);
const commentVObjs = [];
const commentVObjs: TCommentVisualObject[] = [];
let commentCount = 0;
const threadIds = DCCOMMENTS.GetThreadedCommentIds(cref);
threadIds.forEach(cid => {
const comment = DCCOMMENTS.GetComment(cid);
if (comment === undefined)
console.error('GetThreadedViewObjects for cid not found', cid, 'in', threadIds);
if (!comment.comment_isMarkedDeleted) commentCount++;
const level = comment.comment_id_parent === '' ? 0 : 1;
commentVObjs.push({
comment_id: cid,
Expand Down Expand Up @@ -367,6 +402,7 @@ function DeriveThreadedViewObjects(
});
ccol.hasUnreadComments = hasUnreadComments;
ccol.hasReadComments = hasReadComments;
ccol.commentCount = commentCount;
COMMENTCOLLECTION.set(cref, ccol);
return commentReplyVObjs;
}
Expand All @@ -385,21 +421,15 @@ function GetThreadedViewObjects(
: commentVObjs;
}

/**
* @param {string} cref
* @param {string} uid -- User ID is used to determine read/unread status
* @returns {number} Returns the number of comments in a collection
*/
function GetThreadedViewObjectsCount(cref: TCollectionRef, uid: TUserID): number {
return GetThreadedViewObjects(cref, uid).length;
}

function GetCOMMENTVOBJS(): TCommentVisualObjectsMap {
return COMMENTVOBJS;
}

function GetCommentVObj(cref: TCollectionRef, cid: TCommentID): TCommentVisualObject {
const thread = COMMENTVOBJS.get(cref);
if (thread === undefined)
// fail gracefully if thread not found -- this can happen if the comment has been deleted
return;
const cvobj = thread.find(c => c.comment_id === cid);
return cvobj;
}
Expand Down Expand Up @@ -428,7 +458,7 @@ function AddComment(data: {
COMMENTVOBJS
);
cvobj.isBeingEdited = true;
m_RegisterCommentBeingEdited(comment.comment_id);
RegisterCommentBeingEdited(comment.comment_id);

commentVObjs = commentVObjs.map(c =>
c.comment_id === cvobj.comment_id ? cvobj : c
Expand All @@ -454,15 +484,15 @@ function UpdateComment(cobj: TComment, uid: TUserID) {
const cvobj = GetCommentVObj(cobj.collection_ref, cobj.comment_id);
if (cvobj === undefined)
throw new Error(
`ac-comment.UpdateComment could not find cobj ${cobj.comment_id}. Maybe it hasn't been created yet? ${COMMENTVOBJS}`
`ac-comment.UpdateComment could not find cvobj ${cobj.comment_id}. Maybe it hasn't been created yet? ${COMMENTVOBJS}`
);

// mark it unread
cvobj.isMarkedRead = false; // clear read status
DCCOMMENTS.MarkCommentUnread(cvobj.comment_id, uid);

cvobj.isBeingEdited = false;
m_DeRegisterCommentBeingEdited(cobj.comment_id);
DeRegisterCommentBeingEdited(cobj.comment_id);
cvobj.modifytime_string = GetDateString(cobj.comment_modifytime);
commentVObjs = commentVObjs.map(c =>
c.comment_id === cvobj.comment_id ? cvobj : c
Expand Down Expand Up @@ -523,8 +553,9 @@ function RemoveAllCommentsForCref(parms: {
* Does NOT trigger a database update
* (Contrast this with RemoveComment above)
*/
function HandleRemovedComments(comment_ids: TCommentID[]) {
function HandleRemovedComments(comment_ids: TCommentID[], uid: TUserID) {
DCCOMMENTS.HandleRemovedComments(comment_ids);
DeriveAllThreadedViewObjects(uid);
}

/// PASS-THROUGH METHODS //////////////////////////////////////////////////////
Expand Down Expand Up @@ -567,22 +598,26 @@ export {
GetCommentCollection,
UpdateCommentUIState,
CloseCommentCollection,
CloseAllCommentCollections,
MarkRead,
GetCommentStats,
// Comment UI State
GetCommentUIState,
// Open Comments
GetOpenComments,
// Editable Comments
RegisterCommentBeingEdited,
DeRegisterCommentBeingEdited,
GetCommentBeingEdited,
GetCommentsAreBeingEdited,
GetCommentsBeingEdited,
// Unread Comments
GetUnreadRepliesToMe,
GetUnreadComments,
// Comment Thread View Object
DeriveAllThreadedViewObjects,
DeriveThreadedViewObjects,
GetThreadedViewObjects,
GetThreadedViewObjectsCount,
GetCOMMENTVOBJS,
GetCommentVObj,
// Comment Objects
Expand Down
Loading