diff --git a/public/index.html b/public/index.html index 0e9e70d..b2ce9e1 100644 --- a/public/index.html +++ b/public/index.html @@ -117,6 +117,7 @@ + -
+
@@ -139,8 +145,8 @@
- - + +
@@ -195,12 +201,12 @@ Please type some relevant words in the command box.
- +
diff --git a/src/js/bot/recast-ops.js b/src/js/bot/recast-ops.js index d3af5d2..3daf245 100644 --- a/src/js/bot/recast-ops.js +++ b/src/js/bot/recast-ops.js @@ -28,6 +28,7 @@ module.exports = class Recast { bodyRelevant = body.results; intent = bodyRelevant.intents[0]["slug"]; if(intent !== undefined) { + domManipulator.displayIntentBox(intent); domManipulator.showWidget(intent); domManipulator.populateRecastData(intent, bodyRelevant); // self.processIntent(intent); diff --git a/src/js/dom-ops.js b/src/js/dom-ops.js index dfb3a5e..da796d9 100644 --- a/src/js/dom-ops.js +++ b/src/js/dom-ops.js @@ -2,6 +2,10 @@ module.exports = class DomManipulator { constructor() { this.createRepoWidgetCreated = false; + this.intentSlugToIntention = { + 'createrepo' : "Create a Repository in Github", + 'createissue' : "Raise an issue in Github", + }; } showWidget(widgetName) { self = this; @@ -54,6 +58,7 @@ module.exports = class DomManipulator { var createRepoWidget = self.createRepoWidget(); if(!this.isVisible(createRepoWidget)) { createRepoWidget.classList.remove('hide'); + $('#underWidgetLine').show(); } } @@ -61,9 +66,18 @@ module.exports = class DomManipulator { var createIssueWidget = document.getElementById('createissue'); if(!this.isVisible(createIssueWidget)) { createIssueWidget.classList.remove('hide'); + $('#underWidgetLine').show(); } } + displayIntentBox(intent) { + var intentBox = document.getElementById('intentBox'); + if(!this.isVisible(intentBox)) { + intentBox.classList.remove('hide'); + } + $('#intentName').text(this.intentSlugToIntention[intent] + ' [slug: ' + intent + '].'); + } + createRepoWidget() { var existingWidget = document.getElementById('createrepo') if(existingWidget) { @@ -257,7 +271,7 @@ module.exports = class DomManipulator { app.deleteRepository(); break; case "createissue": - app.createIssue(); + self.populateCreateIssueData(recastResponse); break; case "updateissue": app.updateIssue(); @@ -297,6 +311,15 @@ module.exports = class DomManipulator { } } + populateCreateIssueData(recastResponse) { + var issueTitleTextField = document.getElementById('issueTitle'); + if(issueTitleTextField && recastResponse && recastResponse.entities['git-repository'] && recastResponse.entities['git-repository'].length > 0 + && recastResponse.entities['git-repository']['0']['value']) { + var issueTitle = recastResponse.entities['git-repository']['0']['value']; + issueTitleTextField.value = issueTitle; + } + } + isVisible(element) { return element ? !element.classList.contains('hide') : false; } diff --git a/src/js/event-toggles.js b/src/js/event-toggles.js index 7e8944f..4eca8d6 100644 --- a/src/js/event-toggles.js +++ b/src/js/event-toggles.js @@ -23,7 +23,7 @@ module.exports = $(document).ready(function () { $('#command').keyup(function(e){ var code = (e.keyCode ? e.keyCode : e.which); if(code == 13) { - $('widgets').children().hide(); + $('#widgets').children().addClass('hide'); var command = document.getElementById('command').value; if(command) { var text = { "text": command}; @@ -37,8 +37,8 @@ module.exports = $(document).ready(function () { var requestJSON = dom.getDataFromFormAsJSON(); app.createRepository(requestJSON); }) + $("#hideInfoAlert").on('click', function(){ + $('#intentBox').addClass('hide'); + }) - $('#submitForm').click(function(e) { - e.preventDefault(); - }); }); \ No newline at end of file