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,14 +7,13 @@ class KalibroConfigurationsController < ApplicationController | ||
7 | # GET /kalibro_configurations/new | 7 | # GET /kalibro_configurations/new |
8 | def new | 8 | def new |
9 | @kalibro_configuration = KalibroConfiguration.new | 9 | @kalibro_configuration = KalibroConfiguration.new |
10 | + @attributes = @kalibro_configuration.attributes | ||
10 | end | 11 | end |
11 | 12 | ||
12 | # GET /kalibro_configurations | 13 | # GET /kalibro_configurations |
13 | # GET /kalibro_configurations.json | 14 | # GET /kalibro_configurations.json |
14 | def index | 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 | end | 17 | end |
19 | 18 | ||
20 | # POST /kalibro_configurations | 19 | # POST /kalibro_configurations |
@@ -39,6 +38,7 @@ class KalibroConfigurationsController < ApplicationController | @@ -39,6 +38,7 @@ class KalibroConfigurationsController < ApplicationController | ||
39 | # GET /kalibro_configurations/1/edit.json | 38 | # GET /kalibro_configurations/1/edit.json |
40 | def edit | 39 | def edit |
41 | set_kalibro_configuration | 40 | set_kalibro_configuration |
41 | + @attributes = @kalibro_configuration.attributes | ||
42 | end | 42 | end |
43 | 43 | ||
44 | 44 |
app/controllers/metric_configurations_controller.rb
@@ -9,6 +9,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -9,6 +9,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
9 | super | 9 | super |
10 | # find_by_name throws an exception instead of returning nil, unlike ActiveRecord's API | 10 | # find_by_name throws an exception instead of returning nil, unlike ActiveRecord's API |
11 | metric_configuration.metric = KalibroClient::Entities::Processor::MetricCollectorDetails.find_by_name(params[:metric_collector_name]).find_metric_by_code params[:metric_code] | 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 | end | 15 | end |
13 | 16 | ||
14 | def create | 17 | def create |
@@ -24,6 +27,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | @@ -24,6 +27,9 @@ class MetricConfigurationsController < BaseMetricConfigurationsController | ||
24 | #FIXME: set the configuration id just once! | 27 | #FIXME: set the configuration id just once! |
25 | @kalibro_configuration_id = params[:kalibro_configuration_id] | 28 | @kalibro_configuration_id = params[:kalibro_configuration_id] |
26 | @metric_configuration.kalibro_configuration_id = @kalibro_configuration_id | 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 | end | 33 | end |
28 | 34 | ||
29 | def update | 35 | def update |
app/controllers/reading_groups_controller.rb
@@ -8,12 +8,13 @@ class ReadingGroupsController < ApplicationController | @@ -8,12 +8,13 @@ class ReadingGroupsController < ApplicationController | ||
8 | # GET /reading_groups/new | 8 | # GET /reading_groups/new |
9 | def new | 9 | def new |
10 | @reading_group = ReadingGroup.new | 10 | @reading_group = ReadingGroup.new |
11 | + @attributes = @reading_group.attributes | ||
11 | end | 12 | end |
12 | 13 | ||
13 | # GET /reading_groups | 14 | # GET /reading_groups |
14 | # GET /reading_groups.json | 15 | # GET /reading_groups.json |
15 | def index | 16 | def index |
16 | - @reading_groups = ReadingGroup.public | 17 | + @reading_groups = ReadingGroup.public_or_owned_by_user(current_user) |
17 | end | 18 | end |
18 | 19 | ||
19 | # POST /reading_groups | 20 | # POST /reading_groups |
@@ -31,7 +32,9 @@ class ReadingGroupsController < ApplicationController | @@ -31,7 +32,9 @@ class ReadingGroupsController < ApplicationController | ||
31 | 32 | ||
32 | # GET /reading_groups/1/edit | 33 | # GET /reading_groups/1/edit |
33 | # GET /reading_groups/1/edit.json | 34 | # GET /reading_groups/1/edit.json |
34 | - def edit; end | 35 | + def edit |
36 | + @attributes = @reading_group.attributes | ||
37 | + end | ||
35 | 38 | ||
36 | def update | 39 | def update |
37 | if @reading_group.update(reading_group_params) | 40 | if @reading_group.update(reading_group_params) |
app/controllers/repositories_controller.rb
@@ -19,12 +19,18 @@ class RepositoriesController < ApplicationController | @@ -19,12 +19,18 @@ class RepositoriesController < ApplicationController | ||
19 | @project_id = params[:project_id] | 19 | @project_id = params[:project_id] |
20 | @repository = Repository.new | 20 | @repository = Repository.new |
21 | @repository_types = Repository.repository_types | 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 | end | 25 | end |
23 | 26 | ||
24 | # GET /repositories/1/edit | 27 | # GET /repositories/1/edit |
25 | def edit | 28 | def edit |
26 | @project_id = params[:project_id] | 29 | @project_id = params[:project_id] |
27 | @repository_types = Repository.repository_types | 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 | end | 34 | end |
29 | 35 | ||
30 | # POST /projects/1/repositories | 36 | # POST /projects/1/repositories |
app/views/kalibro_configurations/_form.html.erb
@@ -18,6 +18,13 @@ | @@ -18,6 +18,13 @@ | ||
18 | </div> | 18 | </div> |
19 | </div> | 19 | </div> |
20 | 20 | ||
21 | + <div class="form-row"> | ||
22 | + <div class="field-container checkbox"> | ||
23 | + <label> | ||
24 | + <%= check_box :attributes, :public %> Visible to everyone? | ||
25 | + </label> | ||
26 | + </div> | ||
27 | + </div> | ||
21 | </div> | 28 | </div> |
22 | </div> | 29 | </div> |
23 | 30 |
app/views/metric_configurations/_form.html.erb
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | <div class="form-row"> | 34 | <div class="form-row"> |
35 | <div class="field-container"> | 35 | <div class="field-container"> |
36 | <%= f.label :reading_group_id, class: 'control-label' %> | 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 | </div> | 38 | </div> |
39 | <div class="help-container"> | 39 | <div class="help-container"> |
40 | <p> | 40 | <p> |
app/views/reading_groups/_form.html.erb
@@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
3 | 3 | ||
4 | <div class="row margin-left-none"> | 4 | <div class="row margin-left-none"> |
5 | <div class="form-table col-md-9"> | 5 | <div class="form-table col-md-9"> |
6 | - | ||
7 | <div class="form-row"> | 6 | <div class="form-row"> |
8 | <div class="field-container"> | 7 | <div class="field-container"> |
9 | <%= f.label :name, class: 'control-label' %> | 8 | <%= f.label :name, class: 'control-label' %> |
@@ -17,6 +16,13 @@ | @@ -17,6 +16,13 @@ | ||
17 | <%= f.text_area :description, class: 'text-area form-control' %> | 16 | <%= f.text_area :description, class: 'text-area form-control' %> |
18 | </div> | 17 | </div> |
19 | </div> | 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 | </div> | 26 | </div> |
21 | </div> | 27 | </div> |
22 | 28 |
app/views/repositories/_form.html.erb
@@ -79,8 +79,7 @@ | @@ -79,8 +79,7 @@ | ||
79 | <div class="form-row"> | 79 | <div class="form-row"> |
80 | <div class="field-container"> | 80 | <div class="field-container"> |
81 | <%= f.label :kalibro_configuration_id, KalibroConfiguration.model_name.human, class: 'control-label' %> | 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 | </div> | 83 | </div> |
85 | <div class="help-container"> | 84 | <div class="help-container"> |
86 | <p> | 85 | <p> |