diff options
author | Xavier Priour <xavier.priour@bubblyware.com> | 2015-10-15 14:01:13 +0200 |
---|---|---|
committer | Xavier Priour <xavier.priour@bubblyware.com> | 2015-10-17 18:00:46 +0200 |
commit | 468694a84cc164e4923f2d2e4631c37ceb1c4b55 (patch) | |
tree | 654abe750816e8d6fc7e4affff1af7c44932a829 /client | |
parent | 15ebfa63c61694e4aa60e0f9c5047f678d6cf0c4 (diff) | |
download | wekan-468694a84cc164e4923f2d2e4631c37ceb1c4b55.tar.gz wekan-468694a84cc164e4923f2d2e4631c37ceb1c4b55.tar.bz2 wekan-468694a84cc164e4923f2d2e4631c37ceb1c4b55.zip |
Import board: added UI
Diffstat (limited to 'client')
-rw-r--r-- | client/components/boards/boardHeader.jade | 2 | ||||
-rw-r--r-- | client/components/boards/boardHeader.js | 1 | ||||
-rw-r--r-- | client/components/boards/boardHeader.styl | 2 | ||||
-rw-r--r-- | client/components/import/import.jade | 8 | ||||
-rw-r--r-- | client/components/import/import.js | 80 | ||||
-rw-r--r-- | client/components/lists/listHeader.jade | 9 | ||||
-rw-r--r-- | client/components/lists/listHeader.js | 39 |
7 files changed, 93 insertions, 48 deletions
diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade index ffc79143..e460170b 100644 --- a/client/components/boards/boardHeader.jade +++ b/client/components/boards/boardHeader.jade @@ -107,6 +107,8 @@ template(name="createBoardPopup") | {{{_ 'board-private-info'}}} a.js-change-visibility {{_ 'change'}}. input.primary.wide(type="submit" value="{{_ 'create'}}") + | {{_ 'or'}} + a.js-import {{_ 'import-board'}} template(name="boardChangeTitlePopup") diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index dbd76895..92d5f6d4 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -145,6 +145,7 @@ BlazeComponent.extendComponent({ this.setVisibility(this.currentData()); }, 'click .js-change-visibility': this.toggleVisibilityMenu, + 'click .js-import': Popup.open('boardImportBoard'), submit: this.onSubmit, }]; }, diff --git a/client/components/boards/boardHeader.styl b/client/components/boards/boardHeader.styl new file mode 100644 index 00000000..adfe4b19 --- /dev/null +++ b/client/components/boards/boardHeader.styl @@ -0,0 +1,2 @@ +a.js-import + text-decoration underline diff --git a/client/components/import/import.jade b/client/components/import/import.jade new file mode 100644 index 00000000..8059b65b --- /dev/null +++ b/client/components/import/import.jade @@ -0,0 +1,8 @@ +template(name="importPopup") + if error.get + .warning {{_ error.get}} + form + label + | {{_ getLabel}} + textarea.js-card-json(placeholder="{{_ 'import-json-placeholder'}}" autofocus) + input.primary.wide(type="submit" value="{{_ 'import'}}") diff --git a/client/components/import/import.js b/client/components/import/import.js new file mode 100644 index 00000000..f15185ed --- /dev/null +++ b/client/components/import/import.js @@ -0,0 +1,80 @@ +/** + * Abstract root for all import popup screens. + * Descendants must define: + * - getMethodName(): return the Meteor method to call for import, passing json data decoded as object + * and additional data (see below) + * - getAdditionalData(): return object containing additional data passed to Meteor method + * (like list ID and position for a card import) + * - getLabel(): i18n key for the text displayed in the popup, usually to explain how to get the data out of the + * source system. + */ +const ImportPopup = BlazeComponent.extendComponent({ + template() {return 'importPopup';}, + events() { + return [{ + 'submit': (evt) => { + evt.preventDefault(); + const dataJson = $(evt.currentTarget).find('textarea').val(); + let dataObject; + try { + dataObject = JSON.parse(dataJson); + } catch (e) { + this.setError('error-json-malformed'); + return; + } + Meteor.call(this.getMethodName(), dataObject, this.getAdditionalData(), + (error, response) => { + if (error) { + this.setError(error.error); + } else { + Filter.addException(response); + Popup.close(); + } + } + ); + }, + }]; + }, + + onCreated() { + this.error = new ReactiveVar(''); + }, + + setError(error) { + this.error.set(error); + }, +}); + +ImportPopup.extendComponent({ + getAdditionalData() { + const listId = this.data()._id; + const firstCardDom = $(`#js-list-${this.currentData()._id} .js-minicard:first`).get(0); + const sortIndex = Utils.calculateIndex(null, firstCardDom).base; + const result = {listId, sortIndex}; + return result; + }, + + getMethodName() { + return 'importTrelloCard'; + }, + + getLabel() { + return 'import-card-trello-instruction'; + }, +}).register('listImportCardPopup'); + +ImportPopup.extendComponent({ + getAdditionalData() { + const result = {}; + return result; + }, + + getMethodName() { + return 'importTrelloBoard'; + }, + + getLabel() { + return 'import-board-trello-instruction'; + }, +}).register('boardImportBoardPopup'); + diff --git a/client/components/lists/listHeader.jade b/client/components/lists/listHeader.jade index e7b16912..72cd0fe9 100644 --- a/client/components/lists/listHeader.jade +++ b/client/components/lists/listHeader.jade @@ -31,15 +31,6 @@ template(name="listActionPopup") template(name="listMoveCardsPopup") +boardLists -template(name="listImportCardPopup") - if error.get - .warning {{_ error.get}} - form - label - | {{_ 'card-json'}} - textarea.js-card-json(placeholder="{{_ 'card-json-placeholder'}}" autofocus) - input.primary.wide(type="submit" value="{{_ 'import'}}") - template(name="boardLists") ul.pop-over-list each currentBoard.lists diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index e34d23fd..4f5fc3a0 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -49,45 +49,6 @@ Template.listActionPopup.events({ }, }); - -BlazeComponent.extendComponent({ - events() { - return [{ - 'submit': (evt) => { - evt.preventDefault(); - const jsonData = $(evt.currentTarget).find('textarea').val(); - const firstCardDom = $(`#js-list-${this.currentData()._id} .js-minicard:first`).get(0); - const sortIndex = Utils.calculateIndex(null, firstCardDom).base; - let trelloCard; - try { - trelloCard = JSON.parse(jsonData); - } catch (e) { - this.setError('error-json-malformed'); - return; - } - Meteor.call('importTrelloCard', trelloCard, this.currentData()._id, sortIndex, - (error, response) => { - if (error) { - this.setError(error.error); - } else { - Filter.addException(response); - Popup.close(); - } - } - ); - }, - }]; - }, - - onCreated() { - this.error = new ReactiveVar(''); - }, - - setError(error) { - this.error.set(error); - }, -}).register('listImportCardPopup'); - Template.listMoveCardsPopup.events({ 'click .js-select-list'() { const fromList = Template.parentData(2).data; |