[refs #2161] Swap bpl and pl fields into BuildList
This commit is contained in:
parent
372d7dac4d
commit
4e0617a722
|
@ -58,8 +58,8 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
def build
|
def build
|
||||||
@arches = Arch.recent
|
@arches = Arch.recent
|
||||||
@pls = Platform.main
|
@bpls = Platform.main
|
||||||
@bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
|
@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\./ }
|
@project_versions = @project.project_versions.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
@project_version = params[:build][:project_version]
|
@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 }
|
bpls_ids = params[:build][:bpl].blank? ? [] : params[:build][:bpl].select{|_,v| v == "1"}.collect{|x| x[0].to_i }
|
||||||
pls = Platform.where(:id => pls_ids)
|
bpls = Platform.where(:id => bpls_ids)
|
||||||
|
|
||||||
bpl = Platform.find params[:build][:bpl]
|
pl = Platform.find params[:build][:pl]
|
||||||
update_type = params[:build][:update_type]
|
update_type = params[:build][:update_type]
|
||||||
build_requires = params[:build][:build_requires]
|
build_requires = params[:build][:build_requires]
|
||||||
|
|
||||||
|
@ -80,20 +80,20 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
if !check_arches || !check_project_versions
|
if !check_arches || !check_project_versions
|
||||||
@arches = Arch.recent
|
@arches = Arch.recent
|
||||||
@pls = Platform.main
|
@bpls = Platform.main
|
||||||
@bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
|
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
|
||||||
|
|
||||||
render :action => "build"
|
render :action => "build"
|
||||||
else
|
else
|
||||||
flash[:notice], flash[:error] = "", ""
|
flash[:notice], flash[:error] = "", ""
|
||||||
@arches.each do |arch|
|
@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)
|
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
|
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
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class BuildList < ActiveRecord::Base
|
||||||
validates :update_type, :inclusion => UPDATE_TYPES
|
validates :update_type, :inclusion => UPDATE_TYPES
|
||||||
|
|
||||||
validate lambda {
|
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
|
BUILD_CANCELED = 5000
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
= f.select :project_version, @project_versions
|
= f.select :project_version, @project_versions
|
||||||
|
|
||||||
.group.pl_ids_container
|
.group.pl_ids_container
|
||||||
= f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label
|
= f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label
|
||||||
- @pls.each do |pl|
|
- @bpls.each do |bpl|
|
||||||
= f.check_box "pl[#{pl.id}]", :pl_id => pl.id, :class => 'build_pl_ids'
|
= f.check_box "bpl[#{bpl.id}]", :bpl_id => bpl.id, :class => 'build_bpl_ids'
|
||||||
= pl.name
|
= bpl.name
|
||||||
%br
|
%br
|
||||||
|
|
||||||
.group
|
.group
|
||||||
|
@ -43,8 +43,8 @@
|
||||||
%br
|
%br
|
||||||
|
|
||||||
.group
|
.group
|
||||||
= f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label
|
= f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label
|
||||||
= f.select :bpl, @bpls
|
= f.select :pl, @pls
|
||||||
|
|
||||||
.group.navform.wat-cf
|
.group.navform.wat-cf
|
||||||
%button.button{:type => "submit"}
|
%button.button{:type => "submit"}
|
||||||
|
|
|
@ -15,26 +15,26 @@ function uncheck_by_ids(ids) {
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.pl_ids_container input[type="hidden"]').remove();
|
$('.pl_ids_container input[type="hidden"]').remove();
|
||||||
|
|
||||||
$('select#build_bpl').change(function() {
|
$('select#build_pl').change(function() {
|
||||||
var is_bpl_main = false;
|
var is_pl_main = false;
|
||||||
var granted_pl_id = '';
|
var granted_bpl_id = '';
|
||||||
var bpl_id = $('select#build_bpl').val();
|
var pl_id = $('select#build_pl').val();
|
||||||
|
|
||||||
$('input.build_pl_ids').each(function(i,el) {
|
$('input.build_bpl_ids').each(function(i,el) {
|
||||||
var pl_id = $(el).attr('pl_id');
|
var bpl_id = $(el).attr('bpl_id');
|
||||||
if (pl_id == bpl_id) {
|
if (pl_id == bpl_id) {
|
||||||
is_bpl_main = true;
|
is_pl_main = true;
|
||||||
//granted_pl_id = $(el).attr('pl_id');
|
//granted_bpl_id = $(el).attr('bpl_id');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (is_bpl_main) {
|
if (is_pl_main) {
|
||||||
$('input.build_pl_ids').attr('disabled', 'disabled');
|
$('input.build_bpl_ids').attr('disabled', 'disabled');
|
||||||
$('input.build_pl_ids[pl_id="'+bpl_id+'"]').removeAttr('disabled');
|
$('input.build_bpl_ids[bpl_id="'+pl_id+'"]').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
$('input.build_pl_ids').removeAttr('disabled');
|
$('input.build_bpl_ids').removeAttr('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('select#build_bpl').trigger('change');
|
$('select#build_pl').trigger('change');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue