[fixes #17,view][s]: read-only mode (where editing options are hidden).

This commit is contained in:
Rufus Pollock
2012-01-07 03:09:45 +00:00
parent f1c5b8a430
commit 638eff6c3c
4 changed files with 40 additions and 1 deletions

View File

@@ -132,6 +132,19 @@
width: 20px; width: 20px;
} }
/********* read-only mode **********/
.read-only .data-table tr td:first-child,
.read-only .data-table tr th:first-child
{
display: none;
}
.read-only .column-header-menu,
.read-only .row-header-menu
{
display: none;
}
/********************************************************** /**********************************************************
* Data Table Menus * Data Table Menus

View File

@@ -15,6 +15,10 @@ $(function() {
}); });
window.$container.append(window.dataExplorer.el); window.$container.append(window.dataExplorer.el);
}); });
$('a.set-read-only').click(function() {
window.dataExplorer.setReadOnly();
alert('Read-only mode set');
});
}) })
function demoDataset() { function demoDataset() {

View File

@@ -28,7 +28,8 @@
<div class="topbar-inner"> <div class="topbar-inner">
<div class="container-fluid"> <div class="container-fluid">
<a class="brand" href="#">Recline Data Explorer</a> <a class="brand" href="#">Recline Data Explorer</a>
<ul class="nav"> <ul class="nav secondary-nav">
<li><a class="set-read-only" title="Put into read-only mode">Read-only</a></li>
</ul> </ul>
<form class="webstore-load pull-right" title="Update from the specified webstore dataset"> <form class="webstore-load pull-right" title="Update from the specified webstore dataset">
<input type="text" name="source" size="50" /> <input type="text" name="source" size="50" />

View File

@@ -7,6 +7,19 @@ var my = {};
// The primary view for the entire application. // The primary view for the entire application.
// //
// To pass in configuration options use the config key in initialization hash
// e.g.
//
// var explorer = new DataExplorer({
// config: {...}
// })
//
// Config options:
//
// * displayCount: how many documents to display initially (default: 10)
// * readOnly: true/false (default: false) value indicating whether to
// operate in read-only mode (hiding all editing options).
//
// All other views as contained in this one. // All other views as contained in this one.
my.DataExplorer = Backbone.View.extend({ my.DataExplorer = Backbone.View.extend({
tagName: 'div', tagName: 'div',
@@ -47,7 +60,11 @@ my.DataExplorer = Backbone.View.extend({
this.config = options.config || {}; this.config = options.config || {};
_.extend(this.config, { _.extend(this.config, {
displayCount: 10 displayCount: 10
, readOnly: false
}); });
if (this.config.readOnly) {
this.setReadOnly();
}
this.draw(); this.draw();
}, },
@@ -79,6 +96,10 @@ my.DataExplorer = Backbone.View.extend({
}); });
}, },
setReadOnly: function() {
this.el.addClass('read-only');
},
render: function() { render: function() {
var tmplData = this.model.toTemplateJSON(); var tmplData = this.model.toTemplateJSON();
tmplData.displayCount = this.config.displayCount; tmplData.displayCount = this.config.displayCount;