Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Handle non-ObjectId DBRef nav more gracefully.
Browse files Browse the repository at this point in the history
Fixes #71
  • Loading branch information
bobthecow committed Jan 18, 2013
1 parent fb916b6 commit d39b650
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.markdown
Expand Up @@ -10,6 +10,7 @@ Bug fixes:
* Handle Backbone weirdness in docs with both `_id` and `id` properties.
* Fix indent levels in documents with empty objects.
* Stop rejecting all `system*` collections (Ruby backend) — Thanks @ys.
* [Fix #71][i71] — Handle non-ObjectID DBRefs more gracefully.

Improvements:

Expand All @@ -27,8 +28,9 @@ Improvements:
* [Fix #73][i73] — Authenticate against `admin` DB if none is specified (Ruby backend).
* Improve authentication failure error messagine (Ruby backend).

[i41]: https://github.com/bobthecow/genghis/issues/41
[i64]: https://github.com/bobthecow/genghis/issues/64
[i71]: https://github.com/bobthecow/genghis/issues/71
[i41]: https://github.com/bobthecow/genghis/issues/41
[i73]: https://github.com/bobthecow/genghis/issues/73


Expand Down
8 changes: 4 additions & 4 deletions genghis.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions genghis.rb

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/js/genghis/json.js
Expand Up @@ -542,18 +542,25 @@ Genghis.JSON = {
// Iterate through all of the keys in the object.
partial = [];

var cologn = t(gap ? ': ' : ':');
var cologn = t(gap ? ': ' : ':');
var isDbRef = !!(value['$ref'] && value['$id']);
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = createView(k, value);
if (v) {
spanClass = 'p' + (v.collapsed ? ' collapsed' : '');
if (k == '$ref' || k == '$id' || k == '$db') {
spanClass = spanClass + ' ref-' + k.substr(1);
if (isDbRef) {
if (k == '$ref' || k == '$id' || k == '$db') {
spanClass = spanClass + ' ref-' + k.substr(1);
}
}

p = span(spanClass);

if (isDbRef && k == '$id') {
p.setAttribute('data-document-id', Genghis.Models.Document.prototype.thunkId(value[k]));
}

if (v.collapsible) {
p.appendChild(e('button'));
}
Expand Down Expand Up @@ -584,7 +591,7 @@ Genghis.JSON = {
gap = mind;

return span(spanClass, (t('{}')));
} else if (value['$ref'] && value['$id']) {
} else if (isDbRef) {
spanClass = spanClass + ' ref';
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/genghis/views/document_view.js
Expand Up @@ -56,9 +56,9 @@ Genghis.Views.DocumentView = Genghis.Views.BaseDocument.extend({
var $dbRef = $(e.target).parents('.ref');
var db = $dbRef.find('.ref-db .v .s').text() || app.selection.currentDatabase.id;
var coll = $dbRef.find('.ref-ref .v .s').text() || app.selection.currentCollection.id;
var id = $dbRef.find('.ref-id .v .s, .ref-id .v.n').text();
var id = $dbRef.find('.ref-id').attr('data-document-id');

app.router.redirectToDocument(app.selection.currentServer.id, db, coll, id);
app.router.redirectToDocument(app.selection.currentServer.id, db, coll, encodeURIComponent(id));
},
openEditDialog: function() {
var $well = this.$('.well');
Expand Down

0 comments on commit d39b650

Please sign in to comment.