Skip to content

Commit

Permalink
Giving promise to issues-list-view, created Issue model
Browse files Browse the repository at this point in the history
  • Loading branch information
amiuhle committed May 29, 2015
1 parent dc3e375 commit 0a1277e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
9 changes: 9 additions & 0 deletions lib/models/issue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use babel';

export default class Issue {

get title() {
return `${this.tracker.name} #${this.id}: ${this.subject}`;
}

}
11 changes: 4 additions & 7 deletions lib/redmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,10 @@ export default {

listIssues(options={}) {
var params = { project_id: this.projectId };
Object.getOwnPropertyNames(options)
.forEach(key => params[key] = options[key]);
console.log(params);
this.redmine.getIssues(params).then(issues => {
console.log('issues', issues);
this.createIssuesListView().toggle(issues);
}, this.showError);
Object.getOwnPropertyNames(options).forEach(key => params[key] = options[key]);
var issues = this.redmine.getIssues(params);
this.createIssuesListView().show(issues);
issues.then(undefined, this.showError);
},

createIssuesListView() {
Expand Down
22 changes: 13 additions & 9 deletions lib/views/issues-list-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import {$$, SelectListView} from 'atom-space-pen-views';
import shell from 'shell';

import Issue from '../models/issue';

export default class IssuesListView extends SelectListView {

constructor() {
super();
this.controller = null;
Expand All @@ -13,7 +16,7 @@ export default class IssuesListView extends SelectListView {
}

getFilterKey() {
return 'subject';
return 'title';
}

getFilterQuery() {
Expand All @@ -25,21 +28,22 @@ export default class IssuesListView extends SelectListView {
}

toggle(issues) {
this.issues = issues;
if(this.panel && this.panel.isVisible()) {
this.hide();
} else {
this.show();
this.show(issues);
}
}

show() {
show(issuesPromise) {
this.panel = this.panel || atom.workspace.addModalPanel({ item: this });
this.loading.text('Loading issues ...');
this.loadingArea.show();
this.panel.show();
this.setItems(this.issues.issues);
this.focusFilterEditor();
issuesPromise.then(issues => {
this.setItems(issues.issues);
this.focusFilterEditor();
});
}

hide() {
Expand All @@ -49,13 +53,13 @@ export default class IssuesListView extends SelectListView {
}

viewForItem(issue) {
Object.setPrototypeOf(issue, Issue.prototype);
// issue.__proto__ = Issue.prototype;
return $$(function() {
this.li({class: 'two-lines'}, ()=> {
this.div({ class: 'status status-added' });
this.div({ class: `primary-line icon icon-issue-opened` }, ()=> {
this.span('#' + issue.id);
this.span(' – ');
this.span(issue.subject);
this.span(issue.title);
});
this.div({ class: 'secondary-line no-icon' }, ()=> {
this.span(issue.status.name);
Expand Down

0 comments on commit 0a1277e

Please sign in to comment.