#156: add personal repositories as extra on #new page
This commit is contained in:
parent
ae1fd15dad
commit
08966ab738
|
@ -9,17 +9,7 @@ $(document).ready(function() {
|
|||
var path = $('#' + field + '_field_path').val();
|
||||
var label = $('#' + field + '_field_label').val();
|
||||
|
||||
var tr = '<tr>' +
|
||||
'<td>' +
|
||||
'<a href="' + path + '">' + label + '</a>' +
|
||||
'</td>' +
|
||||
'<td class="actions">' +
|
||||
'<input name="' + name + '" type="hidden" value="' + subject.val() + '">' +
|
||||
'<span class="delete"> </span>' +
|
||||
'</td>' +
|
||||
'</tr>';
|
||||
|
||||
form.find('table tbody').append($(tr));
|
||||
addDataToAutocompleteForm(form, path, label, name, subject.val());
|
||||
form.find('.autocomplete').val('');
|
||||
return false;
|
||||
});
|
||||
|
@ -41,3 +31,16 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
function addDataToAutocompleteForm(form, path, label, name, value) {
|
||||
var tr = '<tr>' +
|
||||
'<td>' +
|
||||
'<a href="' + path + '">' + label + '</a>' +
|
||||
'</td>' +
|
||||
'<td class="actions">' +
|
||||
'<input name="' + name + '" type="hidden" value="' + value + '">' +
|
||||
'<span class="delete"> </span>' +
|
||||
'</td>' +
|
||||
'</tr>';
|
||||
form.find('table tbody').append($(tr));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ $(document).ready(function() {
|
|||
if (build_platform.size() == 0) {
|
||||
all_repositories.removeAttr('disabled');
|
||||
auto_create_container.removeAttr('checked');
|
||||
addPersonalPlatformToExtraRepos(selected_option, extra_repos);
|
||||
extra_repos.show();
|
||||
} else {
|
||||
all_repositories.attr('disabled', 'disabled');
|
||||
|
@ -84,6 +85,18 @@ function updateExtraReposAndBuildLists(save_to_platform_id) {
|
|||
});
|
||||
}
|
||||
|
||||
function addPersonalPlatformToExtraRepos(selected_option, extra_repos) {
|
||||
var default_value = extra_repos.find('div[label="' + selected_option.text() + '"]');
|
||||
if (default_value.length == 0) { return; }
|
||||
addDataToAutocompleteForm(
|
||||
extra_repos,
|
||||
default_value.attr('path'),
|
||||
default_value.attr('label'),
|
||||
default_value.attr('name'),
|
||||
default_value.attr('value')
|
||||
);
|
||||
}
|
||||
|
||||
function setBranchSelected(selected_option) {
|
||||
var pl_name = selected_option.text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
||||
var bl_version_sel = $('#build_list_project_version');
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
- if can? :show, @platform
|
||||
%li{:class => (act == :index && contr == :maintainers) ? 'active' : nil}
|
||||
= link_to t("layout.platforms.maintainers"), platform_maintainers_path(@platform)
|
||||
- if can?(:show, @platform)
|
||||
%li{:class => (contr == :mass_builds) ? 'active' : ''}
|
||||
= link_to t("layout.platforms.mass_build"), platform_mass_builds_path(@platform)
|
||||
- if can? :read, @platform.products.build
|
||||
|
|
|
@ -25,8 +25,18 @@
|
|||
%h3= t('activerecord.attributes.build_list.build_for_platform')
|
||||
= f.collection_select :build_for_platform_id, Platform.main, :id, :name
|
||||
.both
|
||||
= render 'shared/autocomplete_form', :field => :extra_repositories, :field_class => Repository, :placeholder => 'uxteam_personal', :subject => @mass_build, :autocomplete_path => autocomplete_extra_repositories_autocompletes_path
|
||||
= render 'shared/autocomplete_form', :field => :extra_build_lists, :field_class => BuildList, :placeholder => '1000000', :subject => @mass_build, :autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
||||
= render 'shared/autocomplete_form',
|
||||
:field => :extra_repositories,
|
||||
:field_class => Repository,
|
||||
:placeholder => 'uxteam_personal',
|
||||
:subject => @mass_build,
|
||||
:autocomplete_path => autocomplete_extra_repositories_autocompletes_path
|
||||
= render 'shared/autocomplete_form',
|
||||
:field => :extra_build_lists,
|
||||
:field_class => BuildList,
|
||||
:placeholder => '1000000',
|
||||
:subject => @mass_build,
|
||||
:autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
||||
%h3= t("activerecord.attributes.build_list.preferences")
|
||||
.both
|
||||
= f.check_box :auto_publish
|
||||
|
|
|
@ -21,8 +21,19 @@
|
|||
%h3= t("activerecord.attributes.build_list.update_type")
|
||||
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES
|
||||
|
||||
= render 'shared/autocomplete_form', :field => :extra_repositories, :field_class => Repository, :placeholder => 'uxteam_personal', :subject => @build_list, :autocomplete_path => autocomplete_extra_repositories_autocompletes_path
|
||||
= render 'shared/autocomplete_form', :field => :extra_build_lists, :field_class => BuildList, :placeholder => '1000000', :subject => @build_list, :autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
||||
= render 'shared/autocomplete_form',
|
||||
:field => :extra_repositories,
|
||||
:field_class => Repository,
|
||||
:placeholder => 'uxteam_personal',
|
||||
:subject => @build_list,
|
||||
:autocomplete_path => autocomplete_extra_repositories_autocompletes_path,
|
||||
:default_values => @project.repositories.select{ |r| r.platform.personal? }
|
||||
= render 'shared/autocomplete_form',
|
||||
:field => :extra_build_lists,
|
||||
:field_class => BuildList,
|
||||
:placeholder => '1000000',
|
||||
:subject => @build_list,
|
||||
:autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
||||
|
||||
%h3= t("activerecord.attributes.build_list.preferences")
|
||||
- [:auto_publish, :auto_create_container].each do |kind|
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/
|
||||
-#
|
||||
Variables:
|
||||
- subject
|
||||
- field
|
||||
- field_class
|
||||
- autocomplete_path
|
||||
- placeholder
|
||||
subject
|
||||
field
|
||||
field_class
|
||||
autocomplete_path
|
||||
placeholder
|
||||
default_values (optional)
|
||||
|
||||
- default_values ||= []
|
||||
- subject_class = subject.class.name.underscore
|
||||
.autocomplete-form{:subject_class => subject_class, :field => field, :path => autocomplete_path, :class => field}
|
||||
%h3= t("activerecord.attributes.build_list.#{field}")
|
||||
|
@ -21,6 +23,7 @@
|
|||
|
||||
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
%tbody
|
||||
- field_name = "#{subject_class}[#{field}][]"
|
||||
- field_class.where(:id => subject.send(field)).each do |extra|
|
||||
%tr
|
||||
- if extra.is_a?(BuildList)
|
||||
|
@ -29,5 +32,12 @@
|
|||
%td= link_to "#{extra.platform.name}/#{extra.name}", [extra.platform, extra]
|
||||
%td.actions
|
||||
- field = extra.is_a?(BuildList) ? 'extra_build_lists' : 'extra_repositories'
|
||||
= hidden_field_tag "#{subject_class}[#{field}][]", extra.id
|
||||
= hidden_field_tag field_name, extra.id
|
||||
%span.delete
|
||||
.default-values
|
||||
- field_class.where(:id => default_values).each do |extra|
|
||||
.hidden{:label => "#{extra.platform.name}/#{extra.name}",
|
||||
:path => url_for([extra.platform, extra]),
|
||||
:name => field_name, :value => extra.id}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue