Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Show name of sheet/note on tag click

  • Loading branch information...
commit b62fe29549237f134aeef2e06cd9b4b282eadb62 1 parent 5cbbdda
Konstantin Vorobyev authored
Showing with 66 additions and 13 deletions.
  1. +40 −12 src/sstack/datamanager.js
  2. +26 −1 src/sstack/sheet.js
View
52 src/sstack/datamanager.js
@@ -22,6 +22,18 @@ var _proxy = function(datamanager, method, handler, params) {//Proxy to DataMana
});
return true;
};
+ if (method == 'getNote') {
+ datamanager.getNote(params[0], function (err, note) {
+ handler(err, note);
+ });
+ return true;
+ };
+ if (method == 'getSheet') {
+ datamanager.getSheet(params[0], function (err, sheet) {
+ handler(err, sheet);
+ });
+ return true;
+ };
if (method == 'getAttachment') {
datamanager.getAttachment(params[0], function (err, uri) {
handler(err, uri);
@@ -103,13 +115,13 @@ var _proxy = function(datamanager, method, handler, params) {//Proxy to DataMana
if (method == 'addTag') {
datamanager.getTags(params[0], function(tags, err) {
if (tags) {
- log('Add tag', tags, params[1], params[2]);
+ // log('Add tag', tags, params[1], params[2]);
if (params[2]) {
tags = datamanager.tagToTag(tags, params[1], params[2]);
} else {
tags = datamanager.tagToNote(tags, params[1]);
};
- log('Saving', tags);
+ // log('Saving', tags);
datamanager.updateTags(params[0], tags, function(id, err) {
if (id) {
handler(id);
@@ -201,6 +213,7 @@ var DataManager = function(database) {//Do DB operations
var NoteTag = function() {
this.name = 'note';
+ this.display = 'note';
};
NoteTag.prototype = new DefaultTag();
@@ -558,7 +571,7 @@ var DataManager = function(database) {//Do DB operations
dtend.setFullYear(dtstart.getFullYear()+1);
dtend.setDate(0);
};
- return {dstart: dtstart, dend: dtend};
+ return {dstart: dtstart, dend: dtend, type: dt.type};
};
return null;
};
@@ -626,18 +639,24 @@ var DataManager = function(database) {//Do DB operations
};
var dt = this._toDate(text);
var dinfo = this.info(text);
+ log('Select DateTag', dinfo);
if (dinfo) {
var dtstart = dinfo.dstart;
var dtend = dinfo.dend;
- values.push({
- op: 'or',
- 'var': [
- 'id', this._in(['type', 'd:',
- 'value', {op: '>=', 'var': dtstart.format('yyyymmdd')},
- 'value', {op: '<=', 'var': dtend.format('yyyymmdd')}
- ]), 'id', this._in(['type', 'd:', 'text', this.adopt(text)])
- ]
- })
+ if (dinfo.type == 'y') {
+ // Only by direct tag
+ values.push('id', this._in(['type', 'd:', 'text', this.adopt(text)]));
+ } else {
+ values.push({
+ op: 'or',
+ 'var': [
+ 'id', this._in(['type', 'd:',
+ 'value', {op: '>=', 'var': dtstart.format('yyyymmdd')},
+ 'value', {op: '<=', 'var': dtend.format('yyyymmdd')}
+ ]), 'id', this._in(['type', 'd:', 'text', this.adopt(text)])
+ ]
+ })
+ }
};
return DefaultTag.prototype.select(this.adopt(text), values);
};
@@ -1196,6 +1215,15 @@ DataManager.prototype.getSheet = function(id, handler) {//Selects sheet
}, this));
};
+DataManager.prototype.getNote = function(id, handler) {//Selects note
+ this.db.findOne('notes', id, _.bind(function (err, data) {
+ if (err) {
+ return handler(err);
+ };
+ handler(null, data);
+ }, this));
+};
+
DataManager.prototype.noteToSheet = function(text, tags) {
if (!tags) {
tags = [];
View
27 src/sstack/sheet.js
@@ -393,6 +393,30 @@ Sheet.prototype.tag_menu_sheet = function(note, tag, items) {
})
};
+Sheet.prototype.tag_click_sheet = function(note, tag) {
+ this.proxy('getSheet', _.bind(function (err, sheet) {
+ if (!err) {
+ _showInfo(sheet.title || 'Untitled');
+ };
+ }, this), [tag.substr(2)]);
+};
+
+Sheet.prototype.tag_click_note = function(note, tag) {
+ this.proxy('getNote', _.bind(function (err, note) {
+ if (!err) {
+ var text = note.text;
+ if (text.indexOf('\n') != -1) {
+ text = text.substr(0, text.indexOf('\n'));
+ } else {
+ if (text.length>50) {
+ text = text.substr(0, 50)+'...';
+ };
+ }
+ _showInfo(text || 'Untitled');
+ };
+ }, this), [tag.substr(2)]);
+};
+
Sheet.prototype.tag_unselect_geo = function(note, tag) {
if (note.geoCreated) {
note.div.find('.geo').remove();
@@ -785,10 +809,11 @@ Sheet.prototype.unselectNote = function() {
};
Sheet.prototype.selectTag = function(t) {
- log('Click tag:', t);
+ // log('Click tag:', t);
this.selected.selectedTag = t;
this.selected.div.find('.note_tag').removeClass('note_tag_selected');
t.div.addClass('note_tag_selected');
+ this.launchTagMethod(this.selected, 'click', t.id);
this.updated();
};
Please sign in to comment.
Something went wrong with that request. Please try again.