-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Datatables gem, yarn package and CSS file - Add code in packs.admin.js - Add Datatables partial and inheritable logic (mountain_view seems unhappy with ajax in webpacker) - Update controller logic and do some optimisation - Migrate Users, Neighbourhoods and Partners indexes to Datatables - Update Neighbourhood edit page to reflect new logic - Update webpack-dev-server, yarn versions, and CI build target - Update README Bonus: Fixes #806, #868, #861, #821 Co-authored-by: Dr Kim Foale <[email protected]>
- Loading branch information
1 parent
6bfda4b
commit 0bb508c
Showing
35 changed files
with
1,376 additions
and
947 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,27 @@ To get an idea of the project and what we're about, check out [the handbook](htt | |
|
||
With that said, here's what you need to get rolling. | ||
|
||
* postgresql, Ruby as specified in `.ruby-version`, and the Bundler gem to install rails 5 etc from the Gemfile | ||
* `bundle exec rails db:setup db:migrate seed:migrate` | ||
* `bundle exec rails import:all_events` | ||
``` | ||
git clone https://github.com/geeksforsocialchange/PlaceCal.git | ||
bundle && yarn | ||
bundle exec rails db:setup db:migrate seed:migrate` | ||
bundle exec rails import:all_events | ||
bundle exec rails server | ||
``` | ||
|
||
* Make sure you use `lvh.me:3000` instead of `localhost` or you might have authentication problems. | ||
* Admin interface is `admin.lvh.me:3000` | ||
* Seeded root user is [email protected] / password | ||
* Access code docs through your local filesystem, and update with `bundle exec rails yard` | ||
|
||
To set up your own server, take a look at `INSTALL.md`. | ||
|
||
## Roadmap | ||
## Contributing | ||
|
||
We welcome new contributors but strongly recommend you have a chat with us in [Geeks for Social Change's Discord server](http://discord.gfsc.studio) and say hi before you do. We will be happy to onboard you properly before you get stuck in. | ||
|
||
## Donations | ||
|
||
If you'd like to support development, please consider sending us a one-off or regular donation on Ko-fi. | ||
|
||
See the current [Roadmap](developers/roadmap.md) | ||
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/M4M43THUM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Datatable < AjaxDatatablesRails::ActiveRecord | ||
extend Forwardable | ||
|
||
def_delegator :@view, :link_to | ||
def_delegator :@view, :edit_admin_neighbourhood_path | ||
def_delegator :@view, :edit_admin_user_path | ||
def_delegator :@view, :edit_admin_partner_path | ||
|
||
def initialize(params, opts = {}) | ||
@view = opts[:view_context] | ||
super | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class NeighbourhoodDatatable < Datatable | ||
def view_columns | ||
# Declare strings in this format: ModelName.column_name | ||
# or in aliased_join_table.column_name format | ||
@view_columns ||= { | ||
id: { source: 'Neighbourhood.id', cond: :eq }, | ||
name: { source: 'Neighbourhood.name' }, | ||
unit_name: { source: 'Neighbourhood.unit_name' }, | ||
unit_code_key: { source: 'Neighbourhood.unit_code_key' }, | ||
unit_code_value: { source: 'Neighbourhood.unit_code_value' }, | ||
} | ||
end | ||
|
||
def data | ||
records.map do |record| | ||
{ | ||
id: link_to(record.id, edit_admin_neighbourhood_path(record)), | ||
name: record.name, | ||
unit_name: record.unit_name, | ||
unit_code_key: record.unit_code_key, | ||
unit_code_value: record.unit_code_value, | ||
# county: record.county, | ||
# district: record.district, | ||
# region: record.region, | ||
# country: record.country | ||
} | ||
end | ||
end | ||
|
||
def get_raw_records | ||
# insert query here | ||
# Neighbourhood.all | ||
options[:neighbourhoods] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class PartnerDatatable < Datatable | ||
def view_columns | ||
# Declare strings in this format: ModelName.column_name | ||
# or in aliased_join_table.column_name format | ||
@view_columns ||= { | ||
id: { source: 'Partner.id', cond: :eq }, | ||
name: { source: 'Partner.name' }, | ||
slug: { source: 'Partner.slug' }, | ||
address: { source: 'Partner.address'} | ||
} | ||
end | ||
|
||
def data | ||
records.map do |record| | ||
{ | ||
id: link_to(record.id, edit_admin_partner_path(record)), | ||
name: link_to(record.name, edit_admin_partner_path(record)), | ||
slug: link_to(record.slug, edit_admin_partner_path(record)), | ||
address: record.address | ||
} | ||
end | ||
end | ||
|
||
def get_raw_records | ||
# insert query here | ||
# Partner.all | ||
options[:partners] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class UserDatatable < Datatable | ||
def view_columns | ||
# Declare strings in this format: ModelName.column_name | ||
# or in aliased_join_table.column_name format | ||
@view_columns ||= { | ||
id: { source: 'User.id', cond: :eq }, | ||
first_name: { source: 'User.first_name' }, | ||
last_name: { source: 'User.last_name' }, | ||
admin_roles: { source: 'User.admin_roles' }, | ||
email: { source: 'User.email' }, | ||
} | ||
end | ||
|
||
def data | ||
records.map do |record| | ||
{ | ||
id: link_to(record.id, edit_admin_user_path(record)), | ||
first_name: link_to(record.first_name, edit_admin_user_path(record)), | ||
last_name: link_to(record.last_name, edit_admin_user_path(record)), | ||
admin_roles: record.admin_roles, | ||
email: record.email, | ||
} | ||
end | ||
end | ||
|
||
def get_raw_records | ||
# insert query here | ||
# User.all | ||
options[:users] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
require("cocoon") | ||
require("select2") | ||
require("datatables.net-bs4") | ||
|
||
import 'bootstrap' | ||
import 'vue' | ||
import 'vue-turbolinks' | ||
|
||
import '../src/behaviors/all_behaviors.js' | ||
import '../src/calendar-form.js' | ||
import '../src/datatable.js' | ||
import '../src/opening-times.js' | ||
import '../src/ward-picker.js' | ||
|
||
$(document).on('turbolinks:load', function() { | ||
|
||
$(document).on('turbolinks:load', function () { | ||
|
||
$('body').init_behaviors() | ||
|
||
$('[data-toggle="tooltip"]').tooltip() | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This makes sure Turbolinks doesn't double load the datatable code | ||
// if you press the browser back button | ||
let dataTable = "" | ||
|
||
document.addEventListener("turbolinks:before-cache", function () { | ||
if (dataTable !== null) { | ||
dataTable.destroy(); | ||
dataTable = null; | ||
} | ||
}); | ||
|
||
document.addEventListener('turbolinks:load', function () { | ||
dataTable = $('#datatable').DataTable({ | ||
"processing": true, | ||
"serverSide": true, | ||
"pageLength": 15, | ||
"ajax": { | ||
"url": $('#datatable').data('source') | ||
}, | ||
"pagingType": "full_numbers", | ||
// Column spec is loaded from a script tag in the view | ||
"columns": columns | ||
}) | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.