Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDMEXT354/Capability to attach same document to different entities #12

Merged
merged 5 commits into from
May 23, 2024

Conversation

yashmeet29
Copy link
Member

Jira: https://jira.tools.sap/browse/SDMEXT-354
Bug: https://jira.tools.sap/browse/SDMEXT-381
Bug: https://jira.tools.sap/browse/SDMEXT-383
This PR includes:

  • User to be able to pick a file with same name from his/her file system and attach it to multiple entities.
  • User will be restricted to attach the same file or file with same name to an entity where already a file with such name is attached.
  • App crashing on incomplete upload

const response = await axios.get(getFolderByPathURL, config);
return response.data.properties["cmis:objectId"].value;
} catch (error) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add console.log(error) here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -64,7 +120,7 @@ async function createAttachment(data, credentials, token, attachments) {
return response;
}

async function deleteAttachment(credentials, token, objectId, attachments) {
async function deleteAttachmentOrFolder(credentials, token, objectId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls rename it to deleteAttachmentsOfFolder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/sdm.js Outdated
this.isFileNameDuplicateInDrafts(attachment_val);
if (duplicateDraftFilesErrMsg != "") {
req.reject(409, duplicateDraftFileErr(duplicateDraftFilesErrMsg));
}
//verify if duplicates exist for the drafts
const duplicateFilesErrMsg = await this.isFileNameDuplicate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not be required now right as other entities you can add same files so we can remove this check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is for the case when user attaches same document multiple times in draft state.
Fix for this Bug: https://jira.tools.sap/browse/SDMEXT-383

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Removed isFileNameDuplicate()

lib/sdm.js Outdated
parentId = response.data.succinctProperties["cmis:objectId"];
}
} else {
parentId = folderIds[0].folderId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we check if folderIds.? i mean not undefined and length>0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/sdm.js Outdated
@@ -103,6 +163,13 @@ module.exports = class SDMAttachmentsService extends (
if (attachmentsToDelete.length > 0) {
req.attachmentsToDelete = attachmentsToDelete;
}
if (req.event == "DELETE") {
const folderIds = await getFolderIdForEntity(attachments, req);
if (folderIds.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for undefined also

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

test/lib/handler/index.test.js Fixed Show fixed Hide fixed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Fixed Show fixed Hide fixed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/handler/index.test.js Dismissed Show dismissed Hide dismissed
test/lib/sdm.test.js Dismissed Show dismissed Hide dismissed
@yashmeet29 yashmeet29 closed this May 22, 2024
@yashmeet29 yashmeet29 reopened this May 22, 2024
@yashmeet29 yashmeet29 merged commit f231f0f into develop May 23, 2024
3 checks passed
@yashmeet29 yashmeet29 deleted the SDMEXT354/CreateFolder branch May 23, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants