From 59bfac2be764584aff661661d05827b8e66c20e1 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sun, 23 Oct 2011 11:37:54 +0400 Subject: [PATCH] [refs #1832] Add some fixes to controllers. Add JS validation to project build --- app/controllers/build_lists_controller.rb | 11 +---------- app/controllers/projects_controller.rb | 2 -- app/views/projects/build.html.haml | 10 +--------- public/javascripts/application.js | 24 +++++++++++++++++++++++ 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index 5210c24dc..bfb8699d9 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -1,8 +1,6 @@ class BuildListsController < ApplicationController before_filter :authenticate_user!, :except => [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt] before_filter :authenticate_build_service!, :only => [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt] - #before_filter :find_platform, :only => [:index, :filter, :show, :publish] - #before_filter :find_repository, :only => [:index, :filter, :show, :publish] before_filter :find_project, :only => [:index, :filter, :show, :publish] before_filter :find_arches, :only => [:index, :filter, :all] before_filter :find_branches, :only => [:index, :filter] @@ -114,14 +112,7 @@ class BuildListsController < ApplicationController end protected - def find_platform - @platform = Platform.find params[:platform_id] - end - - def find_repository - @repository = @platform.repositories.find(params[:repository_id]) - end - + def find_project @project = Project.find params[:project_id] end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9491c616b..028a6806c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,7 +1,5 @@ class ProjectsController < ApplicationController before_filter :authenticate_user! -# before_filter :find_platform -# before_filter :find_repository before_filter :find_project, :only => [:show, :destroy, :build, :process_build] before_filter :get_paths, :only => [:new, :create] diff --git a/app/views/projects/build.html.haml b/app/views/projects/build.html.haml index 2e8b01f13..744476f44 100644 --- a/app/views/projects/build.html.haml +++ b/app/views/projects/build.html.haml @@ -51,14 +51,6 @@ = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.projects.build_button")) = t("layout.projects.build_button") %span.text_button_padding= t("layout.or") - = link_to t("layout.cancel"), root_path, :class => "text_button_padding link_button" --# - :javascript - var pl_counter = 0; - var bpl_id = $('select#build_bpl').val(); - $('input.build_pl_ids').each(function(i,el) { - var pl_id = $(el).attr('pl_id'); - }); - + = link_to t("layout.cancel"), root_path, :class => "text_button_padding link_button" -# content_for :sidebar, render(:partial => 'sidebar') diff --git a/public/javascripts/application.js b/public/javascripts/application.js index e69de29bb..52600bd83 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -0,0 +1,24 @@ +$(document).ready(function() { + $('select#build_bpl').change(function() { + var is_bpl_main = false; + var granted_pl_id = ''; + var bpl_id = $('select#build_bpl').val(); + + $('input.build_pl_ids').each(function(i,el) { + var pl_id = $(el).attr('pl_id'); + if (pl_id == bpl_id) { + is_bpl_main = true; + //granted_pl_id = $(el).attr('pl_id'); + } + }); + + if (is_bpl_main) { + $('input.build_pl_ids').attr('disabled', 'disabled'); + $('input.build_pl_ids[pl_id="'+bpl_id+'"]').removeAttr('disabled'); + } else { + $('input.build_pl_ids').removeAttr('disabled'); + } + }); + + $('select#build_bpl').trigger('change'); +}); \ No newline at end of file