From 468694a84cc164e4923f2d2e4631c37ceb1c4b55 Mon Sep 17 00:00:00 2001 From: Xavier Priour Date: Thu, 15 Oct 2015 14:01:13 +0200 Subject: Import board: added UI --- client/components/boards/boardHeader.jade | 2 + client/components/boards/boardHeader.js | 1 + client/components/boards/boardHeader.styl | 2 + client/components/import/import.jade | 8 ++++ client/components/import/import.js | 80 +++++++++++++++++++++++++++++++ client/components/lists/listHeader.jade | 9 ---- client/components/lists/listHeader.js | 39 --------------- 7 files changed, 93 insertions(+), 48 deletions(-) create mode 100644 client/components/boards/boardHeader.styl create mode 100644 client/components/import/import.jade create mode 100644 client/components/import/import.js (limited to 'client/components') 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; -- cgit v1.2.3-1-g7c22 From 595d5f97ac7b95ff71b391071d7d339e4ccbd4f6 Mon Sep 17 00:00:00 2001 From: Xavier Priour Date: Sat, 17 Oct 2015 19:29:25 +0200 Subject: Import board: now proper createdAt dates --- client/components/import/import.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/components') diff --git a/client/components/import/import.js b/client/components/import/import.js index f15185ed..a2972562 100644 --- a/client/components/import/import.js +++ b/client/components/import/import.js @@ -28,7 +28,7 @@ const ImportPopup = BlazeComponent.extendComponent({ this.setError(error.error); } else { Filter.addException(response); - Popup.close(); + this.onFinish(response); } } ); @@ -43,6 +43,10 @@ const ImportPopup = BlazeComponent.extendComponent({ setError(error) { this.error.set(error); }, + + onFinish() { + Popup.close(); + } }); ImportPopup.extendComponent({ @@ -76,5 +80,9 @@ ImportPopup.extendComponent({ getLabel() { return 'import-board-trello-instruction'; }, + + onFinish(response) { + Utils.goBoardId(response); + }, }).register('boardImportBoardPopup'); -- cgit v1.2.3-1-g7c22 From 4540bd36c4b07080ea5d29f0fb31bb20e637c2d5 Mon Sep 17 00:00:00 2001 From: Xavier Priour Date: Mon, 19 Oct 2015 00:59:50 +0200 Subject: Import board: import comments and log activities --- client/components/activities/activities.jade | 56 +++++++++++++++------------- client/components/activities/activities.js | 17 +++++++-- client/components/import/import.js | 2 +- 3 files changed, 46 insertions(+), 29 deletions(-) (limited to 'client/components') diff --git a/client/components/activities/activities.jade b/client/components/activities/activities.jade index c611ad75..28a9f9c9 100644 --- a/client/components/activities/activities.jade +++ b/client/components/activities/activities.jade @@ -14,41 +14,56 @@ template(name="boardActivities") p.activity-desc +memberName(user=user) - if($eq activityType 'createBoard') - | {{_ 'activity-created' boardLabel}}. + if($eq activityType 'addAttachment') + | {{{_ 'activity-attached' attachmentLink cardLink}}}. - if($eq activityType 'createList') - | {{_ 'activity-added' list.title boardLabel}}. + if($eq activityType 'addBoardMember') + | {{{_ 'activity-added' memberLink boardLabel}}}. + + if($eq activityType 'addComment') + | {{{_ 'activity-on' cardLink}}} + a.activity-comment(href="{{ card.absoluteUrl }}") + +viewer + = comment.text + + if($eq activityType 'archivedCard') + | {{{_ 'activity-archived' cardLink}}}. if($eq activityType 'archivedList') | {{_ 'activity-archived' list.title}}. + if($eq activityType 'createBoard') + | {{_ 'activity-created' boardLabel}}. + if($eq activityType 'createCard') | {{{_ 'activity-added' cardLink boardLabel}}}. + if($eq activityType 'createList') + | {{_ 'activity-added' list.title boardLabel}}. + + if($eq activityType 'importBoard') + | {{{_ 'activity-imported-board' boardLabel sourceLink}}}. + if($eq activityType 'importCard') | {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}. - if($eq activityType 'archivedCard') - | {{{_ 'activity-archived' cardLink}}}. + if($eq activityType 'importList') + | {{{_ 'activity-imported' listLabel boardLabel sourceLink}}}. - if($eq activityType 'restoredCard') - | {{{_ 'activity-sent' cardLink boardLabel}}}. + if($eq activityType 'joinMember') + if($eq currentUser._id member._id) + | {{{_ 'activity-joined' cardLink}}}. + else + | {{{_ 'activity-added' memberLink cardLink}}}. if($eq activityType 'moveCard') | {{{_ 'activity-moved' cardLink oldList.title list.title}}}. - if($eq activityType 'addBoardMember') - | {{{_ 'activity-added' memberLink boardLabel}}}. - if($eq activityType 'removeBoardMember') | {{{_ 'activity-excluded' memberLink boardLabel}}}. - if($eq activityType 'joinMember') - if($eq currentUser._id member._id) - | {{{_ 'activity-joined' cardLink}}}. - else - | {{{_ 'activity-added' memberLink cardLink}}}. + if($eq activityType 'restoredCard') + | {{{_ 'activity-sent' cardLink boardLabel}}}. if($eq activityType 'unjoinMember') if($eq currentUser._id member._id) @@ -56,15 +71,6 @@ template(name="boardActivities") else | {{{_ 'activity-removed' memberLink cardLink}}}. - if($eq activityType 'addComment') - | {{{_ 'activity-on' cardLink}}} - a.activity-comment(href="{{ card.absoluteUrl }}") - +viewer - = comment.text - - if($eq activityType 'addAttachment') - | {{{_ 'activity-attached' attachmentLink cardLink}}}. - span.activity-meta {{ moment createdAt }} template(name="cardActivities") diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index b80493f7..b25c0ca8 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -60,11 +60,22 @@ BlazeComponent.extendComponent({ }, card.title)); }, + listLabel() { + return this.currentData().list().title; + }, + sourceLink() { const source = this.currentData().source; - return source && Blaze.toHTML(HTML.A({ - href: source.url, - }, source.system)); + if(source) { + if(source.url) { + return Blaze.toHTML(HTML.A({ + href: source.url, + }, source.system)); + } else { + return source.system; + } + } + return null; }, memberLink() { diff --git a/client/components/import/import.js b/client/components/import/import.js index a2972562..00918aac 100644 --- a/client/components/import/import.js +++ b/client/components/import/import.js @@ -46,7 +46,7 @@ const ImportPopup = BlazeComponent.extendComponent({ onFinish() { Popup.close(); - } + }, }); ImportPopup.extendComponent({ -- cgit v1.2.3-1-g7c22 From 118b434a5aad35df8eefea85624ab9abafab56f0 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Tue, 20 Oct 2015 20:02:12 +0200 Subject: Provide a default date for lists and cards creation date See https://github.com/wekan/wekan/pull/362#issuecomment-149645497 for motivation. This commit also contains cosmetic changes to the import Popup and on the code style to be more consistent with the code base. --- client/components/boards/boardHeader.jade | 5 +++-- client/components/import/import.jade | 5 ++--- client/components/import/import.js | 28 +++++++++++++++------------- client/components/main/popup.styl | 6 +++--- 4 files changed, 23 insertions(+), 21 deletions(-) (limited to 'client/components') diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade index e460170b..cb86e9bb 100644 --- a/client/components/boards/boardHeader.jade +++ b/client/components/boards/boardHeader.jade @@ -107,8 +107,9 @@ template(name="createBoardPopup") | {{{_ 'board-private-info'}}} a.js-change-visibility {{_ 'change'}}. input.primary.wide(type="submit" value="{{_ 'create'}}") - | {{_ 'or'}} - a.js-import {{_ 'import-board'}} + span.quiet + | {{_ 'or'}} + a.js-import {{_ 'import-board'}} template(name="boardChangeTitlePopup") diff --git a/client/components/import/import.jade b/client/components/import/import.jade index 8059b65b..f63661af 100644 --- a/client/components/import/import.jade +++ b/client/components/import/import.jade @@ -2,7 +2,6 @@ template(name="importPopup") if error.get .warning {{_ error.get}} form - label - | {{_ getLabel}} - textarea.js-card-json(placeholder="{{_ 'import-json-placeholder'}}" autofocus) + p: label(for='import-textarea') {{_ getLabel}} + textarea#import-textarea.js-import-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 index 00918aac..c6957fa9 100644 --- a/client/components/import/import.js +++ b/client/components/import/import.js @@ -1,20 +1,21 @@ -/** - * 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. - */ +/// 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';}, + template() { + return 'importPopup'; + }, + events() { return [{ 'submit': (evt) => { evt.preventDefault(); - const dataJson = $(evt.currentTarget).find('textarea').val(); + const dataJson = $(evt.currentTarget).find('.js-import-json').val(); let dataObject; try { dataObject = JSON.parse(dataJson); @@ -52,7 +53,8 @@ const ImportPopup = BlazeComponent.extendComponent({ ImportPopup.extendComponent({ getAdditionalData() { const listId = this.data()._id; - const firstCardDom = $(`#js-list-${this.currentData()._id} .js-minicard:first`).get(0); + const selector = `#js-list-${this.currentData()._id} .js-minicard:first`; + const firstCardDom = $(selector).get(0); const sortIndex = Utils.calculateIndex(null, firstCardDom).base; const result = {listId, sortIndex}; return result; diff --git a/client/components/main/popup.styl b/client/components/main/popup.styl index 3bef4f7d..8a685069 100644 --- a/client/components/main/popup.styl +++ b/client/components/main/popup.styl @@ -17,9 +17,11 @@ $popupWidth = 300px margin: 4px -10px width: $popupWidth + p, + textarea, input[type="text"], input[type="email"], - input[type="password"] + input[type="password"], input[type="file"] margin: 4px 0 12px width: 100% @@ -30,8 +32,6 @@ $popupWidth = 300px textarea height: 72px - margin: 4px 0 12px - width: 100% .header height: 36px -- cgit v1.2.3-1-g7c22