mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:20 +01:00
Use et2-select webcomponent for quick add button
This commit is contained in:
parent
656e6561d9
commit
5038d060fe
@ -484,18 +484,17 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
|||||||
// check if quick-add selectbox is alread there, only create it again if not
|
// check if quick-add selectbox is alread there, only create it again if not
|
||||||
if (document.getElementById('quick_add_selectbox')) return;
|
if (document.getElementById('quick_add_selectbox')) return;
|
||||||
|
|
||||||
const select = jQuery(document.createElement('select')).attr('id', 'quick_add_selectbox');
|
const select = document.createElement('et2-select');
|
||||||
jQuery(typeof _parent === 'string' ? '#'+_parent : _parent).append(select);
|
select.setAttribute('id', 'quick_add_selectbox');
|
||||||
|
document.getElementById(_parent).append(select);
|
||||||
const self = this;
|
const self = this;
|
||||||
// bind change handler
|
// bind change handler
|
||||||
select.change(function(){
|
select.addEventListener('change', function(){
|
||||||
if (this.value) self.open('', this.value, 'add', {}, undefined, this.value, true);
|
if (this.value) self.open('', this.value, 'add', {}, undefined, this.value, true);
|
||||||
this.value = '';
|
|
||||||
});
|
});
|
||||||
// need to load common translations for app-names
|
// need to load common translations for app-names
|
||||||
this.langRequire(window, [{app: 'common', lang: this.preference('lang')}], function(){
|
this.langRequire(window, [{app: 'common', lang: this.preference('lang')}], function(){
|
||||||
select.append(jQuery(document.createElement('option')).attr('value', '').text(self.lang('Add')+' ...'));
|
let options = [];
|
||||||
const apps = self.link_app_list('add');
|
const apps = self.link_app_list('add');
|
||||||
for(let app in apps)
|
for(let app in apps)
|
||||||
{
|
{
|
||||||
@ -503,10 +502,18 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const option = jQuery(document.createElement('option')).attr('value', app)
|
options.push({
|
||||||
.text(self.lang(self.link_get_registry(app,'entry') || apps[app]));
|
value:app,
|
||||||
select.append(option);
|
label:self.lang(self.link_get_registry(app,'entry') || apps[app]),
|
||||||
|
icon: `${egw.webserverUrl}/${app}/templates/pixelegg/images/navbar.svg`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
select.select_options = options;
|
||||||
|
select.updateComplete.then(function(){
|
||||||
|
select.dropdown.trigger.style.visibility = 'hidden';
|
||||||
|
select.dropdown.trigger.style.height = '0px';
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5580,8 +5580,13 @@ span.overlayContainer img.overlay {
|
|||||||
#egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results {
|
#egw_fw_topmenu_info_items #topmenu_info_quick_add .chzn-container .chzn-results {
|
||||||
max-height: none;
|
max-height: none;
|
||||||
}
|
}
|
||||||
#egw_fw_topmenu_info_items #topmenu_info_quick_add select#quick_add_selectbox {
|
#egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox {
|
||||||
visibility: hidden;
|
height: 0px;
|
||||||
|
float: left;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#egw_fw_topmenu_info_items #topmenu_info_quick_add #quick_add_selectbox::part(form-control-input) {
|
||||||
|
border: none !important;
|
||||||
}
|
}
|
||||||
#egw_fw_topmenu_info_items img#topmenu_info_error {
|
#egw_fw_topmenu_info_items img#topmenu_info_error {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
@ -17,33 +17,19 @@ egw_ready.then(function()
|
|||||||
jQuery('#quick_add').on({
|
jQuery('#quick_add').on({
|
||||||
mouseover: function(ev){
|
mouseover: function(ev){
|
||||||
// do NOT react on bubbeling events from contained selectbox
|
// do NOT react on bubbeling events from contained selectbox
|
||||||
var $select = jQuery('#quick_add_selectbox');
|
var select = document.getElementById('quick_add_selectbox');
|
||||||
if (!$select.children()[0]['value']) $select.children()[0].text = '';
|
select.dropdown.open = true;
|
||||||
var $chosen_div = $select.next();
|
|
||||||
if ($chosen_div.hasClass('chzn-container'))
|
|
||||||
{
|
|
||||||
$chosen_div.show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$select.chosen({
|
|
||||||
disable_search: true,
|
|
||||||
display_selected_options: false
|
|
||||||
});
|
|
||||||
$chosen_div = $select.next();
|
|
||||||
}
|
|
||||||
$select.trigger('liszt:open');
|
|
||||||
$select.on('liszt:hiding_dropdown', function(e){
|
|
||||||
$chosen_div.hide();
|
|
||||||
});
|
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
|
||||||
},
|
},
|
||||||
mouseout: function(ev){
|
mouseout: function(ev){
|
||||||
|
var select = document.getElementById('quick_add_selectbox');
|
||||||
|
|
||||||
// do NOT react on bubbeling events from contained selectbox
|
// do NOT react on bubbeling events from contained selectbox
|
||||||
if (ev.target && ev.relatedTarget && ev.target.id != 'quick_add_selectbox'
|
if (ev.target && ev.relatedTarget && ev.currentTarget.id != "quick_add" && ev.currentTarget.nodeName != 'ET2-SELECT')
|
||||||
&& !jQuery(ev.relatedTarget).hasClass('chzn-container'))
|
|
||||||
{
|
{
|
||||||
jQuery('#quick_add_selectbox').next().hide();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
}
|
}
|
||||||
|
@ -292,8 +292,13 @@
|
|||||||
max-height: none;
|
max-height: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
select#quick_add_selectbox {
|
#quick_add_selectbox {
|
||||||
visibility: hidden;
|
height: 0px;
|
||||||
|
float: left;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#quick_add_selectbox::part(form-control-input) {
|
||||||
|
border: none !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user