generate p_spec_value

This commit is contained in:
Barnabé 2021-08-27 09:46:35 +02:00
parent dfdd443998
commit 374c92b9a4
16 changed files with 185 additions and 1 deletions

View File

@ -0,0 +1,76 @@
# -*- encoding : utf-8 -*-
class Admin::PSpecValuesController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@p_spec_values = PSpecValue.all
@p_spec_values = sort_by_sorting(@p_spec_values, "id DESC")
respond_to do |format|
format.html{
params[:search][:per_page] = params[:search][:per_page] || 100
per_page = params[:search][:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@p_spec_values = @p_spec_values.page(page).per(per_page)
}
end
end
def show
@p_spec_value = PSpecValue.find(params[:id])
end
def new
@p_spec_value = PSpecValue.new
end
def edit
@p_spec_value = PSpecValue.find(params[:id])
end
def create
@p_spec_value = PSpecValue.new(params.require(:p_spec_value).permit!)
if @p_spec_value.save
else
render action: "new"
end
end
def update
@p_spec_value = PSpecValue.find(params[:id])
if @p_spec_value.update_attributes(params.require(:p_spec_value).permit!)
else
render action: "edit"
end
end
def destroy
@p_spec_value = PSpecValue.find(params[:id])
@p_spec_value.destroy
end
end

View File

@ -0,0 +1,2 @@
class PSpecValue < ApplicationRecord
end

View File

@ -0,0 +1,13 @@
=semantic_form_for [:admin, @p_spec_value], :remote => true do |f|
.content
=f.inputs do
= f.input :value, :label => f.object.label_for(:value)
= f.input :unit, :label => f.object.label_for(:unit)
.actions=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,16 @@
%tr#p_spec_value_row{:id => p_spec_value.id}
-tr = {}
-tr[:actions] = capture do
%td.actions
= link_to i(:"trash-o"), [:admin, p_spec_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_p_spec_value_path(p_spec_value), :remote => true
= link_to i(:eye), admin_p_spec_value_path(p_spec_value), :remote => true
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_value}

View File

@ -0,0 +1,2 @@
$('#p_spec_values_rows').prepend("<%= escape_javascript(render(@p_spec_value))%>");
close_pane_hover();

View File

@ -0,0 +1 @@
$('#p_spec_value_row_<%= @p_spec_value.id %>').remove();

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,16 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PSpecValue.human rescue ""
.qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_values}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_values}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,10 @@
.qi_header
%h1
%span
.qi_row
.qi_pannel.qi_plain.padding
=debug @p_spec_value

View File

@ -0,0 +1,2 @@
$('#p_spec_value_row_<%= @p_spec_value.id %>').replaceWith("<%= escape_javascript(render(@p_spec_value))%>");
close_pane_hover();

View File

@ -1,5 +1,16 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :admin do
resources :p_spec_values do
member do
end
collection do
end
end
end
namespace :admin do namespace :admin do
resources :p_spec_types do resources :p_spec_types do
member do member do

View File

@ -0,0 +1,10 @@
class CreatePSpecValues < ActiveRecord::Migration[6.0]
def change
create_table :p_spec_values do |t|
t.string :value
t.string :unit
t.timestamps
end
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_08_27_074532) do ActiveRecord::Schema.define(version: 2021_08_27_074615) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name" t.string "name"
@ -1984,6 +1984,13 @@ ActiveRecord::Schema.define(version: 2021_08_27_074532) do
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "p_spec_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "value"
t.string "unit"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.datetime "ok_at" t.datetime "ok_at"
t.boolean "enabled", default: false t.boolean "enabled", default: false

9
test/fixtures/p_spec_values.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
value: MyString
unit: MyString
two:
value: MyString
unit: MyString

View File

@ -0,0 +1,7 @@
require 'test_helper'
class PSpecValueTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end