basepack 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +64 -44
- data/app/assets/javascripts/basepack/loading_spinner.coffee.erb +2 -2
- data/app/controllers/basepack/base_controller.rb +22 -1
- data/app/views/forms/_bulk_edit.html.haml +1 -1
- data/app/views/forms/_export.html.haml +18 -17
- data/app/views/forms/_import.html.haml +2 -2
- data/app/views/forms/_import_configuration_csv.html.haml +10 -7
- data/app/views/forms/_query.html.haml +8 -8
- data/app/views/forms/_show.html.haml +1 -1
- data/app/views/forms/_show_without_blanks.html.haml +1 -1
- data/app/views/forms/buttons/_apply.html.haml +1 -1
- data/app/views/forms/buttons/_bulk_delete.html.haml +3 -3
- data/app/views/forms/buttons/_create.html.haml +1 -2
- data/app/views/forms/buttons/_delete.html.haml +1 -1
- data/app/views/forms/buttons/_edit.html.haml +1 -1
- data/app/views/forms/buttons/_export.html.haml +1 -2
- data/app/views/forms/buttons/_import.html.haml +1 -1
- data/app/views/forms/buttons/_print.html.haml +1 -1
- data/app/views/forms/buttons/_query.html.haml +3 -3
- data/app/views/forms/buttons/_submit_create.html.haml +1 -1
- data/app/views/forms/edit/_form_colorpicker.html.haml +4 -4
- data/app/views/forms/edit/_form_datetime.html.haml +4 -4
- data/app/views/forms/edit/_form_enumeration.html.haml +19 -20
- data/app/views/forms/edit/_tag_list_with_suggestions.html.haml +1 -1
- data/config/basepack-settings.yml +2 -1
- data/config/locales/cs.yml +60 -5
- data/config/locales/en.yml +53 -9
- data/config/locales/kaminari.en.yml +1 -1
- data/lib/basepack.rb +1 -0
- data/lib/basepack/engine.rb +1 -0
- data/lib/basepack/forms/query.rb +1 -1
- data/lib/basepack/import/model_dragonfly.rb +2 -2
- data/lib/basepack/rails_admin/fields_types/phone.rb +61 -0
- data/lib/basepack/version.rb +1 -1
- data/lib/generators/basepack/install_generator.rb +41 -24
- data/lib/generators/basepack/templates/import.rb +4 -1
- data/lib/generators/rails/scaffold_controller_generator.rb +12 -0
- data/spec/dummy_app/app/controllers/employee_with_destroyable_nesteds_controller.rb +3 -0
- data/spec/dummy_app/app/models/employee_with_destroyable_nested.rb +6 -0
- data/spec/dummy_app/config/routes.rb +6 -2
- data/spec/dummy_app/db/development.sqlite3 +0 -0
- data/spec/dummy_app/db/migrate/20140117153133_add_phone_to_employee.rb +5 -0
- data/spec/dummy_app/db/schema.rb +2 -27
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/development.log +2907 -0
- data/spec/dummy_app/log/test.log +16850 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/6f4d8a75f9952ad791647a0c21be66d3 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/93a7167bf36c621d305a9481e3d25bce +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/a6fad88c8628b92fa21b43b1aa76cf7d +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/b8a8c2faf730407b004ec269c26473d7 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/cb1f853dc4682e46b8f6922910af7491 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/0006b869e74d698c8b4e140f70f87b90 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/2d71a2a9ba73844a029c993068e478d5 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/2f416db7ec3594c66c478e2c70dc5032 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/3202398591e97bce52539e961f5516c4 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/6659113c653e0ca831f730df1b6b0558 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/780412261881a814294a5333a4a042d2 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/7af866e59b2c1fec401995dbceaf6e72 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/8618734b87c2e32d68b15881891d9286 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/93a7167bf36c621d305a9481e3d25bce +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/9b856b2df0d8b82ecd548aebe2c5268f +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/a6fad88c8628b92fa21b43b1aa76cf7d +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/c174814b8349dc263c8f65404949e933 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/c81fa603414eab811f5a75f5be6fc7a0 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/dbc50e82415d51f2497fbc2dc1983bc2 +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/dcaf58e5c22740a96f5f349888c4cc6f +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/ed9f6df23839a0fd1983de2fcda43c5c +0 -0
- data/spec/dummy_app/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy_app/tmp/capybara/capybara-201312292242327883099760.html +127 -0
- data/spec/integration/basic/edit/basepack_basic_edit_spec.rb +58 -0
- data/spec/integration/basic/show/basepack_basic_show_spec.rb +49 -0
- metadata +58 -7
- data/lib/generators/basepack/templates/dragonfly.rb +0 -8
@@ -1,5 +1,5 @@
|
|
1
|
-
= link_to url, class: 'btn btn-danger',
|
2
|
-
:data => { :confirm => I18n.t('admin.form.confirmation'),
|
1
|
+
= link_to url, class: 'btn btn-danger',
|
2
|
+
:data => { :confirm => I18n.t('admin.form.confirmation'),
|
3
3
|
params: params, 'bulk-action-method' => 'delete'} do
|
4
4
|
%i.icon-trash
|
5
|
-
=
|
5
|
+
= Basepack::Utils.translate(resource_class, :delete_all, :menu)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
- if Basepack::Settings.filters.model_name and can?(:create, Basepack::Settings.filters.model_name.constantize)
|
6
6
|
= link_to url, class: classes, data: link_data do
|
7
7
|
%i.icon-search
|
8
|
-
|
8
|
+
= I18n.t('basepack.query.filter')
|
9
9
|
- filters = Basepack::Settings.filters.model_name.constantize.active.where(filter_type: resource_class.to_s).to_a
|
10
10
|
- if filters.present?
|
11
11
|
%button{type: "button", class: classes + ' dropdown-toggle', 'data-toggle' => "dropdown"}
|
@@ -15,11 +15,11 @@
|
|
15
15
|
%small
|
16
16
|
%a{href: polymorphic_path([:filters, association_chain, resource_class].flatten), tabindex: '-1'}
|
17
17
|
%i.icon-folder-open-alt
|
18
|
-
|
18
|
+
= I18n.t('basepack.query.filter_list')
|
19
19
|
- filters.each do |filter|
|
20
20
|
%li{class: (filter.filter == url_params['ql'] ? 'active' : '')}
|
21
21
|
%a{href: polymorphic_path([association_chain, resource_class].flatten, ql: filter.filter), tabindex: '-1'}= filter.name
|
22
22
|
- else
|
23
23
|
= link_to url, class: classes, data: link_data do
|
24
24
|
%i.icon-search
|
25
|
-
= I18n.t('
|
25
|
+
= I18n.t('basepack.query.filter')
|
@@ -1,7 +1,7 @@
|
|
1
|
-
= form.input field.method_name,
|
1
|
+
= form.input field.method_name,
|
2
2
|
as: :string,
|
3
|
-
label: field.label,
|
4
|
-
hint: field.help,
|
5
|
-
required: field.required?,
|
3
|
+
label: field.label,
|
4
|
+
hint: field.help,
|
5
|
+
required: field.required?,
|
6
6
|
input_html: field.html_attributes.reverse_merge({:style => "background-color: #{field.color}", :data => {:color => true}})
|
7
7
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
= form.input field.method_name,
|
1
|
+
= form.input field.method_name,
|
2
2
|
as: :string,
|
3
|
-
label: field.label,
|
4
|
-
hint: field.help,
|
5
|
-
required: field.required?,
|
3
|
+
label: field.label,
|
4
|
+
hint: field.help,
|
5
|
+
required: field.required?,
|
6
6
|
input_html: field.html_attributes.merge({:value => (field.value.present? ? field.value : field.html_default_value)}).reverse_merge({data: { datetimepicker: true, options: field.js_plugin_options.to_json }})
|
@@ -1,20 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
-# = form.input field.method_name, :collection => field.enum , label: field.label, hint: field.help, required: field.required?, input_html: field.html_attributes, { :selected => field.value, :object => form.object }, field.html_attributes.reverse_merge({:data => { :filteringmultiselect => true, :options => js_data.to_json }, :multiple => true})
|
1
|
+
- unless field.multiple?
|
2
|
+
= form.input field.method_name, collection: field.enum, label: field.label, hint: field.help, required: field.required?,
|
3
|
+
input_html: { data: { select: {} } }.deep_merge(field.html_attributes)
|
4
|
+
- else
|
5
|
+
:ruby
|
6
|
+
js_data = {
|
7
|
+
:xhr => false,
|
8
|
+
:sortable => false,
|
9
|
+
:cacheAll => true,
|
10
|
+
:regional => {
|
11
|
+
:chooseAll => t("admin.misc.chose_all"),
|
12
|
+
:chosen => t("admin.misc.chosen", :name => config.label_plural),
|
13
|
+
:clearAll => t("admin.misc.clear_all"),
|
14
|
+
:search => t("admin.misc.search"),
|
15
|
+
:up => t("admin.misc.up"),
|
16
|
+
:down => t("admin.misc.down")
|
17
|
+
}
|
18
|
+
}
|
19
|
+
= form.input field.method_name, :collection => field.enum , label: field.label, hint: field.help, required: field.required?, input_html: field.html_attributes.reverse_merge({:data => { :filteringmultiselect => true, :options => js_data.to_json }, :multiple => true})
|
@@ -11,5 +11,5 @@
|
|
11
11
|
}.to_json
|
12
12
|
}
|
13
13
|
|
14
|
-
= form.input field.method_name, label: "<i class='icon-tags'></i> #{field.label}", hint: field.help, required: field.required? do
|
14
|
+
= form.input field.method_name, label: "<i class='icon-tags'></i> #{h field.label}".html_safe, hint: field.help, required: field.required? do
|
15
15
|
= form.input_field field.method_name, { type: 'text', data: js_data}
|
@@ -4,7 +4,7 @@ defaults: &defaults
|
|
4
4
|
help:
|
5
5
|
title: false
|
6
6
|
export:
|
7
|
-
default_col_sep:
|
7
|
+
default_col_sep: ';'
|
8
8
|
filters:
|
9
9
|
model_name: null # for enabling saved filter set to 'Filter' model for instance
|
10
10
|
bulk_edit:
|
@@ -13,6 +13,7 @@ defaults: &defaults
|
|
13
13
|
- delete
|
14
14
|
- assign
|
15
15
|
import:
|
16
|
+
default_col_sep: ','
|
16
17
|
mime_types: [text/csv, text/plain]
|
17
18
|
model_name: Import
|
18
19
|
default_action: :import
|
data/config/locales/cs.yml
CHANGED
@@ -2,12 +2,67 @@ cs:
|
|
2
2
|
web_name: "Název projektu"
|
3
3
|
misc:
|
4
4
|
loading: "Chvíli strpení"
|
5
|
-
modify_query: "Upravit dotaz"
|
6
|
-
save_filter: "Uložit filtr"
|
7
|
-
error_filter: "Filter nelze uložiť"
|
8
|
-
enter_filter_name: "Prosím vyplňte název filtru"
|
9
5
|
|
10
|
-
|
6
|
+
basepack:
|
7
|
+
misc:
|
8
|
+
submit_create: 'Přidat'
|
9
|
+
flash:
|
10
|
+
error_on_items: "Objekt %{model_label_plural} nelze %{action}"
|
11
|
+
export:
|
12
|
+
no_exported_items: "Počet záznamů pro export"
|
13
|
+
select_all_fields: "Vybrat všechny pole"
|
14
|
+
select: "Vyberte políčka pro export"
|
15
|
+
click_to_reverse_selection: 'Klikněte pro reverzní výběr'
|
16
|
+
fields_from: "Poloíčka z %{name}"
|
17
|
+
fields_from_associated: "Políčka z přiřazeného %{name}"
|
18
|
+
options_for: "Možnosti pro %{name}"
|
19
|
+
csv:
|
20
|
+
skip_header: "Žádná hlavička"
|
21
|
+
skip_header_help: "Neexportovat hlavičku"
|
22
|
+
col_sep_help: "Nechte prázdné pro výchozí ('%{value}')"
|
23
|
+
col_sep:
|
24
|
+
label: "Oddělovač sloupců"
|
25
|
+
comma: "<čárka> ','"
|
26
|
+
semicolon: "<středník> ';'"
|
27
|
+
tab: "<tabulátor>"
|
28
|
+
confirmation: "Export to %{name}"
|
29
|
+
|
30
|
+
import:
|
31
|
+
new_import: "Nový import"
|
32
|
+
import_list: "Sezam importů"
|
33
|
+
csv:
|
34
|
+
configuration: "Konfigurace CSV importu"
|
35
|
+
blank_vals:
|
36
|
+
label: "Prázdné hodnoty"
|
37
|
+
skip: "Přeskočit"
|
38
|
+
use: "Nastavit"
|
39
|
+
column: "Sloupec %{idx}"
|
40
|
+
start: "Spustit"
|
41
|
+
|
42
|
+
bulk_edit:
|
43
|
+
title: "Hromadná změna %{count} položek"
|
44
|
+
|
45
|
+
query:
|
46
|
+
filter: 'Filtr'
|
47
|
+
add_filter: 'Přidat filtr'
|
48
|
+
query: 'Dotaz'
|
49
|
+
filter_list: "Seznam uložených filtrů"
|
50
|
+
modify_query: "Upravit dotaz"
|
51
|
+
save_filter: "Uložit filtr"
|
52
|
+
error_filter: "Filter nelze uložit"
|
53
|
+
enter_filter_name: "Prosím vyplňte název filtru"
|
54
|
+
|
11
55
|
actions:
|
12
56
|
delete_all:
|
13
57
|
menu: "Smazat označené"
|
58
|
+
import:
|
59
|
+
title: "Import"
|
60
|
+
menu: "Import"
|
61
|
+
breadcrumb: "Import"
|
62
|
+
bulk_edit:
|
63
|
+
done: "importováno"
|
64
|
+
title: "Změna %{model_label_plural}"
|
65
|
+
menu: "Hromadná změna"
|
66
|
+
breadcrumb: 'Hromadná úprava'
|
67
|
+
bulk_link: "Změnit vybraný %{model_label_plural}"
|
68
|
+
done: "upraveno"
|
data/config/locales/en.yml
CHANGED
@@ -2,21 +2,65 @@ en:
|
|
2
2
|
web_name: "Project Name"
|
3
3
|
misc:
|
4
4
|
loading: "Loading, please wait"
|
5
|
-
modify_query: "Modify query"
|
6
|
-
save_filter: "Save filter"
|
7
|
-
error_filter: "Filter can't be saved"
|
8
|
-
enter_filter_name: "Please enter filter name"
|
9
|
-
|
10
|
-
admin:
|
11
|
-
actions:
|
12
|
-
delete_all:
|
13
|
-
menu: "Delete selected"
|
14
5
|
|
15
6
|
basepack:
|
7
|
+
misc:
|
8
|
+
submit_create: 'Add'
|
16
9
|
flash:
|
17
10
|
error_on_items: "Following %{model_label_plural} failed to be %{action}"
|
11
|
+
export:
|
12
|
+
no_exported_items: "Exported items count"
|
13
|
+
select_all_fields: "Select All Fields"
|
14
|
+
select: "Select fields to export"
|
15
|
+
click_to_reverse_selection: 'Click to reverse selection'
|
16
|
+
fields_from: "Fields from %{name}"
|
17
|
+
fields_from_associated: "Fields from associated %{name}"
|
18
|
+
options_for: "Options for %{name}"
|
19
|
+
csv:
|
20
|
+
skip_header: "No header"
|
21
|
+
skip_header_help: "Do not output a header (no fields description)"
|
22
|
+
col_sep_help: "Leave blank for default ('%{value}')"
|
23
|
+
col_sep:
|
24
|
+
label: "Column separator"
|
25
|
+
comma: "<comma> ','"
|
26
|
+
semicolon: "<semicolon> ';'"
|
27
|
+
tab: "<tabs>"
|
28
|
+
confirmation: "Export to %{name}"
|
29
|
+
|
30
|
+
import:
|
31
|
+
new_import: "New Import"
|
32
|
+
import_list: "List of Imports"
|
33
|
+
csv:
|
34
|
+
configuration: "Configuration of CSV import"
|
35
|
+
blank_vals:
|
36
|
+
label: "Blank values"
|
37
|
+
skip: "Skip"
|
38
|
+
use: "Set"
|
39
|
+
column: "Column %{idx}"
|
40
|
+
start: "Start Import"
|
41
|
+
|
42
|
+
bulk_edit:
|
43
|
+
title: "Bulk edit for %{count} items"
|
44
|
+
|
45
|
+
query:
|
46
|
+
filter: 'Filter'
|
47
|
+
add_filter: 'Add Filter'
|
48
|
+
query: 'Query'
|
49
|
+
filter_list: "List of Saved Filters"
|
50
|
+
modify_query: "Modify query"
|
51
|
+
save_filter: "Save filter"
|
52
|
+
error_filter: "Filter can't be saved"
|
53
|
+
enter_filter_name: "Please enter filter name"
|
54
|
+
|
18
55
|
actions:
|
56
|
+
delete_all:
|
57
|
+
menu: "Delete selected"
|
58
|
+
import:
|
59
|
+
title: "Import"
|
60
|
+
menu: "Import"
|
61
|
+
breadcrumb: "Import"
|
19
62
|
bulk_edit:
|
63
|
+
done: "imported"
|
20
64
|
title: "Change %{model_label_plural}"
|
21
65
|
menu: "Bulk change"
|
22
66
|
breadcrumb: 'Bulk edit'
|
data/lib/basepack.rb
CHANGED
data/lib/basepack/engine.rb
CHANGED
@@ -2,6 +2,7 @@ require 'csv'
|
|
2
2
|
require 'rails_admin'
|
3
3
|
require 'inherited_resources'
|
4
4
|
require 'select2-rails'
|
5
|
+
require 'bootstrap-sass' #needs to be required before bootstrap-modal-rails
|
5
6
|
require 'bootstrap-modal-rails'
|
6
7
|
require 'underscore-rails'
|
7
8
|
require 'underscore-string-rails'
|
data/lib/basepack/forms/query.rb
CHANGED
@@ -8,8 +8,8 @@ module Basepack
|
|
8
8
|
|
9
9
|
has_many :importables, inverse_of: :import, dependent: :destroy, class_name: 'Basepack::ImportImportable'
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
dragonfly_accessor :file
|
12
|
+
dragonfly_accessor :report
|
13
13
|
|
14
14
|
serialize :configuration, Hash
|
15
15
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rails_admin/config/fields/types/string'
|
2
|
+
require 'phony'
|
3
|
+
|
4
|
+
module RailsAdmin
|
5
|
+
module Config
|
6
|
+
module Fields
|
7
|
+
module Types
|
8
|
+
class Phone < RailsAdmin::Config::Fields::Types::String
|
9
|
+
# Register field type for the type loader
|
10
|
+
RailsAdmin::Config::Fields::Types::register(self)
|
11
|
+
|
12
|
+
register_instance_option :pretty_value do
|
13
|
+
if value.nil?
|
14
|
+
nil
|
15
|
+
else
|
16
|
+
options = {}
|
17
|
+
options[:format] = format if format.present?
|
18
|
+
options[:spaces] = spaces if spaces.present?
|
19
|
+
if Phony.plausible?(normalized_value)
|
20
|
+
Phony.formatted(normalized_value, options).html_safe
|
21
|
+
else
|
22
|
+
value.html_safe
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
register_instance_option :cc do
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
register_instance_option :ndc do
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
register_instance_option :format do
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
register_instance_option :spaces do
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
register_instance_option :export_value do
|
41
|
+
value.inspect
|
42
|
+
end
|
43
|
+
|
44
|
+
# in case you want to save normalized value
|
45
|
+
# must be called from controller
|
46
|
+
# def parse_input(params)
|
47
|
+
# raise params[name].inspect
|
48
|
+
# params[name] = Phony.normalize(params[name], {cc: cc, ndc: ndc}) if params[name].present?
|
49
|
+
# end
|
50
|
+
|
51
|
+
def normalized_value
|
52
|
+
options = {}
|
53
|
+
options[:cc] = cc if cc.present?
|
54
|
+
options[:ndc] = ndc if ndc.present?
|
55
|
+
Phony.normalize(value, options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|