timesheet context menus are now complete:

- query all is moved into context menu
- legacy support only contains button to trigger context menu
- moved some common phrases into the API:
  + Delete this entry
  + Delete these entries
  + You need to select some entries first!
- support for singular and plural confirmation messages
This commit is contained in:
Ralf Becker 2011-04-17 18:53:45 +00:00
parent 8e9279c7b7
commit 6081a5749d
10 changed files with 75 additions and 44 deletions

View File

@ -979,9 +979,9 @@ class etemplate extends boetemplate
'.$prefix.'actionManager = new egwActionManager();
'.$prefix.'objectManager = new egwActionObjectManager("", '.$prefix.'actionManager);
// Add some dummy actions to the actionManager
'.$prefix.'actionManager.updateActions('.str_replace('},',"},\n",
json_encode(nextmatch_widget::egw_actions($content['_actions'], $this->name))).');
'.$prefix.'actionManager.setDefaultExecute("javaScript:nm_action");
var actionLinks = ['.($content['_actions'] ? '"'.implode('","', isset($content['_actions_enabled']) ?
$content['_actions_enabled'] : array_keys($content['_actions'])).'"' : '').'];

View File

@ -528,13 +528,15 @@ class nextmatch_widget
* - string 'onExecute' javascript to run, default 'javascript:nm_action' which runs action specified in nm_action attribute:
* - string 'nm_action'
* + 'alert' debug action, shows alert with action caption, id and id's of selected rows
* + 'submit' default action, sets nm[action], nm[selected]
* + 'submit' default action, sets nm[action], nm[selected] and nm[select_all]
* + 'location' redirects / set location.href to 'url' attribute
* + 'popup' opens popup with url given in 'url' attribute
* - string 'url' url for location or popup
* - string 'target' target for location or popup
* - string 'width' for popup
* - string 'height' for popup
* - string 'confirm' confirmation message
* - string 'confirm_multiple' confirmation message for multiple selected, defaults to 'confirm'
*
* That's what we should return looks JSON encoded like
* [
@ -574,13 +576,6 @@ class nextmatch_widget
if (!is_array($action)) $action = array('caption' => $action);
$action['id'] = $prefix.$id;
// set some defaults
if (!isset($action['type'])) $action['type'] = 'popup';
if (!isset($action['onExecute']))
{
$action['onExecute'] = 'javaScript:nm_action'; // defined in etemplate/js/nextmatch_action.js
}
// set default icon, if no other is specified
if (!isset($action['icon']) && isset($default_icons[$id]))
{
@ -599,12 +594,19 @@ class nextmatch_widget
unset($action['icon']); // no need to submit it
}
// translate labels
if (!$action['no_lang']) $action['caption'] = lang($action['caption']);
if (!$action['no_lang'])
{
$action['caption'] = lang($action['caption']);
if ($action['hint']) $action['hint'] = lang($action['hint']);
}
unset($action['no_lang']);
if (isset($action['confirm']))
foreach(array('confirm','confirm_multiple') as $confirm)
{
$action['confirm'] = lang($action['confirm']).(substr($action['confirm'],-1) != '?' ? '?' : '');
if (isset($action[$confirm]))
{
$action[$confirm] = lang($action[$confirm]).(substr($action[$confirm],-1) != '?' ? '?' : '');
}
}
// link or popup action
@ -633,6 +635,7 @@ class nextmatch_widget
static $egw_action_supported = array( // attributes supported by egw_action
'id','caption','iconUrl','type','default','onExecute','group',
'enabled','allowOnMultiple','hideOnDisabled','data','children',
'hint','checkbox','checked','radioGroup',
);
// add all not egw_action supported attributes to data
$action['data'] = array_merge(array_diff_key($action, array_flip($egw_action_supported)),(array)$action['data']);

View File

@ -100,13 +100,18 @@ function nm_action(_action, _senders)
ids += (_senders[i].id.indexOf(',') >= 0 ? '"'+_senders[i].id.replace(/"/g,'""')+'"' : _senders[i].id) +
((i < _senders.length - 1) ? "," : "");
}
console.log(_action);
console.log(_senders);
//console.log(_action); console.log(_senders);
// let user confirm the action first
if (typeof _action.data.confirm != 'undefined')
var select_all = document.getElementById('exec[nm][select_all]');
// let user confirm the action first (if not select_all set and nm_action == 'submit' --> confirmed later)
if (!(select_all && select_all.value && _action.data.nm_action == 'submit') &&
typeof _action.data.confirm != 'undefined')
{
if (!confirm(_action.data.confirm)) return;
var confirm_msg = _senders.length > 1 && typeof _action.data.confirm_multiple != 'undefined' ?
_action.data.confirm_multiple : _action.data.confirm;
if (!confirm(confirm_msg)) return;
}
var url = '#';
@ -136,8 +141,12 @@ function nm_action(_action, _senders)
break;
case 'submit':
// let user confirm select-all
if (select_all && select_all.value)
{
if (!confirm(select_all.value)) return;
}
var form = document.getElementsByName("eTemplate")[0];
document.getElementById('exec[nm][action]').value = _action.id;
document.getElementById('exec[nm][selected]').value = ids;
if (typeof _action.data.button != 'undefined')
@ -151,3 +160,14 @@ function nm_action(_action, _senders)
break;
}
}
/**
* Callback for select_all checkbox, use hint to confirm all nm_action='submit' before submitting in nm_action()
*
* @param _action
* @param _senders
*/
function nm_select_all(_action, _senders)
{
document.getElementById('exec[nm][select_all]').value = _action.checked ? _action.hint : false;
}

View File

@ -33,6 +33,7 @@ account is expired common de Benutzerkennung ist abgelaufen
accounts common de Benutzerkonten
acl common de ACL
action common de Aktion
actions common de Befehle
active common de Aktiv
add common de Hinzufügen
add %1 category for common de %1 Kategorie hinzufügen für
@ -195,6 +196,8 @@ default height for the windows common de Vorgabewert für Höhe des Fensters
default width for the windows common de Vorgabewert für Breite des Fensters
delete common de Löschen
delete row common de Zeile löschen
delete these entries common de Diese Einträge löschen
delete this entry common de Diesen Eintrag löschen
denmark common de DÄNEMARK
description common de Beschreibung
detail common de Detail
@ -598,6 +601,7 @@ search or select accounts common de Suchen und auswählen von Benutzern
second common de Sekunden
section common de Sektion
select common de Auswählen
select action common de Befehl auswählen
select all %1 %2 for %3 common de Alles auswählen %1 %2 von %3
select category common de Kategorie auswählen
select date common de Datum auswählen
@ -779,6 +783,7 @@ you have successfully logged out common de Sie haben sich erfolgreich abgemeldet
you need to %1set your timezone preference%2. common de Sie müssen %1Ihre Zeitzone in den Einstellungen setzen%2
you need to add the webserver user '%1' to the group '%2'. common de Sie müssen den Webserver-User '%1' zur Gruppe '%2' hinzufügen.
you need to be an egroupware administrator to access this functionality! common de Sie müssen ein EGroupware Administrator sein, um auf diese Funktion zuzugreifen!
you need to select some entries first! common de Sie müssen zuerst einige Datensätze auswählen!
you've tried to open the egroupware application: %1, but you have no permission to access this application. common de Sie haben versucht auf die EGroupware Anwendung %1 zuzugreifen, auf die Sie keine Rechte haben.
your message could <b>not</b> be sent!<br> common de Ihre Nachricht konnte <b>nicht</b> gesendet werden!<br>
your message has been sent common de Ihre Nachricht wurde versendet

View File

@ -33,6 +33,7 @@ account is expired common en Account is expired
accounts common en Accounts
acl common en ACL
action common en Action
actions common en Actions
active common en Active
add common en Add
add %1 category for common en Add %1 category for
@ -195,6 +196,8 @@ default height for the windows common en Default height for the windows
default width for the windows common en Default width for the windows
delete common en Delete
delete row common en Delete row
delete these entries common en Delete these entries
delete this entry common en Delete this entry
denmark common en DENMARK
description common en Description
detail common en Detail
@ -599,6 +602,7 @@ search or select accounts common en search or select accounts
second common en second
section common en Section
select common en Select
select action common en Select action
select all %1 %2 for %3 common en Select all %1 %2 for %3
select category common en Select Category
select date common en Select date
@ -780,6 +784,7 @@ you have successfully logged out common en You have successfully logged out
you need to %1set your timezone preference%2. common en You need to %1set your timezone preference%2.
you need to add the webserver user '%1' to the group '%2'. common en You need to add the webserver user '%1' to the group '%2'.
you need to be an egroupware administrator to access this functionality! common en You need to be an eGroupWare administrator to access this functionality!
you need to select some entries first! common en You need to select some entries first!
you've tried to open the egroupware application: %1, but you have no permission to access this application. common en You've tried to open the eGroupWare application: %1, but you have no permission to access this application.
your message could <b>not</b> be sent!<br> common en Your message could <b>not</b> be sent!<br>
your message has been sent common en Your message has been sent

View File

@ -778,10 +778,9 @@ class timesheet_ui extends timesheet_bo
}
if ($content['nm']['action'])
{
if ($content['use_all']) $content['nm']['select_all'] = $content['use_all']; // legacy support
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
{
$msg = lang('You need to select some timesheets first');
$msg = lang('You need to select some entries first!');
}
else
{
@ -798,7 +797,7 @@ class timesheet_ui extends timesheet_bo
}
$content = array(
// 'nm' => $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP),
'nm' => $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP),
'msg' => $msg,
);
if (!is_array($content['nm']))
@ -821,10 +820,12 @@ class timesheet_ui extends timesheet_bo
'filter_onchange' => "set_style_by_class('table','custom_hide','visibility',this.value == 'custom' ? 'visible' : 'hidden'); if (this.value != 'custom') this.form.submit();",
'filter2' => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'],
'row_id' => 'ts_id',
'actions' => $this->get_actions(),
//'actions' => $this->get_actions(),
'default_cols' => '!legacy_actions', // switch legacy actions column and row off by default
);
}
$content['nm']['actions'] = $this->get_actions();
if($_GET['search'])
{
$content['nm']['search'] = $_GET['search'];
@ -858,6 +859,8 @@ class timesheet_ui extends timesheet_bo
/**
* Get actions / context menu for index
*
* Changes here, require to log out, as $content['nm'] get stored in session!
*
* @return array see nextmatch_widget::egw_actions()
*/
private function get_actions()
@ -884,13 +887,20 @@ class timesheet_ui extends timesheet_bo
'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'group' => $group,
),
'select_all' => array(
'caption' => 'Whole query',
'checkbox' => true,
'onExecute' => 'javaScript:nm_select_all', // uses hint to confirm all nm_action='submit'
'hint' => 'Apply the action on the whole query, NOT only the shown timesheets!!!',
'group' => ++$group,
),
'cat' => nextmatch_widget::category_action(
'timesheet',++$group,'Change category','cat_'
),
'status' => array(
'icon' => 'apply',
'caption' => 'Modify status',
'group' => ++$group,
'group' => $group,
'children' => $this->status_labels,
'prefix' => 'to_status_',
'enabled' => (boolean)$this->status_labels,
@ -908,6 +918,7 @@ class timesheet_ui extends timesheet_bo
'delete' => array(
'caption' => 'Delete',
'confirm' => 'Delete this entry',
'confirm_multiple' => 'Delete these entries',
'group' => ++$group,
),
);

View File

@ -4,9 +4,7 @@
2 month ago timesheet de Vor 2 Monaten
2 years ago timesheet de Vor 2 Jahren
3 years ago timesheet de Vor 3 Jahren
actions timesheet de Aktionen
all projects timesheet de Alle Projekte
all status timesheet de Alle Status
and its members timesheet de und die Mitglieder
applies the changes timesheet de Änderungen durchführen
apply the action on the whole query, not only the shown timesheets!!! timesheet de Wendet den Befehl auf die gesamte Abfrage an, NICHT nur die angezeigten Stundenzettel!!
@ -24,10 +22,9 @@ creates a new field timesheet de neues Feld anlegen
creating new entry timesheet de neuen Eintrag anlegen
custom fields timesheet de Benutzerdefinierte Felder
default document to insert entries timesheet de Standarddokument zum Einfügen von Stundenzetteln
delete this entry timesheet de Diesen Eintrag löschen
delete this status timesheet de Diesen Status löschen
deleted timesheet de gelöscht
deletes this field timesheet de Dies Feld löschen
deletes this field timesheet de Dieses Feld löschen
determines the order the fields are displayed timesheet de verändert die Reihenfolge der angezeigten Felder
directory with documents to insert entries timesheet de Verzeichnis mit Dokumenten zum Einfügen.
document '%1' does not exist or is not readable for you! timesheet de Datei '%1' steht nicht zur Verfügung oder ist nicht für Sie zum lesen freigegeben!
@ -107,7 +104,6 @@ saves this entry and add a new one timesheet de Speichert diesen Eintrag und fü
select a price timesheet de Preis auswählen
select a project timesheet de Projekt auswählen
select a status of the timesheet timesheet de einen status auswählen
select action timesheet de Bitte eine Aktion auswählen
select infolog timesheet de Infolog auswählen
select multiple timeshhets for a further action timesheet de Wählen Sie mehrere Stundenzettel für einen weitere Aktion aus
select the predefined status, whan creating a new timesheet preferences de Wählen Sie einen Status als Vorgabe für neu zu erstellende Stundenzettel aus
@ -116,6 +112,7 @@ show a quantity sum (eg. to sum up negative overtime) admin de Zeige eine Mengen
start timesheet de Start
starttime timesheet de Startzeit
starttime has to be before endtime !!! timesheet de Startzeit muss vor der Endzeit liegen !!!
status timesheet de Status
status deleted. timesheet de Status gelöscht
status of created timesheets timesheet de Status für neue Stundenzettel
status updated. timesheet de Status geändert
@ -137,13 +134,10 @@ timesheet openoffice export timesheet de Export des Stundenzettels als Open Off
timesheet status-%1 '%2' added. timesheet de Stundenzettel Status %1 '%2' hinzugefügt.
timesheet-%1 '%2' updated. timesheet de Stundenzettel Status %1 '%2' geändert
timesheet-%1 deleted. timesheet de Stundenzettel %1 gelöscht
tracker timesheet de Verfolgungssystem
unitprice timesheet de Preis pro Einheit
use this tag for addresslabels. put the content, you want to repeat, between two tags. timesheet de Verwenden Sie diesen Platzhalter für den den Seriendruck. Fügen Sie den Inhalt, der wiederholt werden soll, zwischen zwei Platzhaltern ein.
values for selectbox timesheet de Werte der Auswahlbox
view this entry timesheet de Diesen Eintrag anzeigen
week timesheet de Woche
whole query timesheet de gesamte Abfrage
yesterday timesheet de Gestern
you need to select some timesheets first timesheet de Sie müssen zuerst Datensätze auswählen
your database is not up to date (%1 vs. %2), please run %3setup%4 to update your database. timesheet de Ihre Datenbank ist NICHT aktuell (%1 statt %2), bitte rufen sie %3setup%4 auf um die Datenbank zu aktualisieren.

View File

@ -4,9 +4,7 @@
2 month ago timesheet en 2 month ago
2 years ago timesheet en 2 years ago
3 years ago timesheet en 3 years ago
actions timesheet en Actions
all projects timesheet en All projects
all status timesheet en All status
and its members timesheet en and its members
applies the changes timesheet en applies the changes
apply the action on the whole query, not only the shown timesheets!!! timesheet en Apply the action on the whole query, NOT only the shown timesheets!!!
@ -24,7 +22,6 @@ creates a new field timesheet en creates a new field
creating new entry timesheet en creating new entry
custom fields timesheet en Custom fields
default document to insert entries timesheet en Default document to insert entries
delete this entry timesheet en Delete this entry
delete this status timesheet en Delete this status
deleted timesheet en deleted
deletes this field timesheet en deletes this field
@ -107,7 +104,6 @@ saves this entry and add a new one timesheet en Saves this entry and add a new o
select a price timesheet en Select a price
select a project timesheet en Select a project
select a status of the timesheet timesheet en select a status of the timesheet
select action timesheet en Select action
select infolog timesheet en select Infolog
select multiple timeshhets for a further action timesheet en Select multiple timeshhets for a further action
select the predefined status, whan creating a new timesheet preferences en Select the predefined status, whan creating a new timesheet
@ -116,6 +112,7 @@ show a quantity sum (eg. to sum up negative overtime) admin en Show a quantity s
start timesheet en Start
starttime timesheet en Starttime
starttime has to be before endtime !!! timesheet en Starttime has to be before endtime !!!
status timesheet en Status
status deleted. timesheet en Status deleted.
status of created timesheets timesheet en Status of created timesheets
status updated. timesheet en Status updated.
@ -137,13 +134,10 @@ timesheet openoffice export timesheet en Timesheet OpenOffice export
timesheet status-%1 '%2' added. timesheet en Timesheet Status-%1 '%2' added.
timesheet-%1 '%2' updated. timesheet en Timesheet-%1 '%2' updated.
timesheet-%1 deleted. timesheet en Timesheet-%1 deleted.
tracker timesheet en Tracker
unitprice timesheet en Unitprice
use this tag for addresslabels. put the content, you want to repeat, between two tags. timesheet en Use this tag for addresslabels. Put the content, you want to repeat, between two tags.
values for selectbox timesheet en Values for selectbox
view this entry timesheet en View this entry
week timesheet en Week
whole query timesheet en whole query
yesterday timesheet en Yesterday
you need to select some timesheets first timesheet en You need to select some timesheets first
your database is not up to date (%1 vs. %2), please run %3setup%4 to update your database. timesheet en Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.

File diff suppressed because one or more lines are too long

View File

@ -67,7 +67,7 @@
<textbox type="float" id="price" readonly="true" precision="2"/>
</vbox>
<nextmatch-filterheader id="ts_owner" options="User" no_lang="1" class="$cont[ownerClass]"/>
<nextmatch-filterheader id="ts_status" onchange="1" options="All status"/>
<nextmatch-filterheader id="ts_status" onchange="1" options="Status"/>
<nextmatch-customfields id="customfields"/>
<hbox class="noPrint">
<nextmatch-header label="Actions" class="noPrint" align="right" id="legacy_actions"/>
@ -130,8 +130,7 @@
<row class="noPrint" disabled="!@nm[selectcols]=/legacy_actions/">
<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=timesheet.timesheet_ui.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
<hbox align="right">
<checkbox id="use_all" label="whole query" onchange="if (this.checked==true &amp;&amp; !confirm('Apply the action on the whole query, NOT only the shown timesheets!!!')) this.checked=false;" statustext="Apply the action on the whole query, NOT only the shown timesheets!!!"/>
<buttononly id="legacy_actions" statustext="Select action" label="Select action" onclick="if (!egw_objectManager.executeActionImplementation(this, 'popup')) alert(egw::lang('You need to select some timesheets first')); return false;;"/>
<buttononly id="legacy_actions" statustext="Select action" label="Select action" onclick="if (!egw_objectManager.executeActionImplementation(this, 'popup')) alert(egw::lang('You need to select some entries first!')); return false;;"/>
<button image="arrow_ltr" label="Check all" id="check_all" statustext="Check all" onclick="toggle_all(this.form,form::name('nm[rows][checked][]')); return false;" needed="1" class="checkAllArrow"/>
</hbox>
</row>