Skip to content

Commit

Permalink
fix(vue-grid): fix functional components (#1350)
Browse files Browse the repository at this point in the history
Fixes #1345
  • Loading branch information
SergeyAlexeev authored Aug 23, 2018
1 parent 5784cda commit 5aa21a2
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/dx-vue-grid-bootstrap4/src/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const DxGrid = {
return (
<DxGridBase
rootComponent={GridRoot}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
>
{context.children}
</DxGridBase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const DxColumnChooser = {
containerComponent={Container}
itemComponent={Item}
toggleButtonComponent={ToggleButton}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const DxGroupingPanel = {
itemComponent={GroupPanelItem}
emptyMessageComponent={GroupPanelEmptyMessage}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const DxPagingPanel = {
<DxPagingPanelBase
containerComponent={Pager}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const DxSearchPanel = {
<DxSearchPanelBase
inputComponent={SearchPanelInput}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const DxTableBandHeader = {
rowComponent={TableRow}
bandedHeaderCellComponent={BandedHeaderCell}
invisibleCellComponent={InvisibleCell}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const DxTableColumnVisibility = {
<DxTableColumnVisibilityBase
emptyMessageComponent={EmptyMessage}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const DxTableEditColumn = {
headerCellComponent={EditCommandHeadingCell}
commandComponent={CommandButton}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DxTableEditRow = {
<DxTableEditRowBase
cellComponent={EditCell}
rowComponent={TableRow}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DxTableFilterRow = {
iconComponent={Icon}
editorComponent={Editor}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const DxTableGroupRow = {
cellComponent={TableGroupCell}
rowComponent={TableRow}
indentColumnWidth={33}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DxTableHeaderRow = {
<DxTableHeaderRowBase
cellComponent={TableHeaderCell}
rowComponent={TableRow}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DxTableRowDetail = {
cellComponent={TableDetailCell}
rowComponent={TableRow}
toggleColumnWidth={48}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DxTableSelection = {
cellComponent={TableSelectCell}
headerCellComponent={TableSelectAllCell}
selectionColumnWidth={40}
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-vue-grid-bootstrap4/src/plugins/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DxTable = {
stubCellComponent={TableStubCell}
stubHeaderCellComponent={TableHeaderStubCell}
messages={{ ...defaultMessages, ...context.props.messages }}
{...{ attrs: context.data.attrs, on: context.listeners }}
{...context.data}
/>
);
},
Expand Down
23 changes: 2 additions & 21 deletions packages/dx-vue-grid-bootstrap4/src/templates/table.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
let globalStickyProp;
const testCSSProp = (property, value, noPrefixes) => {
const prop = `${property}:`;
const el = document.createElement('test');
const mStyle = el.style;

if (!noPrefixes) {
mStyle.cssText = `${prop + ['-webkit-', '-moz-', '-ms-', '-o-', ''].join(`${value};${prop}`) + value};`;
} else {
mStyle.cssText = prop + value;
}
return mStyle[property];
};

export const Table = {
name: 'Table',
props: {
Expand All @@ -25,22 +11,17 @@ export const Table = {
data() {
return ({
backgroundColor: 'white',
stickyProp: globalStickyProp,
});
},
mounted() {
this.checkStyles();
},
methods: {
checkStyles() {
globalStickyProp = testCSSProp('position', 'sticky');

const body = document.getElementsByTagName('body')[0];
const { backgroundColor } = window.getComputedStyle(body);

if (this.backgroundColor !== backgroundColor
|| this.stickyProp !== globalStickyProp) {
this.stickyProp = globalStickyProp;
if (this.backgroundColor !== backgroundColor) {
this.backgroundColor = backgroundColor;
}
},
Expand All @@ -51,11 +32,11 @@ export const Table = {
class={{
'table mb-0 dx-g-bs4-overflow-hidden dx-g-bs4-table': true,
'dx-g-bs4-table-head': this.use === 'head',
'dx-g-bs4-table-sticky': !!this.use,
}}
style={{
minWidth: this.minWidth,
...this.use === 'head' ? {
position: this.stickyProp,
backgroundColor: this.backgroundColor,
} : null,
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-vue-grid/src/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DxGrid = {
return (
<DxPluginHost>
<GridCore
{...{ attrs: context.props, on: context.listeners }}
{...context.data}
/>
{context.children}
</DxPluginHost>
Expand Down

0 comments on commit 5aa21a2

Please sign in to comment.