Cache results from jQuery selectors to retrieve namespace name

This commit is contained in:
Douglas Barbosa Alexandre 2016-07-01 16:43:02 -03:00
parent 8353cc6111
commit 3d69d01e1f

View file

@ -7,13 +7,16 @@ class @ImporterStatus
$('.js-add-to-import') $('.js-add-to-import')
.off 'click' .off 'click'
.on 'click', (e) => .on 'click', (e) =>
new_namespace = null
$btn = $(e.currentTarget) $btn = $(e.currentTarget)
$tr = $btn.closest('tr') $tr = $btn.closest('tr')
$target_field = $tr.find('.import-target')
$namespace_input = $target_field.find('input')
id = $tr.attr('id').replace('repo_', '') id = $tr.attr('id').replace('repo_', '')
if $tr.find('.import-target input').length > 0 new_namespace = null
new_namespace = $tr.find('.import-target input').prop('value')
$tr.find('.import-target').empty().append("#{new_namespace}/#{$tr.find('.import-target').data('project_name')}") if $namespace_input.length > 0
new_namespace = $namespace_input.prop('value')
$target_field.empty().append("#{new_namespace}/#{$target_field.data('project_name')}")
$btn $btn
.disable() .disable()