From bf094a6a70108e8f3fb17caa203cfd9bfd92638b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20L=C3=B3pez=20Lugo?= Date: Thu, 8 Mar 2018 12:08:33 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=20General=20Improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added pt-select multi sopport - Look & Feel Dialog improvements --- bower.json | 2 +- pt-crud-table.html | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 809ea7f..57334e7 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "main": "pt-crud-table.html", "dependencies": { "polymer": "Polymer/polymer#^2.0.0", - "pt-select": "plusTTeam/pt-select#^1.0.3", + "pt-select": "plusTTeam/pt-select#^1.0.6", "pt-multilang-input": "plusTTeam/pt-multilang-input#^1.0.3", "pt-tags-input": "plusTTeam/pt-tags-input#^1.0.4", "pt-firebase-file-uploader": "plusTTeam/pt-firebase-file-uploader#^1.0.1", diff --git a/pt-crud-table.html b/pt-crud-table.html index 408bfae..9b7c65b 100644 --- a/pt-crud-table.html +++ b/pt-crud-table.html @@ -50,6 +50,12 @@ paper-dialog h2 { margin-top: 24px; } + + paper-dialog { + --paper-dialog-scrollable: { + max-height: 50vh; + } + } @@ -74,7 +80,7 @@ - +

[[title]]

@@ -187,26 +193,37 @@

[[title]]

} _print(item, column){ - let output = ""; + let output = ''; if (item && column) { try { switch (column.type) { + case 'multiselect': + let value = typeof item[column.path] !== 'undefined' ? item[column.path] : item[column.name]; + let challengesDic = column.items.filter((challenge) =>{ + return value.find((e) =>{ + e === challenge.value; + }) !== 'undefined'; + }); + challengesDic.forEach((item) =>{ + output = output === '' ? item.label : output + ', ' + item.label; + }); + break; case 'select': let itemFound = column.items.find((i) =>{ - let value = typeof item[column.path] !== 'undefined' ? item[column.path] : typeof item[column.name] !== 'undefined' ? item[column.name] : 'Label not found'; + let value = typeof item[column.path] !== 'undefined' ? item[column.path] : item[column.name]; value = column.multilang ? value[this.currentLang] : value; return i.value == value; }); output = itemFound.label; break; default: { - output = typeof item[column.path] !== 'undefined' ? item[column.path] : typeof item[column.name] !== 'undefined' ? item[column.name] : 'Label not found'; + output = typeof item[column.path] !== 'undefined' ? item[column.path] : item[column.name]; output = column.multilang ? output[this.currentLang] : output; break; } } } catch (e) { - console.error(e); + output = 'Unknown'; } } return output; @@ -295,6 +312,15 @@

[[title]]

tempElement.pathToValue = field.pathToValue || 'value'; tempElement.pathToLabel = field.pathToValue || 'label'; break; + case 'multiselect': + tempElement = document.createElement("pt-select"); + tempElement.options = field.items; + tempElement.multiple = true; + tempElement.placeholder = "Select One or More"; + tempElement.label = field.label; + tempElement.pathToValue = field.pathToValue || 'value'; + tempElement.pathToLabel = field.pathToValue || 'label'; + break; case 'date': tempElement = tempElement || document.createElement("vaadin-date-picker"); tempElement.label = field.label;