Skip to content

Commit c02c884

Browse files
committed
feat(scenes): Add does not contain for Calendar action
1 parent c56d552 commit c02c884

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

front/src/config/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,7 @@
22232223
"nameLabel": "Wenn der Name",
22242224
"isExactly": "genau ist",
22252225
"contains": "enthält",
2226+
"doesNotContain": "enthält nicht",
22262227
"startsWith": "beginnt mit",
22272228
"endsWith": "endet mit",
22282229
"hasAnyName": "einen beliebigen Namen hat",

front/src/config/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,7 @@
22232223
"nameLabel": "If the name",
22242224
"isExactly": "is exactly",
22252225
"contains": "contains",
2226+
"doesNotContain": "does not contain",
22262227
"startsWith": "starts with",
22272228
"endsWith": "ends with",
22282229
"hasAnyName": "has any name",

front/src/config/i18n/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,7 @@
22232223
"nameLabel": "Si le nom",
22242224
"isExactly": "est exactement",
22252225
"contains": "contient",
2226+
"doesNotContain": "ne contient pas",
22262227
"startsWith": "commence par",
22272228
"endsWith": "finit par",
22282229
"hasAnyName": "a n'importe quel nom",

front/src/routes/scene/edit-scene/actions/CalendarIsEventRunning.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ class CheckTime extends Component {
217217
<option value="contains">
218218
<Text id="editScene.triggersCard.calendarEventIsComing.contains" />
219219
</option>
220+
<option value="does-not-contain">
221+
<Text id="editScene.triggersCard.calendarEventIsComing.doesNotContain" />
222+
</option>
220223
<option value="starts-with">
221224
<Text id="editScene.triggersCard.calendarEventIsComing.startsWith" />
222225
</option>

server/lib/calendar/calendar.findCurrentlyRunningEvent.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ async function findCurrentlyRunningEvent(calendars, calendarEventNameComparator,
5454
[Op.like]: `%${calendarEventName}%`,
5555
};
5656
break;
57+
case 'does-not-contain':
58+
// @ts-ignore
59+
queryParams.where.name = {
60+
[Op.notLike]: `%${calendarEventName}%`,
61+
};
62+
break;
5763
case 'starts-with':
5864
// @ts-ignore
5965
queryParams.where.name = {

server/models/scene.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const actionSchema = Joi.array().items(
3333
calendar_event_name_comparator: Joi.string().valid(
3434
'is-exactly',
3535
'contains',
36+
'does-not-contain',
3637
'starts-with',
3738
'ends-with',
3839
'has-any-name',

server/test/lib/calendar/calendar.event.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,21 @@ describe('calendar.findCurrentlyRunningEvent', () => {
302302
const eventsId = events.map((e) => e.id);
303303
expect(eventsId).deep.equal(['a2b57b0a-7148-4961-8540-e493104bfd7c']);
304304
});
305+
it('should find event in calendar - does not contain', async () => {
306+
await calendar.createEvent('test-calendar', {
307+
id: 'a2b57b0a-7148-4961-8540-e493104bfd7c',
308+
name: 'my test event',
309+
start: startDate,
310+
end: endDate,
311+
});
312+
const events = await calendar.findCurrentlyRunningEvent(
313+
['test-calendar', 'test-calendar-random'],
314+
'does-not-contain',
315+
'random',
316+
);
317+
const eventsId = events.map((e) => e.id);
318+
expect(eventsId).deep.equal(['a2b57b0a-7148-4961-8540-e493104bfd7c']);
319+
});
305320
it('should find event in calendar - starts-with', async () => {
306321
await calendar.createEvent('test-calendar', {
307322
id: 'a2b57b0a-7148-4961-8540-e493104bfd7c',

0 commit comments

Comments
 (0)