Commit 5836a72a0204664079a4ac63795cc1edb883799d
Committed by
Diego Camarinha
1 parent
6e515ada
Exists in
colab
and in
4 other branches
Added user option for visibility of reading group and configuration
Signed-off-by: Daniel Miranda <danielkza2@gmail.com>
Showing
9 changed files
with
39 additions
and
9 deletions
Show diff stats
app/assets/stylesheets/form_with_tooltip.css
app/controllers/kalibro_configurations_controller.rb
... | ... | @@ -7,14 +7,13 @@ class KalibroConfigurationsController < ApplicationController |
7 | 7 | # GET /kalibro_configurations/new |
8 | 8 | def new |
9 | 9 | @kalibro_configuration = KalibroConfiguration.new |
10 | + @attributes = @kalibro_configuration.attributes | |
10 | 11 | end |
11 | 12 | |
12 | 13 | # GET /kalibro_configurations |
13 | 14 | # GET /kalibro_configurations.json |
14 | 15 | def index |
15 | - @kalibro_configurations = KalibroConfigurationAttributes.where(public: true).map { |cfg_attr| | |
16 | - KalibroConfiguration.find(cfg_attr.kalibro_configuration_id) | |
17 | - }.compact | |
16 | + @kalibro_configurations = KalibroConfiguration.public_or_owned_by_user(current_user) | |
18 | 17 | end |
19 | 18 | |
20 | 19 | # POST /kalibro_configurations |
... | ... | @@ -39,6 +38,7 @@ class KalibroConfigurationsController < ApplicationController |
39 | 38 | # GET /kalibro_configurations/1/edit.json |
40 | 39 | def edit |
41 | 40 | set_kalibro_configuration |
41 | + @attributes = @kalibro_configuration.attributes | |
42 | 42 | end |
43 | 43 | |
44 | 44 | ... | ... |
app/controllers/metric_configurations_controller.rb
... | ... | @@ -9,6 +9,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
9 | 9 | super |
10 | 10 | # find_by_name throws an exception instead of returning nil, unlike ActiveRecord's API |
11 | 11 | metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name]).find_metric_by_code params[:metric_code] |
12 | + @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group| | |
13 | + [reading_group.name, reading_group.id] | |
14 | + } | |
12 | 15 | end |
13 | 16 | |
14 | 17 | def create |
... | ... | @@ -24,6 +27,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController |
24 | 27 | #FIXME: set the configuration id just once! |
25 | 28 | @kalibro_configuration_id = params[:kalibro_configuration_id] |
26 | 29 | @metric_configuration.kalibro_configuration_id = @kalibro_configuration_id |
30 | + @reading_groups = ReadingGroup.public_or_owned_by_user(current_user).map { |reading_group| | |
31 | + [reading_group.name, reading_group.id] | |
32 | + } | |
27 | 33 | end |
28 | 34 | |
29 | 35 | def update | ... | ... |
app/controllers/reading_groups_controller.rb
... | ... | @@ -8,12 +8,13 @@ class ReadingGroupsController < ApplicationController |
8 | 8 | # GET /reading_groups/new |
9 | 9 | def new |
10 | 10 | @reading_group = ReadingGroup.new |
11 | + @attributes = @reading_group.attributes | |
11 | 12 | end |
12 | 13 | |
13 | 14 | # GET /reading_groups |
14 | 15 | # GET /reading_groups.json |
15 | 16 | def index |
16 | - @reading_groups = ReadingGroup.public | |
17 | + @reading_groups = ReadingGroup.public_or_owned_by_user(current_user) | |
17 | 18 | end |
18 | 19 | |
19 | 20 | # POST /reading_groups |
... | ... | @@ -31,7 +32,9 @@ class ReadingGroupsController < ApplicationController |
31 | 32 | |
32 | 33 | # GET /reading_groups/1/edit |
33 | 34 | # GET /reading_groups/1/edit.json |
34 | - def edit; end | |
35 | + def edit | |
36 | + @attributes = @reading_group.attributes | |
37 | + end | |
35 | 38 | |
36 | 39 | def update |
37 | 40 | if @reading_group.update(reading_group_params) | ... | ... |
app/controllers/repositories_controller.rb
... | ... | @@ -19,12 +19,18 @@ class RepositoriesController < ApplicationController |
19 | 19 | @project_id = params[:project_id] |
20 | 20 | @repository = Repository.new |
21 | 21 | @repository_types = Repository.repository_types |
22 | + @configurations = KalibroConfiguration.public_or_owned_by_user(current_user).map { |conf| | |
23 | + [conf.name, conf.id] | |
24 | + } | |
22 | 25 | end |
23 | 26 | |
24 | 27 | # GET /repositories/1/edit |
25 | 28 | def edit |
26 | 29 | @project_id = params[:project_id] |
27 | 30 | @repository_types = Repository.repository_types |
31 | + @configurations = KalibroConfiguration.public_or_owned_by_user(current_user).map { |conf| | |
32 | + [conf.name, conf.id] | |
33 | + } | |
28 | 34 | end |
29 | 35 | |
30 | 36 | # POST /projects/1/repositories | ... | ... |
app/views/kalibro_configurations/_form.html.erb
app/views/metric_configurations/_form.html.erb
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | <div class="form-row"> |
35 | 35 | <div class="field-container"> |
36 | 36 | <%= f.label :reading_group_id, class: 'control-label' %> |
37 | - <%= f.select( :reading_group_id, reading_group_options, {class: 'form-control'} ) %> | |
37 | + <%= f.select( :reading_group_id, reading_groups, {class: 'form-control'} ) %> | |
38 | 38 | </div> |
39 | 39 | <div class="help-container"> |
40 | 40 | <p> | ... | ... |
app/views/reading_groups/_form.html.erb
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 | |
4 | 4 | <div class="row margin-left-none"> |
5 | 5 | <div class="form-table col-md-9"> |
6 | - | |
7 | 6 | <div class="form-row"> |
8 | 7 | <div class="field-container"> |
9 | 8 | <%= f.label :name, class: 'control-label' %> |
... | ... | @@ -17,6 +16,13 @@ |
17 | 16 | <%= f.text_area :description, class: 'text-area form-control' %> |
18 | 17 | </div> |
19 | 18 | </div> |
19 | + <div class="form-row"> | |
20 | + <div class="field-container checkbox"> | |
21 | + <label> | |
22 | + <%= check_box :attributes, :public %> Visible to everyone? | |
23 | + </label> | |
24 | + </div> | |
25 | + </div> | |
20 | 26 | </div> |
21 | 27 | </div> |
22 | 28 | ... | ... |
app/views/repositories/_form.html.erb
... | ... | @@ -79,8 +79,7 @@ |
79 | 79 | <div class="form-row"> |
80 | 80 | <div class="field-container"> |
81 | 81 | <%= f.label :kalibro_configuration_id, KalibroConfiguration.model_name.human, class: 'control-label' %> |
82 | - <% configuration_list = KalibroClient::Entities::Configurations::KalibroConfiguration.all.map { |conf| [conf.name, conf.id] } %> | |
83 | - <%= f.select( :kalibro_configuration_id, configuration_list, class: 'tooltip-control' ) %> | |
82 | + <%= f.select( :kalibro_configuration_id, @configurations, class: 'tooltip-control' ) %> | |
84 | 83 | </div> |
85 | 84 | <div class="help-container"> |
86 | 85 | <p> | ... | ... |