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

💄 [#1309] Make upload widget correspond with design #580

Merged

Conversation

jiromaykin
Copy link
Contributor

@jiromaykin jiromaykin commented Apr 13, 2023

issue: https://taiga.maykinmedia.nl/project/open-inwoner/task/1309

multiple tasks:

  • - needs custom template for input with type=file
  • - form needs to be overridden with a render_form
  • - toggle open/close interface to show/hide file-upload input field
  • - show filename info
  • - show filesize info
  • Disable submit button when no file is chosen and on cancel

other task:

  • - fix failing test "@requests_mock.Mocker() /class TestCaseDetailView(ClearCachesMixin, WebTest):'
  • - errors need to be shown and scrolled into view
  • - client-side errorhandling (browser defaults) needs to be overriden somehow, so the error notifications actually gets shown (with "novalidate"?)
  • - add reset 'close' button to clear the field and the information

@jiromaykin jiromaykin force-pushed the feature/1309-make-upload-widget-correspond-with-design branch from 9f12f73 to e61ddb7 Compare April 13, 2023 08:43
@jiromaykin jiromaykin force-pushed the feature/1309-make-upload-widget-correspond-with-design branch 3 times, most recently from fe4ef13 to c6dc362 Compare April 19, 2023 22:16
@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2023

Codecov Report

Merging #580 (0ef4dee) into develop (112f337) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 0ef4dee differs from pull request most recent head 01546ec. Consider uploading reports for the commit 01546ec to get more accurate results

@@           Coverage Diff            @@
##           develop     #580   +/-   ##
========================================
  Coverage    96.17%   96.17%           
========================================
  Files          564      564           
  Lines        19795    19798    +3     
========================================
+ Hits         19037    19040    +3     
  Misses         758      758           
Impacted Files Coverage Δ
src/open_inwoner/accounts/forms.py 97.93% <ø> (ø)
.../open_inwoner/components/templatetags/form_tags.py 96.15% <100.00%> (+0.09%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jiromaykin jiromaykin force-pushed the feature/1309-make-upload-widget-correspond-with-design branch from 0700f91 to 204d608 Compare April 23, 2023 21:43
@jiromaykin jiromaykin marked this pull request as ready for review April 23, 2023 22:04
{% load i18n form_tags button_tags icon_tags %}

<div class="form__control {{ extra_classes|default:"upload" }}">
<div id="inputfile-group" class="inputfile-group">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe use a different name for id and class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vaszig I've done a bit of research on naming conventions, since we don't have one standard yet in this project.
I found it's not technically necessary, but 'good practice' to have different names for ID's and classes in HTML.
Plus: I will set ID-names with an underscore from now on, and classes with a dash (because for classes the dash can be used as a modifier). I was using camelCase for some ID names, because of javascript, but that's not useful for CSS.

src/open_inwoner/components/templatetags/form_tags.py Outdated Show resolved Hide resolved
src/open_inwoner/templates/pages/cases/status.html Outdated Show resolved Hide resolved
src/open_inwoner/templates/pages/cases/status.html Outdated Show resolved Hide resolved
src/open_inwoner/templates/pages/cases/status.html Outdated Show resolved Hide resolved
src/open_inwoner/templates/pages/cases/status.html Outdated Show resolved Hide resolved
behavior: 'smooth',
})
documentUpload.classList.add('upload--open')
for (let i = 0, max = getFormInfo.length; i < max; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use only variable "i" here?Why do we need "max" as well?

Copy link
Contributor

@Bartvaderkin Bartvaderkin Apr 24, 2023

Choose a reason for hiding this comment

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

My guess is to save the limit condition (because .length is a calculated property)

But for-i loops are terrible, it is much better preferred to use .forEach() on the queryselector result, something like:

getFormInfo.forEach(elem => { elem.style.display = 'none'; })

(a for-of loop would be nice but I don't know if that works with every weird JS itearble thing)

Copy link
Contributor Author

@jiromaykin jiromaykin Apr 24, 2023

Choose a reason for hiding this comment

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

Thanks @Bartvaderkin and @vaszig - I shall attempt to improve this (amongst all the other things).

@jiromaykin jiromaykin force-pushed the feature/1309-make-upload-widget-correspond-with-design branch from 77cc019 to 5f1724c Compare April 25, 2023 08:35
@jiromaykin jiromaykin marked this pull request as draft April 25, 2023 08:43
@jiromaykin jiromaykin marked this pull request as ready for review April 25, 2023 10:57
@jiromaykin jiromaykin force-pushed the feature/1309-make-upload-widget-correspond-with-design branch from 0ef4dee to 01546ec Compare April 25, 2023 12:06
@jiromaykin jiromaykin requested a review from vaszig April 25, 2023 13:01
@jiromaykin
Copy link
Contributor Author

@vaszig and @Bartvaderkin : I have rebased this one to develop so it works with the CMS.

@alextreme
Copy link
Member

Discussed, can be reviewed again by @vaszig . We might need to revisit setting the style display=none in show-file-info.js, but this can be double-checked on the testenvironment after merging

Copy link
Contributor

@vaszig vaszig left a comment

Choose a reason for hiding this comment

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

It seems really nice!I don't see any problems concerning cps headers in my local environment, so we have to make sure we don't have any on the other environments as well.

@alextreme alextreme merged commit 555b39a into develop May 1, 2023
@alextreme alextreme deleted the feature/1309-make-upload-widget-correspond-with-design branch May 1, 2023 15:32
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.

5 participants