Skip to content

Commit

Permalink
add empty messages to table list + new table button (Closes #1841)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman authored and rijkvanzanten committed Oct 31, 2017
1 parent 7792e0b commit 42c8223
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
4 changes: 3 additions & 1 deletion app/core/tableSimple.js
Expand Up @@ -61,8 +61,10 @@ function(app, Backbone, _) {
initialize: function(options) {
this.listenTo(app.router.v.main, 'flashItem', this.flashItem);
this.columns = options.columns || false;
// TODO: Add table row view to add or remove one row
// instead of render the whole table again
this.listenTo(this.collection, 'add remove', this.render);
}

});

return TableSimple;
Expand Down
26 changes: 24 additions & 2 deletions app/modules/tables/views/TablesView.js
Expand Up @@ -3,10 +3,12 @@ define([
'backbone',
'core/directus',
'core/t',
'core/BasePageView'
'core/BasePageView',
'core/widgets/widgets',
'modules/settings/views/modals/table-new'
],

function(app, Backbone, Directus, __t, BasePageView) {
function(app, Backbone, Directus, __t, BasePageView, Widgets, TableNewModal) {

return BasePageView.extend({

Expand All @@ -16,6 +18,26 @@ function(app, Backbone, Directus, __t, BasePageView) {
}
},

leftToolbar: function() {
var widgets = [];

if (app.user.isAdmin()) {
widgets.push(new Widgets.ButtonWidget({
widgetOptions: {
buttonId: 'addBtn',
iconClass: 'add',
buttonClass: 'primary',
buttonText: __t('new_item')
},
onClick: function (event) {
app.router.openViewInModal(new TableNewModal());
}
}));
}

return widgets;
},

beforeRender: function() {
this.setView('#page-content', new Directus.TableSimple({
collection: this.collection,
Expand Down
23 changes: 5 additions & 18 deletions app/templates/modules/tables/tables.handlebars
@@ -1,3 +1,7 @@
{{#unless rows}}
{{{include "listingEmpty"}}}
{{/unless}}
{{#if rows}}
<table class="lines cozy clickable fixed-header pad-first">
<thead>
<tr>
Expand All @@ -14,21 +18,4 @@
{{/rows}}
</tbody>
</table>
{{!--
<table class="table table-striped directus-table" id="directus_tables">
<thead>
<tr>
<!-- <th class="active">Active</th> -->
<th class="table_name">{{t "table_name"}}</th>
<!--<th class="modified">Modified</th>-->
</tr>
</thead>
<tbody>
{{#rows}}
<tr data-id="{{table_name}}">
<td>{{{capitalize table_name}}}</td>
</tr>
{{/rows}}
</tbody>
</table>
--}}
{{/if}}

0 comments on commit 42c8223

Please sign in to comment.