From: Jozef Zigmund <jzigmund(a)redhat.com>
Save button is disabled while any hardware profile doesn't exist. The same condition
for catalogs.
https://bugzilla.redhat.com/show_bug.cgi?id=782503
---
src/app/controllers/deployables_controller.rb | 4 ++++
.../views/deployables/_new_from_image.html.haml | 3 ++-
src/config/locales/en.yml | 2 ++
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/deployables_controller.rb
b/src/app/controllers/deployables_controller.rb
index 102722a..1ddc203 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -41,6 +41,10 @@ class DeployablesController < ApplicationController
@deployable.name = @image.name
@selected_catalogs = params[:catalog_id].to_a
load_catalogs
+ flash[:error] = []
+ flash[:error] << t("deployables.flash.error.no_catalog_exists") if
@catalogs.empty?
+ flash[:error] << t("deployables.flash.error.no_hwp_exists") if
@hw_profiles.empty?
+ @save_disabled = !(flash[:error].empty?)
elsif params[:catalog_id].present?
@catalog = Catalog.find(params[:catalog_id])
require_privilege(Privilege::MODIFY, @catalog)
diff --git a/src/app/views/deployables/_new_from_image.html.haml
b/src/app/views/deployables/_new_from_image.html.haml
index d57c5ed..fd2d609 100644
--- a/src/app/views/deployables/_new_from_image.html.haml
+++ b/src/app/views/deployables/_new_from_image.html.haml
@@ -40,7 +40,8 @@
.centered
%fieldset.align-center
= link_to t('deployables.form.cancel'), catalogs_path, :class =>
'button danger'
- = submit_tag "#{t'deployables.form.save'}", :name =>
'save', :class => 'button primary', :id => 'save_button'
+ = submit_tag "#{t'deployables.form.save'}", :name =>
'save', :class => 'button primary', :id => 'save_button',
:disabled => @save_disabled
+
:javascript
function listChecked() {
$("#checked_catalogs_list").text(function(){
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index d76e0ef..4da412f 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -887,6 +887,8 @@ en:
one: "Insufficient permissions to delete deployable %{not_deleted}!"
other: "Insufficient permissions to delete %{count} deployables
%{not_deleted}!"
not_selected: "No deployable was not selected!"
+ no_catalog_exists: "No catalog exists! Please create one."
+ no_hwp_exists: "No hardware profile exists! Please create one."
warning:
failed: "Deployable was not created: %{message}"
notice:
--
1.7.7.6