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

3391 emphasize template select #3863

Merged
merged 9 commits into from
Oct 14, 2024
7 changes: 2 additions & 5 deletions apps/dashboard/app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ def templates
[label, project.directory, data]
end

if templates.size.positive?
templates.prepend(['', '', { 'data-description': '', 'data-icon': '' }])
else
[]
end
return templates if templates.size.positive?
return []
end

def project_params
Expand Down
110 changes: 53 additions & 57 deletions apps/dashboard/app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,69 @@
%>

<div class='card'>
<h5 class='card-header'>Project Details</h5>
<div class='card-group'>
<div class='card-header'>
<%= form.select(:template, @templates, { prompt: "--- select template ---" }, required: true, label_class: "h4")%>
</div>
<div class='card-group'>
<div class='card'>
<div class='card-body'>
<div class="col">
<div class="field">
<%= form.text_field :name, placeholder: I18n.t('dashboard.jobs_project_name_placeholder'),
help: I18n.t('dashboard.jobs_project_name_validation') %>
</div>

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

<button type="button" class="btn btn-primary mt-2" data-bs-toggle="modal" data-bs-target="#<%= path_selector_id %>">
Select Path
</button>
<div class="field">
<%= form.text_field(:directory, placeholder: I18n.t('dashboard.jobs_project_directory_placeholder'),
readonly: edit_project_action,
required: false,
help: edit_project_action ? '' : I18n.t('dashboard.jobs_project_directory_help_html', root_directory: Project.dataroot.to_s).html_safe,
data: { 'path-selector': true })%>

<%= render(partial: 'shared/path_selector_table', locals: path_selector_locals ) %>
</div>
<button type="button" class="btn btn-primary mt-2" data-bs-toggle="modal" data-bs-target="#<%= path_selector_id %>">
Select Path
</button>

<div class="field">
<%= form.text_area :description, placeholder: I18n.t('dashboard.jobs_project_description_placeholder') %>
</div>
<%= render(partial: 'shared/path_selector_table', locals: path_selector_locals ) %>
</div>

<%- unless @templates.to_a.empty? -%>
<div class="field">
<%= form.select(:template, @templates) %>
<div class="field">
<%= form.text_area :description, placeholder: I18n.t('dashboard.jobs_project_description_placeholder') %>
</div>
</div>
<%- end -%>
</div>
</div>
</div>
<div class="card">
<div class='card-body'>
<div class="col">
<div class="field">
<%= javascript_include_tag 'icon_picker', nonce: true %>
<%= form.text_field :icon, placeholder: "cog", id: "product_icon_select", value: @project.icon_class %>
<% if @project.icon =~ /(fa[bsrl]?):\/\/(.*)/ %>
<% icon = $2; style = $1 %>
<p class="text-center">
<%= fa_icon(icon, fa_style: style, id: "product_icon") %>
</p>
<% else %>
<p class="text-center">
<%= fa_icon("cog", fa_style: "fas", id: "product_icon") %>
</p>
<% end %>
<ul id="icon_picker_list">
</ul>
</div>
<div class="card">
<div class='card-body'>
<div class="col">
<div class="field">
<%= javascript_include_tag 'icon_picker', nonce: true %>
<%= form.text_field :icon, placeholder: "cog", id: "product_icon_select", value: @project.icon_class %>
<% if @project.icon =~ /(fa[bsrl]?):\/\/(.*)/ %>
<% icon = $2; style = $1 %>
<p class="text-center">
<%= fa_icon(icon, fa_style: style, id: "product_icon") %>
</p>
<% else %>
<p class="text-center">
<%= fa_icon("cog", fa_style: "fas", id: "product_icon") %>
</p>
<% end %>
<ul id="icon_picker_list">
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<p>
<%= form.submit 'Save', class: 'btn btn-primary', title: 'Save project' %>
<%= form.button 'Reset', type: :reset, class: 'btn btn-default',
title: 'Clear form fields' %>
<%= link_to 'Back', projects_path, class: 'btn btn-default',
title: 'Return to projects page' %>
</p>
<br>
<p>
<%= form.submit 'Save', class: 'btn btn-primary', title: 'Save project', id: 'submit_form_button' %>
<%= form.button 'Reset', type: :reset, class: 'btn btn-default', id: 'reset_button',
title: 'Clear form fields' %>
<%= link_to 'Back', projects_path, class: 'btn btn-default',
title: 'Return to projects page' %>
</p>
</div>

Loading