diff --git a/client/common.js b/client/common.js index 9bf912701b575e7b98b36aa5dd93cf6b807e7b49..7bb2b68da313368f6de0b253585d6f97fe3b9eef 100644 --- a/client/common.js +++ b/client/common.js @@ -12,6 +12,17 @@ clearSessions = function () { Session.set(strSessionSelectedCollection, undefined); }; +Array.prototype.remove = function () { + var what, a = arguments, L = a.length, ax; + while (L && this.length) { + what = a[--L]; + while ((ax = this.indexOf(what)) !== -1) { + this.splice(ax, 1); + } + } + return this; +}; + Template.registerHelper('getConnection', function () { if (Session.get(strSessionConnection)) { return Connections.findOne({_id: Session.get(strSessionConnection)}); diff --git a/client/views/query_templates/find/find.html b/client/views/query_templates/find/find.html index 1c9dc60944b8a9c68c5696cd2b2b7946e75cd4bb..945d9f4721f0c4d14a1e44ac04c55cd56fcc95b2 100644 --- a/client/views/query_templates/find/find.html +++ b/client/views/query_templates/find/find.html @@ -7,4 +7,15 @@ HH:mm:ss +
+ +
+ +
+
\ No newline at end of file diff --git a/client/views/query_templates/find/find.js b/client/views/query_templates/find/find.js index 658a6c9b4550807b66757f279fb8a5ead9ec6fbc..fc2ecea8608e920af2a5ac15127d23e8d8f7585b 100644 --- a/client/views/query_templates/find/find.js +++ b/client/views/query_templates/find/find.js @@ -1,33 +1,13 @@ /** * Created by sercan on 30.12.2015. */ +var strSessionSelectedOptions = "selectedCursorOptions"; + Template.find.onRendered(function () { // set ace editor - AceEditor.instance("preSelector", { - mode: "javascript", - theme: 'dawn' - }, function (editor) { - editor.$blockScrolling = Infinity; - editor.setOptions({ - fontSize: "11pt", - showPrintMargin: false, - }); - - // remove newlines in pasted text - editor.on("paste", function (e) { - e.text = e.text.replace(/[\r\n]+/g, " "); - }); - // make mouse position clipping nicer - editor.renderer.screenToTextCoordinates = function (x, y) { - var pos = this.pixelToScreenCoordinates(x, y); - return this.session.screenToDocumentPosition( - Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)), - Math.max(pos.column, 0) - ); - }; - // disable Enter Shift-Enter keys - editor.commands.bindKey("Enter|Shift-Enter", executeQuery); - }); + initializeAceEditor(); + initializeOptions(); + initializeSessionVariable(); }); Template.browseCollection.events({ @@ -107,4 +87,57 @@ executeQuery = function () { // stop loading animation l.ladda('stop'); }); +} + +initializeAceEditor = function () { + AceEditor.instance("preSelector", { + mode: "javascript", + theme: 'dawn' + }, function (editor) { + editor.$blockScrolling = Infinity; + editor.setOptions({ + fontSize: "11pt", + showPrintMargin: false, + }); + + // remove newlines in pasted text + editor.on("paste", function (e) { + e.text = e.text.replace(/[\r\n]+/g, " "); + }); + // make mouse position clipping nicer + editor.renderer.screenToTextCoordinates = function (x, y) { + var pos = this.pixelToScreenCoordinates(x, y); + return this.session.screenToDocumentPosition( + Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)), + Math.max(pos.column, 0) + ); + }; + // disable Enter Shift-Enter keys + editor.commands.bindKey("Enter|Shift-Enter", executeQuery); + }); +} + +initializeOptions = function () { + var cmb = $('#cmbCursorOptions'); + $.each(CURSOR_OPTIONS, function (key, value) { + cmb.append($("") + .attr("value", key) + .text(value)); + }); + + cmb.chosen(); + cmb.on('change', function (evt, params) { + var array = Session.get(strSessionSelectedOptions); + if (params.deselected) { + array.remove(params.deselected); + } + else { + array.push(params.selected); + } + Session.set(strSessionSelectedOptions, array); + }); +} + +initializeSessionVariable = function () { + Session.set(strSessionSelectedOptions, []); } \ No newline at end of file diff --git a/lib/query_types.js b/lib/enums.js similarity index 70% rename from lib/query_types.js rename to lib/enums.js index 13b704f70aeda0ead8eb7705a10664b3e0c6fb5a..e07682f292e2fbe9b556049307c2afc57317b679 100644 --- a/lib/query_types.js +++ b/lib/enums.js @@ -10,4 +10,13 @@ QUERY_TYPES = { FINDONE_AND_REPLACE: "findOneAndReplace", FINDONE_AND_UPDATE: "findOneAndUpdate" +} + +CURSOR_OPTIONS = { + PROJECT: "project", + SKIP: "skip", + LIMIT: "limit", + MAX: "max", + MIN: "min", + SORT: "sort" } \ No newline at end of file diff --git a/public/chosen-sprite.png b/public/chosen-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..3611ae4ace1c4b1cbeacd6145b5a79cbc72e0bdc Binary files /dev/null and b/public/chosen-sprite.png differ diff --git a/public/chosen-sprite@2x.png b/public/chosen-sprite@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ffe4d7d1121ca45cd35783696940050c690a8676 Binary files /dev/null and b/public/chosen-sprite@2x.png differ