Hello,
I am looking to prototype the use the new pfTable directive in our project
(katello) and I had a couple of concerns about the directive.
To me it seems like instead of passing in a complex configuration object
that we should just use transclusion to get the desired results. So
instead of this:
$scope.columns = [
{ header: "Name", itemField: "name" },
{ header: "Age", itemField: "age"},
{ header: "Address", itemField: "address" },
{ header: "BirthMonth", itemField: "birthMonth"}
];
$scope.toolbarActionsConfig = {
...
};
// many more configuration objects, edited for brevity
<pf-table-view config="tableConfig"
dt-options="dtOptions"
columns="columns"
items="items"
action-buttons="tableActionButtons"
menu-actions="tableMenuActions">
</pf-table-view>
We'd have something like this:
<pf-table-view config="tableConfig" items="items">
<pf-table-view-headers>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Birth Month</th>
</tr>
</thead>
<pf-menu-actions>
...
</pf-menu-actions>
</pf-table-view-headers>
<pf-table-view-rows>
<tbody>
<tr ng-repeat="row in items">
<td>{{row.name | customFilter}}</td>
<td some-custom-directive>{{row.age}}</td>
<td some-other-custom-directive>{{row.address}}</td>
<td>{{row.birthMonth | date:'medium'}}</td>
<pf-table-actions>
<button type="button" ng-click="doSomething()">Do it!</button>
</pf-table-actions>
</tr>
</tbody>
</pf-table-view-rows>
</pf-table-view>
This allows for more flexibility in using custom directives, filters,
etc. in the table rows themselves. How would one add links to the item
names in the current version? What about a custom filter? What about
custom directives?
Moreover I dislike that the entire configuration object is declared in
the controller, including items that should be in the template instead
of the controller (such as the header names, menu item names, and
action names). To me this is in direct contrast to the separation of
concerns that angular is supposed to help achieve.
Here is a gist in case the formatting above gets broken [1].
What are your thoughts?
Thanks,
Walden
[1] https://gist.github.com/waldenraines/6e293ee84e7ef1686cdc69218404865c
_______________________________________________
Patternfly-angular mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/patternfly-angular