help-texts: add
users with permission edit_help_texts are allowed to select edit help texts from menu and enter texts for all event fields. Other users will see help texts as tooltips. This allows to provide help to users depending on your workflow. help texts are saved by project and studio.
This commit is contained in:
3
website/agenda/planung/css/edit-help-texts.css
Normal file
3
website/agenda/planung/css/edit-help-texts.css
Normal file
@@ -0,0 +1,3 @@
|
||||
textarea{
|
||||
width:100px;
|
||||
}
|
||||
237
website/agenda/planung/help-texts.cgi
Normal file
237
website/agenda/planung/help-texts.cgi
Normal file
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use params();
|
||||
use config();
|
||||
use entry();
|
||||
use template();
|
||||
use auth();
|
||||
use uac();
|
||||
use help_texts();
|
||||
use localization();
|
||||
use JSON;
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params = uac::setDefaultStudio( $params, $user_presets );
|
||||
$params = uac::setDefaultProject( $params, $user_presets );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
return get_help( $config, $request ) if $params->{action} eq 'get';
|
||||
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_help( $config, $request ) if $params->{action} eq 'save';
|
||||
delete_help( $config, $request ) if $params->{action} eq 'delete';
|
||||
}
|
||||
edit_help( $config, $request );
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
return;
|
||||
|
||||
sub save_help {
|
||||
my ($config, $request) = @_;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{edit_help_texts} == 1 ) {
|
||||
uac::permissions_denied('edit_help_texts');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id', 'table', 'column', 'text' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry = {};
|
||||
for my $attr ('project_id', 'studio_id', 'table', 'column', 'text') {
|
||||
$entry->{$attr} = $params->{$attr} if defined $params->{$attr};
|
||||
}
|
||||
my $user_settings = user_settings::get( $config, { user => $user } );
|
||||
$entry->{lang} = $user_settings->{language} || 'en',
|
||||
my $results = help_texts::get($config, {
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
lang => $entry->{lang},
|
||||
table => $entry->{table},
|
||||
column => $entry->{column},
|
||||
});
|
||||
$config->{access}->{write} = 1;
|
||||
if ( @$results ) {
|
||||
help_texts::update( $config, $entry );
|
||||
uac::print_info("help text saved.");
|
||||
} else {
|
||||
my $schedule_id = help_texts::insert( $config, $entry );
|
||||
uac::print_info("help text added.");
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
|
||||
sub delete_help {
|
||||
my ($config, $request) = @_;
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{edit_help_texts} == 1 ) {
|
||||
uac::permissions_denied('edit_help_texts');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id', 'table', 'column', 'text' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry = {};
|
||||
for my $attr ('project_id', 'studio_id', 'table', 'column') {
|
||||
$entry->{$attr} = $params->{$attr} if defined $params->{$attr};
|
||||
}
|
||||
my $user_settings = user_settings::get( $config, { user => $user } );
|
||||
$entry->{lang} = $user_settings->{language} || 'en',
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
help_texts::delete( $config, $entry );
|
||||
uac::print_info("help-text deleted");
|
||||
}
|
||||
|
||||
sub edit_help {
|
||||
my ($config, $request) = @_;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{edit_help_texts} == 1 ) {
|
||||
uac::permissions_denied('edit_help_texts');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $table = "calcms_events";
|
||||
my $help_texts = help_texts::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
table => $table
|
||||
}
|
||||
);
|
||||
my %texts_by_column = map { $_->{column} => $_->{text}} @$help_texts;
|
||||
my $texts_by_column = \%texts_by_column;
|
||||
|
||||
$params->{tables} = [{
|
||||
name => $table,
|
||||
columns => [
|
||||
{table => $table, column => 'title', value => ($texts_by_column->{title} // '') },
|
||||
{table => $table, column => 'user_title', value => ($texts_by_column->{user_title} // '') },
|
||||
{table => $table, column => 'episode', value => ($texts_by_column->{episode} // '') },
|
||||
{table => $table, column => 'start_date', value => ($texts_by_column->{start_date} // '') },
|
||||
{table => $table, column => 'end_date', value => ($texts_by_column->{end_date} // '') },
|
||||
{table => $table, column => 'duration', value => ($texts_by_column->{duration} // '') },
|
||||
{table => $table, column => 'live', value => ($texts_by_column->{live} // '') },
|
||||
{table => $table, column => 'published', value => ($texts_by_column->{published} // '') },
|
||||
{table => $table, column => 'playout', value => ($texts_by_column->{playout} // '') },
|
||||
{table => $table, column => 'archive', value => ($texts_by_column->{archive} // '') },
|
||||
{table => $table, column => 'rerun', value => ($texts_by_column->{rerun} // '') },
|
||||
{table => $table, column => 'draw', value => ($texts_by_column->{draw} // '') },
|
||||
{table => $table, column => 'excerpt', value => ($texts_by_column->{excerpt} // '') },
|
||||
{table => $table, column => 'topic', value => ($texts_by_column->{topic} // '') },
|
||||
{table => $table, column => 'content', value => ($texts_by_column->{content} // '') },
|
||||
{table => $table, column => 'image', value => ($texts_by_column->{image} // '') },
|
||||
{table => $table, column => 'podcast_url', value => ($texts_by_column->{podcast_url} // '') },
|
||||
{table => $table, column => 'archive_url', value => ($texts_by_column->{archive_url} // '') },
|
||||
{table => $table, column => 'wiki_language', value => ($texts_by_column->{wiki_language} // '') },
|
||||
]
|
||||
}];
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'edit-help-texts' } );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub get_help{
|
||||
my ($config, $request) = @_;
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $table = "calcms_events";
|
||||
my $help_texts = help_texts::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
table => $table
|
||||
}
|
||||
);
|
||||
my %texts_by_column = map { $_->{column} => $_->{text}} @$help_texts;
|
||||
my $texts_by_column = \%texts_by_column;
|
||||
print "Content-type:application/json\n\n".JSON::encode_json($texts_by_column);
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my ($config, $params) = @_;
|
||||
|
||||
my $checked = {};
|
||||
|
||||
$checked->{action} = entry::element_of( $params->{action},
|
||||
['get', 'edit', 'save', 'delete']
|
||||
);
|
||||
|
||||
entry::set_numbers( $checked, $params, ['project_id', 'studio_id']);
|
||||
entry::set_strings( $checked, $params, ['table', 'column', 'text']);
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'edit-help-texts' );
|
||||
return $checked;
|
||||
}
|
||||
@@ -333,7 +333,22 @@ $(document).ready(
|
||||
updateCheckBox("#edit_event input[name='published']", 0);
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
jQuery.getJSON("help-texts.cgi?project_id="+getProjectId()+"&studio_id="+getStudioId()+"&action=get",
|
||||
function(data){
|
||||
for (col in data){
|
||||
let value = data[col];
|
||||
console.log(col+" "+value)
|
||||
$(`input[name="${col}"]`).hover(function() {
|
||||
$(this).attr("title",value)
|
||||
});
|
||||
$(`textarea[class="${col}"]`).hover(function() {
|
||||
$(this).attr("title",value)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.log("done")
|
||||
}
|
||||
);
|
||||
|
||||
0
website/agenda/planung/pot/de/edit-help-texts.po
Normal file
0
website/agenda/planung/pot/de/edit-help-texts.po
Normal file
12
website/agenda/planung/pot/de/help-texts.po
Normal file
12
website/agenda/planung/pot/de/help-texts.po
Normal file
@@ -0,0 +1,12 @@
|
||||
msgid "save_button"
|
||||
msgstr "speichern"
|
||||
|
||||
msgid "delete_button"
|
||||
msgstr "löschen"
|
||||
|
||||
msgid "table"
|
||||
msgstr "Tabelle"
|
||||
|
||||
msgid "column"
|
||||
msgstr "spalte"
|
||||
|
||||
@@ -64,3 +64,7 @@ msgstr "Nutzeraktivität"
|
||||
msgid "create-events"
|
||||
msgstr "Sendungen anlegen"
|
||||
|
||||
msgid "edit-help-texts"
|
||||
msgstr "Hilfe bearbeiten"
|
||||
|
||||
|
||||
|
||||
@@ -253,3 +253,6 @@ msgstr "Vorproduktion löschen"
|
||||
msgid "label_read_playout"
|
||||
msgstr "Playout anzeigen"
|
||||
|
||||
msgid "label_edit_help_texts"
|
||||
msgstr "Hilfetexte bearbeiten"
|
||||
|
||||
|
||||
0
website/agenda/planung/pot/en/edit-help-texts.po
Normal file
0
website/agenda/planung/pot/en/edit-help-texts.po
Normal file
12
website/agenda/planung/pot/en/help-texts.po
Normal file
12
website/agenda/planung/pot/en/help-texts.po
Normal file
@@ -0,0 +1,12 @@
|
||||
msgid "save_button"
|
||||
msgstr "save"
|
||||
|
||||
msgid "delete_button"
|
||||
msgstr "delete"
|
||||
|
||||
msgid "table"
|
||||
msgstr "Table"
|
||||
|
||||
msgid "column"
|
||||
msgstr "Column"
|
||||
|
||||
@@ -64,3 +64,6 @@ msgstr "User Stats"
|
||||
msgid "create-events"
|
||||
msgstr "Create Events"
|
||||
|
||||
msgid "edit-help-texts"
|
||||
msgstr "Edit Help"
|
||||
|
||||
|
||||
@@ -256,3 +256,6 @@ msgstr "delete audio recordings"
|
||||
msgid "label_read_playout"
|
||||
msgstr "show playout"
|
||||
|
||||
msgid "label_edit_help_texts"
|
||||
msgstr "edit help texts"
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
<div><a href="user-stats.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>&action=show-user-stats"><img src="image/activity.svg"> <TMPL_VAR .loc.user-stats></a></div>
|
||||
</TMPL_IF>
|
||||
|
||||
<TMPL_IF .allow.edit_help_texts>
|
||||
<div><a id="edit_help_texts" href="help-texts.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR studio_id>&action=edit"><img src="image/help.svg"> <TMPL_VAR .loc.edit-help-texts></a></div>
|
||||
</TMPL_IF>
|
||||
|
||||
<div title="<TMPL_VAR .loc.profile>"><a href="user-settings.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>"><img src="image/settings.svg"> <TMPL_VAR .loc.profile></a></div>
|
||||
|
||||
<div title="<TMPL_VAR .loc.help>"><a href="help.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>"><img src="image/help.svg"> <TMPL_VAR .loc.help></a></div>
|
||||
|
||||
21
website/agenda/planung/templates/edit-help-texts.html
Normal file
21
website/agenda/planung/templates/edit-help-texts.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<script src="js/edit-help-texts.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="css/edit-help-texts.css" type="text/css" />
|
||||
|
||||
<TMPL_LOOP tables>
|
||||
Table <TMPL_VAR name>
|
||||
<table>
|
||||
<TMPL_LOOP columns>
|
||||
<tr>
|
||||
<form action="help-texts.cgi" method=post>
|
||||
<input type="hidden" name="project_id" value="<TMPL_VAR .project_id>">
|
||||
<input type="hidden" name="studio_id" value="<TMPL_VAR .studio_id>">
|
||||
<input type="hidden" name="table" value="<TMPL_VAR table>">
|
||||
<input type="hidden" name="column" value="<TMPL_VAR column>">
|
||||
<td><TMPL_VAR column></td>
|
||||
<td><textarea name="text" style="width:80ch;height:8rem;"><TMPL_VAR value></textarea></td>
|
||||
<td><input type="submit" name="action" value="save"></td>
|
||||
</form>
|
||||
</tr>
|
||||
</TMPL_LOOP>
|
||||
</table>
|
||||
</TMPL_LOOP>
|
||||
Reference in New Issue
Block a user