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

Base modal template #1440

Merged
merged 15 commits into from
Dec 13, 2017
Merged

Base modal template #1440

merged 15 commits into from
Dec 13, 2017

Conversation

mad-anne
Copy link
Contributor

@mad-anne mad-anne commented Dec 6, 2017

Add base modal template for all modals used in dashboard.

Closes #1352

Pull Request Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. The changes are tested.
  6. The code is documented (docstrings, project documentation).
  7. Python code quality checks pass: pycodestyle, pydocstyle, pylint.
  8. JavaScript code quality checks pass: eslint.

@@ -124,7 +124,7 @@ def voucher_delete(request, pk):
instance.delete()
messages.success(
request,
pgettext_lazy('Voucher message', 'Removed voucher %s') % (instance,))
pgettext_lazy('Voucher message', 'Removed voucher %s') % instance)
Copy link
Member

Choose a reason for hiding this comment

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

Please always explicitly pass either a tuple or a dict when interpolating strings with %.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll restore it.

@codecov-io
Copy link

codecov-io commented Dec 6, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@00b88e3). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1440   +/-   ##
=========================================
  Coverage          ?   83.22%           
=========================================
  Files             ?      128           
  Lines             ?     5848           
  Branches          ?      674           
=========================================
  Hits              ?     4867           
  Misses            ?      820           
  Partials          ?      161
Impacted Files Coverage Δ
saleor/dashboard/discount/urls.py 100% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00b88e3...e9aa86c. Read the comment docs.

{% block cancel_action %} {% trans "Cancel" context "Dashboard modal cancel action" %} {% endblock %}
</a>
<button type="submit" class="modal-action btn-flat">
{% block primary_action %} {% trans "Submit" context "Dashboard modal primary action" %} {% endblock %}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of this. Do we ever want to display a generic "Submit" button (or "Wyślij" when localized)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose we don't. I could omit this text and leave an empty block to force passing text value for primary action.

{% endblock %}

{% block content %}
{% trans "Are you sure?" context "Modal promote to staff member text" %}
Copy link
Member

Choose a reason for hiding this comment

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

I realize this string was already here but I feel that "Are you sure?" should really restate the thing that's about to happen. In its current state it will also look awkward when localized ("Czy na pewno?" to avoid gendered forms).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. We can display instead Are you sure you want to promote {{ customer }} to staff member? as we keep doing in confirm_delete modal templates. Referring to those templates, I would rename all of them from confirm_delete to confirm_remove or even remove to keep consistent naming of removal actions.

Copy link
Contributor

@akjanik akjanik left a comment

Choose a reason for hiding this comment

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

LGTM

{% load i18n %}

<form
role="form" method="post" action="{% block action_url %}#!{% endblock %}"
Copy link
Member

Choose a reason for hiding this comment

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

We use 2-spaces indentation in our templates.


<form
role="form" method="post" action="{% block action_url %}#!{% endblock %}"
class="{% block form_class %}form-async{% endblock %}" novalidate>
Copy link
Member

Choose a reason for hiding this comment

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

Here we define class form-async, but in some modal templates in this PR we override it with an empty block and in some other, we don't. Why is that? Is that inconsistency in how our modals work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is that when we perform remove actions we shouldn't make ajax request and go back to model details page (like form-async class treats such modals), but rather simply process form and redirect to address returned from server (usually a list).

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense but it could be documented because either we forget about it or someone else creating a new template will not know how to use it. A comment in this template would be useful.

Copy link
Contributor

@dominik-zeglen dominik-zeglen left a comment

Choose a reason for hiding this comment

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

Finally got rid of those copypase modals

@mad-anne mad-anne self-assigned this Dec 13, 2017
@maarcingebala maarcingebala merged commit a75a435 into saleor:master Dec 13, 2017
@mad-anne mad-anne deleted the base-modal branch January 8, 2018 09:02
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.

None yet

6 participants