Fix build list controller bugs. Fix JS which controls checkboxes. Fix translations. Fix and refactor views. Refs #428

This commit is contained in:
Pavel Chipiga 2012-05-06 00:43:04 +03:00
parent 8819d0845a
commit 52f5e01575
6 changed files with 23 additions and 30 deletions

View File

@ -1,5 +1,5 @@
$(document).ready(function() {
$('#build_list_pl_id').change(function() {
$('#build_list_save_to_platform_id').change(function() {
var platform_id = $(this).val();
var base_platforms = $('.all_platforms input[type=checkbox].build_bpl_ids');
@ -15,7 +15,7 @@ $(document).ready(function() {
$(this).attr('checked', 'checked').removeAttr('disabled').trigger('change');
$(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled');
var rep_name = $('#build_list_pl_id option[value="' + $(this).val() + '"]').text().match(/[\w-]+\/([\w-]+)/)[1];
var rep_name = $('#build_list_save_to_platform_id option[value="' + $(this).val() + '"]').text().match(/[\w-]+\/([\w-]+)/)[1];
if (rep_name != 'main') {
$(this).parent().find('.offset25 input[type="checkbox"][rep_name="' + rep_name + '"]').attr('checked', 'checked');
}
@ -33,7 +33,7 @@ $(document).ready(function() {
setBranchSelected();
});
$('#build_list_pl_id').trigger('change');
$('#build_list_save_to_platform_id').trigger('change');
$('.offset25 label').click(function() {
setPlChecked($(this).prev()[0], !$(this).prev().attr('checked'));
@ -58,10 +58,10 @@ function setPlChecked(pointer, checked) {
}
function setBranchSelected() {
var pl_id = $('#build_list_pl_id').val();
var pl_id = $('#build_list_save_to_platform_id').val();
// Checks if selected platform is main or not:
if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) {
var pl_name = $('#build_list_pl_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1];
var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1];
var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]');
// If there is branch we need - set it selected:
if ( branch_pl_opt.size() > 0 ) {

View File

@ -40,7 +40,7 @@ class Projects::BuildListsController < Projects::BaseController
def create
notices, errors = [], []
@platform = Platform.find params[:build_list][:pl_id]
@platform = Platform.find params[:build_list][:save_to_platform_id]
params[:build_list][:auto_publish] = false if @platform.released
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform|
@ -49,7 +49,7 @@ class Projects::BuildListsController < Projects::BaseController
@build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user
@build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i}
@build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name, :save_to_platform => @build_list.save_to_platform}
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name}
if @build_list.save
notices << t("flash.build_list.saved", flash_options)
else

View File

@ -1,17 +1,16 @@
-set_meta_tags :title => [title_object(@project), t('layout.build_lists.new_header')]
= form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f|
%section.left
%h3= t("activerecord.attributes.build_list.build_for_platofrm")
%h3= t("activerecord.attributes.build_list.build_for_platform")
.all_platforms
- Platform.main.each do |pl|
- if pl.repository_ids.size > 0
.both
= check_box_tag "build_for_platforms[]", pl.id, (params[:build_for_platforms]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}", :'data-released' => pl.released ? 1 : 0
= label_tag "bpls_#{pl.id}", pl.name
.offset25{:style => 'padding-left: 25px'}
= render 'include_repos', :platform => pl
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
%section.right
%h3= t("activerecord.attributes.build_list.pl")
%h3= t("activerecord.attributes.build_list.save_to_platform")
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
%h3= t("activerecord.attributes.build_list.project_version")
- if controller.action_name == 'new'
@ -21,10 +20,7 @@
%h3= t("activerecord.attributes.build_list.arch")
- Arch.recent.each do |arch|
.both
- if controller.action_name == 'new'
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}", :checked => 'checked'
- else
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s) || controller.action_name == 'new', :id => "arches_#{arch.id}"
= label_tag "arches_#{arch.id}", arch.name
%h3= t("activerecord.attributes.build_list.update_type")
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES

View File

@ -18,10 +18,8 @@ en:
additional_repos: Additional repositories
include_repos: Included repositories
created_at: Created on
pl: Repository for package storage
pl_id: Repository for package storage
bpl: Platform
bpl_id: Platform
save_to_platform: Repository for package storage
build_for_platform: Platform
update_type: Update type
build_requires: Build with all the required packages
auto_publish: Automated publising
@ -111,8 +109,8 @@ en:
flash:
build_list:
saved: Build list for project version '%{project_version}', platform '%{bpl}' and architecture '%{arch}' has been created successfully
save_error: Build list for project version '%{project_version}', platform '%{bpl}' and architecture '%{arch}' could not been created
saved: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' has been created successfully
save_error: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' could not been created
no_project_version_selected: Select any version of the project
no_project_version_found: Project version '%{project_version}' not found
no_arch_or_platform_selected: At least one of architecture of platform must selected

View File

@ -18,10 +18,8 @@ ru:
additional_repos: Дополнительные репозитории
include_repos: Подключаемые репозитории
created_at: Создан
pl: Репозиторий для сохранения пакетов
pl_id: Репозиторий для сохранения пакетов
bpl: Платформа
bpl_id: Платформа
save_to_platform: Репозиторий для сохранения пакетов
build_for_platform: Платформа
update_type: Критичность обновления
build_requires: Пересборка с зависимостями
auto_publish: Автоматическая публикация
@ -110,8 +108,8 @@ ru:
flash:
build_list:
saved: Билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' создан успешно
save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}'
saved: Билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' создан успешно
save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}'
no_project_version_selected: Выберите какую-нибудь версию
no_project_version_found: Выбранная версия '%{project_version}' не найдена
no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу

View File

@ -205,7 +205,7 @@ ActiveRecord::Schema.define(:version => 20120505101650) do
t.string "owner_type"
t.string "visibility", :default => "open", :null => false
t.string "platform_type", :default => "main", :null => false
t.string "distrib_type"
t.string "distrib_type", :null => false
end
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
@ -276,11 +276,11 @@ ActiveRecord::Schema.define(:version => 20120505101650) do
t.text "description"
t.string "ancestry"
t.boolean "has_issues", :default => true
t.boolean "has_wiki", :default => false
t.string "srpm_file_name"
t.string "srpm_content_type"
t.integer "srpm_file_size"
t.datetime "srpm_updated_at"
t.boolean "has_wiki", :default => false
t.string "default_branch", :default => "master"
t.boolean "is_rpm", :default => true
t.integer "average_build_time", :default => 0, :null => false
@ -302,6 +302,7 @@ ActiveRecord::Schema.define(:version => 20120505101650) do
end
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
create_table "relations", :force => true do |t|
t.integer "actor_id"
@ -350,13 +351,13 @@ ActiveRecord::Schema.define(:version => 20120505101650) do
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "uname"
t.string "role"
t.string "language", :default => "en"
t.datetime "reset_password_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.text "professional_experience"
t.string "site"