Skip to content

Commit

Permalink
Empty out Price value during save is currency was unset.
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kataria committed Jul 3, 2019
1 parent 3703088 commit 12a460a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -254,7 +254,6 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', '$timeou
service_template_catalog_id: configData.catalog_id,
zone_id: configData.zone_id,
currency_id: configData.currency_id,
price: configData.price,
prov_type: 'generic_ansible_playbook',
type: 'ServiceTemplateAnsiblePlaybook',
additional_tenant_ids: configData.additional_tenant_ids,
Expand All @@ -270,6 +269,12 @@ ManageIQ.angular.app.controller('catalogItemFormController', ['$scope', '$timeou
},
},
};

if (typeof vm.catalogItemModel.currency_id !== 'undefined' && vm.catalogItemModel.currency_id !== '') {
catalog_item.price = configData.price
} else {
catalog_item.price = '';
}
if (vm.catalogItemModel.provisioning_execution_ttl !== undefined) {
catalog_item.config_info.provision.execution_ttl = configData.provisioning_execution_ttl;
}
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/catalog_controller.rb
Expand Up @@ -900,8 +900,8 @@ def atomic_req_submit
st.add_resource(request) if need_prov_dialogs?(@edit[:new][:st_prov_type])
end
end
st.currency = ChargebackRateDetailCurrency.find_by(:id => @edit[:new][:currency].to_i) if @edit[:new][:currency]
st.price = @edit[:new][:price] if @edit[:new][:price]
st.currency = @edit[:new][:currency] ? ChargebackRateDetailCurrency.find_by(:id => @edit[:new][:currency].to_i) : nil
st.price = st.currency ? @edit[:new][:price] : nil if @edit[:new][:price]

if st.save
set_resource_action(st) unless st.kind_of?(ServiceTemplateContainerTemplate)
Expand Down Expand Up @@ -1065,8 +1065,8 @@ def common_st_record_vars(st)
st.generic_subtype = @edit[:new][:generic_subtype] if @edit[:new][:st_prov_type] == 'generic'
st.zone_id = @edit[:new][:zone_id]
st.additional_tenants = Tenant.where(:id => @edit[:new][:tenant_ids]) # Selected Additional Tenants in the tree
st.currency = ChargebackRateDetailCurrency.find_by(:id => @edit[:new][:currency].to_i) if @edit[:new][:currency]
st.price = @edit[:new][:price] if @edit[:new][:price]
st.currency = @edit[:new][:currency] ? ChargebackRateDetailCurrency.find_by(:id => @edit[:new][:currency].to_i) : nil
st.price = st.currency ? @edit[:new][:price] : nil if @edit[:new][:price]
end

def st_set_record_vars(st)
Expand Down Expand Up @@ -1271,7 +1271,7 @@ def get_form_vars

if params[:currency]
@edit[:new][:currency] = params[:currency].blank? ? nil : params[:currency].to_i
@edit[:new][:code_currency] = code_currency_label(params[:currency]) if @edit[:new][:currency]
@edit[:new][:code_currency] = @edit[:new][:currency] ? code_currency_label(params[:currency]) : _('Price / Month')
end
@edit[:new][:price] = params[:price] if params[:price]

Expand Down

0 comments on commit 12a460a

Please sign in to comment.