[refs #2161] Swap bpl and pl fields into BuildList

This commit is contained in:
konstantin.grabar 2011-10-29 16:18:41 +04:00
parent 372d7dac4d
commit 4e0617a722
4 changed files with 30 additions and 30 deletions

View File

@ -58,8 +58,8 @@ class ProjectsController < ApplicationController
def build
@arches = Arch.recent
@pls = Platform.main
@bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
@bpls = Platform.main
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
@project_versions = @project.project_versions.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ }
end
@ -69,10 +69,10 @@ class ProjectsController < ApplicationController
@project_version = params[:build][:project_version]
pls_ids = params[:build][:pl].blank? ? [] : params[:build][:pl].select{|_,v| v == "1"}.collect{|x| x[0].to_i }
pls = Platform.where(:id => pls_ids)
bpls_ids = params[:build][:bpl].blank? ? [] : params[:build][:bpl].select{|_,v| v == "1"}.collect{|x| x[0].to_i }
bpls = Platform.where(:id => bpls_ids)
bpl = Platform.find params[:build][:bpl]
pl = Platform.find params[:build][:pl]
update_type = params[:build][:update_type]
build_requires = params[:build][:build_requires]
@ -80,20 +80,20 @@ class ProjectsController < ApplicationController
if !check_arches || !check_project_versions
@arches = Arch.recent
@pls = Platform.main
@bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
@bpls = Platform.main
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
render :action => "build"
else
flash[:notice], flash[:error] = "", ""
@arches.each do |arch|
pls.each do |pl|
bpls.each do |bpl|
build_list = @project.build_lists.new(:arch => arch, :project_version => @project_version, :pl => pl, :bpl => bpl, :update_type => update_type, :build_requires => build_requires)
if build_list.save
flash[:notice] += t("flash.build_list.saved", :project_version => @project_version, :arch => arch.name, :pl => pl.name, :bpl => bpl)
flash[:notice] += t("flash.build_list.saved", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl)
else
flash[:error] += t("flash.build_list.save_error", :project_version => @project_version, :arch => arch.name, :pl => pl.name, :bpl => bpl)
flash[:error] += t("flash.build_list.save_error", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl)
end
end
end

View File

@ -14,7 +14,7 @@ class BuildList < ActiveRecord::Base
validates :update_type, :inclusion => UPDATE_TYPES
validate lambda {
errors.add(:pl, I18n.t('flash.build_list.wrong_platform')) if bpl.platform_type == 'main' && pl_id != bpl_id
errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id
}
BUILD_CANCELED = 5000

View File

@ -19,10 +19,10 @@
= f.select :project_version, @project_versions
.group.pl_ids_container
= f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label
- @pls.each do |pl|
= f.check_box "pl[#{pl.id}]", :pl_id => pl.id, :class => 'build_pl_ids'
= pl.name
= f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label
- @bpls.each do |bpl|
= f.check_box "bpl[#{bpl.id}]", :bpl_id => bpl.id, :class => 'build_bpl_ids'
= bpl.name
%br
.group
@ -43,8 +43,8 @@
%br
.group
= f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label
= f.select :bpl, @bpls
= f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label
= f.select :pl, @pls
.group.navform.wat-cf
%button.button{:type => "submit"}

View File

@ -15,26 +15,26 @@ function uncheck_by_ids(ids) {
$(document).ready(function() {
$('.pl_ids_container input[type="hidden"]').remove();
$('select#build_bpl').change(function() {
var is_bpl_main = false;
var granted_pl_id = '';
var bpl_id = $('select#build_bpl').val();
$('select#build_pl').change(function() {
var is_pl_main = false;
var granted_bpl_id = '';
var pl_id = $('select#build_pl').val();
$('input.build_pl_ids').each(function(i,el) {
var pl_id = $(el).attr('pl_id');
$('input.build_bpl_ids').each(function(i,el) {
var bpl_id = $(el).attr('bpl_id');
if (pl_id == bpl_id) {
is_bpl_main = true;
//granted_pl_id = $(el).attr('pl_id');
is_pl_main = true;
//granted_bpl_id = $(el).attr('bpl_id');
}
});
if (is_bpl_main) {
$('input.build_pl_ids').attr('disabled', 'disabled');
$('input.build_pl_ids[pl_id="'+bpl_id+'"]').removeAttr('disabled');
if (is_pl_main) {
$('input.build_bpl_ids').attr('disabled', 'disabled');
$('input.build_bpl_ids[bpl_id="'+pl_id+'"]').removeAttr('disabled');
} else {
$('input.build_pl_ids').removeAttr('disabled');
$('input.build_bpl_ids').removeAttr('disabled');
}
});
$('select#build_bpl').trigger('change');
$('select#build_pl').trigger('change');
});