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:
Martin Filser 2021-10-13 13:49:15 +02:00
parent cbc6463019
commit b9178cfcb6
12 changed files with 14 additions and 126 deletions

View file

@ -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;