Skip to content

Commit

Permalink
👽 General Improvements
Browse files Browse the repository at this point in the history
- Added pt-select multi sopport
- Look & Feel Dialog improvements
  • Loading branch information
jesuslopezlugo committed Mar 8, 2018
1 parent c1956b0 commit bf094a6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 31 additions & 5 deletions pt-crud-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
paper-dialog h2 {
margin-top: 24px;
}

paper-dialog {
--paper-dialog-scrollable: {
max-height: 50vh;
}
}
</style>

<iron-iconset-svg name="crudIcons" size="24">
Expand All @@ -74,7 +80,7 @@
</svg>
</iron-iconset-svg>

<paper-dialog id="formDialog">
<paper-dialog id="formDialog" always-on-top>
<h2>[[title]]</h2>
<paper-dialog-scrollable>
<iron-form is="iron-form" id="ironForm" on-iron-form-presubmit="_save">
Expand Down Expand Up @@ -187,26 +193,37 @@ <h2>[[title]]</h2>
}

_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;
Expand Down Expand Up @@ -295,6 +312,15 @@ <h2>[[title]]</h2>
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;
Expand Down

0 comments on commit bf094a6

Please sign in to comment.