mirror of
https://github.com/documize/community.git
synced 2025-08-07 14:35:28 +02:00
don't show personal trello boards
This commit is contained in:
parent
7f5df6e2ab
commit
9ebeb7726b
4 changed files with 166 additions and 161 deletions
|
@ -28,12 +28,14 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
try {
|
||||
config = JSON.parse(this.get('meta.config'));
|
||||
} catch (e) {}
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if (is.empty(config)) {
|
||||
config = {
|
||||
appKey: "",
|
||||
token: "",
|
||||
user: null,
|
||||
board: null,
|
||||
lists: []
|
||||
};
|
||||
|
@ -41,10 +43,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
this.set('config', config);
|
||||
|
||||
if (this.get('config.appKey') !== "" &&
|
||||
this.get('config.token') !== "") {
|
||||
console.log(this.get('isReadonly'));
|
||||
console.log(this.get('isMine'));
|
||||
if (this.get('config.appKey') !== "" && this.get('config.token') !== "") {
|
||||
this.send('auth');
|
||||
}
|
||||
},
|
||||
|
@ -59,20 +58,21 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
let self = this;
|
||||
let boards = this.get('boards');
|
||||
let board = this.get('config.board');
|
||||
let page = this.get('page');
|
||||
let page = this.get('page');
|
||||
|
||||
if (is.null(board) || is.undefined(board)) {
|
||||
if (boards.length) {
|
||||
board = boards[0];
|
||||
this.set('config.board', board);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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');
|
||||
this.get('sectionService').fetch(page, "lists", self.get('config'))
|
||||
.then(function(lists) {
|
||||
let savedLists = self.get('config.lists');
|
||||
if (savedLists === null) {
|
||||
savedLists = [];
|
||||
}
|
||||
|
@ -88,39 +88,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
self.set('config.lists', lists);
|
||||
self.set('busy', false);
|
||||
}, function(error) { //jshint ignore: line
|
||||
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);
|
||||
});
|
||||
|
||||
|
||||
// Trello.get(`boards/${board.id}/lists/open?fields=id,name,url`,
|
||||
// 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;
|
||||
// }
|
||||
// list.included = included;
|
||||
// });
|
||||
//
|
||||
// self.set('config.lists', lists);
|
||||
// self.set('busy', false);
|
||||
// },
|
||||
// function(error) {
|
||||
// self.set('busy', false);
|
||||
// self.set('authenticated', false);
|
||||
// self.showNotification("Unable to fetch board lists");
|
||||
// console.log(error);
|
||||
// });
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -155,7 +128,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
}
|
||||
|
||||
let self = this;
|
||||
let page = this.get('page');
|
||||
let page = this.get('page');
|
||||
|
||||
self.set('busy', true);
|
||||
|
||||
|
@ -175,31 +148,23 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
self.set('config.token', Trello.token());
|
||||
self.set('busy', true);
|
||||
|
||||
self.get('sectionService').fetch(page, "boards", self.get('config'))
|
||||
.then(function(boards) {
|
||||
self.set('busy', false);
|
||||
self.set('boards', boards.filterBy("closed", false));
|
||||
Trello.members.get("me", function(user) {
|
||||
self.set('config.user', user);
|
||||
}, function(error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
self.get('sectionService').fetch(page, "boards", self.get('config'))
|
||||
.then(function(boards) {
|
||||
self.set('busy', false);
|
||||
self.set('boards', boards);
|
||||
self.getBoardLists();
|
||||
}, function(error) { //jshint ignore: line
|
||||
self.set('busy', false);
|
||||
}, function(error) { //jshint ignore: line
|
||||
self.set('busy', false);
|
||||
self.set('authenticated', false);
|
||||
self.showNotification("Unable to fetch boards");
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
// Trello.get("members/me/boards?fields=id,name,url,closed,prefs,idOrganization",
|
||||
// function(boards) {
|
||||
// self.set('busy', false);
|
||||
// self.set('boards', boards.filterBy("closed", false));
|
||||
// self.getBoardLists();
|
||||
// },
|
||||
// function(error) {
|
||||
// self.set('busy', false);
|
||||
// self.set('authenticated', false);
|
||||
// self.showNotification("Unable to fetch boards");
|
||||
// console.log(error);
|
||||
// }
|
||||
// );
|
||||
});
|
||||
},
|
||||
error: function(error) {
|
||||
self.set('busy', false);
|
||||
|
@ -246,7 +211,5 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
}
|
||||
});
|
||||
|
||||
// no private boards?
|
||||
// show who owner is -- logout
|
||||
// app key really required?
|
||||
// pass/save global section config?
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
|
@ -13,14 +13,15 @@ import Ember from 'ember';
|
|||
|
||||
export default Ember.Mixin.create({
|
||||
isReadonly: function() {
|
||||
if (this.get('page.userId') !== this.session.user.id) {
|
||||
return "readonly";
|
||||
} else {
|
||||
if (this.get('page.userId') === this.session.user.id) {
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
return "readonly";
|
||||
}
|
||||
}.property('page'),
|
||||
|
||||
isMine: function() {
|
||||
return this.get('page.userId') !== this.session.user.id;
|
||||
return this.get('page.userId') === this.session.user.id;
|
||||
}.property('page')
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,100 +1,95 @@
|
|||
<style>
|
||||
.trello-board {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
white-space: nowrap;
|
||||
overflow: auto
|
||||
}
|
||||
<style>
|
||||
.trello-board {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
white-space: nowrap;
|
||||
overflow: auto
|
||||
}
|
||||
|
||||
.trello-board-title {
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
}
|
||||
.trello-board-title {
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.trello-list {
|
||||
background-color: #e2e4e6;
|
||||
padding: 10px;
|
||||
border-radius: 3px;
|
||||
margin: 10px 10px 0 0;
|
||||
max-width: 300px;
|
||||
}
|
||||
.trello-list {
|
||||
background-color: #e2e4e6;
|
||||
padding: 10px;
|
||||
border-radius: 3px;
|
||||
margin: 10px 10px 0 0;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
.trello-list-title {
|
||||
font-weight: bold;
|
||||
color: #4c4c4c;
|
||||
font-size: 14px;
|
||||
margin: 5px;
|
||||
}
|
||||
.trello-list-title {
|
||||
font-weight: bold;
|
||||
color: #4c4c4c;
|
||||
font-size: 14px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.trello-list-checkbox {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
.trello-list-checkbox {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
</style>
|
||||
|
||||
{{#section/base-editor document=document folder=folder page=page busy=busy tip="Trello is the visual way to manage your projects and organize anything (https://trello.com)" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
|
||||
{{#section/base-editor document=document folder=folder page=page busy=busy tip="Trello is the visual way to manage your projects and organize anything (https://trello.com)" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action
|
||||
'onAction')}}
|
||||
|
||||
<div class="pull-left width-45">
|
||||
<div class="input-form">
|
||||
<form>
|
||||
<div class="heading">
|
||||
<div class="title">Authentication</div>
|
||||
<div class="tip">Provide Trello App Key and then authenticate</div>
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Trello App Key</label>
|
||||
<div class="tip">Use plain old button below to grab the magic key -- you might need to log into Trello</div>
|
||||
{{focus-input id="trello-appkey" type="password" value=config.appKey}}
|
||||
</div>
|
||||
{{#if authenticated}}
|
||||
<div class="regular-button button-gray" {{ action 'logout' }}>Logout</div>
|
||||
{{else}}
|
||||
<div class="regular-button button-gray" {{ action 'getAppKey' }}>Get App Key</div>
|
||||
<div class="button-gap" />
|
||||
<div class="regular-button button-blue" {{ action 'auth' }}>Authenticate</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
<div class="pull-left width-45">
|
||||
<div class="input-form">
|
||||
<form>
|
||||
<div class="heading">
|
||||
<div class="title">Authentication</div>
|
||||
<div class="tip">Provide Trello App Key and then authenticate</div>
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Trello App Key</label>
|
||||
<div class="tip">Use plain old button below to grab the magic key -- you might need to log into Trello</div>
|
||||
{{focus-input id="trello-appkey" type="password" value=config.appKey readonly=isReadonly}}
|
||||
</div>
|
||||
{{#if authenticated}}
|
||||
<div class="regular-button button-gray" {{ action 'logout' }}>Logout {{config.user.fullName}}</div>
|
||||
{{else}}
|
||||
<div class="regular-button button-gray" {{ action 'getAppKey' }}>Get App Key</div>
|
||||
<div class="button-gap" />
|
||||
<div class="regular-button button-blue" {{ action 'auth' }}>Authenticate</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if authenticated}}
|
||||
<div class="pull-right width-45">
|
||||
<div class="input-form">
|
||||
<div class="heading">
|
||||
<div class="title">Select Board & Lists</div>
|
||||
<div class="tip">Choose lists to include from board</div>
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Board</label>
|
||||
<div class="tip">Select board</div>
|
||||
{{ui-select id="boards-dropdown"
|
||||
content=boards
|
||||
action=(action 'onBoardChange')
|
||||
optionValuePath="id"
|
||||
optionLabelPath="name"
|
||||
selection=config.board
|
||||
readonly=isReadonly}}
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Lists</label>
|
||||
<div class="tip">Select lists to include</div>
|
||||
<div class="trello-board" style="background-color:{{config.board.prefs.backgroundColor}};">
|
||||
<div class="trello-board-title">{{config.board.name}}</div>
|
||||
{{#each config.lists as |list|}}
|
||||
<div class="trello-list" {{action 'onListCheckbox' list.id}}>
|
||||
{{#if list.included}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray trello-list-checkbox" >check_box</i>
|
||||
{{else}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray trello-list-checkbox">check_box_outline_blank</i>
|
||||
{{/if}}
|
||||
<span class="trello-list-title">{{list.name}}</span>
|
||||
{{#if authenticated}}
|
||||
<div class="pull-right width-45">
|
||||
<div class="input-form">
|
||||
<div class="heading">
|
||||
<div class="title">Select Board & Lists</div>
|
||||
<div class="tip">Choose lists to include from board</div>
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Board</label>
|
||||
<div class="tip">Select board</div>
|
||||
{{ui-select id="boards-dropdown" content=boards action=(action 'onBoardChange') optionValuePath="id" optionLabelPath="name" selection=config.board}}
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Lists</label>
|
||||
<div class="tip">Select lists to include</div>
|
||||
<div class="trello-board" style="background-color:{{config.board.prefs.backgroundColor}};">
|
||||
<div class="trello-board-title">{{config.board.name}}</div>
|
||||
{{#each config.lists as |list|}}
|
||||
<div class="trello-list" {{action 'onListCheckbox' list.id}}>
|
||||
{{#if list.included}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray trello-list-checkbox">check_box</i>
|
||||
{{else}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray trello-list-checkbox">check_box_outline_blank</i>
|
||||
{{/if}}
|
||||
<span class="trello-list-title">{{list.name}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
<div class="clearfix" />
|
||||
</div>
|
||||
{{/each}}
|
||||
<div class="clearfix" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{/section/base-editor}}
|
||||
{{/if}}
|
||||
|
||||
{{/section/base-editor}}
|
||||
|
|
|
@ -176,10 +176,18 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) {
|
|||
return nil, fmt.Errorf("error: HTTP status code %d", res.StatusCode)
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
b := []trelloBoard{}
|
||||
|
||||
defer res.Body.Close()
|
||||
dec := json.NewDecoder(res.Body)
|
||||
err = dec.Decode(&boards)
|
||||
err = dec.Decode(&b)
|
||||
|
||||
// we only show open, team boards (not personal)
|
||||
for _, b := range b {
|
||||
if !b.Closed && len(b.OrganizationID) > 0 {
|
||||
boards = append(boards, b)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
@ -267,6 +275,44 @@ func (c *trelloConfig) Clean() {
|
|||
c.Token = strings.TrimSpace(c.Token)
|
||||
}
|
||||
|
||||
// Trello objects based upon https://github.com/VojtechVitek/go-trello
|
||||
type trelloMember struct {
|
||||
ID string `json:"id"`
|
||||
AvatarHash string `json:"avatarHash"`
|
||||
Bio string `json:"bio"`
|
||||
BioData struct {
|
||||
Emoji interface{} `json:"emoji,omitempty"`
|
||||
} `json:"bioData"`
|
||||
Confirmed bool `json:"confirmed"`
|
||||
FullName string `json:"fullName"`
|
||||
PremOrgsAdminID []string `json:"idPremOrgsAdmin"`
|
||||
Initials string `json:"initials"`
|
||||
MemberType string `json:"memberType"`
|
||||
Products []int `json:"products"`
|
||||
Status string `json:"status"`
|
||||
URL string `json:"url"`
|
||||
Username string `json:"username"`
|
||||
AvatarSource string `json:"avatarSource"`
|
||||
Email string `json:"email"`
|
||||
GravatarHash string `json:"gravatarHash"`
|
||||
BoardsID []string `json:"idBoards"`
|
||||
BoardsPinnedID []string `json:"idBoardsPinned"`
|
||||
OrganizationsID []string `json:"idOrganizations"`
|
||||
LoginTypes []string `json:"loginTypes"`
|
||||
NewEmail string `json:"newEmail"`
|
||||
OneTimeMessagesDismissed []string `json:"oneTimeMessagesDismissed"`
|
||||
Prefs struct {
|
||||
SendSummaries bool `json:"sendSummaries"`
|
||||
MinutesBetweenSummaries int `json:"minutesBetweenSummaries"`
|
||||
MinutesBeforeDeadlineToNotify int `json:"minutesBeforeDeadlineToNotify"`
|
||||
ColorBlind bool `json:"colorBlind"`
|
||||
Locale string `json:"locale"`
|
||||
} `json:"prefs"`
|
||||
Trophies []string `json:"trophies"`
|
||||
UploadedAvatarHash string `json:"uploadedAvatarHash"`
|
||||
PremiumFeatures []string `json:"premiumFeatures"`
|
||||
}
|
||||
|
||||
type trelloBoard struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue