view / analysis.html.haml
.container
.calculator
.calculator__display
%input#calculate{ type: 'text', value: "#{@cpp}", disabled: true }/
.calculator__keys
%input{ onclick: 'nine()', type: 'button', value: '9' }/
%input{ onclick: 'eight()', type: 'button', value: '8' }/
.dropdown.position-right
%button.btn.none-focus
= '='
.dropdown-content
= link_to user_calculations_path(operation_type: "=", calculate_piece_price: @cpp),
method: :post,
class: 'button btn btn-info' do
= t('view.btn.calculation')
assets / javascipts / application.js
function nine(){
var calculate = document.getElementById("calculate");
if (calculate.value == "0") {
calculate.value = "9" ;
}
else {
calculate.value = calculate.value + "9";
}
}
function eight(){
var calculate = document.getElementById("calculate");
if (calculate.value == "0") {
calculate.value = "8" ;
}
else {
calculate.value = calculate.value + "8";
}
}
controller / computing_controller.rb
def calculation_piece_payment
@cpp = Calculation.quantity.to_s
end