#757: add migration, update UI, JS

This commit is contained in:
Vokhmin Alexey V 2013-02-18 19:43:30 +04:00
parent 7efae107eb
commit 20691dabc5
11 changed files with 83 additions and 9 deletions

View File

@ -34,6 +34,18 @@ $(document).ready(function() {
}); });
$('#build_list_save_to_repository_id').trigger('change'); $('#build_list_save_to_repository_id').trigger('change');
$('#extra-repos-and-containers #add').click(function() {
var id = $('#extra_repo_field').val();
if (id.length > 0) {
$.get("/build_lists/add_extra", { extra_id: id })
.done(function(data) {
$("#extra-repos-and-containers table tbody").append(data);
});
}
return false;
});
}); });
function setBranchSelected(selected_option) { function setBranchSelected(selected_option) {

View File

@ -1785,3 +1785,8 @@ div.right.slim {
font-size: 10px; font-size: 10px;
} }
} }
#extra-repos-and-containers {
width: 330px;
.actions { width: 50px; }
}

View File

@ -112,6 +112,25 @@ class Projects::BuildListsController < Projects::BaseController
} }
end end
def autocomplete_to_extra
platforms = Platform.includes(:repositories).search(params[:term]).search_order.limit(5)
results = []
platforms.each{ |p| p.repositories.each{ |r| results << {id: r.id, label: "#{p.name}/#{r.name}", value: "#{p.name}/#{r.name}"} } }
bl = BuildList.where(id: params[:term]).first
results << {id: "#{bl.id}-build-list", value: bl.id, label: 'Build list'} if bl
render json: results.to_json
end
def add_extra
if params[:extra_id] =~ /-build-list$/
subject = BuildList.find(params[:extra_id].gsub(/-build-list$/, ''))
else
subject = Repository.find params[:extra_id]
end
render partial: 'extra', locals: {subject: subject}
end
protected protected
def find_build_list def find_build_list

View File

@ -47,7 +47,8 @@ class BuildList < ActiveRecord::Base
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash, attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
:arch_id, :project_id, :save_to_repository_id, :update_type, :arch_id, :project_id, :save_to_repository_id, :update_type,
:save_to_platform_id, :project_version, :use_save_to_repository :save_to_platform_id, :project_version, :use_save_to_repository,
:auto_create_container, :extra_repositories, :extra_containers
LIVE_TIME = 4.week # for unpublished LIVE_TIME = 4.week # for unpublished
MAX_LIVE_TIME = 3.month # for published MAX_LIVE_TIME = 3.month # for published

View File

@ -0,0 +1,7 @@
%tr
- if subject.is_a?(BuildList)
%td= link_to subject.id, subject
- else
%td= link_to "#{subject.platform.name}/#{subject.name}", [subject.platform, subject]
%td.actions
%span.delete &nbsp;

View File

@ -22,13 +22,27 @@
= label_tag "arches_#{arch.id}", arch.name = label_tag "arches_#{arch.id}", arch.name
%h3= t("activerecord.attributes.build_list.update_type") %h3= t("activerecord.attributes.build_list.update_type")
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES .lineForm= f.select :update_type, BuildList::UPDATE_TYPES
#extra-repos-and-containers
%h3= t("activerecord.attributes.build_list.extra_repos")
= autocomplete_field_tag 'extra_repos', nil, autocomplete_to_extra_build_lists_path, :id_element => '#extra_repo_field'
= hidden_field_tag 'extra_repo', nil, :id => 'extra_repo_field'
= submit_tag t("layout.add"), :class => 'button', :id => 'add'
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
%tbody
- Repository.where(id: @build_list.extra_repositories).each do |repo|
= render 'extra', subject: repo
- BuildList.where(id: @build_list.extra_containers).each do |bl|
= render 'extra', subject: bl
%h3= t("activerecord.attributes.build_list.preferences") %h3= t("activerecord.attributes.build_list.preferences")
.both - [:auto_publish, :auto_create_container, :use_save_to_repository].each do |kind|
= f.check_box :auto_publish .both
= f.label :auto_publish = f.check_box kind
.both = f.label kind
= f.check_box :use_save_to_repository
= f.label :use_save_to_repository
%br %br
= f.submit t("layout.projects.build_button") = f.submit t("layout.projects.build_button")

View File

@ -7,6 +7,7 @@ en:
build_list: build_list:
bs_id: Id bs_id: Id
name: Name name: Name
extra_repos: Extra repositories and containers
container_path: Container path container_path: Container path
status: Status status: Status
project_id: Project project_id: Project

View File

@ -7,6 +7,7 @@ ru:
build_list: build_list:
bs_id: Id bs_id: Id
name: Название name: Название
extra_repos: Дополнительные репозитории и контейнеры
container_path: Путь до контейнера container_path: Путь до контейнера
status: Статус status: Статус
project_id: Проект project_id: Проект

View File

@ -220,7 +220,11 @@ Rosa::Application.routes.draw do
put :create_container put :create_container
get :log get :log
end end
collection { post :search } collection {
get :autocomplete_to_extra
get :add_extra
post :search
}
end end
resources :projects, :only => [:index, :new, :create] resources :projects, :only => [:index, :new, :create]

View File

@ -0,0 +1,7 @@
class AddExtraRepositoriesAndContainersToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :auto_create_container, :boolean
add_column :build_lists, :extra_repositories, :text
add_column :build_lists, :extra_containers, :text
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130214101404) do ActiveRecord::Schema.define(:version => 20130218135847) do
create_table "activity_feeds", :force => true do |t| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -134,6 +134,9 @@ ActiveRecord::Schema.define(:version => 20130214101404) do
t.string "last_published_commit_hash" t.string "last_published_commit_hash"
t.integer "container_status" t.integer "container_status"
t.boolean "use_save_to_repository", :default => true t.boolean "use_save_to_repository", :default => true
t.boolean "auto_create_container"
t.text "extra_repositories"
t.text "extra_containers"
end end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"