summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-04-05 12:51:49 -0700
committerMark Wells <mark@freeside.biz>2016-04-05 13:06:08 -0700
commitcc40b7d77271966a6922317774f63f8fa86d0871 (patch)
treeb4de05e311617bc452e67345950a86f67f1c111b /httemplate
parent97dab063eab4cd6106b2d4f96d574a9594984cf7 (diff)
persistent user prefs for UI pages, #41397
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/elements/header.html8
-rw-r--r--httemplate/elements/page_pref.js10
-rw-r--r--httemplate/misc/process/set_page_pref.html12
3 files changed, 30 insertions, 0 deletions
diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html
index c8a83ca7e..699f82c53 100644
--- a/httemplate/elements/header.html
+++ b/httemplate/elements/header.html
@@ -53,6 +53,12 @@ Example:
<% $head |n %>
+%# announce our base path, and the Mason comp path of this page
+ <script type="text/javascript">
+ window.fsurl = <% $fsurl |js_string %>;
+ window.request_comp_path = <% $m->request_comp->path |js_string %>;
+ </script>
+
</HEAD>
<BODY BGCOLOR="#f8f8f8" <% $etc |n %> STYLE="margin-top:0; margin-bottom:0; margin-left:0px; margin-right:0px">
<table width="100%" CELLPADDING=0 CELLSPACING=0 STYLE="padding-left:0px; padding-right:4px" CLASS="fshead">
@@ -178,6 +184,7 @@ Example:
% }
<% $menubar !~ /^\s*$/ ? "$menubar<BR><BR>" : '' %>
+
<%init>
my( $title, $title_noescape, $menubar, $etc, $head ) = ( '', '', '', '', '' );
@@ -225,4 +232,5 @@ if ( scalar(@agentnums) == 1 ) {
$company_name = $conf->config('company_name');
$company_url = $conf->config('company_url');
}
+
</%init>
diff --git a/httemplate/elements/page_pref.js b/httemplate/elements/page_pref.js
new file mode 100644
index 000000000..253c6da86
--- /dev/null
+++ b/httemplate/elements/page_pref.js
@@ -0,0 +1,10 @@
+function set_page_pref(prefname, tablenum, prefvalue, success) {
+ jQuery.post( window.fsurl + 'misc/process/set_page_pref.html',
+ { path: window.request_comp_path,
+ name: prefname,
+ num: tablenum,
+ value: prefvalue
+ },
+ success
+ );
+}
diff --git a/httemplate/misc/process/set_page_pref.html b/httemplate/misc/process/set_page_pref.html
new file mode 100644
index 000000000..a7f123116
--- /dev/null
+++ b/httemplate/misc/process/set_page_pref.html
@@ -0,0 +1,12 @@
+<%init>
+my $path = $cgi->param('path');
+my $name = $cgi->param('name');
+my $tablenum = $cgi->param('num') || '';
+my $value = $cgi->param('value');
+
+my $error = $FS::CurrentUser::CurrentUser->set_page_pref($path, $name, $tablenum, $value);
+my $result = { 'error' => $error }; # in case someone cares
+
+http_header('Content-Type', 'application/json');
+</%init>
+<% encode_json($result) %>