Skip to content

Commit

Permalink
allow for projects#new to use the path_selector
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Apr 1, 2024
1 parent 0930be3 commit 8f15139
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/dashboard/app/javascript/projects_new.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';

import { attachPathSelectors } from './path_selector/path_selector';

jQuery(function() {
$("#project_template").on('change', (event) => templateChange(event));
attachPathSelectors();
});

function templateChange(event) {
Expand Down
28 changes: 26 additions & 2 deletions apps/dashboard/app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<%
edit_project_action = action_name != "new" && action_name != "create"

path_selector_id = "project_directory_path_selector"

path_selector_locals = {
path_selector_id: path_selector_id,
show_files: false,
show_hidden: false,
initial_directory: CurrentUser.home,
table_id: "#{path_selector_id}_table",
breadcrumb_id: "#{path_selector_id}_breadcrumb",
button_id: "#{path_selector_id}_button",
input_field_id: 'project_directory',
favorites: false
}
%>

<div class='card'>
<h5 class='card-header'>Project Details</h5>
<div class='card-group'>
Expand All @@ -13,9 +28,18 @@
</div>

<div class="field">
<%= form.text_field :directory, placeholder: I18n.t('dashboard.jobs_project_directory_placeholder'),
readonly: edit_project_action, help: edit_project_action ? '' : I18n.t('dashboard.jobs_project_directory_help_html', root_directory: Project.dataroot.to_s).html_safe %>
<%= form.text_field(:directory, placeholder: I18n.t('dashboard.jobs_project_directory_placeholder'),
readonly: edit_project_action,
help: edit_project_action ? '' : I18n.t('dashboard.jobs_project_directory_help_html', root_directory: Project.dataroot.to_s).html_safe,
data: { 'path-selector': true })%>

<button type="button" class="btn btn-primary mt-2" data-toggle="modal" data-target="#<%= path_selector_id %>">
Select Path
</button>

<%= render(partial: 'shared/path_selector_table', locals: path_selector_locals ) %>
</div>

<div class="field">
<%= form.text_area :description, placeholder: I18n.t('dashboard.jobs_project_description_placeholder') %>
</div>
Expand Down

0 comments on commit 8f15139

Please sign in to comment.