diff --git a/app/assets/javascripts/angular-new/controllers/statistics_controller.js.coffee b/app/assets/javascripts/angular-new/controllers/statistics_controller.js.coffee index 8e463b427..748e62958 100644 --- a/app/assets/javascripts/angular-new/controllers/statistics_controller.js.coffee +++ b/app/assets/javascripts/angular-new/controllers/statistics_controller.js.coffee @@ -58,20 +58,12 @@ RosaABF.controller 'StatisticsController', ['$scope', '$http', '$timeout', ($sco $scope.range_start = $scope.range_end $scope.range_end = tmp - # $scope.prepareUsersOrGroups = -> - # if $scope.users_or_groups - # items = _.uniq $('#users_or_groups').val().replace(/\s/g, '').split(/,/) - # items = _.reject items, (i) -> - # _.isEmpty(i) - # $scope.users_or_groups = _.first(items, 3).join(', ') + ', ' - $scope.update = -> return if $scope.loading $scope.loading = true $scope.statistics = {} $scope.prepareRange() - # $scope.prepareUsersOrGroups() $('.doughnut-legend').remove() params = diff --git a/app/controllers/autocompletes_controller.rb b/app/controllers/autocompletes_controller.rb index ab69b5279..76f0a5003 100644 --- a/app/controllers/autocompletes_controller.rb +++ b/app/controllers/autocompletes_controller.rb @@ -2,7 +2,6 @@ class AutocompletesController < ApplicationController before_filter :authenticate_user! autocomplete :group, :uname - # autocomplete :user, :uname def autocomplete_user_uname results = User.opened.search(params[:query]).search_order.limit(5) @@ -10,7 +9,6 @@ class AutocompletesController < ApplicationController end def autocomplete_user_or_group - results = [] results << User.opened.search(params[:query]).search_order.limit(5).pluck(:uname) results << Group.search(params[:query]).search_order.limit(5).pluck(:uname) render json: results.flatten.sort.map{ |r| { id: r, name: r } } diff --git a/app/controllers/platforms/products_controller.rb b/app/controllers/platforms/products_controller.rb index d450e3ff8..b6baa483d 100644 --- a/app/controllers/platforms/products_controller.rb +++ b/app/controllers/platforms/products_controller.rb @@ -7,7 +7,6 @@ class Platforms::ProductsController < Platforms::BaseController load_and_authorize_resource :platform load_and_authorize_resource :product, through: :platform, except: :autocomplete_project - before_filter :set_project, only: [:create, :update] def index @products = @products.paginate(page: params[:page]) @@ -55,22 +54,9 @@ class Platforms::ProductsController < Platforms::BaseController end def autocomplete_project - items = Project.accessible_by(current_ability, :membered) - .search(params[:term]).limit(20) + @items = Project.accessible_by(current_ability, :membered) + .search(params[:query]).limit(20) #items.select! {|e| e.repo.branches.count > 0} - render json: items.map{ |p| - { - id: p.id, - label: p.name_with_owner, - value: p.name_with_owner, - project_versions: versions_for_group_select(p) - } - } end - protected - - def set_project - @product.project = Project.find_by_owner_and_name params[:src_project] - end end diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index d0cef6cc0..ebbb96b54 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -89,8 +89,10 @@ module GitHelper def versions_for_group_select(project) return [] unless project - [ [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&:name)], - [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name)] ] + [ + [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&:name).sort], + [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name).sort] + ] end def split_commits_by_date(commits) diff --git a/app/views/platforms/platforms/_form.html.slim b/app/views/platforms/platforms/_form.html.slim index e6a3bed02..10c5a4382 100644 --- a/app/views/platforms/platforms/_form.html.slim +++ b/app/views/platforms/platforms/_form.html.slim @@ -14,13 +14,13 @@ - unless @platform.personal? = f.input :released, as: :boolean - / TODO: autocomplete - = f.input :admin_id, - url: autocomplete_user_uname_autocompletes_path, - as: :autocomplete, - id_element: '#admin_id_field', - input_html: { value: @admin_uname, class: 'form-control' } + = hidden_field_tag 'admin_id', @admin_id, id: 'admin_id_field' + = f.input :admin_id, + input_html: { 'data-ajax' => autocomplete_user_uname_autocompletes_path, + 'data-id' => '#admin_id_field', + value: @admin_uname, + class: 'typeahead' } - if %w(edit update).include? controller.action_name @@ -41,7 +41,7 @@ table.table thead tr - th.lpadding16= t("activerecord.models.arch") + th.lpadding16= t("activerecord.models.arch.name") th.lpadding16= t("activerecord.attributes.platform_arch_setting.default") th.lpadding16= t("activerecord.attributes.platform_arch_setting.time_living") tbody diff --git a/app/views/platforms/product_build_lists/new.html.slim b/app/views/platforms/product_build_lists/new.html.slim index b8c6cbc94..613fdfe9c 100644 --- a/app/views/platforms/product_build_lists/new.html.slim +++ b/app/views/platforms/product_build_lists/new.html.slim @@ -9,8 +9,12 @@ = f.input :project, input_html: { value: pbl.project.name_with_owner }, disabled: true + = f.input :project_version, - collection: versions_for_group_select(pbl.project) + as: :grouped_select, + collection: versions_for_group_select(pbl.project), + group_method: :last, + include_blank: false = f.input :main_script = f.input :params diff --git a/app/views/platforms/products/_form.html.slim b/app/views/platforms/products/_form.html.slim index 4b4ba5782..59bc486cf 100644 --- a/app/views/platforms/products/_form.html.slim +++ b/app/views/platforms/products/_form.html.slim @@ -1,16 +1,33 @@ = f.input :name = f.input :description, as: :text -/ TODO: autocomplete + project_version -= f.input :project, - url: autocomplete_project_platform_products_path(@platform), - as: :autocomplete, - id_element: '#src_project_id', - input_html: { value: @product.project.try(:name_with_owner), - name: 'src_project', - class: 'form-control' } += f.input :project_id, as: :string, + input_html: { 'data-ajax' => autocomplete_project_platform_products_path(@platform), + value: @product.project.try(:name_with_owner) } += hidden_field_tag 'product[project_id]', @product.project_id, id: 'src_project_id' -= f.input :project_version, collection: versions_for_group_select(@product.project) +- content_for :additional_scripts do + coffee: + product_projects = [] + + $('#product_project_id').typeahead + val: 'data' + ajax: + url: $('#product_project_id').data('ajax') + preProcess: (data) -> + product_projects = data + onSelect: (i) -> + $('#src_project_id').val i.value + project = _.find product_projects, (p) -> + p.id.toString() == i.value + if project + $('#product_project_version').html project.project_versions + += f.input :project_version, + as: :grouped_select, + collection: versions_for_group_select(@product.project), + group_method: :last, + include_blank: false = f.input :main_script = f.input :params diff --git a/app/views/platforms/products/autocomplete_project.json.jbuilder b/app/views/platforms/products/autocomplete_project.json.jbuilder new file mode 100644 index 000000000..23d37eba6 --- /dev/null +++ b/app/views/platforms/products/autocomplete_project.json.jbuilder @@ -0,0 +1,5 @@ +json.array!(@items) do |item| + json.id item.id + json.name item.name_with_owner + json.project_versions grouped_options_for_select(versions_for_group_select(item)) +end