mirror of https://github.com/docusealco/docuseal
parent
c2eb94b571
commit
b86aac86d1
@ -0,0 +1,17 @@
|
||||
export default class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
this.dateFrom = this.dataset.fromValue
|
||||
this.dateTo = this.dataset.toValue
|
||||
this.dateFromInput = document.getElementById(this.dataset.fromId)
|
||||
this.dateToInput = document.getElementById(this.dataset.toId)
|
||||
|
||||
this.button.addEventListener('click', () => {
|
||||
this.dateFromInput.value = this.dateFrom || ''
|
||||
this.dateToInput.value = this.dateTo || ''
|
||||
})
|
||||
}
|
||||
|
||||
get button () {
|
||||
return this.querySelector('button')
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 464 B |
|
After Width: | Height: | Size: 400 B |
|
After Width: | Height: | Size: 290 B |
@ -0,0 +1,94 @@
|
||||
<%= render 'shared/turbo_modal', title: t(params[:filter], default: '') do %>
|
||||
<%= form_for @template, method: :get, data: { turbo_frame: :_top }, html: { autocomplete: :off } do |f| %>
|
||||
<%= hidden_field_tag :status, params[:status] if params[:status].present? %>
|
||||
<%= hidden_field_tag :q, params[:q] if params[:q].present? %>
|
||||
<div class="space-y-2">
|
||||
<% if params[:filter] == 'author' %>
|
||||
<%= hidden_field_tag 'created_at[from]', params.dig(:created_at, :from) if params.dig(:created_at, :from).present? %>
|
||||
<%= hidden_field_tag 'created_at[to]', params.dig(:created_at, :to) if params.dig(:created_at, :to).present? %>
|
||||
<%= hidden_field_tag 'completed_at[from]', params.dig(:completed_at, :from) if params.dig(:completed_at, :from).present? %>
|
||||
<%= hidden_field_tag 'completed_at[to]', params.dig(:completed_at, :to) if params.dig(:completed_at, :to).present? %>
|
||||
<div class="form-control mt-6">
|
||||
<%= select_tag :author, options_for_select(@creator_names), required: true, class: 'base-select' %>
|
||||
</div>
|
||||
<% elsif params[:filter] == 'created_at' %>
|
||||
<%= hidden_field_tag 'author', params[:author] if params[:author].present? %>
|
||||
<%= hidden_field_tag 'completed_at[from]', params.dig(:completed_at, :from) if params.dig(:completed_at, :from).present? %>
|
||||
<%= hidden_field_tag 'completed_at[to]', params.dig(:completed_at, :to) if params.dig(:completed_at, :to).present? %>
|
||||
<div class="flex flex-col md:flex-row gap-2">
|
||||
<div class="form-control w-full">
|
||||
<%= label_tag 'created_at[from]', t('from'), for: 'date_from', class: 'label text-sm' %>
|
||||
<%= date_field_tag 'created_at[from]', params.dig(:created_at, :from), id: 'date_from', class: 'base-input !select-sm !h-10"', autocomplete: 'off' %>
|
||||
</div>
|
||||
<div class="form-control w-full">
|
||||
<%= label_tag 'created_at[to]', t('to'), for: 'date_to', class: 'label text-sm' %>
|
||||
<%= date_field_tag 'created_at[to]', params.dig(:created_at, :to), id: 'date_to', class: 'base-input !select-sm !h-10"', autocomplete: 'off' %>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif params[:filter] == 'completed_at' %>
|
||||
<%= hidden_field_tag 'author', params[:author] if params[:author].present? %>
|
||||
<%= hidden_field_tag 'created_at[from]', params.dig(:created_at, :from) if params.dig(:created_at, :from).present? %>
|
||||
<%= hidden_field_tag 'created_at[to]', params.dig(:created_at, :to) if params.dig(:created_at, :to).present? %>
|
||||
<div class="flex flex-col md:flex-row gap-2">
|
||||
<div class="form-control w-full">
|
||||
<%= label_tag 'completed_at[from]', t('from'), for: 'date_from', class: 'label text-sm' %>
|
||||
<%= date_field_tag 'completed_at[from]', params.dig(:completed_at, :from), id: 'date_from', class: 'base-input !select-sm !h-10"', autocomplete: 'off' %>
|
||||
</div>
|
||||
<div class="form-control w-full">
|
||||
<%= label_tag 'completed_at[to]', t('to'), for: 'date_to', class: 'label text-sm' %>
|
||||
<%= date_field_tag 'completed_at[to]', params.dig(:completed_at, :to), id: 'date_to', class: 'base-input !select-sm !h-10"', autocomplete: 'off' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if %w[created_at completed_at].include?(params[:filter]) %>
|
||||
<% current_time = Time.current.in_time_zone(current_account.timezone) %>
|
||||
<div class="flex flex-wrap gap-2 mt-4 md:mt-2">
|
||||
<set-date-button data-from-value="<%= current_time.to_date %>" data-to-value="<%= current_time.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('today') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
<set-date-button data-from-value="<%= current_time.beginning_of_week.to_date %>" data-to-value="<%= current_time.end_of_week.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('this_week') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
<set-date-button data-from-value="<%= (current_time - 1.week).beginning_of_week.to_date %>" data-to-value="<%= (current_time - 1.week).end_of_week.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('last_week') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
<set-date-button data-from-value="<%= current_time.beginning_of_month.to_date %>" data-to-value="<%= current_time.end_of_month.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('this_month') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
<set-date-button data-from-value="<%= (current_time - 1.month).beginning_of_month.to_date %>" data-to-value="<%= (current_time - 1.month).end_of_month.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('last_month') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
<set-date-button data-from-value="<%= current_time.beginning_of_year.to_date %>" data-to-value="<%= current_time.end_of_year.to_date %>" data-from-id="date_from" data-to-id="date_to">
|
||||
<button class="btn btn-xs btn-primary normal-case" data-turbo="false" type="button">
|
||||
<%= svg_icon 'calendar', class: 'w-4 h-4 shrink-0' %>
|
||||
<%= t('this_year') %>
|
||||
</button>
|
||||
</set-date-button>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-control mt-4">
|
||||
<%= f.button button_title(title: t('apply'), disabled_with: t('applying')), name: nil, class: 'base-button' %>
|
||||
</div>
|
||||
<% if params[:filter].present? && params[params[:filter]].present? %>
|
||||
<div class="text-center w-full mt-4">
|
||||
<%= link_to t('remove_condition'), template_path(params[:id], params.to_unsafe_h.except(:id, :filter, :action, :controller, params[:filter].to_sym)), class: 'link', data: { turbo: false } %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Loading…
Reference in new issue