From d6dc51ba932e1ab0890f3ab62814ba5dc6321cad Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 10 Apr 2012 13:05:42 +0400 Subject: [PATCH 1/6] [refs #223] Choosen rep auto set --- app/assets/javascripts/extra/build_list.js | 11 +++++------ app/views/build_lists/_include_repos.html.haml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 02f9d253d..6368c3c00 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -3,30 +3,29 @@ $(document).ready(function() { var platform_id = $(this).val(); var base_platforms = $('.all_platforms input[type=checkbox].build_bpl_ids'); - //$('#include_repos').html($('.preloaded_include_repos .include_repos_' + platform_id).html()); - base_platforms.each(function(){ if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val() }).get()) >= 0) { if ($(this).val() == platform_id) { $(this).attr('checked', 'checked'); $(this).removeAttr('disabled'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); - if ($(this).parent().find('.offset25 label').text() == 'main') { - $(this).parent().find('.offset25 input[type="checkbox"]').attr('checked', 'checked'); + + var rep_name = $('#build_list_pl_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'); } + $(this).parent().find('.offset25 input[type="checkbox"][rep_name="main"]').attr('checked', 'checked'); } else { $(this).removeAttr('checked'); $(this).attr('disabled', 'disabled'); $(this).parent().find('.offset25 input[type="checkbox"]').attr('disabled', 'disabled'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('checked'); } - //$('.additional_pl').parent().find('.offset25 input[type="checkbox"]').attr('disabled', 'disabled'); } else { $(this).removeAttr('disabled'); $(this).removeAttr('checked'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('checked'); - //$('.additional_pl').parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); } }); }); diff --git a/app/views/build_lists/_include_repos.html.haml b/app/views/build_lists/_include_repos.html.haml index d62150f29..372d3865a 100644 --- a/app/views/build_lists/_include_repos.html.haml +++ b/app/views/build_lists/_include_repos.html.haml @@ -1,4 +1,4 @@ - 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}", :pl_id => platform.id + = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :pl_id => platform.id, :rep_name => repo.name = label_tag "include_repos_#{repo.id}", repo.name From 207be85ff4d809283c7bce621427ac427e0d891c Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 10 Apr 2012 16:03:33 +0400 Subject: [PATCH 2/6] [refs #223] Add group select to versions --- app/models/project.rb | 7 +++++++ app/views/build_lists/new.html.haml | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5f0b097cd..2e5f0f277 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -118,6 +118,13 @@ class Project < ActiveRecord::Base tags.map(&:name) + branches.map{|b| "latest_#{b.name}"} end + def versions_for_group_select + [ + ['Tags', tags.map(&:name)], + ['Branches', branches.map{|b| "latest_#{b.name}"}] + ] + end + def members collaborators + groups.map(&:members).flatten end diff --git a/app/views/build_lists/new.html.haml b/app/views/build_lists/new.html.haml index 1a499ef44..f3beb7290 100644 --- a/app/views/build_lists/new.html.haml +++ b/app/views/build_lists/new.html.haml @@ -2,7 +2,10 @@ = form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f| %section.left %h3= t("activerecord.attributes.build_list.project_version") - .lineForm= f.select :project_version, @project.versions + - if controller.action_name == 'new' + .lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch + - else + .lineForm= f.select :project_version, @project.versions_for_group_select %h3= t("activerecord.attributes.build_list.bpl") .all_platforms - Platform.main.each do |pl| From 3cff036508e03ceaa196a766d641dc9530f593c0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 10 Apr 2012 17:07:09 +0400 Subject: [PATCH 3/6] [refs #223] Add new build btn to project page --- app/views/git/shared/_fork.html.haml | 4 +++- config/locales/models/project.en.yml | 1 + config/locales/models/project.ru.yml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/git/shared/_fork.html.haml b/app/views/git/shared/_fork.html.haml index 001100dbb..899a711d0 100644 --- a/app/views/git/shared/_fork.html.haml +++ b/app/views/git/shared/_fork.html.haml @@ -1,2 +1,4 @@ - if can? :fork, @project - .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), fork_project_path(@project), :method => :post, :confirm => t("layout.confirm"), :class => 'button' \ No newline at end of file + .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), fork_project_path(@project), :method => :post, :confirm => t("layout.confirm"), :class => 'button' +- if can? :create, @project.build_lists.new + .r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button' diff --git a/config/locales/models/project.en.yml b/config/locales/models/project.en.yml index f2380d9f8..11f4df34b 100644 --- a/config/locales/models/project.en.yml +++ b/config/locales/models/project.en.yml @@ -10,6 +10,7 @@ en: show: Project build: Build new_build: New build %{project_name} + new_build_list: New build confirm_delete: Are you sure you want to delete this project? new: New project location: Location diff --git a/config/locales/models/project.ru.yml b/config/locales/models/project.ru.yml index 762cb9f82..ae9a75c7a 100644 --- a/config/locales/models/project.ru.yml +++ b/config/locales/models/project.ru.yml @@ -10,6 +10,7 @@ ru: show: Проект build: Собрать new_build: Новая сборка %{project_name} + new_build_list: Новая сборка confirm_delete: Вы уверены, что хотите удалить этот проект? new: Новый проект location: Расположение From c619aa44b79ce76c604c9e52257558b7a6c26166 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 10 Apr 2012 17:11:36 +0400 Subject: [PATCH 4/6] [refs #223] Fix build list status --- config/locales/models/build_list.en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 9b7c6bce5..65e756a92 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -95,7 +95,7 @@ en: success: Build complete build_started: Build started platform_not_found: Platform not found - platform_pending: Platforn pending + platform_pending: Platform pending project_not_found: Project not found project_version_not_found: Project version not found From f7e09c993d1060b9ba431e134b10ec5ff235b8b0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 10 Apr 2012 17:15:48 +0400 Subject: [PATCH 5/6] [refs #223] Optimise code by jQuery chains --- app/assets/javascripts/extra/build_list.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 6368c3c00..682cd9c4a 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -6,8 +6,7 @@ $(document).ready(function() { base_platforms.each(function(){ if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val() }).get()) >= 0) { if ($(this).val() == platform_id) { - $(this).attr('checked', 'checked'); - $(this).removeAttr('disabled'); + $(this).attr('checked', 'checked').removeAttr('disabled'); $(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]; @@ -16,16 +15,12 @@ $(document).ready(function() { } $(this).parent().find('.offset25 input[type="checkbox"][rep_name="main"]').attr('checked', 'checked'); } else { - $(this).removeAttr('checked'); - $(this).attr('disabled', 'disabled'); - $(this).parent().find('.offset25 input[type="checkbox"]').attr('disabled', 'disabled'); - $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('checked'); + $(this).removeAttr('checked').attr('disabled', 'disabled'); + $(this).parent().find('.offset25 input[type="checkbox"]').attr('disabled', 'disabled').removeAttr('checked'); } } else { - $(this).removeAttr('disabled'); - $(this).removeAttr('checked'); - $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); - $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('checked'); + $(this).removeAttr('disabled').removeAttr('checked'); + $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled').removeAttr('checked'); } }); }); From 4ba17be5366579802ff0b82b2b9c5a45a2a14c71 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 10 Apr 2012 20:15:15 +0600 Subject: [PATCH 6/6] [refs #223] fixed rendering fork button --- app/views/git/shared/_fork.html.haml | 48 +++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/app/views/git/shared/_fork.html.haml b/app/views/git/shared/_fork.html.haml index b491b3dfe..9b4b70b7d 100644 --- a/app/views/git/shared/_fork.html.haml +++ b/app/views/git/shared/_fork.html.haml @@ -1,29 +1,31 @@ -- if Group.can_own_project(current_user).present? - .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), '#forkModal', :class => 'button', 'data-toggle' => 'modal' -- if can? :create, @project.build_lists.new - .r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button' +- if can? :fork, @project + - if Group.can_own_project(current_user).present? + .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), '#forkModal', :class => 'button', 'data-toggle' => 'modal' - #forkModal.modal{:style => 'display: none;'} - .modal-header - %a.close{"data-dismiss" => "modal"} × - %h3=t 'layout.projects.fork_modal_header' - .modal-footer - - if current_user.projects.exists? :name => @project.name - %p.center - =t 'layout.projects.already_exists' - =link_to "#{current_user.uname}/#{@project.name}", project_path(current_user.projects.by_name(@project.name).first.id) - - else - = form_for @project, :url => fork_project_path(@project), :html => { :class => :form, :multipart => true, :method => :post } do |f| - =f.submit t('layout.projects.fork_to', :to => current_user.uname), :class => 'btn btn-primary' - - Group.can_own_project(current_user).each do |group| + #forkModal.modal{:style => 'display: none;'} + .modal-header + %a.close{"data-dismiss" => "modal"} × + %h3=t 'layout.projects.fork_modal_header' .modal-footer - - if group.projects.exists? :name => @project.name + - if current_user.projects.exists? :name => @project.name %p.center =t 'layout.projects.already_exists' - =link_to "#{group.uname}/#{@project.name} (#{t 'activerecord.models.group'})", project_path(group.projects.by_name(@project.name).first.id) + =link_to "#{current_user.uname}/#{@project.name}", project_path(current_user.projects.by_name(@project.name).first.id) - else = form_for @project, :url => fork_project_path(@project), :html => { :class => :form, :multipart => true, :method => :post } do |f| - = hidden_field_tag :group, group.id - =f.submit t('layout.projects.fork_to', :to => "#{group.uname} (#{t 'activerecord.models.group'})"), :class => 'btn btn-primary' -- else - .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), fork_project_path(@project), :method => :post, :confirm => t("layout.confirm"), :class => 'button' + =f.submit t('layout.projects.fork_to', :to => current_user.uname), :class => 'btn btn-primary' + - Group.can_own_project(current_user).each do |group| + .modal-footer + - if group.projects.exists? :name => @project.name + %p.center + =t 'layout.projects.already_exists' + =link_to "#{group.uname}/#{@project.name} (#{t 'activerecord.models.group'})", project_path(group.projects.by_name(@project.name).first.id) + - else + = form_for @project, :url => fork_project_path(@project), :html => { :class => :form, :multipart => true, :method => :post } do |f| + = hidden_field_tag :group, group.id + =f.submit t('layout.projects.fork_to', :to => "#{group.uname} (#{t 'activerecord.models.group'})"), :class => 'btn btn-primary' + - else + .r#fork-and-edit= link_to t('layout.projects.fork_and_edit'), fork_project_path(@project), :method => :post, :confirm => t("layout.confirm"), :class => 'button' + +- if can? :create, @project.build_lists.new + .r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button'