diff --git a/app/javascript/application.js b/app/javascript/application.js index 20ab4186f..a29842d45 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -10,6 +10,7 @@ import ToggleCookies from './elements/toggle_cookies' import DisableHidden from './elements/disable_hidden' import TurboModal from './elements/turbo_modal' import NativeAction from './elements/native_action' +import NativeSearch from './elements/native_search' import FileDropzone from './elements/file_dropzone' import MenuActive from './elements/menu_active' import ClipboardCopy from './elements/clipboard_copy' @@ -108,6 +109,7 @@ safeRegisterElement('toggle-visible', ToggleVisible) safeRegisterElement('disable-hidden', DisableHidden) safeRegisterElement('turbo-modal', TurboModal) safeRegisterElement('native-action', NativeAction) +safeRegisterElement('native-search', NativeSearch) safeRegisterElement('file-dropzone', FileDropzone) safeRegisterElement('menu-active', MenuActive) safeRegisterElement('clipboard-copy', ClipboardCopy) diff --git a/app/javascript/elements/native_search.js b/app/javascript/elements/native_search.js new file mode 100644 index 000000000..ecff58ebd --- /dev/null +++ b/app/javascript/elements/native_search.js @@ -0,0 +1,27 @@ +import { target, targetable } from '@github/catalyst/lib/targetable' + +export default targetable(class extends HTMLElement { + static [target.static] = ['form'] + + connectedCallback () { + const bridge = window.webkit?.messageHandlers?.native + + if (!bridge || !this.form) return + + const url = new URL(this.form.action) + + new FormData(this.form).forEach((value, key) => { + if (key !== 'q' && value) url.searchParams.set(key, value) + }) + + this.declared = true + + bridge.postMessage({ type: 'search', op: 'add', url: url.pathname + url.search }) + } + + disconnectedCallback () { + if (this.declared) { + window.webkit?.messageHandlers?.native?.postMessage({ type: 'search', op: 'remove' }) + } + } +}) diff --git a/app/views/shared/_search_input.html.erb b/app/views/shared/_search_input.html.erb index 839cad9ee..501d6eea6 100644 --- a/app/views/shared/_search_input.html.erb +++ b/app/views/shared/_search_input.html.erb @@ -1,28 +1,30 @@ -
- <% Submissions::Filter::ALLOWED_PARAMS.each do |key| %> - <% if params[key].present? %> - + + + <% Submissions::Filter::ALLOWED_PARAMS.each do |key| %> + <% if params[key].present? %> + + <% end %> <% end %> - <% end %> - <% if params[:archived].present? %> - - <% end %> - <% if params[:q].present? %> - - <% end %> - - - - - + <% if params[:archived].present? %> + + <% end %> + <% if params[:q].present? %> + + <% end %> + + + + + +
diff --git a/app/views/submissions_archived/index.html.erb b/app/views/submissions_archived/index.html.erb index 4b478f56a..15ed65dde 100644 --- a/app/views/submissions_archived/index.html.erb +++ b/app/views/submissions_archived/index.html.erb @@ -8,19 +8,19 @@ <% end %> <% end %> -
- <% unless turbo_native_app? %> -
-
-

<%= t('submissions') %> <%= t('archived') %>

-
-
- <% if params[:q].present? || @pagy.pages > 1 || filter_params.present? %> - <%= render 'shared/search_input', placeholder: "#{t('search')}..." %> - <% end %> -
+
+
+ <% unless turbo_native_app? %> +
+

<%= t('submissions') %> <%= t('archived') %>

- <% end %> + <% end %> +
+ <% if params[:q].present? || @pagy.pages > 1 || filter_params.present? %> + <%= render 'shared/search_input', placeholder: "#{t('search')}..." %> + <% end %> +
+
<%= render 'submissions_filters/applied_filters', filter_params:, with_status: true, with_default_status: true %> <%= render 'submissions_filters/filter_button', filter_params: %> diff --git a/app/views/submissions_dashboard/index.html.erb b/app/views/submissions_dashboard/index.html.erb index 48620ba35..803261792 100644 --- a/app/views/submissions_dashboard/index.html.erb +++ b/app/views/submissions_dashboard/index.html.erb @@ -1,21 +1,22 @@ <% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %> <% is_show_tabs = (@pagy.count.nil? || @pagy.count >= 5) || params[:status].present? || filter_params.present? %> <% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %> -<% unless turbo_native_app? %> -
-
-
- <%= render 'dashboard/toggle_view', selected: 'submissions' %> +
+ <% unless turbo_native_app? %> +
+
+ <%= render 'dashboard/toggle_view', selected: 'submissions' %> +
+

+ <%= t('submissions') %> +

-

- <%= t('submissions') %> -

-
+ <% end %>
<% if params[:q].present? || @pagy.pages > 1 || filter_params.present? %> <%= render 'shared/search_input' %> <% end %> - <% if can?(:create, ::Template) %> + <% if can?(:create, ::Template) && !turbo_native_app? %> @@ -28,7 +29,6 @@ <% end %>
-<% end %> <% view_archived_html = capture do %> <% if can?(:manage, :countless) || current_account.submissions.archived.exists? || current_account.templates.where(Submission.where(Submission.arel_table[:template_id].eq(::Template.arel_table[:id])).arel.exists).archived.exists? %>
diff --git a/app/views/template_folders/show.html.erb b/app/views/template_folders/show.html.erb index cb89a887b..2ec96542e 100644 --- a/app/views/template_folders/show.html.erb +++ b/app/views/template_folders/show.html.erb @@ -14,30 +14,31 @@ <% end %> - <% unless turbo_native_app? %> -
- <%= render 'templates/dashboard_dropzone', style: 'height: 137px' %> - <% unless @template_folder.parent_folder %> - <%= render 'templates/dashboard_folder_dropzone', style: 'height: 137px' %> - <% end %> -

- <%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %> - - <%= @template_folder.name %> - - <% if can?(:update, @template_folder) && @template_folder.full_name != TemplateFolder::DEFAULT_NAME %> - - - <%= svg_icon('pencil', class: 'w-7 h-7') %> - - +
+ <% unless turbo_native_app? %> + <%= render 'templates/dashboard_dropzone', style: 'height: 137px' %> + <% unless @template_folder.parent_folder %> + <%= render 'templates/dashboard_folder_dropzone', style: 'height: 137px' %> <% end %> -

+

+ <%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %> + + <%= @template_folder.name %> + + <% if can?(:update, @template_folder) && @template_folder.full_name != TemplateFolder::DEFAULT_NAME %> + + + <%= svg_icon('pencil', class: 'w-7 h-7') %> + + + <% end %> +

+ <% end %>
<% if params[:q].present? || @pagy.count.nil? || @pagy.count > 0 || @template_folders.present? %> <%= render 'shared/search_input' %> <% end %> - <% if can?(:create, ::Template) %> + <% if can?(:create, ::Template) && !turbo_native_app? %> @@ -50,7 +51,6 @@ <% end %>
- <% end %> <% if @template_folders.present? %>
<%= render partial: 'template_folders/folder', collection: @template_folders, as: :folder %> diff --git a/app/views/templates_archived/index.html.erb b/app/views/templates_archived/index.html.erb index d7ad963f1..98702cf2f 100644 --- a/app/views/templates_archived/index.html.erb +++ b/app/views/templates_archived/index.html.erb @@ -7,16 +7,16 @@ <% end %>
<% end %> -<% unless turbo_native_app? %> -
+
+ <% unless turbo_native_app? %>

<%= t('document_templates_html') %> <%= t('archived') %>

- <% if params[:q].present? || @pagy.pages > 1 %> - <%= render 'shared/search_input', placeholder: "#{t('search')}..." %> - <% end %> -
-<% end %> + <% end %> + <% if params[:q].present? || @pagy.pages > 1 %> + <%= render 'shared/search_input', placeholder: "#{t('search')}..." %> + <% end %> +
<% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/template', collection: @templates, locals: { with_folder: true } %> diff --git a/app/views/templates_dashboard/index.html.erb b/app/views/templates_dashboard/index.html.erb index 2c65c1263..d11a120b0 100644 --- a/app/views/templates_dashboard/index.html.erb +++ b/app/views/templates_dashboard/index.html.erb @@ -7,27 +7,28 @@ <% end %> - <% unless turbo_native_app? %> -
- <% unless show_dropzone %> - <%= render 'templates/dashboard_dropzone', style: 'height: 114px' %> - <% end %> - <%= render 'templates/dashboard_folder_dropzone', style: 'height: 114px' %> -
- <% if has_archived || @pagy.count.nil? || @pagy.count > 0 || @template_folders.present? %> -
- <%= render 'dashboard/toggle_view', selected: 'templates' %> -
+
+ <% unless turbo_native_app? %> + <% unless show_dropzone %> + <%= render 'templates/dashboard_dropzone', style: 'height: 114px' %> <% end %> -

- <%= t('document_templates_html') %> -

-
+ <%= render 'templates/dashboard_folder_dropzone', style: 'height: 114px' %> +
+ <% if has_archived || @pagy.count.nil? || @pagy.count > 0 || @template_folders.present? %> +
+ <%= render 'dashboard/toggle_view', selected: 'templates' %> +
+ <% end %> +

+ <%= t('document_templates_html') %> +

+
+ <% end %>
<% if params[:q].present? || @pagy.count.nil? || @pagy.count > 1 || @template_folders.present? %> <%= render 'shared/search_input' %> <% end %> - <% if can?(:create, ::Template) %> + <% if can?(:create, ::Template) && !turbo_native_app? %> @@ -40,7 +41,6 @@ <% end %>
- <% end %> <% view_archived_html = capture do %> <% if has_archived %>
diff --git a/app/views/templates_shared/index.html.erb b/app/views/templates_shared/index.html.erb index aa8048e4d..b7c561f13 100644 --- a/app/views/templates_shared/index.html.erb +++ b/app/views/templates_shared/index.html.erb @@ -7,8 +7,8 @@ <% end %>
<% end %> -<% unless turbo_native_app? %> -
+
+ <% unless turbo_native_app? %>

<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %> <%= t('shared') %> @@ -16,13 +16,13 @@ <%= t('archived') %> <% end %>

-
- <% if params[:q].present? || @pagy.count.nil? || @pagy.count > 1 %> - <%= render 'shared/search_input' %> - <% end %> -
+ <% end %> +
+ <% if params[:q].present? || @pagy.count.nil? || @pagy.count > 1 %> + <%= render 'shared/search_input' %> + <% end %>
-<% end %> +
<% view_archived_html = capture do %> <% if @has_archived && params[:q].blank? %>