summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-06-04 18:44:44 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-06-04 18:44:44 +0200
commit7a20d22daad49653090f52d79a5f424a220f95f6 (patch)
tree39a2748b21f2fa431a87477a93ef3d0e2068036e /apps/files_sharing/js
parenta2db53b928f7b0202391fca3c1d746478be9acae (diff)
parentfc1d6f4c3cd2882c22d71c060c8ffef8c4a44b7e (diff)
downloadnextcloud-server-7a20d22daad49653090f52d79a5f424a220f95f6.tar.gz
nextcloud-server-7a20d22daad49653090f52d79a5f424a220f95f6.zip
Merge pull request #8824 from owncloud/mail_template_editing_in_webui
minimal mail template editor for administrators
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r--apps/files_sharing/js/settings-admin.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js
new file mode 100644
index 00000000000..fa9b236ea98
--- /dev/null
+++ b/apps/files_sharing/js/settings-admin.js
@@ -0,0 +1,78 @@
+$(document).ready(function() {
+
+ var loadTemplate = function (theme, template) {
+ $.get(
+ OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
+ { theme: theme, template: template }
+ ).done(function( result ) {
+ $( '#mailTemplateSettings textarea' ).val(result);
+ }).fail(function( result ) {
+ OC.dialogs.alert(result.message, t('files_sharing', 'Could not load template'));
+ });
+ };
+
+ // load default template
+ var theme = $( '#mts-theme' ).val();
+ var template = $( '#mts-template' ).val();
+ loadTemplate(theme, template);
+
+ $( '#mts-template' ).change(
+ function() {
+ var theme = $( '#mts-theme' ).val();
+ var template = $( this ).val();
+ loadTemplate(theme, template);
+ }
+ );
+
+ $( '#mts-theme' ).change(
+ function() {
+ var theme = $( this ).val();
+ var template = $( '#mts-template' ).val();
+ loadTemplate(theme, template);
+ }
+ );
+
+ $( '#mailTemplateSettings .actions' ).on('click', '.save',
+ function() {
+ var theme = $( '#mts-theme' ).val();
+ var template = $( '#mts-template' ).val();
+ var content = $( '#mailTemplateSettings textarea' ).val();
+ OC.msg.startSaving('#mts-msg');
+ $.post(
+ OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
+ { theme: theme, template: template, content: content }
+ ).done(function() {
+ var data = { status:'success', data:{message:t('files_sharing', 'Saved')} };
+ OC.msg.finishedSaving('#mts-msg', data);
+ }).fail(function(result) {
+ var data = { status: 'error', data:{message:result.responseJSON.message} };
+ OC.msg.finishedSaving('#mts-msg', data);
+ });
+ }
+ );
+
+ $( '#mailTemplateSettings .actions' ).on('click', '.reset',
+ function() {
+ var theme = $( '#mts-theme' ).val();
+ var template = $( '#mts-template' ).val();
+ OC.msg.startSaving('#mts-msg');
+ $.ajax({
+ type: "DELETE",
+ url: OC.generateUrl('apps/files_sharing/settings/mailtemplate'),
+ data: { theme: theme, template: template }
+ }).done(function() {
+ var data = { status:'success', data:{message:t('files_sharing', 'Reset')} };
+ OC.msg.finishedSaving('#mts-msg', data);
+
+ // load default template
+ var theme = $( '#mts-theme' ).val();
+ var template = $( '#mts-template' ).val();
+ loadTemplate(theme, template);
+ }).fail(function(result) {
+ var data = { status: 'error', data:{message:result.responseJSON.message} };
+ OC.msg.finishedSaving('#mts-msg', data);
+ });
+ }
+ );
+
+});