#369: updated autocompletes
This commit is contained in:
parent
e605f068b6
commit
0b7e4a41ec
|
@ -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 =
|
||||
|
|
|
@ -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 } }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue