From c4f903975358f75bd6314c2cc5a1b41b4b2a5fa7 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 9 Nov 2016 12:28:11 +0100 Subject: [PATCH] =?utf8?q?ActionBar:=20bei=20Click=20auf=20Combo=20ohne=20?= =?utf8?q?oberste=20Action=20Men=C3=BC=20aufklappen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Manche Comboboxes wie z.B. »Workflow« oder »mehr« haben auf dem obersten Button keine Action konfiguriert (weder »submit« noch »call«). Um die Benutzer nicht zu sehr zu verwirren, werden diese nun nicht mehr als deaktiviert dargestellt. Bei einem Klick auf den Button-Teil der Combobox wird dann das Menü aufgeklappt, genau so, als hätte man auf den Pfeil-Teil geklickt. --- bin/mozilla/ir.pl | 4 +--- bin/mozilla/is.pl | 12 +++--------- bin/mozilla/oe.pl | 12 +++--------- js/kivi.ActionBar.js | 21 ++++++++++++++------- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 69dd201d9..ecd2696d7 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -267,9 +267,7 @@ sub setup_ir_action_bar { $bar->add_actions('separator'); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('more'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('more') ]); $bar->actions->[-1]->add_actions([ t8('History'), call => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index c2e696854..297a87d5a 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -309,9 +309,7 @@ sub setup_is_action_bar { $bar->add_actions('separator'); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('Workflow'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('Workflow') ]); $bar->actions->[-1]->add_actions([ t8('Use As New'), submit => [ '#form', { action_use_as_new => 1 } ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, @@ -329,9 +327,7 @@ sub setup_is_action_bar { ]); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('Export'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('Export') ]); $bar->actions->[-1]->add_actions([ ($form->{id} ? t8('Print') : t8('Preview')), submit => [ '#form', { action_print => 1 } ], checks => [ @req_trans_desc ], @@ -343,9 +339,7 @@ sub setup_is_action_bar { disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ]); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('more'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('more') ]); $bar->actions->[-1]->add_actions([ t8('History'), call => [ 'set_history_window', $form->{id} * 1, 'id' ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 16a27b667..4f28be89a 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -352,9 +352,7 @@ sub setup_oe_action_bar { $bar->add_actions('separator'); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('Workflow'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('Workflow') ]); $bar->actions->[-1]->add_actions([ t8('Sales Order'), submit => [ '#form', { action_sales_order => 1 } ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, @@ -381,9 +379,7 @@ sub setup_oe_action_bar { ]); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('Export'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('Export') ]); $bar->actions->[-1]->add_actions([ t8('Print'), submit => [ '#form', { action_print => 1 } ], checks => [ @req_trans_desc ], @@ -393,9 +389,7 @@ sub setup_oe_action_bar { checks => [ @req_trans_desc ], ]); $bar->add_actions('combobox'); - $bar->actions->[-1]->add_actions([ t8('more'), - disabled => 1, - ]); + $bar->actions->[-1]->add_actions([ t8('more') ]); $bar->actions->[-1]->add_actions([ t8('History'), call => [ 'set_history_window', $form->{id} * 1, 'id' ], disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, diff --git a/js/kivi.ActionBar.js b/js/kivi.ActionBar.js index 0963d73da..cda193562 100644 --- a/js/kivi.ActionBar.js +++ b/js/kivi.ActionBar.js @@ -10,21 +10,28 @@ namespace('kivi', function(k){ }; k.ActionBarCombobox = function(e) { - this.combobox = e; - this.head = e.childNodes[0]; - this.toggle = this.head.childNodes[1]; - this.list = e.childNodes[0]; + this.combobox = e; + this.head = e.childNodes[0]; + this.topAction = this.head.childNodes[0]; + this.toggle = this.head.childNodes[1]; + this.list = e.childNodes[0]; this.init(); }; k.ActionBarCombobox.prototype = { init: function() { - var obj = this; - $(obj.toggle).on('click', function(event){ + var obj = this; + var toggler = function(event){ $('div.' + CLASSES.combobox + '[id!=' + obj.combobox.id + ']').removeClass(CLASSES.active); $(obj.combobox).toggleClass(CLASSES.active); event.stopPropagation(); - }); + }; + + $(obj.toggle).on('click', toggler); + + var data = $(this.topAction).data('action') || {}; + if (!data.call && !data.submit) + $(this.topAction).on('click', toggler); } }; -- 2.20.1