summaryrefslogtreecommitdiffstats
path: root/client/components/boards/boardBody.js
diff options
context:
space:
mode:
author蔡仲明 (Romulus Urakagi Tsai) <urakagi@gmail.com>2019-11-21 11:25:56 +0800
committerGitHub <noreply@github.com>2019-11-21 11:25:56 +0800
commit3e0bedd8c7a6dec97352212adb1cbde1ade44190 (patch)
tree651ff30d25ddb0416444370368d699e597c142d7 /client/components/boards/boardBody.js
parent9bbeb73db1cd0ce1caaaca8dfb14ea92131bbf9d (diff)
parent4f5de87cc4c2281bd576548693de7c94e6a988c6 (diff)
downloadwekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.gz
wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.bz2
wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.zip
Merge pull request #1 from wekan/master
Update master
Diffstat (limited to 'client/components/boards/boardBody.js')
-rw-r--r--client/components/boards/boardBody.js141
1 files changed, 106 insertions, 35 deletions
diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js
index 6cff5ab1..41b6f4ef 100644
--- a/client/components/boards/boardBody.js
+++ b/client/components/boards/boardBody.js
@@ -89,7 +89,6 @@ BlazeComponent.extendComponent({
helper.append(list.clone());
return helper;
},
- handle: '.js-swimlane-header',
items: '.swimlane:not(.placeholder)',
placeholder: 'swimlane placeholder',
distance: 7,
@@ -193,11 +192,42 @@ BlazeComponent.extendComponent({
// ugly touch event hotfix
enableClickOnTouch('.js-swimlane:not(.placeholder)');
+ import { Cookies } from 'meteor/ostrio:cookies';
+ const cookies = new Cookies();
+
+ this.autorun(() => {
+ let showDesktopDragHandles = false;
+ currentUser = Meteor.user();
+ if (currentUser) {
+ showDesktopDragHandles = (currentUser.profile || {})
+ .showDesktopDragHandles;
+ } else if (cookies.has('showDesktopDragHandles')) {
+ showDesktopDragHandles = true;
+ } else {
+ showDesktopDragHandles = false;
+ }
+ if (
+ Utils.isMiniScreen()
+ || (!Utils.isMiniScreen() && showDesktopDragHandles)
+ ) {
+ $swimlanesDom.sortable({
+ handle: '.js-swimlane-header-handle',
+ });
+ } else {
+ $swimlanesDom.sortable({
+ handle: '.swimlane-header',
+ });
+ }
+
+ // Disable drag-dropping if the current user is not a board member or is comment only
+ $swimlanesDom.sortable('option', 'disabled', !userIsMember());
+ });
+
function userIsMember() {
return (
- Meteor.user() &&
- Meteor.user().isBoardMember() &&
- !Meteor.user().isCommentOnly()
+ Meteor.user()
+ && Meteor.user().isBoardMember()
+ && !Meteor.user().isCommentOnly()
);
}
@@ -210,21 +240,36 @@ BlazeComponent.extendComponent({
},
isViewSwimlanes() {
- const currentUser = Meteor.user();
- if (!currentUser) return false;
- return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
+ currentUser = Meteor.user();
+ if (currentUser) {
+ return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
+ } else {
+ import { Cookies } from 'meteor/ostrio:cookies';
+ const cookies = new Cookies();
+ return cookies.get('boardView') === 'board-view-swimlanes';
+ }
},
isViewLists() {
- const currentUser = Meteor.user();
- if (!currentUser) return true;
- return (currentUser.profile || {}).boardView === 'board-view-lists';
+ currentUser = Meteor.user();
+ if (currentUser) {
+ return (currentUser.profile || {}).boardView === 'board-view-lists';
+ } else {
+ import { Cookies } from 'meteor/ostrio:cookies';
+ const cookies = new Cookies();
+ return cookies.get('boardView') === 'board-view-lists';
+ }
},
isViewCalendar() {
- const currentUser = Meteor.user();
- if (!currentUser) return false;
- return (currentUser.profile || {}).boardView === 'board-view-cal';
+ currentUser = Meteor.user();
+ if (currentUser) {
+ return (currentUser.profile || {}).boardView === 'board-view-cal';
+ } else {
+ import { Cookies } from 'meteor/ostrio:cookies';
+ const cookies = new Cookies();
+ return cookies.get('boardView') === 'board-view-cal';
+ }
},
openNewListForm() {
@@ -261,16 +306,16 @@ BlazeComponent.extendComponent({
scrollLeft(position = 0) {
const swimlanes = this.$('.js-swimlanes');
- swimlanes &&
- swimlanes.animate({
+ swimlanes
+ && swimlanes.animate({
scrollLeft: position,
});
},
scrollTop(position = 0) {
const swimlanes = this.$('.js-swimlanes');
- swimlanes &&
- swimlanes.animate({
+ swimlanes
+ && swimlanes.animate({
scrollTop: position,
});
},
@@ -309,25 +354,46 @@ BlazeComponent.extendComponent({
events(start, end, timezone, callback) {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
const events = [];
+ const pushEvent = function(card, title, start, end, extraCls) {
+ start = start || card.startAt;
+ end = end || card.endAt;
+ title = title || card.title;
+ const className =
+ (extraCls ? `${extraCls} ` : '')
+ + (card.color ? `calendar-event-${card.color}` : '');
+ events.push({
+ id: card._id,
+ title,
+ start,
+ end: end || card.endAt,
+ allDay:
+ Math.abs(end.getTime() - start.getTime()) / 1000 === 24 * 3600,
+ url: FlowRouter.url('card', {
+ boardId: currentBoard._id,
+ slug: currentBoard.slug,
+ cardId: card._id,
+ }),
+ className,
+ });
+ };
currentBoard
.cardsInInterval(start.toDate(), end.toDate())
.forEach(function(card) {
- events.push({
- id: card._id,
- title: card.title,
- start: card.startAt,
- end: card.endAt,
- allDay:
- Math.abs(card.endAt.getTime() - card.startAt.getTime()) /
- 1000 ===
- 24 * 3600,
- url: FlowRouter.url('card', {
- boardId: currentBoard._id,
- slug: currentBoard.slug,
- cardId: card._id,
- }),
- });
+ pushEvent(card);
+ });
+ currentBoard
+ .cardsDueInBetween(start.toDate(), end.toDate())
+ .forEach(function(card) {
+ pushEvent(
+ card,
+ `${card.title} ${TAPi18n.__('card-due')}`,
+ card.dueAt,
+ new Date(card.dueAt.getTime() + 36e5),
+ );
});
+ events.sort(function(first, second) {
+ return first.id > second.id ? 1 : -1;
+ });
callback(events);
},
eventResize(event, delta, revertFunc) {
@@ -360,8 +426,13 @@ BlazeComponent.extendComponent({
};
},
isViewCalendar() {
- const currentUser = Meteor.user();
- if (!currentUser) return false;
- return (currentUser.profile || {}).boardView === 'board-view-cal';
+ currentUser = Meteor.user();
+ if (currentUser) {
+ return (currentUser.profile || {}).boardView === 'board-view-cal';
+ } else {
+ import { Cookies } from 'meteor/ostrio:cookies';
+ const cookies = new Cookies();
+ return cookies.get('boardView') === 'board-view-cal';
+ }
},
}).register('calendarView');