Skip to content

Scroll to uploaded file in file list - #9195

Merged
pdessauw merged 1 commit into
masterfrom
fix-733
Sep 3, 2014
Merged

pdessauw merged 1 commit into
masterfrom
fix-733

Conversation

@pdessauw

Copy link
Copy Markdown
Contributor

When files are uploaded, the cursor scrolls down to the last one and make it blink.

fixes #733

@karlitschek

Copy link
Copy Markdown
Contributor

@PVince81 What do you think?

Comment thread apps/files/js/file-upload.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use triple equal === for type safety.

@PVince81

Copy link
Copy Markdown
Contributor

@pdessauw thanks for the PR.

A few comments:
I'd prefer having the scrolling code directly in the FileList class. Maybe add a function scrollToFile(fileName) that will use the logic you provided (calling _nextPage), etc.
Also, functions that start with an underscore _nextPage are considered private by convention, so you are not allowed to call them from outside the class itself.

  • Move code into the class FileList in a new function scrollToFile(fileName)
  • Use tabs instead of spaces, the indent seems wrong
  • Fix issue commented inline

Comment thread apps/files/js/file-upload.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try not using global selectors.
Once you have moved this code to the FileList class you can use this.$el to access that element, so the right part will become this.$el.scrollTop().

@PVince81

Copy link
Copy Markdown
Contributor

I haven't tested this yet, here are a few questions:

  1. What happens when uploading multiple files ? Will it only highlight the last one ? (it seems so from reading the code). I think it might be good to highlight all the files that were newly uploaded (CC @owncloud/designers)

It should probably highlight ALL the uploaded files, but only scroll to the last one as we can't scroll to multiple files 😄
From the code it seems the scrolling part should work.

I'll test this once you've made the above changes 😄
Thanks.

Comment thread apps/files/js/file-upload.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here with triple equals.
Also I think you don't need to escape the slash, so "\/" becomes '/' (we usually use single quotes from strings)

@pdessauw

Copy link
Copy Markdown
Contributor Author

OK, my JS editor was wrongly setup, I corrected that. I will implement all the design advice you gave me.

Multiple files is working but only highlight the last uploaded file, I will also change that.

@pdessauw

Copy link
Copy Markdown
Contributor Author

I submitted the changes. I created 2 different functions: 1 to scroll, the other to highlight all the uploaded files.

Let me know what you're thinking of the new version.

Comment thread apps/files/js/filelist.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just noticed that we also need to make sure we don't get infinite loops here in case the file is still not found.

I suggest to change _nextPage to return true when a page was appended and false when there are no more pages. This way you'll be able to jump out of this loop/function if the file name is never found for some reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I corrected this portion of code but I can't figure out a proper test to be sure that there is no infinite loop. @PVince81 do you have any suggestion about it?

@PVince81

Copy link
Copy Markdown
Contributor

@pdessauw thanks for making the changes. It is a big improvement 😄

@MorrisJobke MorrisJobke changed the title Fix 733 Scroll to uploaded file in file list Jun 25, 2014
@MorrisJobke

Copy link
Copy Markdown
Contributor

FYI: I updated the title to be more descriptive.

@ghost

ghost commented Jun 25, 2014

Copy link
Copy Markdown

@MorrisJobke MorrisJobke added Design and removed Bug labels Jun 25, 2014
@pdessauw

Copy link
Copy Markdown
Contributor Author

Thanks for the JSHint advice, I have installed it. Way better now :). I'll take care of the last few things and let you know once it is done.

@jancborchardt jancborchardt mentioned this pull request Jul 1, 2014
9 tasks done
@jancborchardt jancborchardt added this to the ownCloud 8 milestone Jul 3, 2014
@jancborchardt jancborchardt mentioned this pull request Jul 4, 2014
1 of 6 tasks
@butonic

butonic commented Aug 5, 2014

Copy link
Copy Markdown
Contributor

@pdessauw did you find the time to work on this? I don't want to duplicate the effort but am eager to finish this...

@butonic

butonic commented Aug 5, 2014

Copy link
Copy Markdown
Contributor

I added the regression tag because the PR goes a long way fixing owncloud-archive/apps#1882 and #10028 - the scrollto feature, used to find and scroll to a file in the filelist.

@pdessauw

pdessauw commented Aug 5, 2014

Copy link
Copy Markdown
Contributor Author

Yeah, I got busy and forgot to finish this work. It shouldn't be too long to produce a correct pull request. I'm on it!

@ghost

ghost commented Aug 11, 2014

Copy link
Copy Markdown

Comment thread apps/files/js/filelist.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is actually wrong. You are expecting an array in the form [{name:'file1.txt'},{name:'file2.txt'}].
Ideally this function should accept an array of strings like ['file1.txt', 'file2.txt'].
Then in the upload.js file you can call it using _.pluck(files, 'name'). This will automatically flatten the array by picking all name properties.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This comment is linked to the one below. As requested, I pluck the array in the file-upload.js, thus, I didn't have to change anything from this part of the code. The function is now working accordingly to the documentation. Is there anything I should change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I see. I don't see anything bad in the code, and since you have two reviews already, I think you can merge it :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this is already fixed.

@PVince81

Copy link
Copy Markdown
Contributor

It does work now, thanks.
I tried to call it on the console with FileList.highlightFiles(["file1.txt", "file2.txt"]) but it didn't work. See my comment in your code for details.

Also: can you add some padding in the scrolling calculation ? I see that when it scrolls down the highlighted file is directly at the top of the list. It might look nice if you could at this point see one or two rows above it.

@PVince81

PVince81 commented Sep 1, 2014

Copy link
Copy Markdown
Contributor

@pdessauw any news ? 😄

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@ghost

ghost commented Sep 3, 2014

Copy link
Copy Markdown

@pdessauw

pdessauw commented Sep 3, 2014

Copy link
Copy Markdown
Contributor Author

@PVince81 I made some changes:

  • Used the pluck function to flatten the array,
  • Modified the offset so that we can see 2 rows up ahead the last highlighted file,
  • Removed the highlighted class from each row 2.5 second after I add it (the animation is set to last 2 seconds).

I defined an inner function (highlightRow) in filelist.js which is called for each row. I did that because of the setTimeout which uses a new function each time it is called and JSLint was ranting about using it in the loop over files. I am not sure about the correctness of doing that, if it needs to be modified, let me know.

@PVince81

PVince81 commented Sep 3, 2014

Copy link
Copy Markdown
Contributor

The code looks good, going to test it again.

@PVince81

PVince81 commented Sep 3, 2014

Copy link
Copy Markdown
Contributor

Very nice, great work! 👍 from me

@owncloud/designers please check it out (@enoch85 ?)

Needs a second reviewer @icewind1991 @th3fallen

@th3fallen

Copy link
Copy Markdown
Contributor

👍

pdessauw added a commit that referenced this pull request Sep 3, 2014
Scroll to uploaded file in file list
@pdessauw
pdessauw merged commit 63dff87 into master Sep 3, 2014
@jancborchardt
jancborchardt deleted the fix-733 branch September 3, 2014 19:13
@MorrisJobke

Copy link
Copy Markdown
Contributor

Is this really a regression? If yes: should this be backported?

@karlitschek

Copy link
Copy Markdown
Contributor

please backport

@PVince81

PVince81 commented Sep 4, 2014

Copy link
Copy Markdown
Contributor

It is a regression introduced by the "render on scroll" feature (aka infinite scroll) for which it wasn't possible to use the same mechanism to automatically scroll down since the element didn't exist yet.

I'll take care of the backport

@PVince81

PVince81 commented Sep 4, 2014

Copy link
Copy Markdown
Contributor

Backported to stable7 as 919d19c

@PVince81

PVince81 commented Sep 5, 2014

Copy link
Copy Markdown
Contributor

@owncloud/designers have you reviewed the highlight animation ?
Forgot that this PR also adds a highlight animation on upload, which is nice, but I'd like to make sure this looks ok.

@DeepDiver1975 DeepDiver1975 modified the milestones: ownCloud 8, 8.0-current Jan 9, 2015
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Files: after selecting file for upload, scroll to where in the list it is and slightly highlight it

10 participants