diff options
author | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-07-24 23:56:51 +0100 |
---|---|---|
committer | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-07-24 23:56:51 +0100 |
commit | d2b1a837e677b62e10a14c1599c4ff59ee21ff34 (patch) | |
tree | fae98d33bf797d84dc282fdf30fe1468cfb5dcd6 | |
parent | f34ef01de90bbb1ed3fbbb1deac9cbe968848de8 (diff) | |
download | wekan-d2b1a837e677b62e10a14c1599c4ff59ee21ff34.tar.gz wekan-d2b1a837e677b62e10a14c1599c4ff59ee21ff34.tar.bz2 wekan-d2b1a837e677b62e10a14c1599c4ff59ee21ff34.zip |
Import boards in Sandstorm
-rw-r--r-- | client/components/boards/boardHeader.js | 1 | ||||
-rw-r--r-- | client/components/import/import.jade | 2 | ||||
-rw-r--r-- | client/components/import/import.js | 2 | ||||
-rw-r--r-- | config/router.js | 3 | ||||
-rw-r--r-- | i18n/en.i18n.json | 2 | ||||
-rw-r--r-- | models/import.js | 5 | ||||
-rw-r--r-- | models/trelloCreator.js | 9 | ||||
-rw-r--r-- | models/wekanCreator.js | 9 |
8 files changed, 29 insertions, 4 deletions
diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index dafbfd30..6af3e320 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -14,6 +14,7 @@ Template.boardMenuPopup.events({ FlowRouter.go('home'); }), 'click .js-outgoing-webhooks': Popup.open('outgoingWebhooks'), + 'click .js-import-board': Popup.open('chooseBoardSource'), }); Template.boardMenuPopup.helpers({ diff --git a/client/components/import/import.jade b/client/components/import/import.jade index d1b3489a..5e737cc6 100644 --- a/client/components/import/import.jade +++ b/client/components/import/import.jade @@ -15,6 +15,8 @@ template(name="importTextarea") p: label(for='import-textarea') {{_ instruction}} textarea.js-import-json(placeholder="{{_ 'import-json-placeholder'}}" autofocus) | {{jsonText}} + if isSandstorm + p.warning {{_ 'import-sandstorm-warning'}} input.primary.wide(type="submit" value="{{_ 'import'}}") template(name="importMapMembers") diff --git a/client/components/import/import.js b/client/components/import/import.js index d72a02dd..64170c1d 100644 --- a/client/components/import/import.js +++ b/client/components/import/import.js @@ -68,10 +68,12 @@ BlazeComponent.extendComponent({ this.importedData.get(), additionalData, this.importSource, + Session.get('fromBoard'), (err, res) => { if (err) { this.setError(err.error); } else { + Session.set('fromBoard', null); Utils.goBoardId(res); } } diff --git a/config/router.js b/config/router.js index d4d13be5..ea85c7e6 100644 --- a/config/router.js +++ b/config/router.js @@ -84,6 +84,9 @@ FlowRouter.route('/import/:source', { name: 'import', triggersEnter: [AccountsTemplates.ensureSignedIn], action(params) { + if (Session.get('currentBoard')) { + Session.set('fromBoard', Session.get('currentBoard')); + } Session.set('currentBoard', null); Session.set('currentCard', null); Session.set('importSource', params.source); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 05d86ff6..da47e1c6 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -206,8 +206,10 @@ "home": "Home", "import": "Import", "import-board": "import board", + "import-board-c": "Import board", "import-board-title-trello": "Import board from Trello", "import-board-title-wekan": "Import board from Wekan", + "import-sandstorm-warning": "Imported board will delete all existing data on board and replace it with imported board.", "from-trello": "From Trello", "from-wekan": "From Wekan", "import-board-instruction-trello": "In your Trello board, go to 'Menu', then 'More', 'Print and Export', 'Export JSON', and copy the resulting text.", diff --git a/models/import.js b/models/import.js index 2e58c90f..09769794 100644 --- a/models/import.js +++ b/models/import.js @@ -2,10 +2,11 @@ import { TrelloCreator } from './trelloCreator'; import { WekanCreator } from './wekanCreator'; Meteor.methods({ - importBoard(board, data, importSource) { + importBoard(board, data, importSource, currentBoard) { check(board, Object); check(data, Object); check(importSource, String); + check(currentBoard, Match.Maybe(String)); let creator; switch (importSource) { case 'trello': @@ -23,6 +24,6 @@ Meteor.methods({ // authorized) nothing to check, everyone can import boards in their account // 3. create all elements - return creator.create(board); + return creator.create(board, currentBoard); }, }); diff --git a/models/trelloCreator.js b/models/trelloCreator.js index fbc4a878..aa86a5c8 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -488,7 +488,14 @@ export class TrelloCreator { } } - create(board) { + create(board, currentBoardId) { + // TODO : Make isSandstorm variable global + const isSandstorm = Meteor.settings && Meteor.settings.public && + Meteor.settings.public.sandstorm; + if (isSandstorm && currentBoardId) { + const currentBoard = Boards.findOne(currentBoardId); + currentBoard.archive(); + } this.parseActions(board.actions); const boardId = this.createBoardAndLabels(board); this.createLists(board.lists, boardId); diff --git a/models/wekanCreator.js b/models/wekanCreator.js index 6dd56fb1..b5f9b0ff 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -478,7 +478,14 @@ export class WekanCreator { } } - create(board) { + create(board, currentBoardId) { + // TODO : Make isSandstorm variable global + const isSandstorm = Meteor.settings && Meteor.settings.public && + Meteor.settings.public.sandstorm; + if (isSandstorm && currentBoardId) { + const currentBoard = Boards.findOne(currentBoardId); + currentBoard.archive(); + } this.parseActivities(board); const boardId = this.createBoardAndLabels(board); this.createLists(board.lists, boardId); |