From 67952260c31d70f98d4adf9458a5d83320062751 Mon Sep 17 00:00:00 2001 From: Gabriel Matute Date: Wed, 22 Feb 2017 12:35:48 -0500 Subject: [PATCH] Enable tag selection, filtering and display --- .../recording_prompt.controller.js | 10 +++-- lib/requests/requestView.js | 12 +++--- lib/requests/services/recorder.js | 9 +++-- lib/requests/services/upload_recording.js | 3 +- lib/requests/services/upload_textrequest.js | 5 ++- lib/requests/views/recording_prompt.view.html | 3 +- .../controllers/response_panel.controller.js | 40 ++++++++++++++----- lib/response/views/response_panel.view.html | 17 +++++--- 8 files changed, 66 insertions(+), 33 deletions(-) diff --git a/lib/requests/controllers/recording_prompt.controller.js b/lib/requests/controllers/recording_prompt.controller.js index de62761..3e7c9b6 100644 --- a/lib/requests/controllers/recording_prompt.controller.js +++ b/lib/requests/controllers/recording_prompt.controller.js @@ -10,7 +10,7 @@ module.exports = function(app, _parent) { function closePrompt() { $timeout(function(){ - _parent.toggle($scope.requestTitle); + _parent.toggle($scope.requestTitle, $scope.requestTags); },0,false); } @@ -32,9 +32,11 @@ module.exports = function(app, _parent) { decrementCounter() }, 1000); } - } + $scope.tags = ["Featured", "HW 3", "Exam 1"]; + $scope.requestTags = []; + $scope.startRecording = function() { $scope.COUNTDOWN = true; $scope.TEXTMODE = false; @@ -49,8 +51,8 @@ module.exports = function(app, _parent) { decrementCounter(); },0,false); }) - }; + // triggers text request box $scope.textRecording = function() { //hide h2, hide start recording button @@ -61,7 +63,7 @@ module.exports = function(app, _parent) { // submit text request $scope.textRequestSubmittion = function (){ - _parent.sendingTextDesc($scope.requestTitle,$scope.textRequestDescription); + _parent.sendingTextDesc($scope.requestTitle,$scope.textRequestDescription,$scope.requestTags); //re-configure $scope.requestTitle = ""; $scope.textRequestDescription = "" diff --git a/lib/requests/requestView.js b/lib/requests/requestView.js index 95c2f7f..0820381 100644 --- a/lib/requests/requestView.js +++ b/lib/requests/requestView.js @@ -77,21 +77,21 @@ function RequestView() { }); }; // enable editor + voice recording - proto.enable = function(title) { + proto.enable = function(title, tags) { if (!this.isRecording()) { this._invoke(function(Recorder) { - Recorder.start(title); + Recorder.start(title, tags); }); this.panel.show(); } }; // send the title and the text description - proto.sendingTextDesc = function(title, request){ + proto.sendingTextDesc = function(title, request, tags){ // console.log(title, request); this._invoke(function(Recorder) { - Recorder.sendingTextRequest(title, request); + Recorder.sendingTextRequest(title, request, tags); }); }; @@ -146,11 +146,11 @@ function RequestView() { this.panel.destroy(); }; // send the title of the request - proto.toggle = function(title) { + proto.toggle = function(title, tags) { if (this.isRecording()) { this.disable(); } else { - this.enable(title); + this.enable(title, tags); } }; diff --git a/lib/requests/services/recorder.js b/lib/requests/services/recorder.js index c5ce994..5dd595a 100644 --- a/lib/requests/services/recorder.js +++ b/lib/requests/services/recorder.js @@ -30,7 +30,7 @@ module.exports = function(app) { } } }, - start: function(title) { + start: function(title, tags) { debugger; if (!this.isRecording()) { this.setRecording(true); @@ -41,6 +41,7 @@ module.exports = function(app) { } else { requestTitle = "No title for this request!" } + requestTags = tags; debugger; EditorRecorder.start(uid, cwd); VoiceRecorder.start(uid); @@ -58,13 +59,13 @@ module.exports = function(app) { }); }, 0, false); debugger; - UploadRecording(uid, EditorRecorder, VoiceRecorder, FileRecorder, cwd, requestTitle); + UploadRecording(uid, EditorRecorder, VoiceRecorder, FileRecorder, cwd, requestTitle, requestTags); } }, - sendingTextRequest: function(title, request){ + sendingTextRequest: function(title, request, tags){ uid = guid(); cwd = FileRecorder.start(uid); - UploadTextRequest(uid, cwd, title, request,FileRecorder); + UploadTextRequest(uid, cwd, title, request, tags, FileRecorder); }, cancel: function() { if (this.isRecording()) { diff --git a/lib/requests/services/upload_recording.js b/lib/requests/services/upload_recording.js index ac93d1e..a8abfcd 100644 --- a/lib/requests/services/upload_recording.js +++ b/lib/requests/services/upload_recording.js @@ -9,7 +9,7 @@ var _ = require('underscore') module.exports = function(app) { var changelog; app.factory('UploadRecording', ['$q', '$rootScope', 'STORAGE_DIRECTORY', 'Slack', function($q, $rootScope, STORAGE_DIRECTORY, Slack) { - return function(uid, editorRecorder, voiceRecorder, workspaceSnapshot, cwd, requestTitle) { + return function(uid, editorRecorder, voiceRecorder, workspaceSnapshot, cwd, requestTitle, requestTags) { var changelogPromise = editorRecorder.stop(uid); var promises = voiceRecorder.stop(uid), wavPromise = promises; @@ -29,6 +29,7 @@ module.exports = function(app) { var recordingInfo = { contact: skype, title: requestTitle, + tags: requestTags, question_id: uid, editor_id: prefs.getEditorID(), transcript: "worked", diff --git a/lib/requests/services/upload_textrequest.js b/lib/requests/services/upload_textrequest.js index a979864..b6e7de7 100644 --- a/lib/requests/services/upload_textrequest.js +++ b/lib/requests/services/upload_textrequest.js @@ -7,8 +7,8 @@ var _ = require('underscore') module.exports = function(app){ app.factory('UploadTextRequest', ['STORAGE_DIRECTORY','EditorRecorder','Slack', function(STORAGE_DIRECTORY, EditorRecorder, Slack){ - return function(uid, cwd, title, request, workspaceSnapshot){ - console.log(uid, cwd, title,request); + return function(uid, cwd, title, request, tags, workspaceSnapshot){ + console.log(uid, cwd, title, request, tags); var folder = path.join(STORAGE_DIRECTORY, uid); var filename = 'recording.json', fullFilename = path.join(folder, filename); @@ -17,6 +17,7 @@ module.exports = function(app){ var recordingInfo = { title: title, request_description: request, + tags: tags, question_id: uid, editor_id: prefs.getEditorID(), transcript: "worked", diff --git a/lib/requests/views/recording_prompt.view.html b/lib/requests/views/recording_prompt.view.html index fec6315..fe92023 100644 --- a/lib/requests/views/recording_prompt.view.html +++ b/lib/requests/views/recording_prompt.view.html @@ -10,10 +10,11 @@

Please keep your request within 1 minute.


Describe your request in the text box below. Click 'Submit' button once you are done! (up to 50 words)

- +
+ diff --git a/lib/response/controllers/response_panel.controller.js b/lib/response/controllers/response_panel.controller.js index a503d36..76ca03a 100644 --- a/lib/response/controllers/response_panel.controller.js +++ b/lib/response/controllers/response_panel.controller.js @@ -22,6 +22,7 @@ module.exports = function(app) { editedRequest: "", editedTitle: "" }; + $scope.search = { query: { title: "" }, active: false, @@ -32,17 +33,35 @@ module.exports = function(app) { this.active = !this.active; } } - $scope.tags = { - all: [ - { name: "All", filter: "" }, - { name: "Featured", filter: "" }, - { name: "Recent", filter: "" } - ], - update: function(newTag) { - this.active = newTag; - } + + baseTags = [ + { name:'All', filter: "" }, + { name:'Pending', filter: function(r) { return r.status.responses.length == 0 } } + ] + + $scope.tags = baseTags; + $scope.activeTag = $scope.tags[0]; + $scope.updateTag = function(tag) { $scope.activeTag = tag; } + + updateTagList = function() { + reqTags = new Set(); + // Collect tags from requests + $scope.$root.requests.forEach(function(request) { + reqTags = new Set([...reqTags, ...request.tags]); + }); + // Process tags from request + reqTags = Array.from(reqTags).map(function(tag) { + return { + name: tag, + filter: function (r) { + return r.tags.indexOf(tag) != -1; + } + } + }); + // Update tags + $scope.tags = baseTags.concat(reqTags); } - $scope.tags.active = $scope.tags.all[0]; + $scope.$root.$watch('requests', updateTagList); var parent = atom.views.getView(atom.workspace).querySelector('.vertical'); parent.appendChild(element.el); @@ -145,6 +164,7 @@ module.exports = function(app) { $scope.selectedObj = obj; $scope.search.active = false; $scope.search.query = ""; + $scope.activeTag = $scope.tags[0]; //call helperCode if (obj.status.responses.length > 0) { diff --git a/lib/response/views/response_panel.view.html b/lib/response/views/response_panel.view.html index d5a408e..4ee727b 100644 --- a/lib/response/views/response_panel.view.html +++ b/lib/response/views/response_panel.view.html @@ -22,8 +22,8 @@

Search

- - {{tag.name}} + + {{tag.name}}
@@ -32,8 +32,13 @@

Search

-
-

R{{$root.requests.length-$index}} {{request.title | limitTo:45}}{{request.title.length > 45 ? '...' : ''}}

+
+

+ R{{$root.requests.length-$index}} {{request.title | limitTo:45}}{{request.title.length > 45 ? '...' : ''}} +

+
+ {{tag}} +

Q: {{request.request_description}}

File:{{request.changelog[1].title}}
@@ -69,7 +74,9 @@

Q: {{request.request_description}}

{{selectedObj.title | limitTo:35}}{{selectedObj.title.length > 30 ? '...' : ''}}

- +
+ {{tag}} +

Q: {{selectedObj.request_description}}

File:{{selectedObj.changelog[1].title}}