owned this note
owned this note
Published
Linked with GitHub
# 22BNI_Merge the concept of Shared virtual folder and Lightbox / Collection
> [22BNI_Merge the concept of Shared virtual folder and Lightbox / Collection](https://link.orangelogic.com/Tasks/22BNI)
[https://link.orangelogic.com/Tasks/22BNI](https://link.orangelogic.com/Tasks/22BNI)
Status: To Do
| When | Who | What |
| -------- | -------- | -------- |
| 2022-9-19 | Lanh Nguyen | Initial Creation |
## Why
In current implementation, Collections are stored in a dedicated tables XD,XL. It prevents us to manage the permission like what we do for Documents
## Target
- Convert lightboxes from a dedicated table to Standard Virtual fodler (Lightbox and Shared lightbox).
- Migrate all existing light box to new Virtual Folders
- Implement Permission request/ collaborators flows
- UI design: https://www.figma.com/file/IQmUET3fxiyswkJomu0Cu2/Merge-the-concept-of-Shared-virtual-folder-and-Lightbox-%2F-Collection-(DO-NOT-MODIFY)?node-id=427%3A204084
## Implementation plan
### Apply Collection UI for Virtual folder
#### 1. UI modification
##### 1.1. Create an activation parameter to enable CollectionsV2
##### 1.2. Modify the "Add to collection" action to open Old/New Collections UI (2d4h)
- Show Albums that you own (you're the createuser) and albums where you have been added as a collaborator (direct permission, not inherited, that info should already be indexed)
- Duplicate the LightboxSelection_AddDocuments_VForm and mdify to handle Album (2d)
- Confirmation popup with permission details (4h)
##### 1.3. My collections UI (2d4h)
- Create new workspace to show collections (4h)
- Update Collections Side Panel to display collection V2(8h): The display order in this side panel (and in teh add to collection popup) should be based ont eh CreateDate of the collection, most recent first.We should however in both case preselect / highlight the last collection the user clicked to view or to add assets to. To be stored in user preferences
- Dynamic menu actions for the collections (4h)
- Update header for collection workspace: Add Share live collection/Creator (4h)
##### 1.4 Add to existing collections (8h)
Create 2 actions Add to existing collections:
- Add to my collections: Same view as 1.2
- Add to existing collections: Show hierachy tree of all collections that user has permission
#### 2. Migrate old Light box to DO_DOCUMENTS
Migration flows:
##### Step 1: Migrate all Lightbox related table to DO
- Run on Primary and Backup (20h)
- Create if not exist a table that lise all the XD record hasn't been migrated yet.
Table column: LM_LIGHTBOXMIGRATION: XDRecordID|Migrated|MotherSet
- Start or resume migrating XD / XL / CQ to DO / DL/ CZ maintaining the recordids. Would be fast, not trigger replication, executed on Primary and Secondary independently. Would create the self DJ entry and FT entry for each XD
- Create self entry on DJ (DO_RecordIDRef=DO_RecordIDChild=XD.RecordID, Level=0)
- Create empty Entry on FT table
- XD => DO Mapping
|XD Field|DO Field|
|-|-|
|Title|Title|
|Id_Client|Id_Client|
|CaptionLong|CaptionLong|
|Representative_XD|Representative_DO|
|RecordID|ProxyForRecordID|
|"XD_EXPIRABLEDOCUMENTS"|ProxyForTable|
|"Album"|DocType|
|""|DocSubType|
|RecordID|RecordID|
|"XD" + numeric part of recordid|Identifier|
- XL -> DL
|XL Field|DL Field|
|-|-|
|DO_RecordIDBot|DO_RecordIDBot|
|Position|Position|
|XL.DO_RecordIDTop|DO_RecordIDTop|
- CQ_CONTACTLIGHTBOXLINKS -> CZ_CONTACTDOCUMENTLINKS
|CQ Field|CZ Field|
|-|-|
|CT_Assigned|CT_RecordID|
|CQ.XD_RecordID|DO_RecordID|
|CanViewItems|CanRead|
|CanAddItems|CanUpload|
|CanEditMetadata|CanWrite|
|CanShare|CanShare|
|CanViewItems|CanFind|
|CanManageRights|CanManageRights|
|"DO_DOCUMENTS"|LinkedTableName|
|EditUserID|CTPermissionEditor|
|EditDate|PermissionEditDate|
|1|DisableInheritance|
- 1st Step: Migrate all Records has CT_Assigned filled
- 2nd Step: Migrate all Records has CT_Assigned empty and Email is filled
- Select all shared emails
`SELECT DISTINCT CQ.Email FROM CQ_CONTACTLIGHTBOXLINKS CQ
JOIN XD_EXPIRABLEDOCUMENTS XD ON XD.RecordID=CQ.XD_RecordID AND CQ.Disabled=0 AND XD.Disabled=0
WHERE ISNULL(CQ.CT_Assigned,'')=''`
- Create all contacts for list of emails if not exist, contact type: **MailingSubscriber**
- Do same run with 1st step but CZ.CT_RecordID = SELECT RecordID from CT_CONTACTS CT Where CT.Email1=CQ.Email
##### Step 2: Set mother for migrated DO (12h)
- Run on Primary only
- A slower API run only on Primary, throttled to not overwhelm replication to place XDs in the users personal folders (would run 5records/second)
- Add all linked assets to DC_lowpriority
`SELECT DO_RecordIDBot FROM DL_DOCLINKS DL JOIN LM_LIGHTBOXMIGRATION LM WHERE DL.DO_RecordIDTop=LM.RecordID AND DL.Disabled=0`
#### Step 3 (Optional do as last) Migrate LastUseDate to DG_DOCUMENTLOGS (2h)
- Migrate all CQ.LastUseDate to DG_DOCUMENTLOGS
- Mapping:
|CQ Field|DG Field|
|-|-|
|CT_Assigned|CT_RecordID|
|CQ.XD_RecordID|DO_RecordID|
|"DO_DOCUMENTS"|ContextualTable|
|"VIEW_DETAILS"|Action|
|LastUseDate|EditDate|
|LastUseDate|CreateDate|
|CQ.RecordID|Reference|
### Share Live Collection Flow
#### Permission on Collections
#### Permission on Assets

##### 1. Implement Share Live Collection Popup UI (8h)
##### 2. Update Existing function (2h)
- Add new column to CZ ContextualRecordID (varchar 17)
- Edit CZ_CONTACTDOCUMENTLINKS_DbBO.RequestPermissions to
- Support input ct recordID, if input CT is empty, use current user
- Support saving ContextualRecordID
##### 3. Store the assigned permissions on collection (4h)
- Do the same at Roles Based permission system to have View/View & Add/Full Control permission on collection
##### 4. Request permission flows Logic + UI (12h)
Logic: When **adding new assets to collection** or **share collection to a new user** (4h)
- If user doesn't have permission on assets
- create new "Access Request Project"
- set Approver group (parameter in first phase) to the Approvers
- custom field to store "Why access is needed"
- add all target users to "Assign to"
- create new Relation (Access Request) and assign to Access Request Project-Collection
- If the "Access Request Project" exist, add more Assign to and Change status to Pending if it's completed
Review Asset Request UI (8h)
[Design](https://www.figma.com/file/IQmUET3fxiyswkJomu0Cu2/Merge-the-concept-of-Shared-virtual-folder-and-Lightbox-%2F-Collection-(DO-NOT-MODIFY)?node-id=563%3A197139)
##### 5. Approve flow UI (16h)
- Create workspace to display all "Access Request Project" called "Collections Request", table view with field: Collection Name (Parent Title), Why access is needed, Collaborators, Status, Requested By
- Create "Open" action to open the "Review Asset Permissions Request"
- Create a widget can be displayed on Damview Details has same view as "Review Asset Permissions Request"
- When Openning "Access Request Project":
- Get all the assets linked to collections that each "Assign to" doesn't have permission
- If having a CZ with Status Rejected => show thump down
- If no CZ, show ?
- When Reject/Approved:
- Get the CZ recordID with CT_RecordID = "Assign to", DO_RecordID= current collection (CZ created from [3.Store-the-assigned-permissions-on-collection](https://hackmd.io/-3ItCeO5QKmljrcjPBfFtw?both#3-Store-the-assigned-permissions-on-collection-2h))
- Create new CZ with the same right with the CZ assign to collection the set the RequestStatus to Approved/Rejected
6. Remove Asset from Collections/Delete Collection (4h)
- Because when deleting collection + removing asset from Collection, they all remove doclink so put the logic to DL_DOCLINKS_DbBO.PostDelete, when DO_RecordID top is Collections and Table Bot/Top is DOCUMENTS, delete all the CZ has ContextualRecordID = CollectionID
- Notes: Keep the soft delete logic. The permission will remaining when collection is deleted (in binned) until collection is permanent deleted