1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-09 15:50:53 +00:00
* Added: Two new profile rule types: `If` for choosing between two different sets of rules based on a condition. `True or False` for a rule that is always true or false.
This commit is contained in:
SirStendec 2019-10-20 15:03:46 -04:00
parent 9c2053bf9b
commit c26f2ea09b
4 changed files with 135 additions and 3 deletions

View file

@ -1,7 +1,7 @@
{
"name": "frankerfacez",
"author": "Dan Salvato LLC",
"version": "4.14.9",
"version": "4.14.10",
"description": "FrankerFaceZ is a Twitch enhancement suite.",
"license": "Apache-2.0",
"scripts": {

View file

@ -40,7 +40,7 @@
</div>
<button
v-else-if="canAddRule"
class="tw-button ffz-button--hollow tw-mg-y-1 tw-full-width"
class="tw-button ffz-button--hollow tw-mg-y-05 tw-full-width"
@click="adding = true"
>
<span class="tw-button__text ffz-i-plus">

View file

@ -0,0 +1,99 @@
<template>
<section class="tw-flex-grow-1 tw-align-self-start">
<div>
<header class="tw-mg-y-05">
{{ t(type.i18n, type.title) }}
</header>
<filter-editor
v-model="value.data[0]"
class="tw-flex-grow-1"
:filters="filters"
:context="context"
:max-rules="type.maxRules"
/>
</div>
<div class="tw-border-t tw-mg-t-05 tw-pd-t-05">
<header class="tw-flex tw-align-items-center">
<div class="ffz--profile__icon tw-pd-r-05 tw-pd-y-05 tw-relative tw-tooltip-wrapper">
<figure :class="[passes ? 'ffz-i-ok' : 'ffz-i-cancel']" />
<div class="tw-tooltip tw-tooltip--down tw-tooltip--align-left">
<span v-if="passes">
{{ t('setting.filters.if.pass', 'This branch is active because the condition is true.') }}
</span>
<span v-else>
{{ t('setting.filters.if.no_pass', 'This branch is not active because the condition is false.') }}
</span>
</div>
</div>
<div class="tw-mg-y-05">
{{ t('setting.filter.if.then', 'Then') }}
</div>
</header>
<filter-editor
v-model="value.data[1]"
class="tw-flex-grow-1"
:filters="filters"
:context="context"
:max-rules="type.maxRules"
/>
</div>
<div class="tw-border-t tw-mg-t-05 tw-pd-t-05">
<header class="tw-flex tw-align-items-center">
<div class="ffz--profile__icon tw-pd-r-05 tw-pd-y-05 tw-relative tw-tooltip-wrapper">
<figure :class="[passes ? 'ffz-i-cancel' : 'ffz-i-ok']" />
<div class="tw-tooltip tw-tooltip--down tw-tooltip--align-left">
<span v-if="passes">
{{ t('setting.filters.if.no_fail', 'This branch is not active because the condition is true.') }}
</span>
<span v-else>
{{ t('setting.filters.if.fail', 'This branch is active because the condition is false.') }}
</span>
</div>
</div>
<div class="tw-mg-y-05">
{{ t('setting.filter.if.else', 'Else') }}
</div>
</header>
<filter-editor
v-model="value.data[2]"
class="tw-flex-grow-1"
:filters="filters"
:context="context"
:max-rules="type.maxRules"
/>
</div>
</section>
</template>
<script>
import {createTester} from 'utilities/filtering';
let last_id = 0;
export default {
props: ['value', 'type', 'filters', 'context'],
data() {
return {
id: last_id++
}
},
computed: {
tester() {
return createTester(this.value.data[0], this.filters);
},
passes() {
return this.tester && this.tester(this.context)
}
}
}
</script>

View file

@ -39,6 +39,39 @@ export const Or = {
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/nested.vue')
};
export const If = {
createTest(config, rule_types) {
const cond = createTester(config[0], rule_types),
if_true = createTester(config[1], rule_types),
if_false = createTester(config[2], rule_types);
return ctx => cond(ctx) ? if_true(ctx) : if_false(ctx)
},
childRules: true,
tall: true,
title: 'If',
i18n: 'settings.filter.if',
default: () => [[], [], []],
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/if.vue')
};
export const Constant = {
createTest(config) {
if ( config )
return () => true;
return () => false;
},
title: 'True or False',
i18n: 'settings.filter.true_false',
default: true,
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/basic-toggle.vue')
}
// Context Stuff
@ -104,7 +137,7 @@ export const Time = {
title: 'Time of Day',
i18n: 'settings.filter.time',
default: ['08:00', '18:00'],
default: () => ['08:00', '18:00'],
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/time.vue')
}