From 2362d7073d79d40a1c3fb32b835ba3f0a617daaa Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 30 Jul 2013 17:31:54 +0600 Subject: [PATCH 01/24] [#242] add ability to recreate build list --- app/controllers/projects/build_lists_controller.rb | 11 +++++++++++ .../build_lists/_recreate_build_list.html.haml | 5 +++++ app/views/projects/build_lists/show.html.haml | 2 ++ config/locales/models/build_list.en.yml | 2 ++ config/locales/models/build_list.ru.yml | 2 ++ 5 files changed, 22 insertions(+) create mode 100644 app/views/projects/build_lists/_recreate_build_list.html.haml diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 64b1cbd91..1969affae 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -49,6 +49,17 @@ class Projects::BuildListsController < Projects::BaseController def create notices, errors = [], [] + if params[:build_list_id] + build_list = BuildList.find params[:build_list_id] + params[:build_list][:save_to_repository_id] = build_list.save_to_repository_id + params[:build_list][:auto_publish] = build_list.auto_publish + params[:build_list][:include_repos] = build_list.include_repos + params[:arches] = build_list.arch_id + params[:build_list][:project_version] = build_list.project_version + params[:build_list][:update_type] = build_list.update_type + params[:build_list][:auto_create_container] = build_list.auto_create_container + end + @repository = Repository.find params[:build_list][:save_to_repository_id] @platform = @repository.platform diff --git a/app/views/projects/build_lists/_recreate_build_list.html.haml b/app/views/projects/build_lists/_recreate_build_list.html.haml new file mode 100644 index 000000000..d6ce8ff0c --- /dev/null +++ b/app/views/projects/build_lists/_recreate_build_list.html.haml @@ -0,0 +1,5 @@ += form_for [build_list.project, build_list.project.build_lists.new], :html => { :class => :form, :method => :post } do |f| + = hidden_field_tag :build_list_id, build_list.id + = f.hidden_field :project_id + = f.submit t('layout.build_lists.recreate_build_list'), :data => {'disable-with' => t('layout.processing')} +.both \ No newline at end of file diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 7ed8b42a7..d73623312 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -163,6 +163,8 @@ - if @build_list.can_create_container? && can?(:create_container, @build_list) = link_to t("layout.build_lists.create_container"), create_container_build_list_path(@build_list), :method => :put, :confirm => t("layout.confirm"), :class => 'button create_container' + .both += render('recreate_build_list', :build_list => @build_list) if can?(:create, @build_list) .hr %h3= t("layout.build_lists.items_header") diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index f580afe8a..2104441eb 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -152,6 +152,8 @@ en: show_filter: Show filters hide_filter: Hide filters + recreate_build_list: Recreate Build List + flash: build_list: saved: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' has been created successfully diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 23a209291..2c8d0c8ff 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -151,6 +151,8 @@ ru: show_filter: Показать фильтры hide_filter: Скрыть фильтры + recreate_build_list: Пересоздать сборку + flash: build_list: saved: Билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' создан успешно From eb184a8156a941096c2f1c1802eef7bb92bdafdd Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 31 Jul 2013 20:57:02 +0600 Subject: [PATCH 02/24] [#242] create build list from existing --- .../projects/build_lists_controller.rb | 25 +++++++++++++------ .../build_lists/_include_repos.html.haml | 4 ++- app/views/projects/build_lists/new.html.haml | 15 ++++++----- app/views/projects/build_lists/show.html.haml | 4 +-- app/views/shared/_autocomplete_form.html.haml | 2 +- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 1969affae..cfc019472 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -44,6 +44,10 @@ class Projects::BuildListsController < Projects::BaseController end def new + if params[:build_list_id] + @build_list = BuildList.find params[:build_list_id] + set_params @build_list + end end def create @@ -51,13 +55,7 @@ class Projects::BuildListsController < Projects::BaseController if params[:build_list_id] build_list = BuildList.find params[:build_list_id] - params[:build_list][:save_to_repository_id] = build_list.save_to_repository_id - params[:build_list][:auto_publish] = build_list.auto_publish - params[:build_list][:include_repos] = build_list.include_repos - params[:arches] = build_list.arch_id - params[:build_list][:project_version] = build_list.project_version - params[:build_list][:update_type] = build_list.update_type - params[:build_list][:auto_create_container] = build_list.auto_create_container + set_params build_list end @repository = Repository.find params[:build_list][:save_to_repository_id] @@ -168,4 +166,17 @@ class Projects::BuildListsController < Projects::BaseController def find_build_list @build_list = BuildList.find(params[:id]) end + + def set_params build_list + params[:build_list] ||= {} + params[:build_list][:save_to_repository_id] = build_list.save_to_repository_id + params[:build_list][:auto_publish] = build_list.auto_publish + params[:build_list][:include_repos] = build_list.include_repos + params[:arches] = [build_list.arch_id.to_s] + params[:build_list][:project_version] = build_list.project_version + params[:build_list][:update_type] = build_list.update_type + params[:build_list][:auto_create_container] = build_list.auto_create_container + params[:build_list][:extra_repositories] = build_list.extra_repositories + params[:build_list][:extra_build_lists] = build_list.extra_build_lists + end end diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index b85263183..a8a2a1463 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -1,4 +1,6 @@ - Repository.custom_sort(platform.repositories).each do |repo| .both - = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :rep_name => repo.name + = check_box_tag "build_list[include_repos][]", repo.id, + (params[:build_list].try(:fetch, :include_repos) || []).include?(repo.id.to_s) || (repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id)), + :id => "include_repos_#{repo.id}", :rep_name => repo.name = label_tag "include_repos_#{repo.id}", repo.name diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 1d672b730..820465b98 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -1,5 +1,5 @@ -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| += form_for new_project_build_list_path(@project), :html => { :class => :form, :method => :post } do |f| %section.left %h3= t("activerecord.attributes.build_list.build_for_platform") .all_platforms @@ -8,8 +8,9 @@ %div{:id => "build_for_pl_#{pl.id}", :class => 'build_for_pl'}= pl.name .offset25= render 'include_repos', :platform => pl %section.right - %h3= t("activerecord.attributes.build_list.save_to_repository") - .lineForm= f.select :save_to_repository_id, save_to_repositories(@project) + %h3= t('activerecord.attributes.build_list.save_to_repository') + - selected = params[:build_list].try(:fetch, :save_to_repository_id) ? {:selected => params[:build_list][:save_to_repository_id]} : nil + .lineForm= f.select :save_to_repository_id, save_to_repositories(@project), selected %h3= t("activerecord.attributes.build_list.project_version") .lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || @project.default_branch %h3= t("activerecord.attributes.build_list.arch") @@ -17,8 +18,9 @@ .both = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s) || (controller.action_name == 'new' && %w(i586 x86_64).include?(arch.name)), :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 + %h3= t('activerecord.attributes.build_list.update_type') + - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : nil + .lineForm= f.select :update_type, BuildList::UPDATE_TYPES, selected = render 'shared/autocomplete_form', :field => :extra_repositories, @@ -37,7 +39,8 @@ %h3= t("activerecord.attributes.build_list.preferences") - [:auto_publish, :auto_create_container].each do |kind| .both - = f.check_box kind + - checked = params[:build_list].try(:fetch, kind) + = check_box_tag "build_list[#{kind}]", checked, checked = f.label kind %br = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index d73623312..ca48b700b 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -163,8 +163,8 @@ - if @build_list.can_create_container? && can?(:create_container, @build_list) = link_to t("layout.build_lists.create_container"), create_container_build_list_path(@build_list), :method => :put, :confirm => t("layout.confirm"), :class => 'button create_container' - .both -= render('recreate_build_list', :build_list => @build_list) if can?(:create, @build_list) + - if can? :create, @build_list + = link_to t('layout.build_lists.recreate_build_list'), new_project_build_list_path(@build_list.project, :build_list_id => @build_list.id), :class => 'button' .hr %h3= t("layout.build_lists.items_header") diff --git a/app/views/shared/_autocomplete_form.html.haml b/app/views/shared/_autocomplete_form.html.haml index 9abe40b05..20fe567cf 100644 --- a/app/views/shared/_autocomplete_form.html.haml +++ b/app/views/shared/_autocomplete_form.html.haml @@ -24,7 +24,7 @@ %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} %tbody - field_name = "#{subject_class}[#{field}][]" - - field_class.where(:id => subject.send(field)).each do |extra| + - field_class.where(:id => params[:build_list].try(:fetch, field) || subject.send(field)).each do |extra| %tr - if extra.is_a?(BuildList) %td= link_to "#{extra.id} (#{extra.project.name} - #{extra.arch.name})", extra From 029273328c8ddddbbe67c13981a4afd72c9a31bc Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 31 Jul 2013 21:10:00 +0600 Subject: [PATCH 03/24] small refactoring build lists controller --- .../projects/build_lists_controller.rb | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index cfc019472..99d71dfde 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -122,36 +122,24 @@ class Projects::BuildListsController < Projects::BaseController end @build_list.publisher = current_user - if @build_list.publish - redirect_to :back, :notice => t('layout.build_lists.publish_success') - else - redirect_to :back, :notice => t('layout.build_lists.publish_fail') - end + message = @build_list.publish ? 'success' : 'fail' + redirect_to :back, :notice => t("layout.build_lists.publish_#{message}") end def reject_publish @build_list.publisher = current_user - if @build_list.reject_publish - redirect_to :back, :notice => t('layout.build_lists.reject_publish_success') - else - redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail') - end + message = @build_list.reject_publish ? 'success' : 'fail' + redirect_to :back, :notice => t("layout.build_lists.reject_publish_#{message}") end def create_container - if @build_list.publish_container - redirect_to :back, :notice => t('layout.build_lists.create_container_success') - else - redirect_to :back, :notice => t('layout.build_lists.create_container_fail') - end + message = @build_list.publish_container ? 'success' : 'fail' + redirect_to :back, :notice => t("layout.build_lists.create_container_#{message}") end def cancel - if @build_list.cancel - redirect_to :back, :notice => t('layout.build_lists.will_be_canceled') - else - redirect_to :back, :notice => t('layout.build_lists.cancel_fail') - end + message = @build_list.cancel ? 'will_be_canceled' : 'cancel_fail' + redirect_to :back, :notice => t("layout.build_lists.#{message}") end def log From aad9a0a3afc0d2914848a01bcaba50e22c97b444 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 01:32:24 +0600 Subject: [PATCH 04/24] [#242] add last build lists list in the new page --- .../build_lists/_last_build_lists.html.haml | 37 +++++++++++++++++++ app/views/projects/build_lists/new.html.haml | 13 ++++--- config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + 4 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 app/views/projects/build_lists/_last_build_lists.html.haml diff --git a/app/views/projects/build_lists/_last_build_lists.html.haml b/app/views/projects/build_lists/_last_build_lists.html.haml new file mode 100644 index 000000000..03f66c5fc --- /dev/null +++ b/app/views/projects/build_lists/_last_build_lists.html.haml @@ -0,0 +1,37 @@ +.all + %h3= t 'layout.build_list.last_build_lists' + -#.lineForm= select_tag :last_build_lists, last_build_lists(@project) + + %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th.lpadding6= t('layout.clone') + %th.lpadding16= t('activerecord.attributes.build_list.status') + %th.lpadding16= t('diff') + %th.lpadding16= t('activerecord.attributes.build_list.project_version') + %th.lpadding16= t('activerecord.attributes.build_list.save_to_repository') + %th.lpadding6= t('activerecord.attributes.build_list.arch_short') + %th.lpadding16= t('activerecord.attributes.build_list.user') + %th.lpadding6= t('activerecord.attributes.build_list.updated_at') + %tbody + - project.build_lists.recent.last(20).each do |build_list| + %tr{:class => "#{build_list_status_color(build_list.status)}"} + %td= link_to t('layout.clone'), new_project_build_list_path(project, :build_list_id => build_list.id) + %td + = build_list.human_status + %br + - if BuildList::HUMAN_STATUSES[build_list.status].in? [:build_pending, :build_started, :build_publish] + %time.js-relative-date{:datetime => build_list.updated_at.strftime("%FT%T%:z"), :title => build_list.updated_at.strftime("%F %T")} + = build_list.updated_at.strftime "%F %T" + - if build_list.build_started? && ((build_list.project.average_build_time || 0) > 0) + \/ + %time + = build_list.project.formatted_average_build_time + %td= build_list_version_link(build_list) + %td= get_version_release build_list + -build_for=" (#{build_list.build_for_platform.name})" if build_list.build_for_platform && build_list.save_to_platform.personal? + %td= link_to "#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}#{build_for}", [build_list.save_to_platform, build_list.save_to_repository] + %td= build_list.arch.try(:name) || t("layout.arches.unexisted_arch") + %td= link_to build_list.user.try(:fullname), build_list.user + %td= build_list.updated_at.strftime('%d/%m/%Y') + .both diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 820465b98..da9e38351 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -9,18 +9,18 @@ .offset25= render 'include_repos', :platform => pl %section.right %h3= t('activerecord.attributes.build_list.save_to_repository') - - selected = params[:build_list].try(:fetch, :save_to_repository_id) ? {:selected => params[:build_list][:save_to_repository_id]} : nil - .lineForm= f.select :save_to_repository_id, save_to_repositories(@project), selected + - selected = params[:build_list].try(:fetch, :save_to_repository_id) ? {:selected => params[:build_list][:save_to_repository_id]} : {} + .lineForm= f.select :save_to_repository_id, save_to_repositories(@project), selected, :id => 'build_list_save_to_repository_id' %h3= t("activerecord.attributes.build_list.project_version") - .lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || @project.default_branch + .lineForm= f.select :project_version, versions_for_group_select(@project), {}, :selected => params[:build_list].try(:fetch, :project_version) || @project.default_branch, :id => 'build_list_project_version' %h3= t("activerecord.attributes.build_list.arch") - Arch.recent.each do |arch| .both = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s) || (controller.action_name == 'new' && %w(i586 x86_64).include?(arch.name)), :id => "arches_#{arch.id}" = label_tag "arches_#{arch.id}", arch.name %h3= t('activerecord.attributes.build_list.update_type') - - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : nil - .lineForm= f.select :update_type, BuildList::UPDATE_TYPES, selected + - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : {} + .lineForm= f.select :update_type, BuildList::UPDATE_TYPES, selected, :id => 'build_list_update_types' = render 'shared/autocomplete_form', :field => :extra_repositories, @@ -46,4 +46,5 @@ = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} .both %br -= render 'projects/base/submenu' \ No newline at end of file += render 'last_build_lists', :project => @project += render 'projects/base/submenu' diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 2104441eb..bc076589e 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -152,6 +152,7 @@ en: show_filter: Show filters hide_filter: Hide filters + last_build_lists: Last Build Lists recreate_build_list: Recreate Build List flash: diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 2c8d0c8ff..1364975ab 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -151,6 +151,7 @@ ru: show_filter: Показать фильтры hide_filter: Скрыть фильтры + last_build_lists: Последние сборки recreate_build_list: Пересоздать сборку flash: From 55b10231466c94b999c58dab4905fe93bc53c190 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 15:47:56 +0600 Subject: [PATCH 05/24] [#242] fix translation --- app/views/projects/build_lists/_last_build_lists.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_last_build_lists.html.haml b/app/views/projects/build_lists/_last_build_lists.html.haml index 03f66c5fc..4c8d37db4 100644 --- a/app/views/projects/build_lists/_last_build_lists.html.haml +++ b/app/views/projects/build_lists/_last_build_lists.html.haml @@ -1,5 +1,5 @@ .all - %h3= t 'layout.build_list.last_build_lists' + %h3= t 'layout.build_lists.last_build_lists' -#.lineForm= select_tag :last_build_lists, last_build_lists(@project) %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} From ed316e6056169a4a1d5a3f6d53914dff006b55da Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 18:01:58 +0600 Subject: [PATCH 06/24] [#242] remove autocomplete form when clone from the build list --- app/assets/javascripts/extra/build_list.js | 7 ++++--- app/views/projects/build_lists/new.html.haml | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 2bba78d7c..39f62ec98 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -1,6 +1,6 @@ $(document).ready(function() { // TODO: Refactor this handler!! It's too complicated. - $('#build_list_save_to_repository_id').change(function() { + $('#build_list_save_to_repository_id').on("change", function() { var selected_option = $(this).find("option:selected"); var platform_id = selected_option.attr('platform_id'); @@ -40,8 +40,9 @@ $(document).ready(function() { } }); - $('#build_list_save_to_repository_id').trigger('change'); - + if($('#from_build_list_id').size() > 0) { + $('#build_list_save_to_repository_id').trigger('change'); + } var ownership_btn = $('.btn.ownership'); ownership_btn.click(function() { diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 00efe7b6c..68e9f9965 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -16,7 +16,8 @@ %h3= t("activerecord.attributes.build_list.arch") - Arch.recent.each do |arch| .both - = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s) || (controller.action_name == 'new' && Arch::DEFAULT.include?(arch.name)), :id => "arches_#{arch.id}" + - checked = (params[:arches]||[]).include?(arch.id.to_s) || (params[:arches].blank? && controller.action_name == 'new' && Arch::DEFAULT.include?(arch.name)) + = check_box_tag "arches[]", arch.id, checked, :id => "arches_#{arch.id}" = label_tag "arches_#{arch.id}", arch.name %h3= t('activerecord.attributes.build_list.update_type') - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : {} @@ -43,6 +44,7 @@ = check_box_tag "build_list[#{kind}]", checked, checked = f.label kind %br + = hidden_field_tag :from_build_list_id, params[:build_list_id] = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} .both %br From f416bd9071c626130c2a121e894a4a14ee03fc49 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 23:18:46 +0600 Subject: [PATCH 07/24] [#242] use datatable --- app/assets/javascripts/extra/build_list.js | 6 +- .../projects/build_lists_controller.rb | 20 ++++++ app/models/ability.rb | 4 +- .../_build_lists_ajax.json.jbuilder | 20 ++++++ .../build_lists/_last_build_lists.html.haml | 70 +++++++++++-------- config/locales/models/build_list.en.yml | 2 + config/locales/models/build_list.ru.yml | 2 + config/routes.rb | 5 +- 8 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 app/views/projects/build_lists/_build_lists_ajax.json.jbuilder diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 39f62ec98..f21850c79 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -40,7 +40,7 @@ $(document).ready(function() { } }); - if($('#from_build_list_id').size() > 0) { + if($('#from_build_list_id').size() == 0) { $('#build_list_save_to_repository_id').trigger('change'); } @@ -77,6 +77,10 @@ $(document).ready(function() { dateFormat: 'dd/mm/yy', showButtonPanel: true }); + + $('#owner_filter_build_lists, #status_filter_build_lists').live('change', function(){ + $('#datatable').dataTable().fnDraw(); + }); }); function updatedDefaultArches(selected_option) { diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 99d71dfde..97a26dce4 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -149,6 +149,25 @@ class Projects::BuildListsController < Projects::BaseController } end + def list + @build_lists = @project.build_lists + sort_col = params[:ol_0] || 7 + sort_dir = params[:sSortDir_0] == 'asc' ? 'asc' : 'desc' + order = "build_lists.updated_at #{sort_dir}" + + @build_lists = @build_lists.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength]) + @total_build_lists = @build_lists.count + #if !params[:sSearch].blank? && search = "%#{params[:sSearch]}%" + # @users = @users.where('users.name ILIKE ? or users.uname ILIKE ? or users.email ILIKE ?', search, search, search) + #end + @build_lists = @build_lists.where(:user_id => current_user) if params[:owner_filter] == 'true' + @build_lists = @build_lists.where(:status => [BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH]) if params[:status_filter] == 'true' + @build_lists = @build_lists.order(order) + + render :partial => 'build_lists_ajax', :layout => false + end + + protected def find_build_list @@ -166,5 +185,6 @@ class Projects::BuildListsController < Projects::BaseController params[:build_list][:auto_create_container] = build_list.auto_create_container params[:build_list][:extra_repositories] = build_list.extra_repositories params[:build_list][:extra_build_lists] = build_list.extra_build_lists + [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 404e063ae..3a4d89c10 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -80,7 +80,7 @@ class Ability can [:read, :log, :owned, :everything], BuildList, :user_id => user.id can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} - can([:read, :log, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} + can([:read, :log, :everything, :list], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} can(:create, BuildList) {|build_list| build_list.project.is_package && @@ -213,7 +213,7 @@ class Ability # relations.actor_type = 'User' AND relations.actor_id = :user OR # relations.actor_type = 'Group' AND relations.actor_id IN (:groups) # ) - + # )", # { # :target_type => parent.classify, diff --git a/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder new file mode 100644 index 000000000..0631575f6 --- /dev/null +++ b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder @@ -0,0 +1,20 @@ +build_lists = @build_lists.map do |build_list| + build_for = " (#{build_list.build_for_platform.name})" if build_list.build_for_platform && build_list.save_to_platform.personal? + [ + [link_to(build_list.id, build_list_path(build_list)), + link_to(t('layout.clone'), new_project_build_list_path(@project, :build_list_id => build_list.id)) + ].join('
').html_safe, + build_list.human_status, + build_list_version_link(build_list), + get_version_release(build_list), + link_to("#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}#{build_for}", [build_list.save_to_platform, build_list.save_to_repository]), + build_list.arch.try(:name) || t('layout.arches.unexisted_arch'), + link_to(build_list.user.try(:fullname), build_list.user), + build_list.updated_at.strftime('%d/%m/%Y') + ] +end + +json.sEcho params[:sEcho].to_i || -1 +json.iTotalRecords @total_build_lists +json.iTotalDisplayRecords @build_lists.count +json.aaData build_lists diff --git a/app/views/projects/build_lists/_last_build_lists.html.haml b/app/views/projects/build_lists/_last_build_lists.html.haml index 4c8d37db4..e3a612f7b 100644 --- a/app/views/projects/build_lists/_last_build_lists.html.haml +++ b/app/views/projects/build_lists/_last_build_lists.html.haml @@ -1,37 +1,45 @@ .all %h3= t 'layout.build_lists.last_build_lists' - -#.lineForm= select_tag :last_build_lists, last_build_lists(@project) + %h4= t 'layout.relations.filters' + .both + = check_box_tag :owner_filter_build_lists, true, params[:owner_filter] == 'true' + = label_tag t('layout.build_lists.only_my_build_lists') + .both + = check_box_tag :status_filter_build_lists, true, params[:status_filter] == 'true' + = label_tag t('layout.build_lists.failed_build_lists') - %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} + - default_column = {:type => 'html', :sortable => false, :searchable => false} + - columns = [default_column, + default_column, + default_column, + default_column, + default_column, + default_column, + default_column, + default_column] + = raw datatable(columns, {:sort_by => "[7, 'asc']", :processing => t('layout.processing'), :search => 'false', + :pagination_labels => {:previous => t('datatables.previous_label'), :next => t('datatables.next_label')}, + :empty_label => t('datatables.empty_label'), + :info_label => t('datatables.info_label'), + :info_empty_label => t('datatables.info_empty_label'), + :filtered_label => t('datatables.filtered_label'), + :table_dom_id => 'datatable', + :auto_width => 'false', + :ajax_source => "#{url_for :controller => 'projects/build_lists', :action => :list}", + :additional_data => {:owner_filter => "' + $('#owner_filter_build_lists:checked').val() + '", + :status_filter => "' + $('#status_filter_build_lists:checked').val() + '"} }) + + %table#datatable.tablesorter.list-users{:cellspacing => 0, :cellpadding => 0} %thead %tr - %th.lpadding6= t('layout.clone') - %th.lpadding16= t('activerecord.attributes.build_list.status') - %th.lpadding16= t('diff') - %th.lpadding16= t('activerecord.attributes.build_list.project_version') - %th.lpadding16= t('activerecord.attributes.build_list.save_to_repository') - %th.lpadding6= t('activerecord.attributes.build_list.arch_short') - %th.lpadding16= t('activerecord.attributes.build_list.user') - %th.lpadding6= t('activerecord.attributes.build_list.updated_at') + %th.th1= t('activerecord.attributes.build_list.id') + %th.th2= t('activerecord.attributes.build_list.status') + %th.th2= t('diff') + %th.th2= t('activerecord.attributes.build_list.project_version') + %th.th2= t('activerecord.attributes.build_list.save_to_repository') + %th.th1= t('activerecord.attributes.build_list.arch_short') + %th.th2= t('activerecord.attributes.build_list.user') + %th.th1= t('activerecord.attributes.build_list.updated_at') %tbody - - project.build_lists.recent.last(20).each do |build_list| - %tr{:class => "#{build_list_status_color(build_list.status)}"} - %td= link_to t('layout.clone'), new_project_build_list_path(project, :build_list_id => build_list.id) - %td - = build_list.human_status - %br - - if BuildList::HUMAN_STATUSES[build_list.status].in? [:build_pending, :build_started, :build_publish] - %time.js-relative-date{:datetime => build_list.updated_at.strftime("%FT%T%:z"), :title => build_list.updated_at.strftime("%F %T")} - = build_list.updated_at.strftime "%F %T" - - if build_list.build_started? && ((build_list.project.average_build_time || 0) > 0) - \/ - %time - = build_list.project.formatted_average_build_time - %td= build_list_version_link(build_list) - %td= get_version_release build_list - -build_for=" (#{build_list.build_for_platform.name})" if build_list.build_for_platform && build_list.save_to_platform.personal? - %td= link_to "#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}#{build_for}", [build_list.save_to_platform, build_list.save_to_repository] - %td= build_list.arch.try(:name) || t("layout.arches.unexisted_arch") - %td= link_to build_list.user.try(:fullname), build_list.user - %td= build_list.updated_at.strftime('%d/%m/%Y') - .both + %br + diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index bc076589e..49692f3c2 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -154,6 +154,8 @@ en: last_build_lists: Last Build Lists recreate_build_list: Recreate Build List + only_my_build_lists: Only My + failed_build_lists: Only Failed flash: build_list: diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 1364975ab..07af69158 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -153,6 +153,8 @@ ru: last_build_lists: Последние сборки recreate_build_list: Пересоздать сборку + only_my_build_lists: Только мои + failed_build_lists: Только сбойные flash: build_list: diff --git a/config/routes.rb b/config/routes.rb index ea1cfcdb3..e8ef1599a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -305,7 +305,10 @@ Rosa::Application.routes.draw do post "/labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label post "/labels/:label_id/update" => "issues#update_label", :as => :issues_update_label resources :build_lists, :only => [:index, :new, :create] do - collection { post :search } + collection { + post :search + get :list + } end resources :collaborators do get :find, :on => :collection From fb25e313c1699ea917c7ddd6f7f57a7e41fa0642 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 23:25:01 +0600 Subject: [PATCH 08/24] [#242] add a clone link into the monitoring page --- app/views/projects/build_lists/_build_list.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_build_list.html.haml b/app/views/projects/build_lists/_build_list.html.haml index 1b9476e79..a186a9f32 100644 --- a/app/views/projects/build_lists/_build_list.html.haml +++ b/app/views/projects/build_lists/_build_list.html.haml @@ -1,5 +1,7 @@ %tr{:id => "row#{build_list_counter}", :class => "#{build_list_status_color(build_list.status)}"} - %td= link_to build_list.id, build_list + %td= [link_to(build_list.id, build_list), + (link_to(t('layout.clone'), new_project_build_list_path(build_list.project, + :build_list_id => build_list.id)) if can?(:create, build_list))].compact.join('
').html_safe %td = build_list.human_status %br From 3290c91182ac9db8bf96c3ad19b3594701f0b288 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 1 Aug 2013 23:25:30 +0600 Subject: [PATCH 09/24] [#242] small refactoring --- app/views/projects/build_lists/_build_lists_ajax.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder index 0631575f6..a4c3a1011 100644 --- a/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder +++ b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder @@ -1,7 +1,7 @@ build_lists = @build_lists.map do |build_list| build_for = " (#{build_list.build_for_platform.name})" if build_list.build_for_platform && build_list.save_to_platform.personal? [ - [link_to(build_list.id, build_list_path(build_list)), + [link_to(build_list.id, build_list), link_to(t('layout.clone'), new_project_build_list_path(@project, :build_list_id => build_list.id)) ].join('
').html_safe, build_list.human_status, From b8954471a94d3cef63f28a7a0be0f9b7b1e54746 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sat, 3 Aug 2013 09:58:45 +0600 Subject: [PATCH 10/24] [#242] refactoring controller --- .../projects/build_lists_controller.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 97a26dce4..c32b6dda0 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -11,6 +11,8 @@ class Projects::BuildListsController < Projects::BaseController load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true load_and_authorize_resource :except => NESTED_ACTIONS + before_filter :create_from_build_list, :only => [:new, :create] + def search new_params = {:filter => {}} params[:filter].each do |k,v| @@ -44,27 +46,17 @@ class Projects::BuildListsController < Projects::BaseController end def new - if params[:build_list_id] - @build_list = BuildList.find params[:build_list_id] - set_params @build_list - end end def create notices, errors = [], [] - if params[:build_list_id] - build_list = BuildList.find params[:build_list_id] - set_params build_list - end - @repository = Repository.find params[:build_list][:save_to_repository_id] @platform = @repository.platform params[:build_list][:save_to_platform_id] = @platform.id params[:build_list][:auto_publish] = false unless @repository.publish_without_qa? - build_for_platforms = Repository.select(:platform_id). where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id) @@ -174,7 +166,10 @@ class Projects::BuildListsController < Projects::BaseController @build_list = BuildList.find(params[:id]) end - def set_params build_list + def create_from_build_list + return if params[:build_list_id] + @build_list = BuildList.find params[:build_list_id] + params[:build_list] ||= {} params[:build_list][:save_to_repository_id] = build_list.save_to_repository_id params[:build_list][:auto_publish] = build_list.auto_publish From 8de9411203f2d0a407325a32e054de7dcdf3045c Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 5 Aug 2013 15:33:59 +0600 Subject: [PATCH 11/24] [#242] refactoring controller --- app/controllers/projects/build_lists_controller.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index c32b6dda0..880a3ef33 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -171,15 +171,11 @@ class Projects::BuildListsController < Projects::BaseController @build_list = BuildList.find params[:build_list_id] params[:build_list] ||= {} - params[:build_list][:save_to_repository_id] = build_list.save_to_repository_id - params[:build_list][:auto_publish] = build_list.auto_publish - params[:build_list][:include_repos] = build_list.include_repos + keys = [:save_to_repository_id, :auto_publish, :include_repos, + :project_version, :update_type, :auto_create_container, + :extra_repositories, :extra_build_lists] + keys.each { |key| params[:build_list][key] = @build_list.send(key) } params[:arches] = [build_list.arch_id.to_s] - params[:build_list][:project_version] = build_list.project_version - params[:build_list][:update_type] = build_list.update_type - params[:build_list][:auto_create_container] = build_list.auto_create_container - params[:build_list][:extra_repositories] = build_list.extra_repositories - params[:build_list][:extra_build_lists] = build_list.extra_build_lists [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } end end From 541e1ebbe538b0423344136690fcc0ee6b1586bb Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 5 Aug 2013 17:21:30 +0600 Subject: [PATCH 12/24] [#242] fix last refactoring of the controller --- app/controllers/projects/build_lists_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 880a3ef33..0aa33bfc1 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -167,7 +167,7 @@ class Projects::BuildListsController < Projects::BaseController end def create_from_build_list - return if params[:build_list_id] + return if params[:build_list_id].blank? @build_list = BuildList.find params[:build_list_id] params[:build_list] ||= {} @@ -175,7 +175,7 @@ class Projects::BuildListsController < Projects::BaseController :project_version, :update_type, :auto_create_container, :extra_repositories, :extra_build_lists] keys.each { |key| params[:build_list][key] = @build_list.send(key) } - params[:arches] = [build_list.arch_id.to_s] + params[:arches] = [@build_list.arch_id.to_s] [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } end end From 6bebb3b156f50b7d5ff6e2e04d6cc70ec03f3291 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 00:34:42 +0600 Subject: [PATCH 13/24] [#242] add ajax clone --- .../javascripts/extra/autocomplete-form.js | 4 +- app/assets/javascripts/extra/build_list.js | 32 +++++++++--- .../projects/build_lists_controller.rb | 5 ++ .../_build_lists_ajax.json.jbuilder | 3 +- .../projects/build_lists/_new_form.html.haml | 49 +++++++++++++++++++ app/views/projects/build_lists/new.html.haml | 49 +------------------ app/views/shared/_autocomplete_form.html.haml | 5 +- 7 files changed, 86 insertions(+), 61 deletions(-) create mode 100644 app/views/projects/build_lists/_new_form.html.haml diff --git a/app/assets/javascripts/extra/autocomplete-form.js b/app/assets/javascripts/extra/autocomplete-form.js index 5de3ae488..9d92651d7 100644 --- a/app/assets/javascripts/extra/autocomplete-form.js +++ b/app/assets/javascripts/extra/autocomplete-form.js @@ -1,6 +1,6 @@ $(document).ready(function() { - $('.autocomplete-form .button.add').click(function() { + $(document).on('click', '.autocomplete-form .button.add', function() { var form = $(this).parent(); var field = form.attr('field'); var subject = $('#' + field + '_field'); @@ -24,7 +24,7 @@ $(document).ready(function() { width: 500 }); - $('.autocomplete-form .icon-question-sign').click(function() { + $(document).on('click', '.autocomplete-form .icon-question-sign', function() { var field = $(this).parent().attr('field'); var dialog = $('#' + field + '_dialog'); if (dialog.is(':visible')) { dialog.dialog('close'); } else { dialog.dialog('open'); } diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index f21850c79..47ea5a8c3 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -1,8 +1,11 @@ $(document).ready(function() { - // TODO: Refactor this handler!! It's too complicated. - $('#build_list_save_to_repository_id').on("change", function() { - var selected_option = $(this).find("option:selected"); + var new_form = $('#new_form'); + var ownership_btn = $('.btn.ownership'); + var perpage_btn = $('.btn.per_page'); + // TODO: Refactor this handler!! It's too complicated. + $(document).on('change', '#build_list_save_to_repository_id', function(){ + var selected_option = $(this).find("option:selected"); var platform_id = selected_option.attr('platform_id'); var rep_name = selected_option.text().match(/[\w-]+\/([\w-]+)/)[1]; @@ -44,7 +47,6 @@ $(document).ready(function() { $('#build_list_save_to_repository_id').trigger('change'); } - var ownership_btn = $('.btn.ownership'); ownership_btn.click(function() { ownership_btn.removeClass('active'); $('#filter_ownership').val($(this).val()); @@ -52,7 +54,6 @@ $(document).ready(function() { return false; }); - var perpage_btn = $('.btn.per_page'); perpage_btn.click(function() { perpage_btn.removeClass('active'); $('#per_page').val($(this).val()); @@ -78,9 +79,24 @@ $(document).ready(function() { showButtonPanel: true }); - $('#owner_filter_build_lists, #status_filter_build_lists').live('change', function(){ + $(document).on('change', '#owner_filter_build_lists, #status_filter_build_lists', function(){ $('#datatable').dataTable().fnDraw(); }); + + $(document).on('click', '#clone_build_list', function() { + $.ajax({ + type: 'GET', + url: $(this).attr('href') + '&show=inline', + success: function(data){ + new_form.html(data); + $(document).scrollTop(new_form.offset().top); + }, + error: function(data){ + alert('error') // TODO remove + } + }); + return false; + }); }); function updatedDefaultArches(selected_option) { @@ -107,7 +123,7 @@ function addPersonalPlatformToExtraRepos(selected_option, extra_repos) { default_value.attr('label'), default_value.attr('name'), default_value.attr('value') - ); + ); } function setBranchSelected(selected_option) { @@ -122,4 +138,4 @@ function setBranchSelected(selected_option) { // hack for FF to force render of select box. bl_version_sel[0].innerHTML = bl_version_sel[0].innerHTML; } -} \ No newline at end of file +} diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 0aa33bfc1..7cae0fd48 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -46,6 +46,11 @@ class Projects::BuildListsController < Projects::BaseController end def new + if params[:show] == 'inline' && params[:build_list_id].present? + render '_new_form', :layout => false, :locals => {:project => @project, :build_list => @build_list} + else + render :new + end end def create diff --git a/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder index a4c3a1011..128c1020d 100644 --- a/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder +++ b/app/views/projects/build_lists/_build_lists_ajax.json.jbuilder @@ -2,7 +2,8 @@ build_lists = @build_lists.map do |build_list| build_for = " (#{build_list.build_for_platform.name})" if build_list.build_for_platform && build_list.save_to_platform.personal? [ [link_to(build_list.id, build_list), - link_to(t('layout.clone'), new_project_build_list_path(@project, :build_list_id => build_list.id)) + link_to(t('layout.clone'), new_project_build_list_path(@project, :build_list_id => build_list.id), + :id => 'clone_build_list') ].join('
').html_safe, build_list.human_status, build_list_version_link(build_list), diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml new file mode 100644 index 000000000..0d1e33992 --- /dev/null +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -0,0 +1,49 @@ += form_for new_project_build_list_path(project), :html => { :class => :form, :method => :post } do |f| + %section.left + %h3= t("activerecord.attributes.build_list.build_for_platform") + .all_platforms + - availables_main_platforms.each do |pl| + .both + %div{:id => "build_for_pl_#{pl.id}", :class => 'build_for_pl'}= pl.name + .offset25= render 'include_repos', :platform => pl + %section.right + %h3= t('activerecord.attributes.build_list.save_to_repository') + - selected = params[:build_list].try(:fetch, :save_to_repository_id) ? {:selected => params[:build_list][:save_to_repository_id]} : {} + .lineForm= f.select :save_to_repository_id, save_to_repositories(project), selected, :id => 'build_list_save_to_repository_id' + %h3= t("activerecord.attributes.build_list.project_version") + .lineForm= f.select :project_version, versions_for_group_select(project), {}, :selected => params[:build_list].try(:fetch, :project_version) || project.default_branch, :id => 'build_list_project_version' + %h3= t("activerecord.attributes.build_list.arch") + - Arch.recent.each do |arch| + .both + - checked = (params[:arches]||[]).include?(arch.id.to_s) || (params[:arches].blank? && controller.action_name == 'new' && Arch::DEFAULT.include?(arch.name)) + = check_box_tag "arches[]", arch.id, checked, :id => "arches_#{arch.id}" + = label_tag "arches_#{arch.id}", arch.name + %h3= t('activerecord.attributes.build_list.update_type') + - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : {} + .lineForm= f.select :update_type, BuildList::UPDATE_TYPES, selected, :id => 'build_list_update_types' + + = render 'shared/autocomplete_form', + :field => :extra_repositories, + :field_class => Repository, + :placeholder => 'uxteam_personal', + :subject => @build_list, + :autocomplete_path => autocomplete_extra_repositories_autocompletes_path, + :default_values => project.repositories.select{ |r| r.platform.personal? } + = render 'shared/autocomplete_form', + :field => :extra_build_lists, + :field_class => BuildList, + :placeholder => '1000000', + :subject => build_list, + :autocomplete_path => autocomplete_extra_build_list_autocompletes_path + + %h3= t("activerecord.attributes.build_list.preferences") + - [:auto_publish, :auto_create_container].each do |kind| + .both + - checked = params[:build_list].try(:fetch, kind) + = check_box_tag "build_list[#{kind}]", checked, checked + = f.label kind + %br + = hidden_field_tag :from_build_list_id, params[:build_list_id] + = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} +.both + diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 68e9f9965..974f0e091 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -1,52 +1,5 @@ -set_meta_tags :title => [title_object(@project), t('layout.build_lists.new_header')] -= form_for new_project_build_list_path(@project), :html => { :class => :form, :method => :post } do |f| - %section.left - %h3= t("activerecord.attributes.build_list.build_for_platform") - .all_platforms - - availables_main_platforms.each do |pl| - .both - %div{:id => "build_for_pl_#{pl.id}", :class => 'build_for_pl'}= pl.name - .offset25= render 'include_repos', :platform => pl - %section.right - %h3= t('activerecord.attributes.build_list.save_to_repository') - - selected = params[:build_list].try(:fetch, :save_to_repository_id) ? {:selected => params[:build_list][:save_to_repository_id]} : {} - .lineForm= f.select :save_to_repository_id, save_to_repositories(@project), selected, :id => 'build_list_save_to_repository_id' - %h3= t("activerecord.attributes.build_list.project_version") - .lineForm= f.select :project_version, versions_for_group_select(@project), {}, :selected => params[:build_list].try(:fetch, :project_version) || @project.default_branch, :id => 'build_list_project_version' - %h3= t("activerecord.attributes.build_list.arch") - - Arch.recent.each do |arch| - .both - - checked = (params[:arches]||[]).include?(arch.id.to_s) || (params[:arches].blank? && controller.action_name == 'new' && Arch::DEFAULT.include?(arch.name)) - = check_box_tag "arches[]", arch.id, checked, :id => "arches_#{arch.id}" - = label_tag "arches_#{arch.id}", arch.name - %h3= t('activerecord.attributes.build_list.update_type') - - selected = params[:build_list].try(:fetch, :update_type) ? {:selected => params[:build_list][:update_version]} : {} - .lineForm= f.select :update_type, BuildList::UPDATE_TYPES, selected, :id => 'build_list_update_types' - - = render 'shared/autocomplete_form', - :field => :extra_repositories, - :field_class => Repository, - :placeholder => 'uxteam_personal', - :subject => @build_list, - :autocomplete_path => autocomplete_extra_repositories_autocompletes_path, - :default_values => @project.repositories.select{ |r| r.platform.personal? } - = render 'shared/autocomplete_form', - :field => :extra_build_lists, - :field_class => BuildList, - :placeholder => '1000000', - :subject => @build_list, - :autocomplete_path => autocomplete_extra_build_list_autocompletes_path - - %h3= t("activerecord.attributes.build_list.preferences") - - [:auto_publish, :auto_create_container].each do |kind| - .both - - checked = params[:build_list].try(:fetch, kind) - = check_box_tag "build_list[#{kind}]", checked, checked - = f.label kind - %br - = hidden_field_tag :from_build_list_id, params[:build_list_id] - = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} -.both +#new_form= render 'new_form', :project => @project, :build_list => @build_list %br = render 'last_build_lists', :project => @project = render 'projects/base/submenu' diff --git a/app/views/shared/_autocomplete_form.html.haml b/app/views/shared/_autocomplete_form.html.haml index 20fe567cf..1665a8aaf 100644 --- a/app/views/shared/_autocomplete_form.html.haml +++ b/app/views/shared/_autocomplete_form.html.haml @@ -12,8 +12,9 @@ .autocomplete-form{:subject_class => subject_class, :field => field, :path => autocomplete_path, :class => field} %h3= t("activerecord.attributes.build_list.#{field}") %span.icon-question-sign - .dialog{:title => t("activerecord.attributes.build_list.#{field}"), :id => "#{field}_dialog"} - = render "shared/autocomplete_docs/#{field}" + - if !(params[:show] == 'inline' && params[:build_list_id].present?) + .dialog{:title => t("activerecord.attributes.build_list.#{field}"), :id => "#{field}_dialog"} + = render "shared/autocomplete_docs/#{field}" .both = autocomplete_field_tag field, nil, "#{autocomplete_path}?#{{:platform_id => subject.save_to_platform.try(:id)}.to_param}", :placeholder => placeholder, :class => 'autocomplete', :update_elements => {:id => "##{field}_field", :path => "##{field}_field_path", :label => "##{field}_field_label"} = hidden_field_tag field, nil, :id => "#{field}_field" From 23d3478ccc7f7d2b7d8b85ac48703d75ce6ec74e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 16:56:33 +0600 Subject: [PATCH 14/24] [#242] ugly update selected repositories --- app/assets/javascripts/extra/build_list.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 47ea5a8c3..bd1973d85 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -89,6 +89,27 @@ $(document).ready(function() { url: $(this).attr('href') + '&show=inline', success: function(data){ new_form.html(data); + //$('#build_list_save_to_repository_id').trigger('change'); + + var selected_option = $('#build_list_save_to_repository_id').find("option:selected"); + var platform_id = selected_option.attr('platform_id'); + var rep_name = selected_option.text().match(/[\w-]+\/([\w-]+)/)[1]; + var all_repositories = $('.all_platforms input'); + var build_platform = $('#build_for_pl_' + platform_id); + all_repositories.removeAttr('checked'); + + if (build_platform.size() == 0) { + all_repositories.removeAttr('disabled'); + } else { + all_repositories.attr('disabled', 'disabled'); + var parent = build_platform.parent(); + parent.find('input').removeAttr('disabled'); + parent.find('input[rep_name="main"]').attr('checked', 'checked'); + if (rep_name != 'main') { + parent.find('input[rep_name="' + rep_name + '"]').attr('checked', 'checked'); + } + } + $(document).scrollTop(new_form.offset().top); }, error: function(data){ From 4205acb47d3d46dc38e1b5995be298c44eff22d0 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 17:01:21 +0600 Subject: [PATCH 15/24] [#242] small fix --- app/views/projects/build_lists/_new_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index 0d1e33992..4ce11f4fc 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -43,7 +43,7 @@ = check_box_tag "build_list[#{kind}]", checked, checked = f.label kind %br - = hidden_field_tag :from_build_list_id, params[:build_list_id] + = hidden_field_tag :from_build_list_id, params[:build_list_id] if params[:build_list_id].present? = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} .both From ba0d6c665f75d08dd612068a40b208f026597de4 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 19:46:57 +0600 Subject: [PATCH 16/24] [#242] fixed repository selection --- app/views/projects/build_lists/_include_repos.html.haml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index a8a2a1463..649904cba 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -1,6 +1,8 @@ - Repository.custom_sort(platform.repositories).each do |repo| .both - = check_box_tag "build_list[include_repos][]", repo.id, - (params[:build_list].try(:fetch, :include_repos) || []).include?(repo.id.to_s) || (repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id)), - :id => "include_repos_#{repo.id}", :rep_name => repo.name + - if params[:build_list].try(:[], :include_repos).present? + - checked = (params[:build_list].try(:[], :include_repos) || []).include?(repo.id.to_s) + - else checked = false + = check_box_tag 'build_list[include_repos][]', repo.id, checked, + :id => "include_repos_#{repo.id}", :rep_name => repo.name = label_tag "include_repos_#{repo.id}", repo.name From d28b8d41f27b1c5249464b84ef91df153c91baaf Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 19:47:11 +0600 Subject: [PATCH 17/24] [#242] remove unneeded code --- app/assets/javascripts/extra/build_list.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index bd1973d85..47ea5a8c3 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -89,27 +89,6 @@ $(document).ready(function() { url: $(this).attr('href') + '&show=inline', success: function(data){ new_form.html(data); - //$('#build_list_save_to_repository_id').trigger('change'); - - var selected_option = $('#build_list_save_to_repository_id').find("option:selected"); - var platform_id = selected_option.attr('platform_id'); - var rep_name = selected_option.text().match(/[\w-]+\/([\w-]+)/)[1]; - var all_repositories = $('.all_platforms input'); - var build_platform = $('#build_for_pl_' + platform_id); - all_repositories.removeAttr('checked'); - - if (build_platform.size() == 0) { - all_repositories.removeAttr('disabled'); - } else { - all_repositories.attr('disabled', 'disabled'); - var parent = build_platform.parent(); - parent.find('input').removeAttr('disabled'); - parent.find('input[rep_name="main"]').attr('checked', 'checked'); - if (rep_name != 'main') { - parent.find('input[rep_name="' + rep_name + '"]').attr('checked', 'checked'); - } - } - $(document).scrollTop(new_form.offset().top); }, error: function(data){ From ec47e6f24baa4fddd6f166c37625795235cb79de Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 20:16:50 +0600 Subject: [PATCH 18/24] [#242] fixed repositories checkbox disabled attribute --- app/controllers/projects/build_lists_controller.rb | 2 +- app/views/projects/build_lists/_include_repos.html.haml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 7b3bc7814..f36a172ac 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -173,7 +173,7 @@ class Projects::BuildListsController < Projects::BaseController params[:build_list] ||= {} keys = [:save_to_repository_id, :auto_publish, :include_repos, :project_version, :update_type, :auto_create_container, - :extra_repositories, :extra_build_lists] + :extra_repositories, :extra_build_lists, :build_for_platform_id] keys.each { |key| params[:build_list][key] = @build_list.send(key) } params[:arches] = [@build_list.arch_id.to_s] [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index 649904cba..1b1f5205f 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -4,5 +4,6 @@ - checked = (params[:build_list].try(:[], :include_repos) || []).include?(repo.id.to_s) - else checked = false = check_box_tag 'build_list[include_repos][]', repo.id, checked, + :disabled => params[:build_list].try(:[], :build_for_platform_id).to_i != platform.id, :id => "include_repos_#{repo.id}", :rep_name => repo.name = label_tag "include_repos_#{repo.id}", repo.name From 63cab38c7dbc70a56d870213bf061d3b92b3bc4e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 20:20:59 +0600 Subject: [PATCH 19/24] [#242] remove old code --- app/controllers/projects/build_lists_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index f36a172ac..bf3bbb900 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -149,9 +149,6 @@ class Projects::BuildListsController < Projects::BaseController @build_lists = @build_lists.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength]) @total_build_lists = @build_lists.count - #if !params[:sSearch].blank? && search = "%#{params[:sSearch]}%" - # @users = @users.where('users.name ILIKE ? or users.uname ILIKE ? or users.email ILIKE ?', search, search, search) - #end @build_lists = @build_lists.where(:user_id => current_user) if params[:owner_filter] == 'true' @build_lists = @build_lists.where(:status => [BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH]) if params[:status_filter] == 'true' @build_lists = @build_lists.order(order) From b0ab33f13f6fecd3285e2b5a4256b1a641168511 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 20:27:28 +0600 Subject: [PATCH 20/24] [#242] small refactoring --- .../projects/build_lists/_last_build_lists.html.haml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/views/projects/build_lists/_last_build_lists.html.haml b/app/views/projects/build_lists/_last_build_lists.html.haml index e3a612f7b..6af6589af 100644 --- a/app/views/projects/build_lists/_last_build_lists.html.haml +++ b/app/views/projects/build_lists/_last_build_lists.html.haml @@ -8,15 +8,8 @@ = check_box_tag :status_filter_build_lists, true, params[:status_filter] == 'true' = label_tag t('layout.build_lists.failed_build_lists') - - default_column = {:type => 'html', :sortable => false, :searchable => false} - - columns = [default_column, - default_column, - default_column, - default_column, - default_column, - default_column, - default_column, - default_column] + - columns, default_column = [], {:type => 'html', :sortable => false, :searchable => false} + - 8.times { columns << default_column } = raw datatable(columns, {:sort_by => "[7, 'asc']", :processing => t('layout.processing'), :search => 'false', :pagination_labels => {:previous => t('datatables.previous_label'), :next => t('datatables.next_label')}, :empty_label => t('datatables.empty_label'), From c13e44dc640fee219ca250dd0777e01e97b58edb Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 21:54:58 +0600 Subject: [PATCH 21/24] [#242] another fix checked repositories --- app/views/projects/build_lists/_include_repos.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index 1b1f5205f..9dba1869f 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -1,7 +1,7 @@ - Repository.custom_sort(platform.repositories).each do |repo| .both - if params[:build_list].try(:[], :include_repos).present? - - checked = (params[:build_list].try(:[], :include_repos) || []).include?(repo.id.to_s) + - checked = (params[:build_list].try(:[], :include_repos) || []).include?(repo.id) - else checked = false = check_box_tag 'build_list[include_repos][]', repo.id, checked, :disabled => params[:build_list].try(:[], :build_for_platform_id).to_i != platform.id, From a6b0831761155269c156668a45e9c63f409a21e5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 6 Aug 2013 22:33:08 +0600 Subject: [PATCH 22/24] [#242] again fix checked repositories --- app/views/projects/build_lists/_include_repos.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index 9dba1869f..0d7149928 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -1,7 +1,7 @@ - Repository.custom_sort(platform.repositories).each do |repo| .both - if params[:build_list].try(:[], :include_repos).present? - - checked = (params[:build_list].try(:[], :include_repos) || []).include?(repo.id) + - checked = (params[:build_list].try(:[], :include_repos).map(&:to_s) || []).include?(repo.id.to_s) - else checked = false = check_box_tag 'build_list[include_repos][]', repo.id, checked, :disabled => params[:build_list].try(:[], :build_for_platform_id).to_i != platform.id, From 789b4e2cb4bb33a8a19e96293b8c4370858719f4 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Aug 2013 15:29:49 +0600 Subject: [PATCH 23/24] [#242] check boxs checked by default --- app/views/projects/build_lists/_last_build_lists.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/build_lists/_last_build_lists.html.haml b/app/views/projects/build_lists/_last_build_lists.html.haml index 6af6589af..256b034a5 100644 --- a/app/views/projects/build_lists/_last_build_lists.html.haml +++ b/app/views/projects/build_lists/_last_build_lists.html.haml @@ -2,10 +2,10 @@ %h3= t 'layout.build_lists.last_build_lists' %h4= t 'layout.relations.filters' .both - = check_box_tag :owner_filter_build_lists, true, params[:owner_filter] == 'true' + = check_box_tag :owner_filter_build_lists, true, (params[:owner_filter] || 'true') == 'true' = label_tag t('layout.build_lists.only_my_build_lists') .both - = check_box_tag :status_filter_build_lists, true, params[:status_filter] == 'true' + = check_box_tag :status_filter_build_lists, true, (params[:status_filter] || 'true') == 'true' = label_tag t('layout.build_lists.failed_build_lists') - columns, default_column = [], {:type => 'html', :sortable => false, :searchable => false} From 3b8ed4ce40c3922c70d3886288a5387006333c57 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 7 Aug 2013 15:36:48 +0600 Subject: [PATCH 24/24] [#242] dont create build list from another --- app/controllers/projects/build_lists_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index bf3bbb900..3bcfeb044 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -11,7 +11,7 @@ class Projects::BuildListsController < Projects::BaseController load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true load_and_authorize_resource :except => NESTED_ACTIONS - before_filter :create_from_build_list, :only => [:new, :create] + before_filter :create_from_build_list, :only => :new def index params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter]