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

Default upload text should change to file name #121

Open
1 task
ghost opened this issue Oct 22, 2021 · 12 comments
Open
1 task

Default upload text should change to file name #121

ghost opened this issue Oct 22, 2021 · 12 comments

Comments

@ghost
Copy link

ghost commented Oct 22, 2021

Summary

PR #120 solves the styling of the modal, but the "No file selected message" does not change to the name of the file uploaded.

Things to Consider

  • Assign a custom class or id for the span tag which encloses the default message.
  • Implement a JS snippet that looks for the file upload event to be triggered. On completion, replace the string inside the tag to the file name.

This page would be a nice material to refer to.

Criteria for Completion

  • On uploading a file, the No file selected should be replaced with the file name.

What it looks like right now:
Screenshot 2021-10-22 at 20-33-14 Volunteers INKIND

What it should look like:
Screenshot 2021-10-22 at 20-35-21 Volunteers INKIND

@chandan270
Copy link

Can I work on this issue?

@ghost
Copy link
Author

ghost commented Oct 23, 2021

@chandan270 that would be great. Just wait for @garettarrowood's ping, and you can work on the issue.

@garettarrowood
Copy link
Member

Thanks @chandan270 !

@garettarrowood
Copy link
Member

@chandan270 - Are you still interested in completing this work? Just checking in.

@ghost
Copy link
Author

ghost commented Dec 2, 2021

@garettarrowood I'll fix this issue this after the 8th of this month.

@garettarrowood
Copy link
Member

That'd we great! Thanks @Ashvith !

@garettarrowood garettarrowood assigned ghost Dec 2, 2021
@ghost
Copy link
Author

ghost commented Dec 2, 2021

@garettarrowood need some help with adding Javascript. I am actually clueless about where we can add JS files here. Is it supposed to be inside javascript/controllers?

This is what I wanted to add:

const actualBtn = document.getElementById('select-file');

const fileChosen = document.getElementById('file-chosen');

actualBtn.addEventListener('change', function(){
  fileChosen.textContent = this.files[0].name
})

@garettarrowood
Copy link
Member

@Ashvith - I'm not experienced with StimulusReflex JS conventions at all.

I would say try it in a couple places that seem to make sense, and use your best judgement. As long as we get it working, and its named well (as in, the file is named well), we should be able to either run with your convention, or refactor it to another place as we grow smarter/more experienced :) .

@ghost
Copy link
Author

ghost commented Dec 10, 2021

@garettarrowood Looks like this is out of my experience too. If you want to, I could have a look at some of the tutorials, and examples and maybe fix this sometimes later?

@garettarrowood
Copy link
Member

If you can even get this to work in a <script> tag at the bottom of the HTML file, I'm fine with it.

@ghost
Copy link
Author

ghost commented Dec 16, 2021

I've tried the script method, and it isn't working as well. Stimulus-Reflex is the only way. I've tried some examples, but then I was not able to succeed because when the label-for click element is triggered, the application is supposed to wait till the user chooses a file, but in my case, it starts looking for the file directly even before the user can click, which is non-existent at the time of the event, and so it throws a controller error.

@ghost ghost removed their assignment Dec 16, 2021
@JelenaD1
Copy link
Contributor

Can I take over and work on this issue? @garettarrowood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants