mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-24 13:59:27 +08:00
Merge branch 'master' of https://github.com/Deployd/Deployd
This commit is contained in:
@@ -57,6 +57,47 @@
|
||||
<!-- container -->
|
||||
|
||||
<!-- PARTIAL TEMPLATES -->
|
||||
<script id="collection-view-template" type="html/template">
|
||||
<div class="twelve columns">
|
||||
<div class="panel">
|
||||
<h6><%= name %> Collection</h6>
|
||||
<p>This is the <%= name %> collection in your database. You and your users (with proper permissions) can interact with this collection in these ways:</p>
|
||||
<ul>
|
||||
<li><strong>Create</strong>: POST /<%= name %>/ { foo: bar }</li>
|
||||
<li><strong>List</strong>: GET /<%= name %></li>
|
||||
<li><strong>Search</strong>: GET /search/<%= name %></li>
|
||||
</ul>
|
||||
<!--<input class="input-text" placeholder="Search" />-->
|
||||
<table style="table-layout:fixed;">
|
||||
<thead>
|
||||
<% _.each(results[0], function (val, key, list) {%>
|
||||
<th style="overflow:hidden;" width="<% print(Math.floor(100 / (numFields + 2))); %>%"><%= key %></th>
|
||||
<% }); %>
|
||||
<th width="<% print(Math.floor(100 / (numFields + 2))); %>%">edit</th>
|
||||
<th width="<% print(Math.floor(100 / (numFields + 2))); %>%">remove</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% _.each(results, function (element, index, list) {%>
|
||||
<tr>
|
||||
<% _.each(element, function (val, key, obj) { %>
|
||||
<td style="overflow: hidden;" width="<% print(Math.floor(100 / (numFields + 2))); %>%" ><%= val %></td>
|
||||
<%});%>
|
||||
<td width="<% print(Math.floor(100 / (numFields + 2))); %>%">
|
||||
<a class="edit-item">edit</a>
|
||||
</td>
|
||||
<td width="<% print(Math.floor(100 / (numFields + 2))); %>%">
|
||||
<a class="remove-item">remove</a>
|
||||
|
||||
</tr>
|
||||
<%});%>
|
||||
</tbody>
|
||||
</table>
|
||||
<a class="small radius nice blue button">Create New <%= name %></a>
|
||||
<a class="small radius nice white button">Export <%= name %></a>
|
||||
<a class="small radius nice white button">Upload <%= name %></a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script id="one-dimensional-list" type="html/template">
|
||||
//TODO: Wire this up and add option to delete.
|
||||
//Good generic way to handle collections with single property
|
||||
@@ -383,9 +424,11 @@
|
||||
.script(m + 'plugin.js')
|
||||
.script(m + 'form.js')
|
||||
.script(m + 'schema-model.js')
|
||||
.script(m + 'collection-model.js')
|
||||
// partials
|
||||
.script(p + 'plugin-view.js')
|
||||
.script(p + 'schema-view.js')
|
||||
.script(p + 'collection-view.js')
|
||||
// views
|
||||
.script(v + 'app-nav-view.js')
|
||||
// router
|
||||
|
||||
8
public/dashboard/js/model/collection-model.js
Normal file
8
public/dashboard/js/model/collection-model.js
Normal file
@@ -0,0 +1,8 @@
|
||||
window.CollectionModel = Backbone.Model.extend({
|
||||
url: function () {
|
||||
return '/' + this.get("name");
|
||||
},
|
||||
parse: function (response) {
|
||||
return {results: response};
|
||||
}
|
||||
});
|
||||
24
public/dashboard/js/view/partial/collection-view.js
Normal file
24
public/dashboard/js/view/partial/collection-view.js
Normal file
@@ -0,0 +1,24 @@
|
||||
window.CollectionView = Backbone.View.extend({
|
||||
template: _.template($("#collection-view-template").html()),
|
||||
schemaChange: function (msg) {
|
||||
// $(".save-changes", this.el).html("Save Changes").removeClass("white").addClass("blue");
|
||||
if (msg.get("errors")) {
|
||||
$(".alert-box", this.el).addClass("error").css("display", "block").html(msg.get("errors")[0].message);
|
||||
}
|
||||
else if (msg.get("description")) {
|
||||
$(".alert-box", this.el).addClass("success").css("display", "block").html("Schema saved successfully.");
|
||||
}
|
||||
else {
|
||||
$(".alert-box", this.el).addClass("warning").css("display", "block").html("Couldn't determine if schema was saved.");
|
||||
}
|
||||
},
|
||||
initialize: function () {
|
||||
console.log('initialize() in CollectionView');
|
||||
console.log(this.model);
|
||||
this.model.bind("all", this.render, this);
|
||||
},
|
||||
render: function () {
|
||||
console.log('render() in CollectionView');
|
||||
$(this.el).html(this.template(this.model.toJSON()));
|
||||
}
|
||||
});
|
||||
@@ -10,15 +10,33 @@ window.PluginView = Backbone.View.extend({
|
||||
if (obj.get("description")) {
|
||||
//TODO: Plug this in to a view/model/template
|
||||
var _schemaModel = new SchemaModel(obj);
|
||||
var _schemaEl = $("<div />").attr("id", "id-"+obj._id);
|
||||
var _schemaEl = $("<div />").attr("id", "id-"+obj.get('_id'));
|
||||
$(_self.el).append(_schemaEl);
|
||||
var _schemaView = new SchemaView({
|
||||
el: _schemaEl,
|
||||
model: _schemaModel
|
||||
});
|
||||
_schemaView.render();
|
||||
return;
|
||||
}
|
||||
if (obj.get("collection")) {
|
||||
console.log(obj.toJSON());
|
||||
var _collectionModel = new CollectionModel({
|
||||
name: obj.get('collection'),
|
||||
numFields: _.size(obj.get('decsription')),
|
||||
description: obj.get('decsription'),
|
||||
results: []
|
||||
});
|
||||
console.log(obj.get('collection'));
|
||||
console.log(_collectionModel.url());
|
||||
var _collectionEl = $("<div />").attr("id", "id-PLACEHOLDER");
|
||||
$(_self.el).append(_collectionEl);
|
||||
var _collectionView = new CollectionView({
|
||||
el: _collectionEl,
|
||||
model: _collectionModel
|
||||
});
|
||||
_collectionModel.fetch();
|
||||
// _collectionView.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user