B4J Question [SOLVED] Indicate row item new or updated

Harris

Expert
Licensed User
Longtime User
I have morphed the ABMFeedback project to suit my new project needs - since it already contained most of the desired functionality (why reinvent the wheel?).

What I ask now is - how to implement a procedure where new items added, or existing items updated, will visually indicate this to the user(s)? In the picture below - update the background color of the first col (the star) to green (or something)...

Three tables can be updated. Cases, the master along with notes and attachments.

I was thinking about a last_updated (timestamp) field in cases, that would get updated to Now on insertion or edit (be it the cases, notes or attachment that was new or updated). Then, in the users table, add another field (last_read - timestamp) that would get updated (somehow) after all new issues were read.
New record updates would be determined by comparing users last_read to cases last_updated...

How would YOU accomplish this?

Thanks

abfeedback.jpg
 

Harris

Expert
Licensed User
Longtime User
Then, in the users table, add another field (last_read - timestamp) that would get updated (somehow) after all new issues were read.
I see this being a problem... The first issue read would sett all others (read or not) to read...
Need another method...
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Actually, @alwaysbusy already had the solution in the feedback app - my old brain just could not comprende... until a second look.
Logic is in feedback app - so I won't repeat it here.

B4X:
  ' reset everyones read status for this case  (except the current user)
    DBM.SQLDelete(SQL, "DELETE FROM caseread WHERE CaseRCaseID = " & ActiveCaseId &" AND CaseRUserID <> "&UserID )

I added this: &" AND CaseRUserID <> "&UserID - so the current user who added a new note would not get notified that there is a new note... Noted!

I shall use the same above in the Update cases and attachment tables code. Now, any user (other than the current who posted) will get notified of new issues when someone else adds / modifies the content.

Admin - as an administrator, you need to know when someone updated a case, without reviewing each one - looking for something new...

User - as a user, you need to know when Admin (or other) updated the Status, added/edited a note or posted new attachement - without reviewing each one - looking for something new...

This added functionality can not be overlooked or overstated - it is imperative (in this design anyway).

Note:
Without all of you intelligent people in this community contributing (rather than just consuming) - complex / important issues like this would not get resolved.
Hats off and a big bow to you contributors!


newllok.jpg
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
B4X:
    Dim checkmp As Map
    checkmp.Initialize
    checkmp.Put("attaches",Attachments.Size)      
    checkmp.Put("casetype",casetype.GetActiveItemId() )  
    checkmp.Put("casesummary", (casesummary.Text))
    checkmp.Put("casedescription", (casedescription.Text))
    checkmp.Put("casepoints", casepoints.GetActiveItemId())
    checkmp.Put("casestatus", casestatus.GetActiveItemId())
    checkmp.Put("caseversion", caseversion.text)
  
   Log(" check map: "&checkmp)
   Log(" edit  map: "&CaseEdit)
  
    If CaseEdit.Size = 0 Then  ' inserted record - it is NEW - force WasEdit code below...
        WasEdit = True
    Else
        WasEdit = CheckEdit(checkmp)   ' was anything changed?  Compare original to saved content... 
    End If
  
    If WasEdit Then
        Log(" Setting userids in save")
        ' reset everyones read status for this case
        DBM.SQLDelete(SQL, "DELETE FROM caseread WHERE CaseRCaseID = " & ActiveCaseId &" AND CaseRUserID <> "&UserID&" AND comp_id = "&Main.comp_id )
    End If
  
    WasEdit = False


Sub CheckEdit(checkmap As Map) As Boolean
  
    Dim res  As Boolean = False
  
    For i = 0 To CaseEdit.Size-1  ' CaseEdit saved each item to a map to compare against checkmap to see if anything changed.
        Dim ky As String = CaseEdit.GetKeyAt(i)
        Dim v1 As String = CaseEdit.GetDefault(ky,"x")
        Dim v2 As String = checkmap.GetDefault(ky,"x")
        If v1 <> v2 Then
            res = True
            Log(" Different key value found: "&ky&"  -  "&v1&" -  "&v2)
            Exit
        End If
      
    Next

   Return res  
  
End Sub

This might not be immediately obvious.

CaseEdit map was created when inserting a new record (just initialized) or editing an existing record (created map of existing fields).

When editing, if any field does not equal previous view saved - it was updated (edited) - sets WasEdit to True. Happens in saving a new or edit record.
This forces - DBM.SQLDelete(SQL, "DELETE FROM caseread WHERE CaseRCaseID = " & ActiveCaseId &" AND CaseRUserID <> "&UserID&" AND comp_id = "&Main.comp_id ) to be called....

Without this check, all "looked at records" would have appeared to been modified by another user - and flagged as such. Only new or modified records will inform other users that they need to examine THIS record - for updates...

Thanks
 
Last edited:
Upvote 0
Top