From 13d918b0e13dbacb85204de3f8890ca7de05ffe3 Mon Sep 17 00:00:00 2001 From: yaacov Date: Thu, 13 Apr 2017 11:09:06 +0300 Subject: [PATCH] Do not enable disabled button when items are selected --- app/helpers/application_helper/button/basic.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper/button/basic.rb b/app/helpers/application_helper/button/basic.rb index 5a14bb164e89..c82dfabbbd04 100644 --- a/app/helpers/application_helper/button/basic.rb +++ b/app/helpers/application_helper/button/basic.rb @@ -42,9 +42,15 @@ def localized(key, value = nil) # self[:prompt] -- the user has to confirm the action # self[:hidden] -- the button is not displayed in the toolbar # self[:text] -- text for the button + # self[:onwhen] -- enable button if items are selected def calculate_properties - self[:enabled] = !disabled? if self[:enabled].nil? - self[:title] = @error_message if @error_message.present? + enabled = !disabled? + self[:enabled] = enabled if self[:enabled].nil? + + unless self[:enabled] || enabled + self[:onwhen] = nil + self[:title] = @error_message if @error_message.present? + end end # Check if all instance variables for that button works with are set and