Commit a3f02f4a authored by Klaus-Dieter Quibeldey-Cirkel's avatar Klaus-Dieter Quibeldey-Cirkel 🏀

Merge branch...

Merge branch '1388-please-set-the-editor-settings-vertically-centered-and-left-justified-as-default-for-all-card-types' into 'staging'

Resolve "Please set the editor settings "vertically centered" and "left justified" as default for all card-types."

Closes #1388

See merge request arsnova/flashcards!1653
parents d1e6bb32 bb96c0e9
...@@ -27,6 +27,13 @@ let cardTypesWithNotesForDifficultyLevel = [2]; ...@@ -27,6 +27,13 @@ let cardTypesWithNotesForDifficultyLevel = [2];
let cardTypesWithCardsetTitleNavigation = [14]; let cardTypesWithCardsetTitleNavigation = [14];
let cardTypesOrder = [{cardType: 2}, {cardType: 0}, {cardType: 15}, {cardType: 3}, {cardType: 6}, {cardType: 13}, {cardType: 12}, {cardType: 11}, {cardType: 5}, {cardType: 1}, {cardType: 10}, {cardType: 7}, {cardType: 4}, {cardType: 8}, {cardType: 9}, {cardType: 14}]; let cardTypesOrder = [{cardType: 2}, {cardType: 0}, {cardType: 15}, {cardType: 3}, {cardType: 6}, {cardType: 13}, {cardType: 12}, {cardType: 11}, {cardType: 5}, {cardType: 1}, {cardType: 10}, {cardType: 7}, {cardType: 4}, {cardType: 8}, {cardType: 9}, {cardType: 14}];
//0: left
//1: center
//2: right
//3: justify
let defaultTextAlign = 0;
let defaultCentered = true;
let cardTypeCubeSides = [ let cardTypeCubeSides = [
//0: Lernkartei / Flashcard //0: Lernkartei / Flashcard
[ [
...@@ -34,21 +41,18 @@ let cardTypeCubeSides = [ ...@@ -34,21 +41,18 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"gotLearningGoalPlaceholder": true "gotLearningGoalPlaceholder": true
}, },
{ {
"contentId": 4, "contentId": 4,
"side": "right", "side": "right",
"defaultStyle": "lecture", "defaultStyle": "lecture",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -56,7 +60,6 @@ let cardTypeCubeSides = [ ...@@ -56,7 +60,6 @@ let cardTypeCubeSides = [
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
...@@ -67,13 +70,13 @@ let cardTypeCubeSides = [ ...@@ -67,13 +70,13 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": true "defaultTextAlign": "center"
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": true, "defaultTextAlign": "center",
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
} }
...@@ -83,20 +86,17 @@ let cardTypeCubeSides = [ ...@@ -83,20 +86,17 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
} }
], ],
//3: Glossar / Glossary //3: Glossar / Glossary
...@@ -105,13 +105,13 @@ let cardTypeCubeSides = [ ...@@ -105,13 +105,13 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false "defaultTextAlign": "center"
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false, "defaultTextAlign": "center",
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -119,7 +119,6 @@ let cardTypeCubeSides = [ ...@@ -119,7 +119,6 @@ let cardTypeCubeSides = [
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
], ],
...@@ -128,14 +127,12 @@ let cardTypeCubeSides = [ ...@@ -128,14 +127,12 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -143,7 +140,6 @@ let cardTypeCubeSides = [ ...@@ -143,7 +140,6 @@ let cardTypeCubeSides = [
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
], ],
...@@ -153,14 +149,12 @@ let cardTypeCubeSides = [ ...@@ -153,14 +149,12 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"gotLearningGoalPlaceholder": true "gotLearningGoalPlaceholder": true
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -168,7 +162,6 @@ let cardTypeCubeSides = [ ...@@ -168,7 +162,6 @@ let cardTypeCubeSides = [
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
], ],
...@@ -177,14 +170,13 @@ let cardTypeCubeSides = [ ...@@ -177,14 +170,13 @@ let cardTypeCubeSides = [
{ {
"contentId": 2, "contentId": 2,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 1, "contentId": 1,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false, "defaultTextAlign": "center",
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -192,7 +184,6 @@ let cardTypeCubeSides = [ ...@@ -192,7 +184,6 @@ let cardTypeCubeSides = [
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
], ],
...@@ -201,20 +192,17 @@ let cardTypeCubeSides = [ ...@@ -201,20 +192,17 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
} }
], ],
//8: Notizen / Notes //8: Notizen / Notes
...@@ -222,8 +210,7 @@ let cardTypeCubeSides = [ ...@@ -222,8 +210,7 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "post-it", "defaultStyle": "post-it"
"defaultCentered": false
} }
], ],
//9: To-dos / To-do //9: To-dos / To-do
...@@ -231,8 +218,7 @@ let cardTypeCubeSides = [ ...@@ -231,8 +218,7 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "pink", "defaultStyle": "pink"
"defaultCentered": false
} }
], ],
//10: Fotokartei / Photo library //10: Fotokartei / Photo library
...@@ -240,14 +226,12 @@ let cardTypeCubeSides = [ ...@@ -240,14 +226,12 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "white", "defaultStyle": "white"
"defaultCentered": false
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "white", "defaultStyle": "white"
"defaultCentered": false
} }
], ],
//11: Quiz //11: Quiz
...@@ -255,14 +239,12 @@ let cardTypeCubeSides = [ ...@@ -255,14 +239,12 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": true
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": true,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
} }
...@@ -272,26 +254,22 @@ let cardTypeCubeSides = [ ...@@ -272,26 +254,22 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 3, "contentId": 3,
"side": "right", "side": "right",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 4, "contentId": 4,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default"
"defaultCentered": false
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -299,14 +277,12 @@ let cardTypeCubeSides = [ ...@@ -299,14 +277,12 @@ let cardTypeCubeSides = [
"contentId": 5, "contentId": 5,
"side": "top", "side": "top",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
}, },
{ {
"contentId": 6, "contentId": 6,
"side": "bottom", "side": "bottom",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
], ],
...@@ -316,21 +292,18 @@ let cardTypeCubeSides = [ ...@@ -316,21 +292,18 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"gotLearningGoalPlaceholder": true "gotLearningGoalPlaceholder": true
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
}, },
{ {
"contentId": 3, "contentId": 3,
"side": "left", "side": "left",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
}, },
...@@ -338,7 +311,6 @@ let cardTypeCubeSides = [ ...@@ -338,7 +311,6 @@ let cardTypeCubeSides = [
"contentId": 4, "contentId": 4,
"side": "right", "side": "right",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true "isAnswer": true
} }
...@@ -348,8 +320,7 @@ let cardTypeCubeSides = [ ...@@ -348,8 +320,7 @@ let cardTypeCubeSides = [
{ {
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "white", "defaultStyle": "white"
"defaultCentered": false
} }
], ],
...@@ -359,14 +330,12 @@ let cardTypeCubeSides = [ ...@@ -359,14 +330,12 @@ let cardTypeCubeSides = [
"contentId": 1, "contentId": 1,
"side": "front", "side": "front",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"gotLearningGoalPlaceholder": true "gotLearningGoalPlaceholder": true
}, },
{ {
"contentId": 2, "contentId": 2,
"side": "back", "side": "back",
"defaultStyle": "default", "defaultStyle": "default",
"defaultCentered": false,
"isAnswer": true, "isAnswer": true,
"isAnswerFocus": true "isAnswerFocus": true
} }
...@@ -466,19 +435,49 @@ export let CardType = class CardType { ...@@ -466,19 +435,49 @@ export let CardType = class CardType {
return cardTypesWithDictionary.includes(cardType); return cardTypesWithDictionary.includes(cardType);
} }
static setDefaultCenteredText (cardType) { static setDefaultCenteredText (cardType, returnValue = undefined) {
let centerTextElement = [false, false, false, false, false, false]; let centerTextElement = Array(6).fill(defaultCentered);
let alignType = [1, 1, 1, 1, 1, 1]; let textAlignType = Array(6).fill(defaultTextAlign);
let cubeSides = this.getCardTypeCubeSides(cardType); let cubeSides = this.getCardTypeCubeSides(cardType);
for (let i = 0; i < centerTextElement.length; i++) { for (let i = 0; i < centerTextElement.length; i++) {
for (let l = 0; l < cubeSides.length; l++) { for (let l = 0; l < cubeSides.length; l++) {
if (cubeSides[l].contentId === (i + 1)) { if (cubeSides[l].contentId === (i + 1)) {
centerTextElement[i] = cubeSides[l].defaultCentered; if (cubeSides[l].defaultCentered !== undefined) {
centerTextElement[i] = cubeSides[l].defaultCentered;
}
if (cubeSides[l].defaultTextAlign !== undefined) {
switch (cubeSides[l].defaultTextAlign) {
case "left":
textAlignType[i] = 0;
break;
case "center":
textAlignType[i] = 1;
break;
case "right":
textAlignType[i] = 2;
break;
case "justify":
textAlignType[i] = 3;
break;
case "default":
textAlignType[i] = defaultTextAlign;
break;
}
}
} }
} }
} }
Session.set('centerTextElement', centerTextElement); if (returnValue !== undefined) {
Session.set('alignType', alignType); switch (returnValue) {
case 1:
return centerTextElement;
case 2:
return textAlignType;
}
} else {
Session.set('centerTextElement', centerTextElement);
Session.set('alignType', textAlignType);
}
} }
static getSubjectPlaceholderText (cardType = -1) { static getSubjectPlaceholderText (cardType = -1) {
......
...@@ -348,37 +348,37 @@ Meteor.startup(function () { ...@@ -348,37 +348,37 @@ Meteor.startup(function () {
cards = Cards.find({centerTextElement: {$exists: false}}).fetch(); cards = Cards.find({centerTextElement: {$exists: false}}).fetch();
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
let centerTextElement; let cardset = Cardsets.findOne({_id: cards[i].cardset_id}, {fields: {_id: 1, cardType: 1}});
if (Cardsets.findOne({_id: cards[i].cardset_id}).cardType === 2) { if (cardset !== undefined) {
centerTextElement = [true, true, false, false, false, false]; Cards.update({
} else { _id: cards[i]._id
centerTextElement = [false, false, false, false, false, false];
}
Cards.update({
_id: cards[i]._id
},
{
$set: {
centerTextElement: centerTextElement
}, },
$unset: { {
centerText: 1 $set: {
centerTextElement: CardType.setDefaultCenteredText(cardset.cardType, 1)
},
$unset: {
centerText: 1
}
} }
} );
); }
} }
cards = Cards.find({alignType: {$exists: false}}).fetch(); cards = Cards.find({alignType: {$exists: false}}).fetch();
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
Cards.update({ let cardset = Cardsets.findOne({_id: cards[i].cardset_id}, {fields: {_id: 1, cardType: 1}});
_id: cards[i]._id if (cardset !== undefined) {
}, Cards.update({
{ _id: cards[i]._id
$set: { },
alignType: [1, 1, 1, 1, 1, 1] {
$set: {
alignType: CardType.setDefaultCenteredText(cardset.cardType, 2)
}
} }
} );
); }
} }
cards = Cards.find({date: {$exists: false}}).fetch(); cards = Cards.find({date: {$exists: false}}).fetch();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment