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

Restore from/to date filter and overlap alert #249

Open
jpmckinney opened this issue Sep 28, 2022 · 1 comment
Open

Restore from/to date filter and overlap alert #249

jpmckinney opened this issue Sep 28, 2022 · 1 comment
Assignees
Milestone

Comments

@jpmckinney
Copy link
Member

Old snippets from Vue code:

    if (this.dateFrom && this.dateTo) {
        if (date_from.isSameOrBefore(filterTo) && date_to.isSameOrAfter(filterFrom)) {
            var isFromIn = date_from.isAfter(filterFrom)
            var isToIn = date_to.isBefore(filterTo)
            if (isFromIn || isToIn) {
                n.overlap_alert = true
                n.overlap_from = isFromIn ? n.active_job.date_from : this.dateFrom
                n.overlap_to = isToIn ? n.active_job.date_to : this.dateTo
            }
        } else {
            result &= false
        }
    } else if (this.dateFrom) {
        if (date_to.isBefore(filterFrom)) {
            return false
        }

        if (date_from.isAfter(filterFrom)) {
            n.overlap_alert = true
            n.overlap_from = date_from.toDate()
            n.overlap_to = n.active_job.date_to
        }
    } else if (this.dateTo) {
        if (date_from.isAfter(filterTo)) {
            return false
        }

        if (date_to.isBefore(filterTo)) {
            n.overlap_alert = true
            n.overlap_from = n.active_job.date_from
            n.overlap_to = date_to.toDate()
        }
    }
{# if collection.overlap_alert #}
            <div class="alert alert-danger" hidden>
                {# https://icons.getbootstrap.com/icons/calendar-x/ #}
                <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="bi bi-calendar-x b-icon" viewBox="0 0 16 16">
                    <path d="M6.146 7.146a.5.5 0 0 1 .708 0L8 8.293l1.146-1.147a.5.5 0 1 1 .708.708L8.707 9l1.147 1.146a.5.5 0 0 1-.708.708L8 9.707l-1.146 1.147a.5.5 0 0 1-.708-.708L7.293 9 6.146 7.854a.5.5 0 0 1 0-.708z"/>
                    <path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/>
                </svg>
                {% translate "This collection does not completely overlap with the selected date range. Date range matched: " %}
                <strong>{# collection.overlap_from|date:"M Y" #} - {# collection.overlap_to|date:"M Y" #}</strong>
            </div>
{# endif #}
            <div class="custom-control custom-radio">
                <input type="radio" value="custom" class="custom-control-input" name="date_range" id="f-custom"{% if "custom" in request.GET|getlist:"date_range" %} checked{% endif %}>
                <label class="custom-control-label" for="f-custom">
                    {% translate "Custom" %}
                </label>
            </div>
            <input type="date" name="date_from" class="small" value={{ date_from|default:"1970-01-01" }}>
            <input type="date" name="date_to" class="small" value={{ date_from|default:now }}>
            <button type="button" class="btn btn-sm btn-primary">{% translate "Go" %}</button>
        "now": now.strftime("%Y-%m-%d"),
@jpmckinney jpmckinney added the ui label Sep 28, 2022
@jpmckinney jpmckinney self-assigned this Sep 29, 2022
@jpmckinney jpmckinney added this to the Priority milestone Sep 29, 2022
@jpmckinney
Copy link
Member Author

Merging #118:

Disable selection of future dates in data range filter

Can do with a bit of JS (so that caching doesn't cause the max to be in the past) https://stackoverflow.com/questions/23671407/restrict-future-dates-in-html5-date-input

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

1 participant