Skip to content

Commit

Permalink
Merge pull request #2447 from ChrisBr/branching
Browse files Browse the repository at this point in the history
 Branching image templates (ui) (supersedes #2435)
  • Loading branch information
bgeuken committed Dec 12, 2016
2 parents 4597700 + c34c6a5 commit 3f2a5de
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/api/app/assets/javascripts/webui/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
//= require webui/application/attribute
//= require webui/application/main
//= require webui/application/repository_tab
//= require webui/application/image_templates

function remove_dialog() {
$(".dialog").remove();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(function() {
$(".image_template").on("click", function(e){
$('#target_package').val(this.getAttribute('data-package'));
$('#linked_package').val(this.getAttribute('data-package'));
$('#linked_project').val(this.getAttribute('data-project'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,22 @@ dl.templateslist
background: rgba(0, 0, 0, 0) image-url('radiobutton-checked.png') no-repeat scroll left top
border: 0 none
min-height: 16x

.templates_form
margin: 1em

.name_appliance
display: block
font-size: 13pt

.create_appliance
display: block
width: 9em
padding: 0.5em
text-align: center
margin-top: 2em

.name_appliance_form
padding: 0.3em
margin: 1em 0.5em
width: 30em
4 changes: 4 additions & 0 deletions src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def format_projectname(prjname, login)
'scheduling' => 'The repository state is being calculated right now'
}

def check_first(index)
index == 1 ? true : nil
end

def repo_status_icon(status, details = nil)
icon = REPO_STATUS_ICONS[status] || 'eye'

Expand Down
19 changes: 16 additions & 3 deletions src/api/app/views/webui/image_templates/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
Choose a base template

%fieldset.templateslist
- first_template = nil
- @projects.each do |project|
%dl.templateslist
%dt
= link_to(title_or_name(project), project_show_path(project))
- project.packages.each do |template|
- project.packages.each.with_index(1) do |template, index|
%label
%input{ name: 'image', type: 'radio', class: 'hidden' }
%input{ name: 'image', type: 'radio', class: 'hidden image_template', checked: check_first(index), data: { project: project, package: template } }
- first_template = template if index == 1
%dd
%span.form-radio
- if template.has_icon?
Expand All @@ -24,6 +26,17 @@
- if project.packages.empty?
%p
There are currently no base image templates available for project <strong>#{title_or_name(project)}</strong>.
- if @projects.empty?
- if first_template
.templates_form
= form_tag({ controller: :package, action: :save_new_link, project: User.current.home_project_name }, method: :post, id: 'appliance_form') do
= hidden_field_tag 'linked_project', first_template.project
= hidden_field_tag 'linked_package', first_template.name
= label_tag(:target_package, 'Name your appliance', class: 'name_appliance')
%span
(Maximum of 200 characters, no blank, /, :, - or ; characters)
%br
= text_field_tag(:target_package, first_template, class: 'name_appliance_form', required: true)
= submit_tag('Create appliance', class: 'create_appliance')
- elsif @projects.empty?
%p
There are no templates yet, sorry.

0 comments on commit 3f2a5de

Please sign in to comment.