generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'calculators-constructor' of github.com:ita-social-proje…
…cts/ZeroWaste into 970-ability-upload-logo
- Loading branch information
Showing
22 changed files
with
181 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static targets = ["textarea"]; | ||
|
||
connect() { | ||
this.resize(this.element); | ||
} | ||
|
||
resize(textarea) { | ||
textarea.style.height = "auto"; | ||
textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight | ||
} | ||
|
||
input(event) { | ||
this.resize(event.target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,3 @@ | ||
<div id="calculators-edit" class="container"> | ||
<%= simple_form_for @calculator, url: { action: 'update' }, wrapper: :horizontal_form, html: { novalidate: false } do |f| %> | ||
<div class="form-group row"> | ||
<div class="my-auto col-4 has-float-label"> | ||
<%= f.input :name, class: 'form-control', required: true %> | ||
</div> | ||
<div class="my-auto col-4 has-float-label"> | ||
<%= f.input :preferable, class: 'form-control' %> | ||
</div> | ||
</div> | ||
|
||
<h4 class="mt-5"><%= t('.add_new_field_label') %></h4> | ||
|
||
<div class="form-group row"> | ||
<div class="col-6"> | ||
<%= select_tag :kind, | ||
options_from_collection_for_select(Field.kinds.keys, :itself, :capitalize), | ||
id: 'calculator_fields_kind', | ||
prompt: t('.form.select_field_kind_label'), | ||
class: 'custom-select', | ||
data: { 'fields-list' => { form: [NamedValue.name, Select.name], | ||
parameter: [Value.name, RangeField.name, Select.name, Calculation.name], | ||
result: [Calculation.name] } } %> | ||
</div> | ||
<div class="col-4"> | ||
<%= select_tag :type, '', id: 'calculator_fields_type', | ||
prompt: t('.form.select_field_type_label'), | ||
class: 'custom-select', | ||
disabled: true %> | ||
</div> | ||
<div class="col-2"> | ||
<%= link_to t('buttons.create'), '#', | ||
class: 'btn btn-success text-white disabled', | ||
id: 'add-calculator-field', | ||
data: { url: new_account_calculator_field_path(calculator_slug: @calculator) } %> | ||
</div> | ||
</div> | ||
|
||
<div class="my-5"> | ||
<h4 class="mb-2"><%= t('.form.form_label') %></h4> | ||
<div class="form-group row" data-kind='form' data-selector-letter='F' data-last-selector='<%= extract_max_selector(@form_fields) %>'> | ||
<% if @form_fields.any? %> | ||
<%= f.fields_for :fields, @form_fields do |ff| %> | ||
<%= render 'account/calculators/fields/form', f: ff %> | ||
<% end %> | ||
<% else %> | ||
<p class="my-3 ms-3 text-black-50" data-empty-text=true><%= t('.form.no_fields_yet_label') %></p> | ||
<% end %> | ||
</div> | ||
|
||
<h4 class="mb-2"><%= t('.form.parameters_label') %></h4> | ||
<div class="form-group row" data-kind='parameter' data-selector-letter='P' data-last-selector='<%= extract_max_selector(@parameter_fields) %>'> | ||
<% if @parameter_fields.any? %> | ||
<%= f.fields_for :fields, @parameter_fields do |ff| %> | ||
<%= render 'account/calculators/fields/form', f: ff %> | ||
<% end %> | ||
<% else %> | ||
<p class="my-3 ms-3 text-black-50" data-empty-text=true><%= t('.form.no_fields_yet_label') %></p> | ||
<% end %> | ||
</div> | ||
|
||
<h4 class="mb-2"><%= t('.form.results_label') %></h4> | ||
<div class="form-group row" data-kind='result' data-selector-letter='R' data-last-selector='<%= extract_max_selector(@result_fields) %>'> | ||
<% if @result_fields.any? %> | ||
<%= f.fields_for :fields, @result_fields do |ff| %> | ||
<%= render 'account/calculators/fields/form', f: ff %> | ||
<% end %> | ||
<% else %> | ||
<p class="my-3 ms-3 text-black-50" data-empty-text=true><%= t('.form.no_fields_yet_label') %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="my-4 row"> | ||
<div class="col-12 d-flex justify-content-end button-group"> | ||
<%= f.button :submit, t('.form.update_calculator_button'), class: 'btn btn-green me-2' %> | ||
<%= link_to account_calculators_path, class: 'btn btn-danger d-flex align-items-center justify-content-center' do %> | ||
<span class="me-1"><%= t('buttons.cancel') %></span> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<div class="container"> | ||
<%= render "account/calculators/partials/form", calculator: @calculator %> | ||
</div> |
6 changes: 6 additions & 0 deletions
6
app/views/account/calculators/partials/_color_selector.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="nested-fields"> | ||
<%= f.input :color, as: :color, label: 'Choose a Color for Calculator Page:', | ||
input_html: { | ||
class: 'color-input', | ||
} %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
app/views/shared/under_construction.html.erb → ...views/shared/_under_construction.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<section class="under-construction"> | ||
<div class="under-construction__wrapper"> | ||
<div class="under-construction__content"> | ||
<h1 class="under-construction__title"><%= t('.title') %></h1> | ||
<p class="under-construction__text"><%= t('.text') %></p> | ||
<p class="under-construction__text"><%= t('.text_update') %></p> | ||
</div> | ||
<div class="under-construction__img-box"> | ||
<%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %> | ||
</div> | ||
</div> | ||
</section> | ||
<section class="under-construction"> | ||
<div class="under-construction__wrapper"> | ||
<div class="under-construction__content"> | ||
<h1 class="under-construction__title"><%= t('.title') %></h1> | ||
<p class="under-construction__text"><%= t('.text') %></p> | ||
<p class="under-construction__text"><%= t('.text_update') %></p> | ||
</div> | ||
<div class="under-construction__img-box"> | ||
<%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %> | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddColorToCalculators < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :calculators, :color, :string, default: "#8fba3b" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.