Skip to content

Commit

Permalink
added possibility to prevent duplicated collection of elements, see #169
Browse files Browse the repository at this point in the history
  • Loading branch information
klues committed Nov 3, 2022
1 parent a49251c commit 2ef7b0f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/lang/i18n.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,5 +841,6 @@
"quotationMark": "quotation mark",
"hyphen": "hyphen",
"space": "space",
"readElementActionsInAdditionToLabel": "Read element actions in addition to label"
"readElementActionsInAdditionToLabel": "Read element actions in addition to label",
"preventCollectingTheSameCellSeveralTimesInARow": "Prevent collecting the same cell several times in a row"
}
3 changes: 2 additions & 1 deletion src/js/model/GridElementCollect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class GridElementCollect extends GridElement.extend({
mode: [String],
singleLine: [Boolean],
convertToLowercase: [Boolean],
textElemSizeFactor: [Number]
textElemSizeFactor: [Number],
preventDuplicatedCollect: [Boolean]
}) {
constructor(props) {
props = props || {};
Expand Down
7 changes: 7 additions & 0 deletions src/js/service/collectElementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ let dictionaryKey = null;
let autoCollectImage = true;
let collectMode = GridElementCollect.MODE_AUTO;
let convertToLowercase = true;
let preventDuplicatedCollect = false;
let lastCollectId = null;

collectElementService.initWithElements = function (elements, dontAutoPredict) {
registeredCollectElements = [];
Expand All @@ -51,6 +53,7 @@ collectElementService.initWithElements = function (elements, dontAutoPredict) {
}, null);
collectMode = copy.mode || collectMode;
convertToLowercase = copy.convertToLowercase !== false;
preventDuplicatedCollect = copy.preventDuplicatedCollect;
registeredCollectElements.push(copy);
}
});
Expand Down Expand Up @@ -275,6 +278,10 @@ function isImageMode(elementMode) {
}

$(window).on(constants.ELEMENT_EVENT_ID, function (event, element) {
if (lastCollectId === element.id && preventDuplicatedCollect) {
return;
}
lastCollectId = element.id;
let label = i18nService.getTranslation(element.label);
let image = element.image ? (element.image.data || element.image.url) : null;

Expand Down
6 changes: 6 additions & 0 deletions src/vue-components/modals/editElementCollect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<label for="convertToLowercase">{{ $t('convertUppercaseKeyboardLettersToLowercase') }}</label>
</div>
</div>
<div class="row">
<div class="col-12">
<input v-if="gridElement" id="preventDuplicatedCollect" type="checkbox" v-model="gridElement.preventDuplicatedCollect"/>
<label for="preventDuplicatedCollect">{{ $t('preventCollectingTheSameCellSeveralTimesInARow') }}</label>
</div>
</div>
</div>
</template>

Expand Down

0 comments on commit 2ef7b0f

Please sign in to comment.