Skip to content

Commit

Permalink
added tag 'release-beta-2024-01-26-12.11/+0100' for beta version in f…
Browse files Browse the repository at this point in the history
…older beta.
  • Loading branch information
klues committed Jan 26, 2024
1 parent 28cc23f commit bcbc5b2
Show file tree
Hide file tree
Showing 27 changed files with 754 additions and 26 deletions.
2 changes: 1 addition & 1 deletion latest/app/build/asterics-grid.bundle.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions latest/app/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ nav #helpButton:focus {
font-weight: bold;
}

.multiselect__tag {
color: black !important;
}

@media (max-height: 355px) {
#syncVisualization {
display: none;
Expand Down
26 changes: 24 additions & 2 deletions latest/app/lang/i18n.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"GridActionSpeak": "Speak label",
"GridActionSpeakCustom": "Speak custom text",
"GridActionAudio": "Play recorded audio",
"GridActionWordForm": "Change word forms",
"GridActionNavigate": "Navigate to other grid",
"GridActionARE": "AsTeRICS action",
"GridActionOpenHAB": "OpenHAB action",
Expand Down Expand Up @@ -728,6 +729,7 @@
"convertUppercaseKeyboardLettersToLowercase": "Convert uppercase keyboard letters to lowercase",
"TAB_GENERAL": "General",
"TAB_IMAGE": "Image",
"TAB_WORDFORMS": "Word forms",
"TAB_ACTIONS": "Actions",
"colorCategory": "Color category",
"colors": "Colors",
Expand Down Expand Up @@ -954,6 +956,26 @@
"searchForCustomText": "Search for custom text",
"customText": "Custom text",
"searchForCollectedText": "Search for collected text",
"infoPleaseDefineAHomeGridInManageGrids": "Info: please define a home grid in \"Manage grids -> Home grid\" in order to reliably showing correct paths.",
"dontAddElementToCollectElement": "Don't add element to collect element"
"dontAddElementToCollectElement": "Don't add element to collect element",
"addWordForm": "Add word form",
"importExport": "Import / Export",
"importFromClipboard": "Import from clipboard",
"copyToClipboard": "Copy to clipboard",
"currentWordForms": "Current word forms",
"noWordFormsDefined": "(no word forms defined)",
"moveUp": "Move up",
"moveDown": "Move down",
"overrideExistingWordForms": "Override existing word forms",
"doYouReallyWantDeleteExistingWordForms": "Do you really want to delete all existing word forms and replace them by the content of the clipboard?",
"clipboardContainsNoWordFormsPleaseCopyFrom": "Clipboard contains no word forms, please copy from any spreadsheet with 1-3 columns: (1) value, e.g. \"are\", (2) optional language code, e.g. \"EN\", (3) optional word form tags, e.g. \"1.PERS, PLURAL\".",
"actionType": "Action type",
"tags": "Tags",
"WORDFORM_MODE_CHANGE_ELEMENTS": "Change word form in grid elements",
"WORDFORM_MODE_CHANGE_BAR": "Change word form in collection element",
"WORDFORM_MODE_CHANGE_EVERYWHERE": "Change word form everywhere",
"WORDFORM_MODE_NEXT_FORM": "Change this element to next word form",
"WORDFORM_MODE_RESET_FORMS": "Reset currently displayed word forms",
"toggleTagOnSelectingItMultipleTimes": "Toggle tags on selecting it multiple times",
"successfullyImportedWordForms": "Successfully imported {count} word forms.",
"infoPleaseDefineAHomeGridInManageGrids": "Info: please define a home grid in \"Manage grids -> Home grid\" in order to reliably showing correct paths."
}
3 changes: 2 additions & 1 deletion latest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"predictionary": "^1.6.0",
"superlogin-client": "^0.8.0",
"vue": "^2.7.0",
"vue-i18n": "8"
"vue-i18n": "8",
"vue-multiselect": "^2.1.8"
},
"devDependencies": {
"@babel/core": "^7.21.8",
Expand Down
2 changes: 1 addition & 1 deletion latest/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ self.addEventListener('install', (event) => {
self.addEventListener('activate', event => {
clients.claim();
sendToClients({type: constants.SW_EVENT_ACTIVATED, activated: true});
console.log('Service Worker active! Version: https://github.com/asterics/AsTeRICS-Grid/releases/tag/release-2024-01-26-12.08/+0100');
console.log('Service Worker active! Version: https://github.com/asterics/AsTeRICS-Grid/releases/tag/release-beta-2024-01-26-12.11/+0100');
});

self.addEventListener('message', (event) => {
Expand Down
5 changes: 5 additions & 0 deletions latest/src/css/modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,9 @@ font-weight: bold;
.modal .warn {
font-weight: bold;
color: #c96a00;
}

.modal .success {
font-weight: bold;
color: darkgreen;
}
3 changes: 2 additions & 1 deletion latest/src/js/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { collectElementService } from "./service/collectElementService";
import { UndoService } from "./service/data/undoService";
import { GridData } from "./model/GridData";
import { templates } from "./templates";
import { imageUtil } from "./util/imageUtil";
import { fontUtil } from "./util/fontUtil";
import { predictionService } from "./service/predictionService";
import { constants } from "./util/constants";
import { gridUtil } from "./util/gridUtil";
import { GridElement } from "./model/GridElement.js";
import { GridActionNavigate } from "./model/GridActionNavigate.js";
import {stateService} from "./service/stateService.js";

function Grid(gridContainerId, gridItemClass, options) {
var thiz = this;
Expand Down Expand Up @@ -75,6 +75,7 @@ function Grid(gridContainerId, gridItemClass, options) {
//only add global grid if not in edit mode
promises.push(
dataService.getGlobalGrid().then((globalGrid) => {
stateService.setGlobalGrid(globalGrid);
if (globalGrid) {
let autowidth = true;
let heightPercentage = options.globalGridHeightPercentage
Expand Down
46 changes: 46 additions & 0 deletions latest/src/js/model/GridActionWordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { modelUtil } from '../util/modelUtil';
import { constants } from '../util/constants';
import { Model } from '../externals/objectmodel';

class GridActionWordForm extends Model({
id: String,
modelName: String,
modelVersion: String,
type: [String],
tags: [Model.Array(String)],
toggle: [Boolean]
}) {
constructor(properties, elementToCopy) {
properties = modelUtil.setDefaults(properties, elementToCopy, GridActionWordForm);
super(properties);
this.id = this.id || modelUtil.generateId('grid-action-word-form');
}

static getModelName() {
return 'GridActionWordForm';
}
}

GridActionWordForm.WORDFORM_MODE_CHANGE_ELEMENTS = "WORDFORM_MODE_CHANGE_ELEMENTS";
GridActionWordForm.WORDFORM_MODE_CHANGE_BAR = "WORDFORM_MODE_CHANGE_BAR";
GridActionWordForm.WORDFORM_MODE_CHANGE_EVERYWHERE = "WORDFORM_MODE_CHANGE_EVERYWHERE";
GridActionWordForm.WORDFORM_MODE_NEXT_FORM = 'WORDFORM_MODE_NEXT_FORM';
GridActionWordForm.WORDFORM_MODE_RESET_FORMS = 'WORDFORM_MODE_RESET_FORMS';

GridActionWordForm.MODES = [
GridActionWordForm.WORDFORM_MODE_CHANGE_ELEMENTS,
GridActionWordForm.WORDFORM_MODE_CHANGE_BAR,
GridActionWordForm.WORDFORM_MODE_CHANGE_EVERYWHERE,
GridActionWordForm.WORDFORM_MODE_NEXT_FORM,
GridActionWordForm.WORDFORM_MODE_RESET_FORMS
];

GridActionWordForm.defaults({
id: '', //will be replaced by constructor
modelName: GridActionWordForm.getModelName(),
modelVersion: constants.MODEL_VERSION,
type: GridActionWordForm.WORDFORM_MODE_CHANGE_ELEMENTS,
tags: []
});

export { GridActionWordForm };
9 changes: 7 additions & 2 deletions latest/src/js/model/GridElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { GridActionChangeLang } from './GridActionChangeLang';
import { GridActionYoutube } from './GridActionYoutube';
import { GridActionOpenWebpage } from './GridActionOpenWebpage.js';
import { GridActionAudio } from './GridActionAudio.js';
import {WordForm} from "./WordForm.js";
import {GridActionWordForm} from "./GridActionWordForm.js";

class GridElement extends Model({
id: String,
Expand All @@ -25,6 +27,7 @@ class GridElement extends Model({
x: [Number],
y: [Number],
label: [Object, String, undefined], //map locale -> translation, e.g. "de" => LabelDE
wordForms: [Model.Array(WordForm)],
backgroundColor: [String],
colorCategory: [String],
hidden: [Boolean],
Expand All @@ -48,6 +51,7 @@ class GridElement extends Model({
};
properties = modelUtil.setDefaults(properties, elementToCopy, GridElement) || {};
properties.actions = properties.actions || [new GridActionSpeak()];
properties.wordForms = properties.wordForms || [];
super(Object.assign(defaults, properties));
this.id = this.id || modelUtil.generateId('grid-element');
}
Expand All @@ -58,8 +62,8 @@ class GridElement extends Model({
return newElem;
}

toHTML(metadata, locale) {
return templates.getGridItem(this, locale, metadata);
toHTML(metadata) {
return templates.getGridItem(this, metadata);
}

hasSetPosition() {
Expand All @@ -81,6 +85,7 @@ class GridElement extends Model({
GridActionNavigate,
GridActionSpeakCustom,
GridActionAudio,
GridActionWordForm,
GridActionPredict,
GridActionCollectElement,
GridActionARE,
Expand Down
14 changes: 14 additions & 0 deletions latest/src/js/model/WordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Model } from '../externals/objectmodel';

class WordForm extends Model({
lang: [String],
tags: [Model.Array(String)],
value: [String]
}) {}

WordForm.defaults({
tags: [],
value: ''
});

export { WordForm };
44 changes: 40 additions & 4 deletions latest/src/js/service/actionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { GridActionSpeak } from '../model/GridActionSpeak.js';
import { GridActionSpeakCustom } from '../model/GridActionSpeakCustom.js';
import {audioUtil} from "../util/audioUtil.js";
import {MainVue} from "../vue/mainVue.js";
import {stateService} from "./stateService.js";
import {GridActionWordForm} from "../model/GridActionWordForm.js";

let actionService = {};

Expand All @@ -38,7 +40,6 @@ actionService.doAction = function (gridId, gridElementId) {
}
}
doActions(gridElement, gridId);
$(window).trigger(constants.ELEMENT_EVENT_ID, [gridElement]);
});
};

Expand Down Expand Up @@ -74,13 +75,22 @@ async function doActions(gridElement, gridId) {
actions: actions
});
});
$(window).trigger(constants.ELEMENT_EVENT_ID, [gridElement]);
metadata = metadata || (await dataService.getMetadata());
let actionTypes = actions.map((a) => a.modelName);
let navBackActions = [GridActionAudio.getModelName(), GridActionChangeLang.getModelName(), GridActionSpeak.getModelName(), GridActionSpeakCustom.getModelName()];
let noNavBackActions = GridElement.getActionTypeModelNames().filter(name => !navBackActions.includes(name));
if (metadata.toHomeAfterSelect && !collectElementService.isCurrentGridKeyboard() && !actionTypes.some(type => noNavBackActions.includes(type))) {
let noNavBackActions = GridElement.getActionTypeModelNames().filter((name) => !navBackActions.includes(name));
if (
metadata.toHomeAfterSelect &&
!collectElementService.isCurrentGridKeyboard() &&
!stateService.hasGlobalGridElement(gridElement.id) &&
!actionTypes.some((type) => noNavBackActions.includes(type))
) {
Router.toMain();
}
if (!actionTypes.includes(GridActionWordForm.getModelName())) {
stateService.resetWordFormTags();
}
}

/**
Expand All @@ -98,7 +108,11 @@ async function doAction(gridElement, action, options) {
switch (action.modelName) {
case 'GridActionSpeak':
log.debug('action speak');
speechService.speak(gridElement.label, {
let langWordFormMap = stateService.getCurrentWordFormAllLangs(gridElement.id);
let labelCopy = JSON.parse(JSON.stringify(gridElement.label));
Object.assign(labelCopy, langWordFormMap);
labelCopy[i18nService.getContentLang()] = stateService.getCurrentUIWordForm(gridElement.id);
speechService.speak(labelCopy, {
lang: action.speakLanguage,
speakSecondary: true,
minEqualPause: minPauseSpeak
Expand All @@ -120,6 +134,28 @@ async function doAction(gridElement, action, options) {
audioUtil.playAudio(action.dataBase64);
}
break;
case 'GridActionWordForm':
switch (action.type) {
case GridActionWordForm.WORDFORM_MODE_CHANGE_ELEMENTS:
stateService.addWordFormTags(action.tags, action.toggle);
break;
case GridActionWordForm.WORDFORM_MODE_CHANGE_BAR:
collectElementService.addWordFormTagsToLast(action.tags);
break;
case GridActionWordForm.WORDFORM_MODE_CHANGE_EVERYWHERE:
stateService.addWordFormTags(action.tags, action.toggle);
collectElementService.addWordFormTagsToLast(action.tags);
break;
case GridActionWordForm.WORDFORM_MODE_NEXT_FORM:
let currentId = stateService.nextWordForm(gridElement.id);
collectElementService.replaceLast(gridElement, currentId);
break;
case GridActionWordForm.WORDFORM_MODE_RESET_FORMS:
stateService.resetWordFormTags();
collectElementService.fixateLastWordForm();
break;
}
break;
case 'GridActionNavigate':
if (action.navType === GridActionNavigate.NAV_TYPES.TO_HOME) {
Router.toMain();
Expand Down
48 changes: 45 additions & 3 deletions latest/src/js/service/collectElementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { dataService } from './data/dataService.js';
import { GridActionAudio } from '../model/GridActionAudio.js';
import { TextConfig } from '../model/TextConfig.js';
import {arasaacService} from "./pictograms/arasaacService.js";
import {GridActionWordForm} from "../model/GridActionWordForm.js";
import {stateService} from "./stateService.js";

let collectElementService = {};

Expand Down Expand Up @@ -204,6 +206,39 @@ collectElementService.doCollectElementActions = async function (action) {
predictionService.predict(collectedText, dictionaryKey);
};

collectElementService.addWordFormTagsToLast = function (tags, toggle) {
let lastElement = collectedElements[collectedElements.length - 1];
if (lastElement && !lastElement.wordFormFixated) {
let lastElementCopy = JSON.parse(JSON.stringify(lastElement));
lastElementCopy.wordFormTags = lastElementCopy.wordFormTags || [];
let currentLabel = getLabel(lastElementCopy);
lastElementCopy.wordFormTags = stateService.mergeTags(lastElementCopy.wordFormTags, tags, toggle);
let newLabel = stateService.getWordForm(lastElementCopy, {searchTags: lastElementCopy.wordFormTags});
if (newLabel && newLabel !== currentLabel) {
collectedElements[collectedElements.length - 1] = lastElementCopy;
updateCollectElements();
}
}
};

collectElementService.replaceLast = function (element, currentId) {
element = JSON.parse(JSON.stringify(element));
let lastElement = collectedElements[collectedElements.length - 1];
if (lastElement && lastElement.id === element.id) {
collectedElements.pop();
}
element.wordFormId = currentId;
collectedElements.push(element);
updateCollectElements();
};

collectElementService.fixateLastWordForm = function () {
let lastElement = collectedElements[collectedElements.length - 1];
if (lastElement) {
lastElement.wordFormFixated = true;
}
}

/**
* @return returns true if the current grid is (probably) a keyboard
*/
Expand Down Expand Up @@ -373,7 +408,8 @@ function getLastElement() {
}

function getLabel(element) {
return i18nService.getTranslation(element.label) || '';
let wordForm = stateService.getWordForm(element, {searchTags: element.wordFormTags, wordFormId: element.wordFormId});
return wordForm || i18nService.getTranslation(element.label) || '';
}

function setLabel(element, newLabel) {
Expand Down Expand Up @@ -465,7 +501,8 @@ $(window).on(constants.ELEMENT_EVENT_ID, function (event, element) {
GridActionSpeak.getModelName(),
GridActionSpeakCustom.getModelName(),
GridActionNavigate.getModelName(),
GridActionAudio.getModelName()
GridActionAudio.getModelName(),
GridActionWordForm.getModelName()
];
let ignoreActions = GridElement.getActionTypeModelNames().filter((e) => !notIgonoreActions.includes(e));
if (getActionTypes(element).some((type) => ignoreActions.includes(type))) {
Expand All @@ -478,8 +515,13 @@ $(window).on(constants.ELEMENT_EVENT_ID, function (event, element) {
if (navigateAction && getLabel(element).length !== 1 && !navigateAction.addToCollectElem) {
return; // no adding of text if the element contains an navigate action and it's no single keyboard character
}
let wordFormAction = getActionOfType(element, GridActionWordForm.getModelName());
if (wordFormAction && wordFormAction.type === GridActionWordForm.WORDFORM_MODE_NEXT_FORM) {
return; // no adding, since the action itself adds the element
}

let label = getLabel(element);
let label = stateService.getDisplayText(element.id) || getLabel(element);
element.wordFormTags = stateService.getCurrentWordFormTags();
let image = getImage(element);
let lastImage = getLastImage();

Expand Down
Loading

0 comments on commit bcbc5b2

Please sign in to comment.