Skip to content

Commit

Permalink
#451 fixed collect elements to work with new CSS grid layout
Browse files Browse the repository at this point in the history
  • Loading branch information
klues committed Nov 27, 2024
1 parent db838b4 commit c508204
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/js/service/collectElementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,17 @@ collectElementService.initWithElements = function (elements, dontAutoPredict) {
});
keyboardLikeFactor = oneCharacterElements / normalElements;
if (registeredCollectElements.length > 0) {
let intervalHandler = setInterval(() => {
if ($('.item[data-type="ELEMENT_TYPE_COLLECT"]').length > 0) {
clearInterval(intervalHandler);
updateCollectElements();
if (!dontAutoPredict) {
predictionService.predict(getPredictText(), dictionaryKey);
}
}
}, 100);
updateCollectElements();
if (!dontAutoPredict) {
predictionService.predict(getPredictText(), dictionaryKey);
}
}
};

collectElementService.clearCollectElements = function() {
$('.collect-container').empty();
}

collectElementService.doCollectElementActions = async function (action) {
if (!action) {
return;
Expand Down Expand Up @@ -306,7 +305,7 @@ async function updateCollectElements(isSecondTry) {
${text}
</span>`;
outerContainerJqueryElem.html(
(html = `<div class="collect-container" dir="auto" style="flex: 1; background-color: #e8e8e8; text-align: justify;">${html}</div>`)
(html = `<div class="collect-container" dir="auto" style="height: 100%; flex: 1; background-color: #e8e8e8; text-align: justify;">${html}</div>`)
);
fontUtil.adaptFontSize($(`#${collectElement.id}`));
} else {
Expand Down Expand Up @@ -381,15 +380,15 @@ async function updateCollectElements(isSecondTry) {
<div style="display:flex; justify-content: center">
${imgHTML}
</div>
<div style="text-align: center; font-size: ${textHeight}px; line-height: ${lineHeight}px; height: ${lineHeight}px; width: ${elemWidth}px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; ${
<div style="text-align: center; font-weight: bold; font-size: ${textHeight}px; line-height: ${lineHeight}px; height: ${lineHeight}px; width: ${elemWidth}px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; ${
!showLabel ? 'display: none' : ''
}">
${image ? label : ''}
</div>
</div>`;
}
let additionalCSS = useSingleLine ? 'overflow-x: auto; overflow-y: hidden;' : 'flex-wrap: wrap;';
html = `<div class="collect-container" dir="auto" style="flex: 1; display: flex; flex-direction: row; background-color: #e8e8e8; text-align: justify; ${additionalCSS}">${html}</div>`;
html = `<div class="collect-container" dir="auto" style="height: 100%; flex: 1; display: flex; flex-direction: row; background-color: #e8e8e8; text-align: justify; ${additionalCSS}">${html}</div>`;
outerContainerJqueryElem.html(html);
if (useSingleLine) {
let scroll =
Expand Down
9 changes: 6 additions & 3 deletions src/vue-components/grid-display/grid-display.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<grid-layout class="grid-layout-container" v-if="renderGrid" :rows="renderGrid.rowCount" :columns="columns" :options="{backgroundColor: metadata.colorConfig.gridBackgroundColor, componentType: 'ol'}">
<grid-element v-for="elem in renderGrid.gridElements" :key="elem.id" :x="elem.x" :y="elem.y" :width="elem.width" :height="elem.height" component-type="li">
<div class="element-container" :id="elem.id" tabindex="40" :aria-label="getAriaLabel(elem)" :data-empty="isEmpty(elem)" :style="`margin: 2px; border-radius: 3px; border: 1px solid ${getBorderColor()}; background-color: ${getBackgroundColor(elem)};`">
<grid-element-normal :grid-element="elem" :metadata="metadata" aria-hidden="true"/>
<grid-element-normal v-if="elem.type === GridElementModel.ELEMENT_TYPE_NORMAL" :grid-element="elem" :metadata="metadata" aria-hidden="true"/>
<grid-element-collect v-if="elem.type === GridElementModel.ELEMENT_TYPE_COLLECT" aria-hidden="true"/>
</div>
</grid-element>
</grid-layout>
Expand All @@ -27,14 +28,16 @@ import { GridActionCollectElement } from '../../js/model/GridActionCollectElemen
import { GridActionNavigate } from '../../js/model/GridActionNavigate';
import { GridActionWebradio } from '../../js/model/GridActionWebradio';
import { GridActionYoutube } from '../../js/model/GridActionYoutube';
import GridElementCollect from './gridElementCollect.vue';
export default {
components: { GridElement, GridElementNormal, GridLayout },
components: { GridElementCollect, GridElement, GridElementNormal, GridLayout },
props: ["gridData", "metadata"],
data() {
return {
renderGrid: null,
columns: null
columns: null,
GridElementModel: GridElementModel
}
},
watch: {
Expand Down
24 changes: 24 additions & 0 deletions src/vue-components/grid-display/gridElementCollect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div class="grid-item-content">
<div class="collect-outer-container text-container" style="position: absolute; display: flex; top: 5px; right: 5px; bottom: 5px; left: 5px;">
</div>
</div>
</template>

<script>
export default {
props: [],
data() {
return {
}
},
methods: {
},
mounted() {
},
}
</script>

<style scoped>
</style>
3 changes: 3 additions & 0 deletions src/vue-components/views/gridView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import { systemActionService } from '../../js/service/systemActionService';
import GridDisplay from '../grid-display/grid-display.vue';
import { gridUtil } from '../../js/util/gridUtil';
import { collectElementService } from '../../js/service/collectElementService';
let vueApp = null;
let UNLOCK_COUNT = 8;
Expand Down Expand Up @@ -280,6 +281,7 @@
async loadGrid(gridData, options = {}) {
options.continueInputMethods = options.continueInputMethods || false;
options.forceReload = options.forceReload || false;
collectElementService.clearCollectElements();
if (gridData && (options.forceReload || !this.renderGridData || this.renderGridData.id !== gridData.id)) {
if (gridUtil.hasAREModel(gridData)) {
let areModel = gridUtil.getAREModel(gridData);
Expand Down Expand Up @@ -314,6 +316,7 @@
initContextmenu();
this.initInputMethods(options);
this.highlightElements();
collectElementService.initWithElements(this.renderGridData.gridElements);
$(document).trigger(constants.EVENT_GRID_LOADED);
},
highlightElements() {
Expand Down

0 comments on commit c508204

Please sign in to comment.