mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Merge pull request #3000 from NicoP-S/master
Trello vote import & hide export button if with_api is disabled
This commit is contained in:
commit
93eccffd44
5 changed files with 59 additions and 31 deletions
|
@ -33,22 +33,6 @@ Template.boardMenuPopup.events({
|
|||
'click .js-card-settings': Popup.open('boardCardSettings'),
|
||||
});
|
||||
|
||||
Template.boardMenuPopup.helpers({
|
||||
exportUrl() {
|
||||
const params = {
|
||||
boardId: Session.get('currentBoard'),
|
||||
};
|
||||
const queryParams = {
|
||||
authToken: Accounts._storedLoginToken(),
|
||||
};
|
||||
return FlowRouter.path('/api/boards/:boardId/export', params, queryParams);
|
||||
},
|
||||
exportFilename() {
|
||||
const boardId = Session.get('currentBoard');
|
||||
return `wekan-export-board-${boardId}.json`;
|
||||
},
|
||||
});
|
||||
|
||||
Template.boardChangeTitlePopup.events({
|
||||
submit(event, templateInstance) {
|
||||
const newTitle = templateInstance
|
||||
|
|
|
@ -298,10 +298,11 @@ template(name="boardMenuPopup")
|
|||
if currentUser.isBoardAdmin
|
||||
hr
|
||||
ul.pop-over-list
|
||||
li
|
||||
a(href="{{exportUrl}}", download="{{exportFilename}}")
|
||||
i.fa.fa-share-alt
|
||||
| {{_ 'export-board'}}
|
||||
if withApi
|
||||
li
|
||||
a(href="{{exportUrl}}", download="{{exportFilename}}")
|
||||
i.fa.fa-share-alt
|
||||
| {{_ 'export-board'}}
|
||||
li
|
||||
a.js-outgoing-webhooks
|
||||
i.fa.fa-globe
|
||||
|
@ -326,11 +327,12 @@ template(name="boardMenuPopup")
|
|||
if isSandstorm
|
||||
hr
|
||||
ul.pop-over-list
|
||||
li
|
||||
a(href="{{exportUrl}}", download="{{exportFilename}}")
|
||||
i.fa.fa-share-alt
|
||||
i.fa.fa-sign-out
|
||||
| {{_ 'export-board'}}
|
||||
if withApi
|
||||
li
|
||||
a(href="{{exportUrl}}", download="{{exportFilename}}")
|
||||
i.fa.fa-share-alt
|
||||
i.fa.fa-sign-out
|
||||
| {{_ 'export-board'}}
|
||||
li
|
||||
a.js-import-board
|
||||
i.fa.fa-share-alt
|
||||
|
|
|
@ -196,14 +196,14 @@ Template.boardMenuPopup.events({
|
|||
},
|
||||
'click .js-change-board-color': Popup.open('boardChangeColor'),
|
||||
'click .js-change-language': Popup.open('changeLanguage'),
|
||||
'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function() {
|
||||
'click .js-archive-board ': Popup.afterConfirm('archiveBoard', function () {
|
||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
currentBoard.archive();
|
||||
// XXX We should have some kind of notification on top of the page to
|
||||
// confirm that the board was successfully archived.
|
||||
FlowRouter.go('home');
|
||||
}),
|
||||
'click .js-delete-board': Popup.afterConfirm('deleteBoard', function() {
|
||||
'click .js-delete-board': Popup.afterConfirm('deleteBoard', function () {
|
||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
Popup.close();
|
||||
Boards.remove(currentBoard._id);
|
||||
|
@ -215,7 +215,18 @@ Template.boardMenuPopup.events({
|
|||
'click .js-card-settings': Popup.open('boardCardSettings'),
|
||||
});
|
||||
|
||||
|
||||
Template.boardMenuPopup.onCreated(function () {
|
||||
this.apiEnabled = new ReactiveVar(false);
|
||||
Meteor.call('_isApiEnabled', (e, result) => {
|
||||
this.apiEnabled.set(result)
|
||||
})
|
||||
})
|
||||
|
||||
Template.boardMenuPopup.helpers({
|
||||
withApi() {
|
||||
return Template.instance().apiEnabled.get()
|
||||
},
|
||||
exportUrl() {
|
||||
const params = {
|
||||
boardId: Session.get('currentBoard'),
|
||||
|
@ -237,7 +248,7 @@ Template.memberPopup.events({
|
|||
Popup.close();
|
||||
},
|
||||
'click .js-change-role': Popup.open('changePermissions'),
|
||||
'click .js-remove-member': Popup.afterConfirm('removeMember', function() {
|
||||
'click .js-remove-member': Popup.afterConfirm('removeMember', function () {
|
||||
const boardId = Session.get('currentBoard');
|
||||
const memberId = this.userId;
|
||||
Cards.find({ boardId, members: memberId }).forEach(card => {
|
||||
|
@ -578,7 +589,7 @@ BlazeComponent.extendComponent({
|
|||
'subtext-with-parent',
|
||||
'no-parent',
|
||||
];
|
||||
options.forEach(function(element) {
|
||||
options.forEach(function (element) {
|
||||
if (element !== value) {
|
||||
$(`#${element} ${MCB}`).toggleClass(CKCLS, false);
|
||||
$(`#${element}`).toggleClass(CKCLS, false);
|
||||
|
|
|
@ -198,6 +198,10 @@ if (Meteor.isServer) {
|
|||
return process.env.CAS_ENABLED === 'true';
|
||||
}
|
||||
|
||||
function isApiEnabled() {
|
||||
return process.env.WITH_API === 'true';
|
||||
}
|
||||
|
||||
Meteor.methods({
|
||||
sendInvitation(emails, boards) {
|
||||
check(emails, [String]);
|
||||
|
@ -314,6 +318,10 @@ if (Meteor.isServer) {
|
|||
return isCasEnabled();
|
||||
},
|
||||
|
||||
_isApiEnabled() {
|
||||
return isApiEnabled();
|
||||
},
|
||||
|
||||
// Gets all connection methods to use it in the Template
|
||||
getAuthenticationsEnabled() {
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const DateString = Match.Where(function(dateAsString) {
|
||||
const DateString = Match.Where(function (dateAsString) {
|
||||
check(dateAsString, String);
|
||||
return moment(dateAsString, moment.ISO_8601).isValid();
|
||||
});
|
||||
|
@ -285,6 +285,29 @@ export class TrelloCreator {
|
|||
cardToCreate.members = wekanMembers;
|
||||
}
|
||||
}
|
||||
// add vote
|
||||
if (card.idMembersVoted) {
|
||||
// Trello only know's positive votes
|
||||
const positiveVotes = [];
|
||||
card.idMembersVoted.forEach(trelloId => {
|
||||
if (this.members[trelloId]) {
|
||||
const wekanId = this.members[trelloId];
|
||||
// we may map multiple Trello members to the same wekan user
|
||||
// in which case we risk adding the same user multiple times
|
||||
if (!positiveVotes.find(wId => wId === wekanId)) {
|
||||
positiveVotes.push(wekanId);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
})
|
||||
if (positiveVotes.length > 0) {
|
||||
cardToCreate.vote = {
|
||||
question: cardToCreate.title,
|
||||
positive: positiveVotes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// insert card
|
||||
const cardId = Cards.direct.insert(cardToCreate);
|
||||
// keep track of Trello id => Wekan id
|
||||
|
@ -345,7 +368,7 @@ export class TrelloCreator {
|
|||
// so we make it server only, and let UI catch up once it is done, forget about latency comp.
|
||||
const self = this;
|
||||
if (Meteor.isServer) {
|
||||
file.attachData(att.url, function(error) {
|
||||
file.attachData(att.url, function (error) {
|
||||
file.boardId = boardId;
|
||||
file.cardId = cardId;
|
||||
file.userId = self._user(att.idMemberCreator);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue