Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
14 app/assets/javascripts/app/controllers/issues_controller.js
... ... @@ -1,14 +1,20 @@
1 1 App.IssuesController = Ember.ArrayController.create({
2 2 content: [],
3   - search: function(repo) {
4   - var that = this;
  3 + fetch: function(options) {
  4 + var that = this,
  5 + issue_params = {repo: options.repo},
  6 + url = options.searching === true ? "/issues/search" : "/issues";
5 7
6 8 this.reset();
7 9
  10 + if (typeof(options.search_term) != "undefined" && options.search_term) issue_params.search_term = options.search_term;
  11 + if (typeof(options.mentioned) != "undefined" && options.mentioned) issue_params.options = "mentioned";
  12 + issue_params.state = typeof(options.state) == "undefined" ? "open" : options.state;
  13 +
8 14 $.ajax({
9   - url: "/api/issues",
  15 + url: url,
10 16 type: "GET",
11   - data: {repo: repo},
  17 + data: issue_params,
12 18 success: function(response) {
13 19 if (response.success === 1) {
14 20 response.issues.forEach(function(issue) {
51 app/assets/javascripts/app/views/issueFiltersView.js
... ... @@ -1,19 +1,52 @@
1   -App.IssueFiltersView = Ember.View.extend({
2   - elementId: "issue_filters",
3   - classNames: ["inscribed"],
4   - childViews: [App.IssueTypesView, App.IssueSearchView],
  1 +App.IssueTypesView = Ember.View.extend({
  2 + init: function() {
  3 + this._super();
  4 + },
  5 + click: function(event) {
  6 + var target = event.target,
  7 + repo = App.IssuesController.get("repo");
  8 +
  9 + $(target).addClass("current").siblings().removeClass("current")
  10 +
  11 + if (target.id === 'everyone_issues') App.IssuesController.fetch({repo: repo});
  12 + if (target.id === 'mentioning_issues') App.IssuesController.fetch({repo: repo, mentioned: true});
  13 + if (target.id === 'closed_issues') App.IssuesController.fetch({repo: repo, state: "closed"});
  14 + }
  15 +})
  16 +
  17 +App.IssueSearchView = Ember.TextField.extend({
5 18 init: function() {
6 19 this._super();
  20 + this.setupSelectors();
  21 + this.setupEvents();
7 22 },
8 23 setupSelectors: function() {
  24 + this.el = $("#issue_filters");
  25 + this.issue_term = $("#issue_term", this.el);
  26 + this.search_issue = $("#search_issue", this.el);
9 27
  28 + console.log(this)
10 29 },
11 30 setupEvents: function() {
12   -
  31 + this.search_issue.click(Ember.proxy(this.searchIssue, this));
13 32 },
14   - click: function(event) {
15   - var target = event.target;
16   -
17   - console.log(target.id)
  33 + searchIssue: function() {
  34 + var search_term = this.issue_term.val(),
  35 + repo = App.IssuesController.get("repo");
  36 +
  37 + if (search_term) App.IssuesController.fetch({repo: repo, search_term: search_term, searching: true});
  38 + }
  39 +})
  40 +
  41 +App.IssueFiltersView = Ember.View.extend({
  42 + init: function() {
  43 + this._super();
  44 + this.createChildViews();
  45 + },
  46 + childViews: [App.IssueTypesView, App.IssueSearchView],
  47 + createChildViews: function() {
  48 + _.each(this.childViews, function(child_view) {
  49 + child_view.create();
  50 + })
18 51 }
19 52 })
10 app/assets/javascripts/app/views/issueSearchView.js
... ... @@ -1,10 +0,0 @@
1   -App.IssueSearchView = Ember.TextField.extend({
2   - elementId: "issue_term",
3   - classNames: ["textbox"],
4   - didInsertElement: function() {
5   - this.set("placeholder", "Search issue");
6   - },
7   - insertNewline: function() {
8   -
9   - }
10   -})
5 app/assets/javascripts/app/views/issueTypesView.js
... ... @@ -1,5 +0,0 @@
1   -App.IssueTypesView = Ember.View.extend({
2   - tagName: "menu",
3   - elementId: "issue_types",
4   - templateName: "app/templates/issue_types"
5   -})
11 app/assets/javascripts/app/views/repoFinderView.js
@@ -19,8 +19,9 @@ App.RepoFinderView = Ember.View.extend({
19 19 _searchRepo: function() {
20 20 var repo = this.repo_query.val();
21 21 if (repo) {
  22 + this.spinner.show();
22 23 App.IssuesController.set("repo", repo);
23   - App.IssuesController.search(repo);
  24 + App.IssuesController.fetch({repo: repo});
24 25 }
25 26 },
26 27 _handleKeypress: function(event) {
@@ -32,7 +33,11 @@ App.RepoFinderView = Ember.View.extend({
32 33 stateChanged: function() {
33 34 var state = App.IssuesController.get("state");
34 35
35   - if (_.indexOf(["displayingIssues", "viewIssueDetails", "newIssue"], state) != -1) this.el.hide()
36   - else this.el.show()
  36 + if (_.indexOf(["displayingIssues", "viewIssueDetails", "newIssue"], state) != -1) {
  37 + this.spinner.hide();
  38 + this.el.hide();
  39 + } else {
  40 + this.el.show();
  41 + }
37 42 }
38 43 })
10 app/views/dashboard/_issue_filters.html.haml
... ... @@ -0,0 +1,10 @@
  1 +#issue_filters.inscribed
  2 + #search_box_wrapper.sugar
  3 + .textbox_wrapper
  4 + %input{:type => :text, :id => :issue_term, :class => :textbox, :placeholder => 'Search issue'}
  5 + = image_tag 'search_button.png', :id => :search_issue
  6 +
  7 + %menu#issue_types
  8 + %li#everyone_issues Everyone's issues
  9 + %li#mentioning_issues Mentioning you
  10 + %li#closed_issues Closed issues

No commit comments for this range

Something went wrong with that request. Please try again.