added sortable
This commit is contained in:
parent
24f8743ee6
commit
a86b2b8995
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
class CompanyActivitiesController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_user!
|
||||
include ApplicationHelper
|
||||
before_action :check_access
|
||||
before_action :set_company_activity, only: %i[show edit update destroy]
|
||||
|
|
@ -62,6 +62,20 @@ class CompanyActivitiesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def chg_prio
|
||||
par = params[:ord].tr('sort_', '')
|
||||
parray = par.split(',')
|
||||
temp_i = 1
|
||||
parray.each do |pa|
|
||||
exp = CompanyActivity.where(id: pa).first
|
||||
next if exp.blank?
|
||||
|
||||
exp.prio = temp_i
|
||||
exp.save
|
||||
temp_i += 1
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
|
|
|||
|
|
@ -62,6 +62,20 @@ class CompanySizesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def chg_prio
|
||||
par = params[:ord].tr('sort_', '')
|
||||
parray = par.split(',')
|
||||
temp_i = 1
|
||||
parray.each do |pa|
|
||||
exp = CompanySize.where(id: pa).first
|
||||
next if exp.blank?
|
||||
|
||||
exp.prio = temp_i
|
||||
exp.save
|
||||
temp_i += 1
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
|
|
|||
|
|
@ -62,6 +62,20 @@ class ExpensesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def chg_prio
|
||||
par = params[:ord].tr('sort_', '')
|
||||
parray = par.split(',')
|
||||
temp_i = 1
|
||||
parray.each do |pa|
|
||||
exp = Expense.where(id: pa).first
|
||||
next if exp.blank?
|
||||
|
||||
exp.prio = temp_i
|
||||
exp.save
|
||||
temp_i += 1
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
|
|
|||
|
|
@ -62,6 +62,20 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def chg_prio
|
||||
par = params[:ord].tr('sort_', '')
|
||||
parray = par.split(',')
|
||||
temp_i = 1
|
||||
parray.each do |pa|
|
||||
exp = Project.where(id: pa).first
|
||||
next if exp.blank?
|
||||
|
||||
exp.prio = temp_i
|
||||
exp.save
|
||||
temp_i += 1
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
# CompanyActivity
|
||||
class CompanyActivity < ApplicationRecord
|
||||
default_scope { order(prio: :asc) }
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
# Company Size
|
||||
class CompanySize < ApplicationRecord
|
||||
default_scope { order(prio: :asc) }
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Expanse
|
||||
class Expense < ApplicationRecord
|
||||
default_scope { order(name: :asc) }
|
||||
default_scope { order(prio: :asc) }
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
# Project
|
||||
class Project < ApplicationRecord
|
||||
default_scope { order(prio: :asc) }
|
||||
# == Constants ============================================================
|
||||
|
||||
# == Attributes ===========================================================
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@
|
|||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th>Priorytet</th>
|
||||
<th style="width: 200px">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tbody id="sortable_list">
|
||||
<% @company_activities.each do |company_activity| %>
|
||||
<tr>
|
||||
<tr id="sort_<%= company_activity.id %>">
|
||||
<td><%= company_activity.name %></td>
|
||||
<td><%= company_activity.description %></td>
|
||||
<td><%= company_activity.prio %></td>
|
||||
<td>
|
||||
<%= link_to raw('<i class="fas fa-edit"></i> Edycja'), edit_company_activity_path(company_activity), class: 'btn-sm btn-info' %>
|
||||
<%= link_to raw('<i class="fas fa-trash-can"></i> Usuń'), company_activity, class: 'btn-sm btn-danger', method: :delete, data: { confirm: 'Czy na pewno?' } %>
|
||||
|
|
@ -27,5 +29,20 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% content_for :foot_scripts do %>
|
||||
$( function() {
|
||||
$( "#sortable_list" ).sortable({
|
||||
update: function( event, ui ) {
|
||||
var str = "";
|
||||
$('#sortable_list > tr').each(function(index, tr) {
|
||||
str += tr.id + ",";
|
||||
});
|
||||
$.post( "/company_activities/chg_prio", { authenticity_token: $('meta[name="csrf-token"]').attr("content"), ord: str }, function( data ) {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
$( "tbody" ).disableSelection();
|
||||
} );
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@
|
|||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th>Priorytet</th>
|
||||
<th style="width: 200px">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tbody id="sortable_list">
|
||||
<% @company_sizes.each do |company_size| %>
|
||||
<tr>
|
||||
<tr id="sort_<%= company_size.id %>">
|
||||
<td><%= company_size.name %></td>
|
||||
<td><%= company_size.description %></td>
|
||||
<td><%= company_size.prio %></td>
|
||||
<td>
|
||||
<%= link_to raw('<i class="fas fa-edit"></i> Edycja'), edit_company_size_path(company_size), class: 'btn-sm btn-info' %>
|
||||
<%= link_to raw('<i class="fas fa-trash-can"></i> Usuń'), company_size, class: 'btn-sm btn-danger', method: :delete, data: { confirm: 'Czy na pewno?' } %>
|
||||
|
|
@ -27,5 +29,20 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% content_for :foot_scripts do %>
|
||||
$( function() {
|
||||
$( "#sortable_list" ).sortable({
|
||||
update: function( event, ui ) {
|
||||
var str = "";
|
||||
$('#sortable_list > tr').each(function(index, tr) {
|
||||
str += tr.id + ",";
|
||||
});
|
||||
$.post( "/company_sizes/chg_prio", { authenticity_token: $('meta[name="csrf-token"]').attr("content"), ord: str }, function( data ) {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
$( "tbody" ).disableSelection();
|
||||
} );
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@
|
|||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th>Priorytet</th>
|
||||
<th style="width: 200px">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tbody id="sortable_list">
|
||||
<% @expenses.each do |expense| %>
|
||||
<tr>
|
||||
<tr id="sort_<%= expense.id %>">
|
||||
<td><%= expense.name %></td>
|
||||
<td><%= expense.description %></td>
|
||||
<td><%= expense.prio %></td>
|
||||
<td>
|
||||
<%= link_to raw('<i class="fas fa-edit"></i> Edycja'), edit_expense_path(expense), class: 'btn-sm btn-info' %>
|
||||
<%= link_to raw('<i class="fas fa-trash-can"></i> Usuń'), expense, class: 'btn-sm btn-danger', method: :delete, data: { confirm: 'Czy na pewno?' } %>
|
||||
|
|
@ -27,5 +29,20 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% content_for :foot_scripts do %>
|
||||
$( function() {
|
||||
$( "#sortable_list" ).sortable({
|
||||
update: function( event, ui ) {
|
||||
var str = "";
|
||||
$('#sortable_list > tr').each(function(index, tr) {
|
||||
str += tr.id + ",";
|
||||
});
|
||||
$.post( "/expenses/chg_prio", { authenticity_token: $('meta[name="csrf-token"]').attr("content"), ord: str }, function( data ) {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
$( "tbody" ).disableSelection();
|
||||
} );
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= stylesheet_link_tag 'font_awesomeall', 'tempusdominus-bootstrap-4.min', 'select2.min', 'bootstrap-duallistbox.min', 'summernote-bs4', 'adminlte.min' %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'tinymce/tinymce.min' %>
|
||||
<%= javascript_include_tag 'tinymce/tinymce.min', 'jquery-ui.min' %>
|
||||
</head>
|
||||
|
||||
<body class="hold-transition sidebar-mini">
|
||||
|
|
@ -103,6 +103,9 @@
|
|||
|
||||
<!-- REQUIRED SCRIPTS -->
|
||||
|
||||
<%= javascript_include_tag 'jquery.min', 'bootstrap.bundle.min', 'bs-custom-file-input.min', 'moment-with-locales.min', 'select2.full.min', 'jquery.bootstrap-duallistbox.min', 'tempusdominus-bootstrap-4.min', 'summernote-bs4', 'adminlte.min', 'bootstrap-switch.min', 'forms' %>
|
||||
<%= javascript_include_tag 'jquery.min', 'bootstrap.bundle.min', 'bs-custom-file-input.min', 'moment-with-locales.min', 'select2.full.min', 'jquery.bootstrap-duallistbox.min', 'tempusdominus-bootstrap-4.min', 'summernote-bs4', 'adminlte.min', 'bootstrap-switch.min', 'forms', 'jquery-ui.min' %>
|
||||
<script type="text/javascript">
|
||||
<%= yield :foot_scripts %>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@
|
|||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th>Priorytet</th>
|
||||
<th style="width: 200px">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tbody id="sortable_list">
|
||||
<% @projects.each do |project| %>
|
||||
<tr>
|
||||
<tr id="sort_<%= project.id %>">
|
||||
<td><%= project.name %></td>
|
||||
<td><%= project.description %></td>
|
||||
<td><%= project.prio %></td>
|
||||
<td>
|
||||
<%= link_to raw('<i class="fas fa-edit"></i> Edycja'), edit_project_path(project), class: 'btn-sm btn-info' %>
|
||||
<%= link_to raw('<i class="fas fa-trash-can"></i> Usuń'), project, class: 'btn-sm btn-danger', method: :delete, data: { confirm: 'Czy na pewno?' } %>
|
||||
|
|
@ -27,5 +29,20 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% content_for :foot_scripts do %>
|
||||
$( function() {
|
||||
$( "#sortable_list" ).sortable({
|
||||
update: function( event, ui ) {
|
||||
var str = "";
|
||||
$('#sortable_list > tr').each(function(index, tr) {
|
||||
str += tr.id + ",";
|
||||
});
|
||||
$.post( "/projects/chg_prio", { authenticity_token: $('meta[name="csrf-token"]').attr("content"), ord: str }, function( data ) {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
$( "tbody" ).disableSelection();
|
||||
} );
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
# require 'mailman'
|
||||
require 'mail'
|
||||
require 'builder'
|
||||
ENV['RAILS_ENV'] ||= 'development'
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
|
||||
prio = 1
|
||||
Expense.all.each do |exp|
|
||||
exp.prio = prio
|
||||
exp.save
|
||||
prio += 1
|
||||
end
|
||||
|
||||
prio = 1
|
||||
CompanyActivity.all.each do |exp|
|
||||
exp.prio = prio
|
||||
exp.save
|
||||
prio += 1
|
||||
end
|
||||
|
||||
prio = 1
|
||||
Project.all.each do |exp|
|
||||
exp.prio = prio
|
||||
exp.save
|
||||
prio += 1
|
||||
end
|
||||
|
||||
prio = 1
|
||||
CompanySize.all.each do |exp|
|
||||
exp.prio = prio
|
||||
exp.save
|
||||
prio += 1
|
||||
end
|
||||
|
|
@ -6,6 +6,7 @@ pl:
|
|||
expense:
|
||||
name: "Nazwa"
|
||||
description: "Opis"
|
||||
prio: "Priorytet"
|
||||
errors:
|
||||
models:
|
||||
expense:
|
||||
|
|
|
|||
|
|
@ -13,10 +13,14 @@ Rails.application.routes.draw do
|
|||
post 'home/order_meeting_save'
|
||||
resources :home, only: %i[index show]
|
||||
devise_for :users
|
||||
post 'company_sizes/chg_prio'
|
||||
resources :company_sizes
|
||||
post 'expenses/chg_prio'
|
||||
resources :expenses
|
||||
resources :tags
|
||||
post 'company_activities/chg_prio'
|
||||
resources :company_activities
|
||||
post 'projects/chg_prio'
|
||||
resources :projects
|
||||
resources :partners
|
||||
resources :experts
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
class AddPrioToExpenses < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :expenses, :prio, :integer, after: :description, default: 0
|
||||
add_index :expenses, :prio
|
||||
add_column :company_activities, :prio, :integer, after: :description, default: 0
|
||||
add_index :company_activities, :prio
|
||||
add_column :projects, :prio, :integer, after: :description, default: 0
|
||||
add_index :projects, :prio
|
||||
add_column :company_sizes, :prio, :integer, after: :description, default: 0
|
||||
add_index :company_sizes, :prio
|
||||
end
|
||||
end
|
||||
10
db/schema.rb
10
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: 2022_06_15_092725) do
|
||||
ActiveRecord::Schema.define(version: 2022_06_28_085754) do
|
||||
|
||||
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
|
|
@ -36,10 +36,12 @@ ActiveRecord::Schema.define(version: 2022_06_15_092725) do
|
|||
create_table "company_activities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.integer "prio", default: 0
|
||||
t.integer "created_by"
|
||||
t.integer "updated_by"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["prio"], name: "index_company_activities_on_prio"
|
||||
end
|
||||
|
||||
create_table "company_activities_dotations", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
|
|
@ -51,10 +53,12 @@ ActiveRecord::Schema.define(version: 2022_06_15_092725) do
|
|||
create_table "company_sizes", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.integer "prio", default: 0
|
||||
t.integer "created_by"
|
||||
t.integer "updated_by"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["prio"], name: "index_company_sizes_on_prio"
|
||||
end
|
||||
|
||||
create_table "company_sizes_dotations", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
|
|
@ -164,10 +168,12 @@ ActiveRecord::Schema.define(version: 2022_06_15_092725) do
|
|||
create_table "expenses", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.integer "prio", default: 0
|
||||
t.integer "created_by"
|
||||
t.integer "updated_by"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["prio"], name: "index_expenses_on_prio"
|
||||
end
|
||||
|
||||
create_table "experts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
|
|
@ -211,10 +217,12 @@ ActiveRecord::Schema.define(version: 2022_06_15_092725) do
|
|||
create_table "projects", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.integer "prio", default: 0
|
||||
t.integer "created_by"
|
||||
t.integer "updated_by"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["prio"], name: "index_projects_on_prio"
|
||||
end
|
||||
|
||||
create_table "roles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
|
|
|
|||
Loading…
Reference in New Issue