g qis sorecop_cats

This commit is contained in:
Barnabé 2021-09-23 18:19:47 +02:00
parent 8e7442dcc0
commit a9a5e22251
15 changed files with 173 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 @sorecop_cat

View File

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

View File

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

View File

@ -0,0 +1,9 @@
class CreateSorecopCats < ActiveRecord::Migration[6.0]
def change
create_table :sorecop_cats do |t|
t.string :name
t.timestamps
end
end
end

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

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

View File

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