graph_starter 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/graph_starter/assets_controller.rb +22 -0
- data/app/models/concerns/graph_starter/authorizable.rb +5 -2
- data/app/views/graph_starter/assets/_admin_buttons.html.slim +7 -0
- data/app/views/graph_starter/assets/_form.html.slim +34 -0
- data/app/views/graph_starter/assets/_search.html.slim +6 -0
- data/app/views/graph_starter/assets/edit.html.slim +1 -20
- data/app/views/graph_starter/assets/index.html.slim +11 -9
- data/app/views/graph_starter/assets/new.html.slim +2 -0
- data/app/views/graph_starter/properties/_property.html.slim +1 -1
- data/app/views/layouts/graph_starter/_menu.html.slim +1 -1
- data/config/routes.rb +7 -0
- data/lib/graph_starter/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd1a89466936369ecfe1ef04d02e25c537e441ee
|
4
|
+
data.tar.gz: d17ce41642598fa8f2228a43163ca2ef59cdb969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ebae16750e98a0c9c7c28e2cec7b6e2ae314ee30ecde5ddbea043e1fb0543b4207cd40edfc39586d24e7c98342d4a6c66d600e744673ac16b5a93848bc25aba
|
7
|
+
data.tar.gz: e7331c09fd4db1f72e6f58f479d6257b216f09a1d8f08c8b0696be1456ec1723443bc93ea1f214a5f47145c612eb48e3b762b491745c21b6b6bbee6b30c9eac2
|
@@ -76,6 +76,28 @@ module GraphStarter
|
|
76
76
|
redirect_to action: :edit
|
77
77
|
end
|
78
78
|
|
79
|
+
def new
|
80
|
+
@asset = model_class.new
|
81
|
+
end
|
82
|
+
|
83
|
+
def create
|
84
|
+
@asset = model_class.create(params[params[:model_slug].singularize])
|
85
|
+
|
86
|
+
if @asset.persisted?
|
87
|
+
redirect_to action: :show, id: @asset.id
|
88
|
+
else
|
89
|
+
puts '@asset.errors.messages', @asset.errors.messages.inspect
|
90
|
+
flash[:error] = @asset.errors.messages.to_a.map {|pair| pair.join(' ') }.join(' / ')
|
91
|
+
redirect_to :back
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def destroy
|
96
|
+
asset.destroy
|
97
|
+
|
98
|
+
redirect_to action: :index
|
99
|
+
end
|
100
|
+
|
79
101
|
def rate
|
80
102
|
if current_user
|
81
103
|
rating = asset.rating_for(current_user)
|
@@ -6,8 +6,11 @@ module GraphStarter
|
|
6
6
|
property :private, type: ActiveAttr::Typecasting::Boolean, default: false
|
7
7
|
validates :private, inclusion: {in: [true, false]}
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
if GraphStarter.configuration.user_class
|
10
|
+
has_many :in, :allowed_users, rel_class: :CanAccess, model_class: GraphStarter.configuration.user_class
|
11
|
+
end
|
12
|
+
|
13
|
+
has_many :in, :allowed_groups, rel_class: :CanAccess, model_class: :'GraphStarter::Group'
|
11
14
|
end
|
12
15
|
|
13
16
|
def set_access_levels(model, access_levels)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
= form_for @asset, url: url_for(action: action), html: {class: 'ui form'} do |f|
|
2
|
+
= image_tag @asset.first_image_source_url, class: 'ui medium image' if @asset.class.has_image? || @asset.class.has_images?
|
3
|
+
/.field
|
4
|
+
/ label Image
|
5
|
+
|
6
|
+
/ = f.file_field :image
|
7
|
+
|
8
|
+
- @asset.class.authorized_properties_and_levels(current_user).each do |property, level|
|
9
|
+
.field
|
10
|
+
- editable_properties = GraphStarter.configuration.editable_properties[@asset.class.name.to_sym]
|
11
|
+
- can_write = (level == 'write') && !f.nil? && (editable_properties.nil? || editable_properties.map(&:to_s).include?(property.name))
|
12
|
+
|
13
|
+
- if @asset.class.display_property?(property.name) || can_write
|
14
|
+
label = property.name.humanize
|
15
|
+
|
16
|
+
= render partial: 'graph_starter/properties/property', locals: {property: property, asset: @asset, form: f, can_write: can_write}
|
17
|
+
|
18
|
+
- @asset.class.authorized_associations.each do |name, association|
|
19
|
+
javascript:
|
20
|
+
var current_#{name} = [];
|
21
|
+
|
22
|
+
.field
|
23
|
+
label = name.to_s.humanize
|
24
|
+
|
25
|
+
- field_name = (association.type == :has_many ? "#{name.to_s.singularize}_ids" : "#{name}_id")
|
26
|
+
- target_class = association.target_class
|
27
|
+
- options = target_class.as(:n).pluck(target_class.name_property, target_class.id_property_name)
|
28
|
+
= f.select field_name, options, {}, class: 'ui fluid search dropdown', multiple: ''
|
29
|
+
|
30
|
+
javascript:
|
31
|
+
$('.ui.dropdown').dropdown()
|
32
|
+
|
33
|
+
= f.submit action.humanize, class: 'ui button'
|
34
|
+
|
@@ -4,23 +4,4 @@
|
|
4
4
|
|
5
5
|
h1 = @asset.name
|
6
6
|
|
7
|
-
=
|
8
|
-
|
9
|
-
= image_tag @asset.first_image_source_url, class: 'ui medium image'
|
10
|
-
/.field
|
11
|
-
/ label Image
|
12
|
-
|
13
|
-
/ = f.file_field :image
|
14
|
-
|
15
|
-
- @asset.class.authorized_properties_and_levels(current_user).each do |property, level|
|
16
|
-
.field
|
17
|
-
- editable_properties = GraphStarter.configuration.editable_properties[@asset.class.name.to_sym]
|
18
|
-
- can_write = (level == 'write') && !f.nil? && (editable_properties.nil? || editable_properties.map(&:to_s).include?(property.name))
|
19
|
-
|
20
|
-
- if @asset.class.display_property?(property.name) || can_write
|
21
|
-
label = property.name.humanize
|
22
|
-
|
23
|
-
= render partial: 'graph_starter/properties/property', locals: {property: property, asset: @asset, form: f, can_write: can_write}
|
24
|
-
|
25
|
-
|
26
|
-
= f.submit 'Update', class: 'ui button'
|
7
|
+
= render partial: 'form', locals: {action: 'update'}
|
@@ -1,17 +1,14 @@
|
|
1
1
|
|
2
2
|
- if @assets.present?
|
3
|
-
|
4
|
-
.ui.icon.input
|
5
|
-
input.prompt type="text" placeholder="Search..." style="width: 400px"
|
6
|
-
i.search.icon
|
7
|
-
.results
|
8
|
-
|
9
|
-
.ui.divider
|
3
|
+
= render partial: 'search'
|
10
4
|
|
11
5
|
javascript:
|
12
|
-
$('.ui.search').search({
|
6
|
+
$('.ui.search').search({
|
7
|
+
onSelect: function (result, response) { window.location.replace(result.url) },
|
8
|
+
apiSettings: {url: "/#{@model_slug}/search/{query}.json"}
|
9
|
+
})
|
13
10
|
|
14
|
-
|
11
|
+
.ui.divider
|
15
12
|
|
16
13
|
- count = @assets.size
|
17
14
|
- total_count = @all_assets.count
|
@@ -19,4 +16,9 @@
|
|
19
16
|
|
20
17
|
.ui.divider
|
21
18
|
|
19
|
+
a.ui.labeled.icon.button.right.floated href="#{new_asset_path}"
|
20
|
+
i.write.icon
|
21
|
+
| New
|
22
|
+
|
23
|
+
|
22
24
|
= render partial: 'graph_starter/assets/cards', locals: {assets: @assets}
|
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
- when /ActiveAttr::Typecasting::Boolean$/, /Boolean$/
|
30
30
|
- if can_write
|
31
|
-
= form.select property.name, [['
|
31
|
+
= form.select property.name, [['False', false], ['True', true]], {}, class: 'ui dropdown'
|
32
32
|
- else
|
33
33
|
= value
|
34
34
|
- else
|
@@ -2,7 +2,7 @@
|
|
2
2
|
= link_to 'Home', '/', class: "item #{'active' if request.path == '/'}"
|
3
3
|
- config = GraphStarter::CONFIG
|
4
4
|
- menu_models = config.menu_models && config.menu_models.map(&:to_s)
|
5
|
-
- GraphStarter::Asset.descendants.each do |model_class|
|
5
|
+
- GraphStarter::Asset.descendants.sort_by {|m| (menu_models || []).index(m.name) || 0 }.each do |model_class|
|
6
6
|
- next if menu_models && !model_class.name.in?(menu_models)
|
7
7
|
- path = graph_starter.assets_path(model_slug: model_class.model_slug)
|
8
8
|
= link_to model_class.name.tableize.humanize, path, class: "item #{'active' if request.path.match(/^#{path}/)}"
|
data/config/routes.rb
CHANGED
@@ -18,9 +18,16 @@ GraphStarter::Engine.routes.draw do
|
|
18
18
|
put 'authorizables/:model_slug/:id.:format' => 'authorizables#update'
|
19
19
|
|
20
20
|
get ':model_slug' => 'assets#index', as: :assets
|
21
|
+
|
22
|
+
get ':model_slug/new' => 'assets#new', as: :new_asset
|
23
|
+
post ':model_slug' => 'assets#create', as: :create_asset
|
24
|
+
|
21
25
|
get ':model_slug/:id' => 'assets#show', as: :asset
|
22
26
|
get ':model_slug/:id/edit' => 'assets#edit', as: :edit_asset
|
23
27
|
put ':model_slug/:id/rate/:new_rating' => 'assets#rate', as: :rate_asset
|
24
28
|
get ':model_slug/search/:query.json' => 'assets#search', as: :search_assets
|
29
|
+
|
30
|
+
get ':model_slug/:id/destroy' => 'assets#destroy', as: :destroy_asset
|
31
|
+
|
25
32
|
patch ':model_slug/:id' => 'assets#update'
|
26
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph_starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -138,10 +138,13 @@ files:
|
|
138
138
|
- app/views/graph_starter/assets/_body.html.slim
|
139
139
|
- app/views/graph_starter/assets/_cards.html.slim
|
140
140
|
- app/views/graph_starter/assets/_dynamic_items.html.slim
|
141
|
+
- app/views/graph_starter/assets/_form.html.slim
|
141
142
|
- app/views/graph_starter/assets/_property_items.html.slim
|
143
|
+
- app/views/graph_starter/assets/_search.html.slim
|
142
144
|
- app/views/graph_starter/assets/edit.html.slim
|
143
145
|
- app/views/graph_starter/assets/home.html.slim
|
144
146
|
- app/views/graph_starter/assets/index.html.slim
|
147
|
+
- app/views/graph_starter/assets/new.html.slim
|
145
148
|
- app/views/graph_starter/assets/show.html.slim
|
146
149
|
- app/views/graph_starter/authorizables/show.json.jbuilder
|
147
150
|
- app/views/graph_starter/authorizables/user_and_group_search.json.jbuilder
|