Set card attachment as background image. Part 2.

Thanks to xet7 !

Related #486
This commit is contained in:
Lauri Ojansivu 2023-06-03 12:43:10 -04:00
parent e892a6104a
commit ed92db87bc
4 changed files with 49 additions and 7 deletions

View file

@ -175,6 +175,10 @@ BlazeComponent.extendComponent({
const ret = Cards.findOne(this.data().meta.cardId).coverId == this.data()._id;
return ret;
},
isBackgroundImage() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
return currentBoard.backgroundImageURL === $(".attachment-thumbnail-img").attr("src");
},
events() {
return [
{
@ -191,6 +195,20 @@ BlazeComponent.extendComponent({
Cards.findOne(this.data().meta.cardId).unsetCover();
Popup.back();
},
'click .js-add-background-image'() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
currentBoard.setBackgroundImageURL($(".attachment-thumbnail-img").attr("src"));
Utils.setBackgroundImage();
Popup.back();
event.preventDefault();
},
'click .js-remove-background-image'() {
const currentBoard = Boards.findOne(Session.get('currentBoard'));
currentBoard.setBackgroundImageURL("");
Utils.setBackgroundImage();
Popup.back();
Utils.reload();
},
'click .js-move-storage-fs'() {
Meteor.call('moveAttachmentToStorage', this.data()._id, "fs");
Popup.back();