diff --git a/static/css/main.css b/static/css/main.css index 4ef2abcd..2daf5c58 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -1,6 +1,9 @@ .nav-tabs { cursor:pointer; -} +} +.datatable_hidden { + display:none; +} .navbar-logo { margin: 4px 0px; float: left; @@ -149,4 +152,4 @@ background: white; cursor: inherit; display: block; -} \ No newline at end of file +} diff --git a/static/js/app/partials/modals/templateModal.html b/static/js/app/partials/modals/templateModal.html index 383d2a2e..eae984a8 100644 --- a/static/js/app/partials/modals/templateModal.html +++ b/static/js/app/partials/modals/templateModal.html @@ -38,6 +38,7 @@ Name + Content diff --git a/static/js/app/templates.js b/static/js/app/templates.js index fef91e00..2d96de2b 100644 --- a/static/js/app/templates.js +++ b/static/js/app/templates.js @@ -16,7 +16,17 @@ var icons = { // Save attempts to POST to /templates/ function save(){ template.name = $("#name").val() - console.log(template) + template.subject = $("#subject").val() + template.html = CKEDITOR.instances["html_editor"].getData(); + template.text = $("#text_editor").val() + // Add the attachments + $.each($("#attachmentsTable").DataTable().rows().data(), function(i, target){ + template.attachments.push({ + name : target[1], + content: target[3], + type: target[4], + }) + }) // Submit the template api.templates.post(template) .success(function(data){ @@ -25,8 +35,7 @@ function save(){ dismiss() }) .error(function(data){ - $("#modal\\.flashes").empty().append("
\ - " + data.responseJSON.message + "
") + modalError(data.responseJSON.message) }) } @@ -42,18 +51,14 @@ function attach(files){ var reader = new FileReader(); /* Make this a datatable */ reader.onload = function(e){ - // Add the attachment - template.attachments.push({ - name: file.name, - content: reader.result.split(",")[1], - type: file.type || "application/octet-stream" - }) var icon = icons[file.type] || "fa-file-o" // Add the record to the modal attachmentsTable.row.add([ '', file.name, - '' + '', + reader.result.split(",")[1], + file.type || "application/octet-stream" ]).draw() } reader.onerror = function(e) { @@ -66,7 +71,12 @@ function attach(files){ function edit(t){ $("#html_editor").ckeditor() $("#attachmentsTable").show() - $("#attachmentsTable").dataTable(); + $("#attachmentsTable").DataTable({ + "aoColumnDefs" : [{ + "targets" : [3,4], + "sClass" : "datatable_hidden" + }] + }); if (t == "new") { template = {attachments:[]} } @@ -82,7 +92,7 @@ function load(){ $.each(templates, function(i, template){ templateTable.row.add([ template.name, - template.modified_date + moment(template.modified_date).format('MMMM Do YYYY, h:mm:ss a') ]).draw() }) } diff --git a/templates/templates.html b/templates/templates.html index 9fbc492f..957d620c 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -94,7 +94,7 @@
- +