1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-10 07:55:25 +02:00

don't show personal trello boards

This commit is contained in:
Harvey Kandola 2016-05-19 15:39:53 -07:00
parent 7f5df6e2ab
commit 9ebeb7726b
4 changed files with 166 additions and 161 deletions

View file

@ -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');
}
},
@ -66,7 +65,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
board = boards[0];
this.set('config.board', board);
}
} else {
}
else {
this.set('config.board', boards.findBy('id', board.id));
}
@ -94,33 +94,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
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: {
@ -175,10 +148,16 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
self.set('config.token', Trello.token());
self.set('busy', true);
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.filterBy("closed", false));
self.set('boards', boards);
self.getBoardLists();
}, function(error) { //jshint ignore: line
self.set('busy', false);
@ -186,20 +165,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
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?

View file

@ -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')
});

View file

@ -1,40 +1,41 @@
<style>
.trello-board {
.trello-board {
width: 100%;
padding: 10px;
white-space: nowrap;
overflow: auto
}
}
.trello-board-title {
.trello-board-title {
font-weight: bold;
color: #fff;
font-size: 16px;
}
}
.trello-list {
.trello-list {
background-color: #e2e4e6;
padding: 10px;
border-radius: 3px;
margin: 10px 10px 0 0;
max-width: 300px;
}
}
.trello-list-title {
.trello-list-title {
font-weight: bold;
color: #4c4c4c;
font-size: 14px;
margin: 5px;
}
}
.trello-list-checkbox {
.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="pull-left width-45">
<div class="input-form">
<form>
<div class="heading">
@ -44,10 +45,10 @@
<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}}
{{focus-input id="trello-appkey" type="password" value=config.appKey readonly=isReadonly}}
</div>
{{#if authenticated}}
<div class="regular-button button-gray" {{ action 'logout' }}>Logout</div>
<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" />
@ -55,10 +56,10 @@
{{/if}}
</form>
</div>
</div>
</div>
{{#if authenticated}}
<div class="pull-right width-45">
{{#if authenticated}}
<div class="pull-right width-45">
<div class="input-form">
<div class="heading">
<div class="title">Select Board & Lists</div>
@ -67,13 +68,7 @@
<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}}
{{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>
@ -83,7 +78,7 @@
{{#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>
<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}}
@ -94,7 +89,7 @@
</div>
</div>
</div>
</div>
{{/if}}
</div>
{{/if}}
{{/section/base-editor}}

View file

@ -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"`