generate p_grade

This commit is contained in:
Barnabé 2021-08-27 18:43:38 +02:00
parent 7c0bfc9ae4
commit bea1f58564
16 changed files with 180 additions and 1 deletions

View File

@ -0,0 +1,76 @@
# -*- encoding : utf-8 -*-
class Admin::PGradesController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@p_grades = PGrade.all
@p_grades = sort_by_sorting(@p_grades, "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_grades = @p_grades.page(page).per(per_page)
}
end
end
def show
@p_grade = PGrade.find(params[:id])
end
def new
@p_grade = PGrade.new
end
def edit
@p_grade = PGrade.find(params[:id])
end
def create
@p_grade = PGrade.new(params.require(:p_grade).permit!)
if @p_grade.save
else
render action: "new"
end
end
def update
@p_grade = PGrade.find(params[:id])
if @p_grade.update_attributes(params.require(:p_grade).permit!)
else
render action: "edit"
end
end
def destroy
@p_grade = PGrade.find(params[:id])
@p_grade.destroy
end
end

2
app/models/p_grade.rb Normal file
View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
$('#p_grade_row_<%= @p_grade.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_grade_path(), :class => "btn btn-primary btn-ap-add", :remote => true
%h1
=PGrade.human rescue ""
.qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_grades}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_grades}

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_grade

View File

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

View File

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

View File

@ -0,0 +1,9 @@
class CreatePGrades < ActiveRecord::Migration[6.0]
def change
create_table :p_grades do |t|
t.string :grade
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.
ActiveRecord::Schema.define(version: 2021_08_27_082814) do
ActiveRecord::Schema.define(version: 2021_08_27_164230) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
@ -1462,6 +1462,12 @@ ActiveRecord::Schema.define(version: 2021_08_27_082814) do
t.datetime "updated_at", precision: 6, null: false
end
create_table "p_grades", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "grade"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "p_nutris", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name"
t.boolean "public", default: true

7
test/fixtures/p_grades.yml vendored Normal file
View File

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

View File

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