Skip to content

Commit

Permalink
omnitable es6 updates - core omnitable
Browse files Browse the repository at this point in the history
- eslint object shorthand rule
- eslint prefer-arrow rule

Save(autofix) 5-6 times in vscode, reformat document if autofix broke indentation.

Autoformatting may have adjusted whole files on occasion.

Minor es6 changes.

Signed-off-by: Patrik Kullman <[email protected]>
  • Loading branch information
Patrik Kullman committed Sep 10, 2018
1 parent 2302b0f commit 6bbd7f2
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 113 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"no-use-before-define": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"object-shorthand": ["error", "always"],
"one-var": [
"error",
{
Expand All @@ -102,6 +103,7 @@
"error",
"always"
],
"prefer-arrow-callback": "error",
"quotes": [
"error",
"single"
Expand Down
16 changes: 8 additions & 8 deletions cosmoz-omnitable-group-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

_slotName: 'group-row',

_columnChanged: function (newColumn) {
_columnChanged(newColumn) {
if (!newColumn) {
return;
}
Expand All @@ -57,15 +57,15 @@
this.columns = [newColumn];
},

_getTemplateInstance: function (column) {
_getTemplateInstance(column) {
return column.dataTemplatizer.getInstance();
},

_detachTemplateInstance: function (instance, column, element) {
_detachTemplateInstance(instance, column, element) {
column.dataTemplatizer.detachInstance(instance, element);
},

_configureTemplateInstance: function (instance) {
_configureTemplateInstance(instance) {
if (instance.item !== this.item && this.item !== undefined) {
this._forwardProperty(instance, 'item', this.item);
this._forwardProperty(instance, 'selected', this.selected);
Expand All @@ -74,7 +74,7 @@
}
},

_itemUpdated: function (itemChange) {
_itemUpdated(itemChange) {
if (itemChange.path === 'item') {
this.elements.forEach(function (element) {
this._forwardProperty(this.getElementTemplateInstance(element), 'item', itemChange.value, true);
Expand All @@ -86,19 +86,19 @@
}
},

_selectedChanged: function (selected) {
_selectedChanged(selected) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'selected', selected, true);
});
},

_expandedChanged: function (expanded) {
_expandedChanged(expanded) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'expanded', expanded, true);
});
},

_foldedChanged: function (folded) {
_foldedChanged(folded) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'folded', folded, true);
});
Expand Down
8 changes: 4 additions & 4 deletions cosmoz-omnitable-header-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@

_slotName: 'header-cell',

_getTemplateInstance: function (column) {
_getTemplateInstance(column) {
return column.headerTemplatizer.getInstance();
},

_detachTemplateInstance: function (instance, column, element) {
_detachTemplateInstance(instance, column, element) {
if (column.headerTemplatizer) {
column.headerTemplatizer.detachInstance(instance, element);
}
},

_configureElement: function (element, column) {
_configureElement(element, column) {
this.toggleClass(column.headerCellClass, true, element);
this.toggleClass('header-cell', true, element);
element.setAttribute('title', column.title);
},

_configureTemplateInstance: function (instance) {
_configureTemplateInstance(instance) {
this._forwardPropertiesFlush(instance);
}
});
Expand Down
16 changes: 8 additions & 8 deletions cosmoz-omnitable-item-expand.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@

_slotName: 'item-expand-line',

_getTemplateInstance: function (column) {
_getTemplateInstance(column) {
return column.dataTemplatizer.getInstance();
},

_detachTemplateInstance: function (instance, column, element) {
_detachTemplateInstance(instance, column, element) {
column.dataTemplatizer.detachInstance(instance, element);
},

_configureElement: function (element, column) {
_configureElement(element, column) {
element.column = column;
},

_configureTemplateInstance: function (instance) {
_configureTemplateInstance(instance) {
if (instance.item !== this.item && this.item !== undefined) {
this._forwardProperty(instance, 'item', this.item);
this._forwardProperty(instance, 'selected', this.selected);
Expand All @@ -92,15 +92,15 @@
}
},

_updateSize: function (columnsCount) {
_updateSize(columnsCount) {
this.hidden = columnsCount === 0;
if (this.expanded) {
// Notify omnitable that this item is expanded and my need individual resize
this.fire('update-item-size', { item: this.item }, { bubbles: true});
}
},

_itemUpdated: function (itemChange) {
_itemUpdated(itemChange) {
if (itemChange.path === 'item') {
this.elements.forEach(function (element) {
this._forwardProperty(this.getElementTemplateInstance(element), 'item', itemChange.value, true);
Expand All @@ -112,13 +112,13 @@
}
},

_selectedChanged: function (selected) {
_selectedChanged(selected) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'selected', selected, true);
});
},

_expandedChanged: function (expanded) {
_expandedChanged(expanded) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'expanded', expanded, true);
});
Expand Down
36 changes: 15 additions & 21 deletions cosmoz-omnitable-item-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,21 @@

_slotName: 'item-cell',

_getTemplateInstance: function (column) {
return column.dataTemplatizer.getInstance();
},
_getTemplateInstance: column => column.dataTemplatizer.getInstance(),

_detachTemplateInstance: function (instance, column, element) {
_detachTemplateInstance(instance, column, element) {
column.dataTemplatizer.detachInstance(instance, element);
},

_configureElement: function (element, column) {
_configureElement(element, column) {
element.style.flexBasis = column.editable ? column.editWidth : column.width;
element.style.minWidth = column.editable ? column.editMinWidth : column.minWidth;
element.style.flexGrow = column.flex;
element.setAttribute('title', this._getCellTitle(column, this.item));
element.setAttribute('class', this._computeItemRowCellClasses(column));
},

_configureTemplateInstance: function (instance) {
_configureTemplateInstance(instance) {
if (instance.item !== this.item && this.item !== undefined) {
this._forwardProperty(instance, 'item', this.item);
this._forwardProperty(instance, 'selected', this.selected);
Expand All @@ -90,41 +88,37 @@
}
},

_computeItemRowCellClasses: function (column) {
var originalIndex = column.__index;
return 'itemRow-cell'
_computeItemRowCellClasses: column =>
'itemRow-cell'
+ (column.cellClass ? ' ' + column.cellClass + ' ' : '')
+ ' cosmoz-omnitable-column-' + originalIndex;
},
+ ' cosmoz-omnitable-column-' + column.__index,

_itemUpdated: function (itemChange) {
_itemUpdated(itemChange) {
if (itemChange.path === 'item') {
this.elements.forEach(function (element) {
this.elements.forEach(element => {
this._forwardProperty(this.getElementTemplateInstance(element), 'item', itemChange.value, true);
element.setAttribute('title', this._getCellTitle(this.getElementColumn(element), this.item));
}, this);
});
} else {
this.elements.forEach(function (element) {
this.elements.forEach(element => {
this._forwardNotifyPath(this.getElementTemplateInstance(element), itemChange.path, itemChange.value, true, true);
}, this);
});
}
},

_selectedChanged: function (selected) {
_selectedChanged(selected) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'selected', selected, true);
});
},

_expandedChanged: function (expanded) {
_expandedChanged(expanded) {
this.templateInstances.forEach(instance => {
this._forwardProperty(instance, 'expanded', expanded, true);
});
},

_getCellTitle: function (column, item) {
return column && column.getString(item, column.valuePath);
},
_getCellTitle: (column, item) => column && column.getString(item, column.valuePath)
});
}());
</script>
7 changes: 4 additions & 3 deletions cosmoz-omnitable-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@

// HACK: ensure paper-dropdown-menu updates current selected item label after translation change
// See https://github.com/PolymerElements/paper-dropdown-menu/issues/197
_labelChanged: function () {
_labelChanged() {
if (this.classList.contains('iron-selected')) {
this.fire('iron-deselect', { item: this});
this.fire('iron-select', { item: this});
const detail = { item: this };
this.fire('iron-deselect', detail);
this.fire('iron-select', detail);
}
}
});
Expand Down
Loading

0 comments on commit 6bbd7f2

Please sign in to comment.