diff --git a/app/controllers/admin/p_spec_types_controller.rb b/app/controllers/admin/p_spec_types_controller.rb new file mode 100644 index 0000000..5d3ed6b --- /dev/null +++ b/app/controllers/admin/p_spec_types_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSpecTypesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_spec_types = PSpecType.all + + @p_spec_types = sort_by_sorting(@p_spec_types, "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_types = @p_spec_types.page(page).per(per_page) + + } + end + end + + def show + @p_spec_type = PSpecType.find(params[:id]) + + end + + def new + @p_spec_type = PSpecType.new + + end + + def edit + @p_spec_type = PSpecType.find(params[:id]) + + end + + def create + @p_spec_type = PSpecType.new(params.require(:p_spec_type).permit!) + + if @p_spec_type.save + + else + render action: "new" + + end + + end + + + def update + @p_spec_type = PSpecType.find(params[:id]) + + + if @p_spec_type.update_attributes(params.require(:p_spec_type).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_spec_type = PSpecType.find(params[:id]) + @p_spec_type.destroy + + end +end diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb new file mode 100644 index 0000000..30aea9e --- /dev/null +++ b/app/models/p_spec_type.rb @@ -0,0 +1,2 @@ +class PSpecType < ApplicationRecord +end diff --git a/app/views/admin/p_spec_types/_form.html.haml b/app/views/admin/p_spec_types/_form.html.haml new file mode 100644 index 0000000..0a8acc2 --- /dev/null +++ b/app/views/admin/p_spec_types/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_spec_type], :remote => true do |f| + + .content + =f.inputs do + = f.input :type, :label => f.object.label_for(:type) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_spec_types/_p_spec_type.html.haml b/app/views/admin/p_spec_types/_p_spec_type.html.haml new file mode 100644 index 0000000..fd475e3 --- /dev/null +++ b/app/views/admin/p_spec_types/_p_spec_type.html.haml @@ -0,0 +1,16 @@ +%tr#p_spec_type_row{:id => p_spec_type.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_spec_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_spec_type_path(p_spec_type), :remote => true + = link_to i(:eye), admin_p_spec_type_path(p_spec_type), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_type} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_types/create.js.erb b/app/views/admin/p_spec_types/create.js.erb new file mode 100644 index 0000000..e9f7774 --- /dev/null +++ b/app/views/admin/p_spec_types/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_types_rows').prepend("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/destroy.js.erb b/app/views/admin/p_spec_types/destroy.js.erb new file mode 100644 index 0000000..e97e73c --- /dev/null +++ b/app/views/admin/p_spec_types/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/edit.js.erb b/app/views/admin/p_spec_types/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/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_types/index.html.haml b/app/views/admin/p_spec_types/index.html.haml new file mode 100644 index 0000000..46d02ec --- /dev/null +++ b/app/views/admin/p_spec_types/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSpecType.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_types} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_types} + + + diff --git a/app/views/admin/p_spec_types/new.js.erb b/app/views/admin/p_spec_types/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/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_types/show.html.haml b/app/views/admin/p_spec_types/show.html.haml new file mode 100644 index 0000000..6005a84 --- /dev/null +++ b/app/views/admin/p_spec_types/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_type \ No newline at end of file diff --git a/app/views/admin/p_spec_types/update.js.erb b/app/views/admin/p_spec_types/update.js.erb new file mode 100644 index 0000000..2f952cc --- /dev/null +++ b/app/views/admin/p_spec_types/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').replaceWith("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 00b564d..59c5ff0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_spec_types do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_article_serial_nums do member do diff --git a/db/migrate/20210827074532_create_p_spec_types.rb b/db/migrate/20210827074532_create_p_spec_types.rb new file mode 100644 index 0000000..ab9699c --- /dev/null +++ b/db/migrate/20210827074532_create_p_spec_types.rb @@ -0,0 +1,9 @@ +class CreatePSpecTypes < ActiveRecord::Migration[6.0] + def change + create_table :p_spec_types do |t| + t.string :type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8d9270f..2ebe559 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_26_145816) do +ActiveRecord::Schema.define(version: 2021_08_27_074532) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1978,6 +1978,12 @@ ActiveRecord::Schema.define(version: 2021_08_26_145816) do t.index ["p_fournisseur_id"], name: "index_p_ship_bills_on_p_fournisseur_id" end + create_table "p_spec_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "type" + 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_types.yml b/test/fixtures/p_spec_types.yml new file mode 100644 index 0000000..860f9b8 --- /dev/null +++ b/test/fixtures/p_spec_types.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + type: + +two: + type: diff --git a/test/models/p_spec_type_test.rb b/test/models/p_spec_type_test.rb new file mode 100644 index 0000000..97553a9 --- /dev/null +++ b/test/models/p_spec_type_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSpecTypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end