generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 11
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' into textarea-formula-field
- Loading branch information
Showing
62 changed files
with
1,309 additions
and
133 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
@layer components { | ||
.main-show-container { | ||
@apply flex flex-col bg-white rounded-lg shadow-md w-full p-6 text-left mt-4; | ||
} | ||
|
||
.back-arrow { | ||
@apply rounded mb-4 px-2 flex items-center; | ||
} | ||
|
||
.calc-details { | ||
@apply flex flex-col mb-4 px-2; | ||
} | ||
|
||
.showpage-buttons { | ||
@apply flex justify-start w-full space-x-4; | ||
} | ||
|
||
.showpage-text { | ||
@apply text-slate-600 text-sm; | ||
} | ||
} |
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
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,20 @@ | ||
class Api::V1::PadCalculatorsController < ApplicationController | ||
def calculate | ||
@validation = MhcCalculatorValidator.new(params) | ||
|
||
if @validation.valid? | ||
calc_service = Calculators::PadUsageService.new( | ||
user_age: params[:user_age], | ||
menstruation_age: params[:menstruation_age], | ||
menopause_age: params[:menopause_age], | ||
average_menstruation_cycle_duration: params[:average_menstruation_cycle_duration], | ||
pads_per_cycle: params[:pads_per_cycle], | ||
pad_category: params[:pad_category] | ||
) | ||
|
||
render json: calc_service.calculate, status: :ok | ||
else | ||
render json: { errors: @validation.errors }, status: :unprocessable_entity | ||
end | ||
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
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
26 changes: 26 additions & 0 deletions
26
app/javascript/controllers/constructors_form_indexing_controller.js
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,26 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="constructors-form-indexing" | ||
export default class extends Controller { | ||
static targets = ["index"]; | ||
|
||
afterInsert(event) { | ||
const fieldsets = this.element.querySelectorAll(":scope > .nested-fields"); | ||
const span = fieldsets[fieldsets.length - 1].querySelector("[data-constructors-form-indexing-target='index']") | ||
|
||
if (span) { | ||
span.textContent = `${fieldsets.length}`; | ||
} | ||
} | ||
|
||
afterRemove(event) { | ||
const fieldsets = this.element.querySelectorAll(":scope > .nested-fields"); | ||
|
||
fieldsets.forEach((fieldset, index) => { | ||
const span = fieldset.querySelector("[data-constructors-form-indexing-target='index']"); | ||
if (span) { | ||
span.textContent = `${index + 1}`; | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.