mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +01:00
isMiniScreen and showDesktopDragHandles centralized in class Utils
- a lot of same code everywhere in many files, this is against the concept "don't repeat yourself"
This commit is contained in:
parent
cbc6463019
commit
b9178cfcb6
12 changed files with 14 additions and 126 deletions
|
|
@ -191,21 +191,11 @@ BlazeComponent.extendComponent({
|
|||
});
|
||||
|
||||
this.autorun(() => {
|
||||
let showDesktopDragHandles = false;
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
showDesktopDragHandles = (currentUser.profile || {})
|
||||
.showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
showDesktopDragHandles = true;
|
||||
} else {
|
||||
showDesktopDragHandles = false;
|
||||
}
|
||||
if (Utils.isMiniScreen() || showDesktopDragHandles) {
|
||||
if (Utils.isMiniScreenOrShowDesktopDragHandles()) {
|
||||
$swimlanesDom.sortable({
|
||||
handle: '.js-swimlane-header-handle',
|
||||
});
|
||||
} else if (!Utils.isMiniScreen() && !showDesktopDragHandles) {
|
||||
} else if (!Utils.isMiniScreen() && !Utils.isShowDesktopDragHandles()) {
|
||||
$swimlanesDom.sortable({
|
||||
handle: '.swimlane-header',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,11 +3,7 @@ template(name="minicard")
|
|||
class="{{#if isLinkedCard}}linked-card{{/if}}"
|
||||
class="{{#if isLinkedBoard}}linked-board{{/if}}"
|
||||
class="minicard-{{colorClass}}")
|
||||
if isMiniScreen
|
||||
.handle
|
||||
.fa.fa-arrows
|
||||
unless isMiniScreen
|
||||
if showDesktopDragHandles
|
||||
if isMiniScreenOrShowDesktopDragHandles
|
||||
.handle
|
||||
.fa.fa-arrows
|
||||
if cover
|
||||
|
|
|
|||
|
|
@ -75,16 +75,6 @@ BlazeComponent.extendComponent({
|
|||
}).register('minicard');
|
||||
|
||||
Template.minicard.helpers({
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
hiddenMinicardLabelText() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
|
|
|
|||
|
|
@ -117,22 +117,11 @@ BlazeComponent.extendComponent({
|
|||
});
|
||||
|
||||
this.autorun(() => {
|
||||
let showDesktopDragHandles = false;
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
showDesktopDragHandles = (currentUser.profile || {})
|
||||
.showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
showDesktopDragHandles = true;
|
||||
} else {
|
||||
showDesktopDragHandles = false;
|
||||
}
|
||||
|
||||
if (Utils.isMiniScreen() || showDesktopDragHandles) {
|
||||
if (Utils.isMiniScreenOrShowDesktopDragHandles()) {
|
||||
$cards.sortable({
|
||||
handle: '.handle',
|
||||
});
|
||||
} else if (!Utils.isMiniScreen() && !showDesktopDragHandles) {
|
||||
} else if (!Utils.isMiniScreen() && !Utils.isShowDesktopDragHandles()) {
|
||||
$cards.sortable({
|
||||
handle: '.minicard',
|
||||
});
|
||||
|
|
@ -178,19 +167,6 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
}).register('list');
|
||||
|
||||
Template.list.helpers({
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.miniList.events({
|
||||
'click .js-select-list'() {
|
||||
const listId = this._id;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ template(name="listHeader")
|
|||
a.js-add-card.fa.fa-plus.list-header-plus-icon(title="{{_ 'add-card-to-top-of-list'}}")
|
||||
a.fa.fa-navicon.js-open-list-menu(title="{{_ 'listActionPopup-title'}}")
|
||||
if currentUser.isBoardAdmin
|
||||
if showDesktopDragHandles
|
||||
if isShowDesktopDragHandles
|
||||
a.list-header-handle.handle.fa.fa-arrows.js-list-handle
|
||||
|
||||
template(name="editListTitleForm")
|
||||
|
|
|
|||
|
|
@ -122,18 +122,7 @@ BlazeComponent.extendComponent({
|
|||
Template.listHeader.helpers({
|
||||
isBoardAdmin() {
|
||||
return Meteor.user().isBoardAdmin();
|
||||
},
|
||||
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.listActionPopup.helpers({
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ template(name="swimlaneFixedHeader")
|
|||
a.fa.fa-plus.js-open-add-swimlane-menu.swimlane-header-plus-icon(title="{{_ 'add-swimlane'}}")
|
||||
a.fa.fa-navicon.js-open-swimlane-menu(title="{{_ 'swimlaneActionPopup-title'}}")
|
||||
unless isMiniScreen
|
||||
if showDesktopDragHandles
|
||||
if isShowDesktopDragHandles
|
||||
a.swimlane-header-handle.handle.fa.fa-arrows.js-swimlane-header-handle
|
||||
if isMiniScreen
|
||||
a.swimlane-header-miniscreen-handle.handle.fa.fa-arrows.js-swimlane-header-handle
|
||||
|
|
|
|||
|
|
@ -28,19 +28,6 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
}).register('swimlaneHeader');
|
||||
|
||||
Template.swimlaneHeader.helpers({
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.swimlaneFixedHeader.helpers({
|
||||
isBoardAdmin() {
|
||||
return Meteor.user().isBoardAdmin();
|
||||
|
|
|
|||
|
|
@ -95,22 +95,11 @@ function initSortable(boardComponent, $listsDom) {
|
|||
//}
|
||||
|
||||
boardComponent.autorun(() => {
|
||||
let showDesktopDragHandles = false;
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
showDesktopDragHandles = (currentUser.profile || {})
|
||||
.showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
showDesktopDragHandles = true;
|
||||
} else {
|
||||
showDesktopDragHandles = false;
|
||||
}
|
||||
|
||||
if (Utils.isMiniScreen() || showDesktopDragHandles) {
|
||||
if (Utils.isMiniScreenOrShowDesktopDragHandles) {
|
||||
$listsDom.sortable({
|
||||
handle: '.js-list-handle',
|
||||
});
|
||||
} else if (!Utils.isMiniScreen() && !showDesktopDragHandles) {
|
||||
} else if (!Utils.isMiniScreen() && !Utils.isShowDesktopDragHandles()) {
|
||||
$listsDom.sortable({
|
||||
handle: '.js-list-header',
|
||||
});
|
||||
|
|
@ -172,19 +161,8 @@ BlazeComponent.extendComponent({
|
|||
// the user will legitimately expect to be able to select some text with
|
||||
// his mouse.
|
||||
|
||||
let showDesktopDragHandles = false;
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
showDesktopDragHandles = (currentUser.profile || {})
|
||||
.showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
showDesktopDragHandles = true;
|
||||
} else {
|
||||
showDesktopDragHandles = false;
|
||||
}
|
||||
|
||||
const noDragInside = ['a', 'input', 'textarea', 'p'].concat(
|
||||
Utils.isMiniScreen() || showDesktopDragHandles
|
||||
Utils.isMiniScreenOrShowDesktopDragHandles()
|
||||
? ['.js-list-handle', '.js-swimlane-header-handle']
|
||||
: ['.js-list-header'],
|
||||
);
|
||||
|
|
@ -264,16 +242,6 @@ BlazeComponent.extendComponent({
|
|||
}).register('addListForm');
|
||||
|
||||
Template.swimlane.helpers({
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
canSeeAddList() {
|
||||
return Meteor.user().isBoardAdmin();
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ template(name="changeSettingsPopup")
|
|||
a.js-toggle-desktop-drag-handles
|
||||
i.fa.fa-arrows
|
||||
| {{_ 'show-desktop-drag-handles'}}
|
||||
if showDesktopDragHandles
|
||||
if isShowDesktopDragHandles
|
||||
i.fa.fa-check
|
||||
unless currentUser.isWorker
|
||||
li
|
||||
|
|
|
|||
|
|
@ -259,16 +259,6 @@ Template.changeLanguagePopup.events({
|
|||
});
|
||||
|
||||
Template.changeSettingsPopup.helpers({
|
||||
showDesktopDragHandles() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
hiddenSystemMessages() {
|
||||
currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ Utils = {
|
|||
const currentUser = Meteor.user();
|
||||
if (currentUser) {
|
||||
return (currentUser.profile || {}).showDesktopDragHandles;
|
||||
} else if (window.localStorage.getItem('showDesktopDragHandles')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue