From 8748caea025b4ed140059fc35ba41cdbebe448fa Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 17 Jun 2014 16:11:26 +0600 Subject: [PATCH] [#369] some fixes new build list page --- .../new_build_list_controller.js.erb | 42 +++++++++++++------ .../projects/build_lists/_new_form.html.haml | 20 +++++---- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/angular-new/controllers/new_build_list_controller.js.erb b/app/assets/javascripts/angular-new/controllers/new_build_list_controller.js.erb index 1d23feacf..31d85a9eb 100644 --- a/app/assets/javascripts/angular-new/controllers/new_build_list_controller.js.erb +++ b/app/assets/javascripts/angular-new/controllers/new_build_list_controller.js.erb @@ -1,40 +1,58 @@ -RosaABF.controller('NewBuildListController', ['$scope', '$http', '$timeout', - function($scope, $http, $timeout) { +RosaABF.controller('NewBuildListController', ['$scope', '$http', '$timeout', function($scope, $http, $timeout) { - $scope.save_to_repository = null; - $scope.build_for_platform = null; + $scope.save_to_repository_id = null; - var save_to_repository_id = $('#build_list_save_to_repository_id'); + var save_to_repository = $('#build_list_save_to_repository_id'); var all_repositories = $('.all_platforms input'); var auto_create_container = $('#build_list_auto_create_container'); var extra_repos = $('.autocomplete-form.extra_repositories'); var build_list_auto_publish_status = $('#build_list_auto_publish_status'); var bl_version_sel = $('#build_list_project_version'); var all_platforms_name = $('h4.build_for_pl'); + var build_for_platform_id = null; + var build_platform = null; + + $scope.init = function(pl_id, save_to_repository_id) { + build_for_platform_id = pl_id; + build_platform = $('#build_for_pl_' + pl_id); + $scope.save_to_repository_id = save_to_repository_id; + } + + $scope.getPlatformClass = function(pl_id) { + if (build_platform.size() > 0 && build_for_platform_id !== pl_id) { + return 'text-muted'; + } + } + + $scope.needHidePlatform = function(pl_id) { + if (build_platform.size() > 0 && build_for_platform_id !== pl_id) { + return true; + } + else { + return false; + } + } $scope.change_save_to_repository = function() { - var selected_option = save_to_repository_id.find("option:selected"); - var platform_id = selected_option.attr('platform_id'); + var selected_option = save_to_repository.find('option:selected'); var rep_name = selected_option.text().match(/[\w-]+\/([\w-]+)/)[1]; - var build_platform = $('#build_for_pl_' + platform_id); + build_for_platform_id = selected_option.attr('platform_id'); + build_platform = $('#build_for_pl_' + build_for_platform_id); all_repositories.removeAttr('checked'); - updateExtraReposAndBuildLists(platform_id); + updateExtraReposAndBuildLists(build_for_platform_id); updatedDefaultArches(selected_option); $('.autocomplete-form table tbody').empty(); if (build_platform.size() == 0) { all_repositories.removeAttr('disabled'); - all_platforms_name.removeClass('text-muted'); auto_create_container.removeAttr('checked'); addPersonalPlatformToExtraRepos(selected_option, extra_repos); extra_repos.show(); } else { all_repositories.attr('disabled', 'disabled'); - all_platforms_name.addClass('text-muted'); - build_platform.removeClass('text-muted'); extra_repos.hide(); var parent = build_platform.parent(); parent.find('input').removeAttr('disabled'); diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index 605b41299..81c0cfa8d 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -4,20 +4,22 @@ %h3= t 'activerecord.attributes.build_list.build_for_platform' - build_for_platform = params[:build_list].try :[], :build_for_platform - build_for_platform_id = build_for_platform.try(:id).presence || 'null' - .all_platforms{ 'ng-init' => "build_for_platform = #{build_for_platform_id}" } + - save_to_repository_id = params[:build_list].try(:[], :save_to_repository_id).presence || 'null' + .all_platforms{ 'ng-init' => "init('#{build_for_platform_id}', #{save_to_repository_id})" } - availables_main_platforms.each do |pl| - .clearfix - %h4{ id: "build_for_pl_#{pl.id}", class: 'build_for_pl', - 'ng-class' => "{text-muted: }" }= pl.name + %div{ 'ng-hide' => "needHidePlatform('#{pl.id}')" } + %h4{ id: "build_for_pl_#{pl.id}", class: 'build_for_pl', 'ng-class' => "getPlatformClass('#{pl.id}')" }= pl.name = render 'include_repos', platform: pl, build_for_platform: build_for_platform .col-md-5 %h3= t 'activerecord.attributes.build_list.save_to_repository' - - selected = params[:build_list].try(:[], :save_to_repository_id).presence || 'null' - = f.select :save_to_repository_id, save_to_repositories(project), {}, class: 'form-control', - 'ng-model' => 'save_to_repository', 'ng-change' => 'change_save_to_repository()', - 'ng-init' => "" + = f.select :save_to_repository_id, save_to_repositories(project), + { selected: params[:build_list].try(:[], :save_to_repository_id) }, + class: 'form-control', 'ng-change' => 'change_save_to_repository()', + 'ng-model' => 'save_to_repository_id' %h3= t 'activerecord.attributes.build_list.project_version' - = f.select :project_version, versions_for_group_select(project), {selected: params[:build_list].try(:[], :project_version) || project.default_branch}, class: 'form-control' + = f.select :project_version, versions_for_group_select(project), + { selected: params[:build_list].try(:[], :project_version) || project.default_branch }, + class: 'form-control' %h3= t 'activerecord.attributes.build_list.arch' - Arch.recent.each do |arch| - checked = (params[:arches]||[]).include?(arch.id.to_s) || (params[:arches].blank? && controller.action_name == 'new' && Arch::DEFAULT.include?(arch.name))