From a877ac49f9fe7f1656afb09b602a4b2a67070ec0 Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Fri, 29 Jul 2016 14:44:38 -0700 Subject: [PATCH 1/2] UI-2333: updated layout to use footable --- app.js | 93 +++++++++++++++--------------------------- views/logs-detail.html | 2 +- views/logs-layout.html | 30 +++++++++++++- 3 files changed, 64 insertions(+), 61 deletions(-) diff --git a/app.js b/app.js index 82bd72e..1d1464d 100644 --- a/app.js +++ b/app.js @@ -411,7 +411,7 @@ define(function(require){ return self.apiUrl + 'accounts/' + self.accountId + '/faxes/'+ type +'/' + mediaId + '/attachment?auth_token=' + self.authToken; }, - renderLogs: function(pArgs) { + oldRenderLogs: function(pArgs) { var self = this, args = pArgs || {}, parent = args.container || $('#fax_app_container .app-content-wrapper'), @@ -430,11 +430,35 @@ define(function(require){ }); }, + renderLogs: function(pArgs) { + var self = this, + args = pArgs || {}, + parent = args.container || $('#fax_app_container .app-content-wrapper'); + + self.logsGetData(function(logs) { + var formattedData = self.logsFormatDataTable(logs), + template = $(monster.template(self, 'logs-layout', { logs: formattedData })); + + monster.ui.footable(template.find('.footable')); + + self.logsBindEvents(template); + + parent + .fadeOut(function() { + $(this) + .empty() + .append(template) + .fadeIn(); + }); + }); + }, + + logsBindEvents: function(template) { var self = this; template.on('click','.detail-link', function() { - var logId = $(this).data('id'); + var logId = $(this).parents('tr').data('id'); self.logsRenderDetailPopup(logId); }); @@ -461,11 +485,15 @@ define(function(require){ var self = this, formattedArray = []; - $.each(logs, function() { - formattedArray.push([this.hasOwnProperty('error'), this.from || '-', this.to || '-', monster.util.toFriendlyDate(this.created), this.id, this.id, this.created]); + _.each(logs, function(log) { + log.formatted = {}; + log.formatted.hasError = log.hasOwnProperty('error'); + log.formatted.from = log.from || '-'; + log.formatted.to = log.to || '-'; + log.formatted.date = monster.util.toFriendlyDate(log.created); }); - return formattedArray; + return logs; }, logsFormatDetailData: function(details) { @@ -492,57 +520,6 @@ define(function(require){ return formattedData; }, - logsInitTable: function(template, callback) { - var self = this, - hasError, - iconClass, - columns = [ - { - 'sTitle': self.i18n.active().fax.logs.tableTitles.status, - 'fnRender': function(obj) { - hasError = obj.aData[0]; - iconClass = hasError ? 'thumbs-down monster-red' : 'thumbs-up monster-green'; - - return ''; - } - }, - { - 'sTitle': self.i18n.active().fax.logs.tableTitles.from - }, - { - 'sTitle': self.i18n.active().fax.logs.tableTitles.to - }, - { - 'sTitle': self.i18n.active().fax.logs.tableTitles.date - }, - { - 'sTitle': self.i18n.active().fax.logs.tableTitles.details, - 'fnRender': function(obj) { - return ''; - } - }, - { - 'sTitle': 'ID', - bVisible: false - }, - { - 'sTitle': 'Timestamp', - bVisible: false - } - ]; - - self.logsGetData(function(logs) { - monster.ui.table.create('logs', template.find('#smtp_logs_grid'), columns, logs, { - sDom: '<"table-custom-actions">frtlip', - aaSorting: [[3, 'desc']] - }); - - $.fn.dataTableExt.afnFiltering.pop(); - - callback && callback(); - }); - }, - logsGetData: function(callback) { var self = this; @@ -552,9 +529,7 @@ define(function(require){ accountId: self.accountId }, success: function(data) { - var formattedData = self.logsFormatDataTable(data.data); - - callback && callback(formattedData); + callback && callback(data.data); } }); }, diff --git a/views/logs-detail.html b/views/logs-detail.html index bb53c75..b37ac8d 100644 --- a/views/logs-detail.html +++ b/views/logs-detail.html @@ -25,6 +25,6 @@
- +
diff --git a/views/logs-layout.html b/views/logs-layout.html index f37dc3a..915d2b8 100644 --- a/views/logs-layout.html +++ b/views/logs-layout.html @@ -1,5 +1,33 @@
-
+ + + + + + + + + + + + + {{#each logs}} + + + + + + + + {{/each}} + +
{{ i18n.fax.logs.tableTitles.status }}{{ i18n.fax.logs.tableTitles.from }}{{ i18n.fax.logs.tableTitles.to }}{{ i18n.fax.logs.tableTitles.date }}{{ i18n.fax.logs.tableTitles.details }}
+ {{#if formatted.hasError}} + + {{else}} + + {{/if}} + {{ formatted.from }}{{ formatted.to }}{{formatted.date}}
From 72b24b3e0af8355b3a15a5728025176168f53c6f Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Fri, 29 Jul 2016 15:03:01 -0700 Subject: [PATCH 2/2] OOB: renamed tab to be clearer --- i18n/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index 010a057..c4cf192 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -4,7 +4,7 @@ "menuTitles": { "inbound": "Inbound faxes", "outbound": "Outbound faxes", - "logs": "Logs" + "logs": "Email-to-Fax Logs" }, "table": { "columns": {