mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Move and Copy Card Popup remembers the last confirmed field values
This commit is contained in:
parent
73ff4c7966
commit
e528474fc5
3 changed files with 125 additions and 8 deletions
|
|
@ -725,17 +725,17 @@ template(name="boardsAndLists")
|
||||||
if $eq _id currentBoard._id
|
if $eq _id currentBoard._id
|
||||||
option(value="{{_id}}" selected) {{_ 'current'}}
|
option(value="{{_id}}" selected) {{_ 'current'}}
|
||||||
else
|
else
|
||||||
option(value="{{_id}}") {{title}}
|
option(value="{{_id}}" selected="{{#if isMoveAndCopyDialogOptionBoardId _id}}selected{{/if}}") {{title}}
|
||||||
|
|
||||||
label {{_ 'swimlanes'}}:
|
label {{_ 'swimlanes'}}:
|
||||||
select.js-select-swimlanes
|
select.js-select-swimlanes
|
||||||
each swimlanes
|
each swimlanes
|
||||||
option(value="{{_id}}") {{title}}
|
option(value="{{_id}}" selected="{{#if isMoveAndCopyDialogOptionSwimlaneId _id}}selected{{/if}}") {{title}}
|
||||||
|
|
||||||
label {{_ 'lists'}}:
|
label {{_ 'lists'}}:
|
||||||
select.js-select-lists
|
select.js-select-lists
|
||||||
each aBoardLists
|
each aBoardLists
|
||||||
option(value="{{_id}}") {{title}}
|
option(value="{{_id}}" selected="{{#if isMoveAndCopyDialogOptionListId _id}}selected{{/if}}") {{title}}
|
||||||
|
|
||||||
.edit-controls.clearfix
|
.edit-controls.clearfix
|
||||||
button.primary.confirm.js-done {{_ 'done'}}
|
button.primary.confirm.js-done {{_ 'done'}}
|
||||||
|
|
|
||||||
|
|
@ -806,8 +806,11 @@ Template.moveCardPopup.events({
|
||||||
let boardId;
|
let boardId;
|
||||||
// if we are a worker, we won't have a board select so we just use the
|
// if we are a worker, we won't have a board select so we just use the
|
||||||
// current boardId of the card.
|
// current boardId of the card.
|
||||||
if (bSelect) boardId = bSelect.options[bSelect.selectedIndex].value;
|
if (bSelect) {
|
||||||
else boardId = card.boardId;
|
boardId = bSelect.options[bSelect.selectedIndex].value;
|
||||||
|
} else {
|
||||||
|
boardId = card.boardId;
|
||||||
|
}
|
||||||
const lSelect = $('.js-select-lists')[0];
|
const lSelect = $('.js-select-lists')[0];
|
||||||
const listId = lSelect.options[lSelect.selectedIndex].value;
|
const listId = lSelect.options[lSelect.selectedIndex].value;
|
||||||
const slSelect = $('.js-select-swimlanes')[0];
|
const slSelect = $('.js-select-swimlanes')[0];
|
||||||
|
|
@ -824,8 +827,53 @@ Template.moveCardPopup.events({
|
||||||
});
|
});
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {
|
onCreated() {
|
||||||
subManager.subscribe('board', Session.get('currentBoard'), false);
|
const boardId = Utils.getCurrentBoardId();
|
||||||
this.selectedBoardId = new ReactiveVar(Session.get('currentBoard'));
|
subManager.subscribe('board', boardId, false);
|
||||||
|
this.selectedBoardId = new ReactiveVar(boardId);
|
||||||
|
this.setMoveAndCopyDialogOption(boardId);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** set the last confirmed dialog field values
|
||||||
|
* @param boardId the current board id
|
||||||
|
*/
|
||||||
|
setMoveAndCopyDialogOption(boardId) {
|
||||||
|
this.moveAndCopyDialogOption = {
|
||||||
|
'boardId' : "",
|
||||||
|
'swimlaneId' : "",
|
||||||
|
'listId' : "",
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentOptions = Meteor.user().getMoveAndCopyDialogOptions();
|
||||||
|
if (currentOptions && boardId && currentOptions[boardId]) {
|
||||||
|
this.moveAndCopyDialogOption = currentOptions[boardId];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** returns if the board id was the last confirmed one
|
||||||
|
* @param boardId check this board id
|
||||||
|
* @return if the board id was the last confirmed one
|
||||||
|
*/
|
||||||
|
isMoveAndCopyDialogOptionBoardId(boardId) {
|
||||||
|
let ret = this.moveAndCopyDialogOption.boardId == boardId;
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** returns if the swimlane id was the last confirmed one
|
||||||
|
* @param swimlaneId check this swimlane id
|
||||||
|
* @return if the swimlane id was the last confirmed one
|
||||||
|
*/
|
||||||
|
isMoveAndCopyDialogOptionSwimlaneId(swimlaneId) {
|
||||||
|
let ret = this.moveAndCopyDialogOption.swimlaneId == swimlaneId;
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** returns if the list id was the last confirmed one
|
||||||
|
* @param listId check this list id
|
||||||
|
* @return if the list id was the last confirmed one
|
||||||
|
*/
|
||||||
|
isMoveAndCopyDialogOptionListId(listId) {
|
||||||
|
let ret = this.moveAndCopyDialogOption.listId == listId;
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
boards() {
|
boards() {
|
||||||
|
|
@ -854,8 +902,27 @@ BlazeComponent.extendComponent({
|
||||||
events() {
|
events() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
'click .js-done'() {
|
||||||
|
const bSelect = this.$('.js-select-boards')[0];
|
||||||
|
const boardId = bSelect.options[bSelect.selectedIndex].value;
|
||||||
|
|
||||||
|
const lSelect = this.$('.js-select-lists')[0];
|
||||||
|
const listId = lSelect.options[lSelect.selectedIndex].value;
|
||||||
|
|
||||||
|
const slSelect = this.$('.js-select-swimlanes')[0];
|
||||||
|
const swimlaneId = slSelect.options[slSelect.selectedIndex].value;
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
'boardId' : boardId,
|
||||||
|
'swimlaneId' : swimlaneId,
|
||||||
|
'listId' : listId,
|
||||||
|
}
|
||||||
|
Meteor.user().setMoveAndCopyDialogOption(boardId, options);
|
||||||
|
},
|
||||||
'change .js-select-boards'(event) {
|
'change .js-select-boards'(event) {
|
||||||
this.selectedBoardId.set($(event.currentTarget).val());
|
const boardId = $(event.currentTarget).val();
|
||||||
|
this.selectedBoardId.set(boardId);
|
||||||
|
this.setMoveAndCopyDialogOption(boardId);
|
||||||
subManager.subscribe('board', this.selectedBoardId.get(), false);
|
subManager.subscribe('board', this.selectedBoardId.get(), false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,32 @@ Users.attachSchema(
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
'profile.moveAndCopyDialog' : {
|
||||||
|
/**
|
||||||
|
* move and copy card dialog
|
||||||
|
*/
|
||||||
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
blackbox: true,
|
||||||
|
},
|
||||||
|
'profile.moveAndCopyDialog.$.boardId': {
|
||||||
|
/**
|
||||||
|
* last selected board id
|
||||||
|
*/
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
'profile.moveAndCopyDialog.$.swimlaneId': {
|
||||||
|
/**
|
||||||
|
* last selected swimlane id
|
||||||
|
*/
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
'profile.moveAndCopyDialog.$.listId': {
|
||||||
|
/**
|
||||||
|
* last selected list id
|
||||||
|
*/
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
'profile.notifications': {
|
'profile.notifications': {
|
||||||
/**
|
/**
|
||||||
* enabled notifications for the user
|
* enabled notifications for the user
|
||||||
|
|
@ -616,6 +642,17 @@ Users.helpers({
|
||||||
return this._getListSortBy()[1];
|
return this._getListSortBy()[1];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** returns all confirmed move and copy dialog field values
|
||||||
|
* <li> the board, swimlane and list id is stored for each board
|
||||||
|
*/
|
||||||
|
getMoveAndCopyDialogOptions() {
|
||||||
|
let _ret = {}
|
||||||
|
if (this.profile && this.profile.moveAndCopyDialog) {
|
||||||
|
_ret = this.profile.moveAndCopyDialog;
|
||||||
|
}
|
||||||
|
return _ret;
|
||||||
|
},
|
||||||
|
|
||||||
hasTag(tag) {
|
hasTag(tag) {
|
||||||
const { tags = [] } = this.profile || {};
|
const { tags = [] } = this.profile || {};
|
||||||
return _.contains(tags, tag);
|
return _.contains(tags, tag);
|
||||||
|
|
@ -731,6 +768,19 @@ Users.helpers({
|
||||||
});
|
});
|
||||||
|
|
||||||
Users.mutations({
|
Users.mutations({
|
||||||
|
/** set the confirmed board id/swimlane id/list id of a board
|
||||||
|
* @param boardId the current board id
|
||||||
|
* @param options an object with the confirmed field values
|
||||||
|
*/
|
||||||
|
setMoveAndCopyDialogOption(boardId, options) {
|
||||||
|
let currentOptions = this.getMoveAndCopyDialogOptions();
|
||||||
|
currentOptions[boardId] = options;
|
||||||
|
return {
|
||||||
|
$set: {
|
||||||
|
'profile.moveAndCopyDialog': currentOptions,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
toggleBoardStar(boardId) {
|
toggleBoardStar(boardId) {
|
||||||
const queryKind = this.hasStarred(boardId) ? '$pull' : '$addToSet';
|
const queryKind = this.hasStarred(boardId) ? '$pull' : '$addToSet';
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue