mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
select which boards and date since, individual board not working yet
This commit is contained in:
parent
16bf5237b9
commit
1e37c68d99
7 changed files with 166 additions and 87 deletions
|
@ -50,7 +50,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
token: "",
|
||||
user: null,
|
||||
board: null,
|
||||
lists: []
|
||||
lists: [],
|
||||
boards: []
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -101,6 +102,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
this.set('noBoards', false);
|
||||
|
||||
if (is.undefined(self.get('initDateTimePicker'))) {
|
||||
$.datetimepicker.setLocale('en');
|
||||
$('#trello-since').datetimepicker();
|
||||
self.set('initDateTimePicker', "Done");
|
||||
}
|
||||
|
||||
if (is.null(board) || is.undefined(board)) {
|
||||
if (boards.length) {
|
||||
board = boards[0];
|
||||
|
@ -150,6 +157,15 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
}
|
||||
},
|
||||
|
||||
onBoardCheckbox(id) {
|
||||
let boards = this.get('config.boards');
|
||||
let board = boards.findBy('id', id);
|
||||
|
||||
if (board !== null) {
|
||||
Ember.set(board, 'included', !board.included);
|
||||
}
|
||||
},
|
||||
|
||||
auth() {
|
||||
if (this.get('appKey') === "") {
|
||||
$("#trello-appkey").addClass('error').focus();
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
|
||||
|
||||
{{#if authenticated}}
|
||||
{{#if noBoards}}
|
||||
<div class="input-control">
|
||||
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
|
||||
</div>
|
||||
{{else}}
|
||||
|
||||
<div class="pull-left width-50">
|
||||
<div class="input-form">
|
||||
|
@ -10,13 +15,34 @@
|
|||
<div class="title">Select Board & Lists</div>
|
||||
<div class="tip">Choose lists to include from board</div>
|
||||
</div>
|
||||
{{#if noBoards}}
|
||||
<div class="input-control">
|
||||
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
|
||||
<label>Show summary from (default 7 days ago)</label>
|
||||
{{input id="trello-since" value=config.since type="text" }}<br>
|
||||
</div>
|
||||
{{else}}
|
||||
|
||||
<div class="input-control">
|
||||
<label>Board</label>
|
||||
<label>Select which boards you want to see</label>
|
||||
<div class="tip">All boards are selectd by default</div>
|
||||
<div class="github-board">
|
||||
{{#each config.boards as |board|}}
|
||||
<div class="github-list" {{action 'onBoardCheckbox' board.id}}>
|
||||
{{#if board.included}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box</i>
|
||||
{{else}}
|
||||
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box_outline_blank</i>
|
||||
{{/if}}
|
||||
<span style="background-color: {{board.prefs.backgroundColor}}">{{board.name}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
<div class="clearfix" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-right width-50">
|
||||
<div class="input-form">
|
||||
<div class="input-control">
|
||||
<label>Individual 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>
|
||||
|
@ -38,9 +64,9 @@
|
|||
<div class="clearfix" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{else}}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
package trello
|
||||
|
||||
const graphsTemplate = `
|
||||
{{if false}}
|
||||
|
||||
<b>Single Boards (graphs)</b><br>
|
||||
{{range $b := .Boards}}
|
||||
<div>
|
||||
|
@ -25,4 +27,6 @@ const graphsTemplate = `
|
|||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
`
|
||||
|
|
|
@ -15,7 +15,7 @@ const renderTemplate = `
|
|||
<h3>Header for Trello Multi-Board Test (in master_template.go)</h3>
|
||||
` + labelsTemplate +
|
||||
boardsTemplate +
|
||||
// graphsTemplate +
|
||||
graphsTemplate +
|
||||
membersTemplate +
|
||||
archiveTemplate +
|
||||
tradTemplate +
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
|
||||
package trello
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type secrets struct {
|
||||
Token string `json:"token"`
|
||||
|
@ -20,9 +23,11 @@ type secrets struct {
|
|||
type trelloConfig struct {
|
||||
AppKey string `json:"appKey"`
|
||||
Token string `json:"token"`
|
||||
Board trelloBoard `json:"board"` // TODO review
|
||||
Lists []trelloList `json:"lists"` // TODO review
|
||||
Board trelloBoard `json:"board"`
|
||||
Lists []trelloList `json:"lists"`
|
||||
Boards []trelloBoard `json:"boards"`
|
||||
Since string `json:"since,omitempty"`
|
||||
SincePtr *time.Time `json:"-"`
|
||||
}
|
||||
|
||||
func (c *trelloConfig) Clean() {
|
||||
|
@ -162,6 +167,7 @@ type trelloBoard struct {
|
|||
Blue string `json:"blue"`
|
||||
Purple string `json:"purple"`
|
||||
} `json:"labelNames"`
|
||||
Included bool `json:"included"` // indicates whether we display this board
|
||||
}
|
||||
|
||||
type trelloBoardBackground struct {
|
||||
|
@ -258,6 +264,8 @@ type trelloBoardAssign struct {
|
|||
}
|
||||
|
||||
type trelloRender struct {
|
||||
Config trelloConfig
|
||||
|
||||
Boards []trelloRenderBoard
|
||||
|
||||
Since string
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
package trello
|
||||
|
||||
const tradTemplate = `
|
||||
{{if eq 1 (len .Boards)}}
|
||||
<h3>#Board Name</h3>
|
||||
{{if false}}
|
||||
{{range $b := .Boards}}
|
||||
<p class="non-printable-message">Non-printable</p>
|
||||
<div class="section-trello-render non-printable">
|
||||
|
|
|
@ -183,13 +183,36 @@ func (*Provider) Render(ctx *provider.Context, config, data string) string {
|
|||
// Refresh just sends back data as-is.
|
||||
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
|
||||
var c = trelloConfig{}
|
||||
json.Unmarshal([]byte(config), &c)
|
||||
log.IfErr(json.Unmarshal([]byte(config), &c))
|
||||
|
||||
save := trelloRender{}
|
||||
save.Config = c
|
||||
save.Boards = make([]trelloRenderBoard, 0, len(c.Boards))
|
||||
|
||||
for _, board := range c.Boards {
|
||||
if len(c.Since) >= len("yyyy/mm/dd hh:ss") {
|
||||
var since time.Time
|
||||
tt := []byte("yyyy-mm-ddThh:mm:00Z")
|
||||
for _, i := range []int{0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15} {
|
||||
tt[i] = c.Since[i]
|
||||
}
|
||||
err := since.UnmarshalText(tt)
|
||||
if err != nil {
|
||||
log.ErrorString("Date unmarshall '" + c.Since + "'->'" + string(tt) + "' error: " + err.Error())
|
||||
} else {
|
||||
c.SincePtr = &since
|
||||
}
|
||||
}
|
||||
dateMessage := ""
|
||||
if c.SincePtr == nil {
|
||||
dateMessage = " (the last 7 days)"
|
||||
since := time.Now().AddDate(0, 0, -7)
|
||||
c.SincePtr = &since
|
||||
c.Since = (*c.SincePtr).Format("2006/01/02 ")
|
||||
}
|
||||
save.Since = (*c.SincePtr).Format("January 2, 2006") + dateMessage
|
||||
|
||||
for _, board := range c.Boards {
|
||||
if board.Included {
|
||||
var payload = trelloRenderBoard{}
|
||||
|
||||
c.Board = board
|
||||
|
@ -216,12 +239,11 @@ func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
|
|||
payload.CardCount += len(list.Cards)
|
||||
}
|
||||
|
||||
payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, nil) // TODO pass in date
|
||||
payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, c.Since)
|
||||
|
||||
save.Boards = append(save.Boards, payload)
|
||||
}
|
||||
|
||||
save.Since = "# 1 Aug 2016 #"
|
||||
}
|
||||
|
||||
j, err := json.Marshal(save)
|
||||
|
||||
|
@ -268,6 +290,10 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for bx := range boards {
|
||||
boards[bx].Included = true // include boards by default
|
||||
}
|
||||
|
||||
return boards, nil
|
||||
}
|
||||
|
||||
|
@ -387,9 +413,9 @@ func fetchMember(config *trelloConfig, render *trelloRender, memberID string) (m
|
|||
return
|
||||
}
|
||||
|
||||
func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since *time.Time) (actions []trelloAction, archived []trelloCard) {
|
||||
func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since string) (actions []trelloAction, archived []trelloCard) {
|
||||
|
||||
sinceString := "2016-08-01" // TODO
|
||||
sinceString := since[:10]
|
||||
|
||||
if len(config.AppKey) == 0 {
|
||||
config.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue