diff --git a/app/app/components/section/trello/type-editor.js b/app/app/components/section/trello/type-editor.js index c9a08b60..e0cac549 100644 --- a/app/app/components/section/trello/type-editor.js +++ b/app/app/components/section/trello/type-editor.js @@ -117,30 +117,34 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, this.set('config.board', boards.findBy('id', board.id)); } - this.get('sectionService').fetch(page, "lists", self.get('config')) - .then(function (lists) { - let savedLists = self.get('config.lists'); - if (savedLists === null) { - savedLists = []; - } - - lists.forEach(function (list) { - let saved = savedLists.findBy("id", list.id); - let included = true; - if (is.not.undefined(saved)) { - included = saved.included; + if (is.null(board.id) || is.undefined(board.id)) { + self.set('busy', false); + } else { + this.get('sectionService').fetch(page, "lists", self.get('config')) + .then(function (lists) { + let savedLists = self.get('config.lists'); + if (savedLists === null) { + savedLists = []; } - list.included = included; - }); - self.set('config.lists', lists); - self.set('busy', false); - }, function (error) { //jshint ignore: line - self.set('busy', false); - self.set('authenticated', false); - self.showNotification("Unable to fetch board lists"); - console.log(error); - }); + lists.forEach(function (list) { + let saved = savedLists.findBy("id", list.id); + let included = true; + if (is.not.undefined(saved)) { + included = saved.included; + } + list.included = included; + }); + + self.set('config.lists', lists); + self.set('busy', false); + }, function (error) { //jshint ignore: line + self.set('busy', false); + self.set('authenticated', false); + self.showNotification("Unable to fetch board lists"); + console.log(error); + }); + } }, actions: { @@ -203,8 +207,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, self.get('sectionService').fetch(page, "boards", self.get('config')) .then(function (boards) { self.set('busy', false); - self.set('boards', boards); + boards.unshift({ id: null, name: "--None--", backgroundColor: "white" }); // add the non-selection to the front self.set('config.boards', boards); // save the boards in the config too + self.set('boards', boards); self.getBoardLists(); }, function (error) { //jshint ignore: line self.set('busy', false); diff --git a/app/app/templates/components/section/trello/type-editor.hbs b/app/app/templates/components/section/trello/type-editor.hbs index abe80c8a..973bb4fb 100644 --- a/app/app/templates/components/section/trello/type-editor.hbs +++ b/app/app/templates/components/section/trello/type-editor.hbs @@ -25,14 +25,16 @@
All boards are selectd by default
{{#each config.boards as |board|}} -
- {{#if board.included}} - check_box - {{else}} - check_box_outline_blank - {{/if}} - {{board.name}} -
+ {{#if board.id}} +
+ {{#if board.included}} + check_box + {{else}} + check_box_outline_blank + {{/if}} + {{board.name}} +
+ {{/if}} {{/each}}
@@ -46,24 +48,26 @@
Select board
{{ui-select id="boards-dropdown" content=boards action=(action 'onBoardChange') optionValuePath="id" optionLabelPath="name" selection=config.board}}
-
- -
Select lists to include
-
-
{{config.board.name}}
- {{#each config.lists as |list|}} -
- {{#if list.included}} - check_box - {{else}} - check_box_outline_blank - {{/if}} - {{list.name}} -
- {{/each}} -
+ {{#if config.board.id}} +
+ +
Select lists to include
+
+
{{config.board.name}}
+ {{#each config.lists as |list|}} +
+ {{#if list.included}} + check_box + {{else}} + check_box_outline_blank + {{/if}} + {{list.name}} +
+ {{/each}} +
+
-
+ {{/if}}
{{/if}} diff --git a/core/section/trello/trello.go b/core/section/trello/trello.go index 561b7c8e..2569eafa 100644 --- a/core/section/trello/trello.go +++ b/core/section/trello/trello.go @@ -224,7 +224,7 @@ func (*Provider) Refresh(ctx *provider.Context, config, data string) string { } for _, board := range c.Boards { - if board.Included { + if board.Included && board.ID != "" { var payload = trelloRenderBoard{} c.Board = board @@ -315,6 +315,9 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) { } func getLists(config trelloConfig) (lists []trelloList, err error) { + if config.Board.ID == "" { + return + } uri := fmt.Sprintf("https://api.trello.com/1/boards/%s/lists/open?key=%s&token=%s", config.Board.ID, config.AppKey, config.Token) req, err := http.NewRequest("GET", uri, nil) log.IfErr(err)