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

feat(copy): drag-drop shift modifier to move/copy a document #1079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nlzet
Copy link

@nlzet nlzet commented Feb 3, 2025

Adding a new feature to allow copying documents together with the underlying files.

While holding shift you can either drag the document(s) onto the document view (to copy within the same category), or onto a category by dropping it onto the category navigation on the left.

This functionality will rely on projectcaluma/alexandria#757

addon/components/category-nav/category.js Show resolved Hide resolved
addon/components/category-nav/category.js Outdated Show resolved Hide resolved
addon/components/category-nav/category.js Outdated Show resolved Hide resolved
addon/components/document-view.hbs Outdated Show resolved Hide resolved
addon/components/document-view.hbs Outdated Show resolved Hide resolved
addon/components/document-view.js Outdated Show resolved Hide resolved
Comment on lines 39 to 41
get canDropCopy() {
return Boolean(
this.dragAction === "copy" &&
this.args.filters &&
this.args.filters.categories,
);
}

get canDropUpload() {
return Boolean(
this.dragAction === "upload" &&
this.args.filters &&
this.args.filters.categories,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to distinguish these two? Couldn't you just do something like this?

Suggested change
get canDropCopy() {
return Boolean(
this.dragAction === "copy" &&
this.args.filters &&
this.args.filters.categories,
);
}
get canDropUpload() {
return Boolean(
this.dragAction === "upload" &&
this.args.filters &&
this.args.filters.categories,
);
}
get canDrop() {
return Boolean(
["copy", "upload"].includes(this.dragAction) &&
this.args.filters &&
this.args.filters.categories,
);
}

Copy link
Author

Choose a reason for hiding this comment

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

For the component purpose it could be simplified but in the template I'm depending on separate methods to differentiate between two different translations. See document-view.hbs

Copy link
Contributor

Choose a reason for hiding this comment

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

I think differentiating by this.dragAction in the template would be the way to go for this.

Copy link
Author

Choose a reason for hiding this comment

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

Changed

addon/components/document-view.js Outdated Show resolved Hide resolved
@nlzet nlzet force-pushed the feat-drag-drop-copy branch 3 times, most recently from 333562d to 118cffb Compare February 13, 2025 09:31
@nlzet
Copy link
Author

nlzet commented Feb 13, 2025

@anehx rebased and added some fixes and comments

@@ -7,8 +7,7 @@
>
<div class="uk-flex uk-flex-middle uk-padding-small">
<DocumentUploadButton
@categoryId={{@filters.categories}}
@afterUpload={{this.refreshDocumentList}}
@categoryId={{@filters.categories}} @afterUpload={{this.refreshDocumentList}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's revert this formatting change.

Copy link
Author

Choose a reason for hiding this comment

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

Reverted

Comment on lines 39 to 41
get canDropCopy() {
return Boolean(
this.dragAction === "copy" &&
this.args.filters &&
this.args.filters.categories,
);
}

get canDropUpload() {
return Boolean(
this.dragAction === "upload" &&
this.args.filters &&
this.args.filters.categories,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think differentiating by this.dragAction in the template would be the way to go for this.

addon/components/document-view.js Outdated Show resolved Hide resolved
@nlzet nlzet force-pushed the feat-drag-drop-copy branch from 118cffb to d385a1b Compare February 18, 2025 13:30
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.

2 participants