diff --git a/app/controllers/admin/p_spec_values_controller.rb b/app/controllers/admin/p_spec_values_controller.rb new file mode 100644 index 0000000..2dfd736 --- /dev/null +++ b/app/controllers/admin/p_spec_values_controller.rb @@ -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 diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb new file mode 100644 index 0000000..17c7684 --- /dev/null +++ b/app/models/p_spec_value.rb @@ -0,0 +1,2 @@ +class PSpecValue < ApplicationRecord +end diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml new file mode 100644 index 0000000..6d0339f --- /dev/null +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -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" + \ No newline at end of file diff --git a/app/views/admin/p_spec_values/_p_spec_value.html.haml b/app/views/admin/p_spec_values/_p_spec_value.html.haml new file mode 100644 index 0000000..64de749 --- /dev/null +++ b/app/views/admin/p_spec_values/_p_spec_value.html.haml @@ -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} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_values/create.js.erb b/app/views/admin/p_spec_values/create.js.erb new file mode 100644 index 0000000..8aef8dd --- /dev/null +++ b/app/views/admin/p_spec_values/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_values_rows').prepend("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/destroy.js.erb b/app/views/admin/p_spec_values/destroy.js.erb new file mode 100644 index 0000000..643c933 --- /dev/null +++ b/app/views/admin/p_spec_values/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/edit.js.erb b/app/views/admin/p_spec_values/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/index.html.haml b/app/views/admin/p_spec_values/index.html.haml new file mode 100644 index 0000000..8f34bd1 --- /dev/null +++ b/app/views/admin/p_spec_values/index.html.haml @@ -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} + + + diff --git a/app/views/admin/p_spec_values/new.js.erb b/app/views/admin/p_spec_values/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/show.html.haml b/app/views/admin/p_spec_values/show.html.haml new file mode 100644 index 0000000..6414fbc --- /dev/null +++ b/app/views/admin/p_spec_values/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_value \ No newline at end of file diff --git a/app/views/admin/p_spec_values/update.js.erb b/app/views/admin/p_spec_values/update.js.erb new file mode 100644 index 0000000..b7e6986 --- /dev/null +++ b/app/views/admin/p_spec_values/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').replaceWith("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 59c5ff0..b1d1e69 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_spec_values do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_spec_types do member do diff --git a/db/migrate/20210827074615_create_p_spec_values.rb b/db/migrate/20210827074615_create_p_spec_values.rb new file mode 100644 index 0000000..442275a --- /dev/null +++ b/db/migrate/20210827074615_create_p_spec_values.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 2ebe559..a09865a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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| t.string "name" @@ -1984,6 +1984,13 @@ ActiveRecord::Schema.define(version: 2021_08_27_074532) do t.datetime "updated_at", precision: 6, null: false 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| t.datetime "ok_at" t.boolean "enabled", default: false diff --git a/test/fixtures/p_spec_values.yml b/test/fixtures/p_spec_values.yml new file mode 100644 index 0000000..b54b2ea --- /dev/null +++ b/test/fixtures/p_spec_values.yml @@ -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 diff --git a/test/models/p_spec_value_test.rb b/test/models/p_spec_value_test.rb new file mode 100644 index 0000000..021bdc7 --- /dev/null +++ b/test/models/p_spec_value_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSpecValueTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end