v2 Style conditions and formulas

  1. Hello,

    Skuid Version: 13.0.11

    Model that is used for style condition, if the data for that model is changed/edited then an error will be produced. (The XML for a page bellow is set up to reproduce the problem).

  2. If there are 2 conditions, where one of the conditions is in context and other one is not, if the condition without context is before the condition with context then the 2nd condition will lose context. (Not reproduced in the example below).

Best,

Lukas

<skuid__page unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
<models>
<model id="UIModel" limit="20" query="true" createrowifnonefound="false" datasource="Ui-Only">
    <fields>
        <field id="NewField" displaytype="TEXT" length="255"/>
        <field id="NewField1" displaytype="TEXT" length="255"/>
    </fields>
    <conditions/>
    <actions/>
</model>
<model id="UIModel2" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only">
    <fields>
        <field id="NewField" displaytype="TEXT" length="255"/>
        <field id="NewField1" displaytype="TEXT" length="255"/>
    </fields>
    <conditions/>
    <actions/>
</model>
</models>
<components>
<skuid__text contents="Reproduce Error:
&#10;- Add a new row with data, and then remove the data. Console will show an error:&amp;nbsp;&amp;nbsp;Cannot read property &amp;#39;unsubscribe&amp;#39; of undefined
&#10;- UI Setup: attach style conditions, particularly Formulas.
&#10;- This also happens if the row is deleted, or data in first column gets changed
&#10;- Only tested with UI Models, might be happening with SF Models and other type of conditions.
&#10;
&#10;After this error was produced once it will keeping produced - don&amp;#39;t why it keeps throwing it." uniqueid="sk-qwe-52243"/>
<skuid__table allowColumnFreezing="dragDrop" model="UIModel2" uniqueid="sk-m5Y-9209" mode="edit" pageSize="10">
    <fields>
        <field id="NewField" uniqueid="fi-m5e-15356"/>
        <field id="NewField1" uniqueid="fi-qwx-56012"/>
    </fields>
    <filtering enableSearch="false"/>
    <rowActions>
        <action type="multi" label="Delete">
            <actions>
                <action type="markRowsForDeletion" model="UIModel2" affectedrows="context"/>
            </actions>
        </action>
    </rowActions>
    <massActions/>
    <actions>
        <action type="multi" label="Add">
            <actions>
                <action type="createRow" model="UIModel2" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="all"/>
            </actions>
        </action>
    </actions>
    <styles>
        <spacing/>
    </styles>
</skuid__table>
<skuid__deck columnGutter=".75em" rowGutter=".75em" model="UIModel2" showSaveCancel="false" verticalAlign="top" minWidth="350px" uniqueid="sk-m6A-18996" title="Deck">
    <components>
        <skuid__text contents="<strong>Text Component:</strong>
&#10;test1234 {{NewField}}" uniqueid="sk-m4y-2145" model="UIModel2">
            <renderConditions logictype="and"/>
            <styleVariantConditions>
                <rule logictype="and" styleSettingsVariantOverride="gigantic">
                    <condition type="fieldvalue" enclosevalueinquotes="true" fieldmodel="UIModel2" sourcetype="fieldvalue" nosourcerowbehavior="deactivate" sourceproperty="isNew" operator="=" field="NewField" value="Test2"/>
                </rule>
            </styleVariantConditions>
            <styles>
                <spacing bottom="3"/>
            </styles>
            <conditions>
                <condition type="contextrow" field="Id" mergefield="Id" operator="="/>
            </conditions>
        </skuid__text>
        <skuid__form showErrorsInline="true" model="UIModel2" uniqueid="sk-m6R-21377" mode="read">
            <sections>
                <section title="Form Component" showHeading="true">
                    <rows>
                        <row>
                            <fields>
                                <skuid__field id="NewField" uniqueId="sk-m6Z-25997">
                                    <renderConditions logictype="and" onhidedatabehavior="keep"/>
                                    <enableConditions/>
                                    <styleVariantConditions>
                                        <rule logictype="and">
                                            <condition type="formula" operator="=" fieldmodel="UIModel2" sourcetype="fieldvalue" field="NewField" value="" enclosevalueinquotes="true">
                                                <formula>C__Value({{NewField}})</formula>
                                            </condition>
                                        </rule>
                                    </styleVariantConditions>
                                </skuid__field>
                                <skuid__field id="NewField1" uniqueId="sk-qrY-43919">
                                    <renderConditions logictype="and" onhidedatabehavior="keep"/>
                                    <enableConditions/>
                                    <styleVariantConditions>
                                        <rule logictype="and">
                                            <condition type="formula" operator="=" fieldmodel="UIModel2" sourcetype="fieldvalue" field="NewField" value="" enclosevalueinquotes="true">
                                                <formula>C__Value({{NewField}})</formula>
                                            </condition>
                                        </rule>
                                    </styleVariantConditions>
                                </skuid__field>
                            </fields>
                        </row>
                    </rows>
                </section>
            </sections>
            <conditions>
                <condition type="contextrow" field="Id" mergefield="Id" operator="="/>
            </conditions>
        </skuid__form>
    </components>
    <filtering enableSearch="false"/>
</skuid__deck>
</components>
<resources>
    <labels/>
    <javascript>
<jsitem location="formulafunction" name="newFormulaFunction" cachelocation="false" url="">const utils = skuid.utils;
const {
    DISPLAY_TYPES: {
        NUMBER,
        STRING,
    }
} = skuid.constants;
// Register a new formula function named C__REPEAT for use in the runtime
new skuid.formula.FormulaFunction(
    "Value",
    function( fieldValue) {
        console.log(fieldValue);
        return fieldValue
    },
);</jsitem>
</javascript>
    <css/>
    <actionsequences/>
</resources>
<styles>
    <styleitem type="background" bgtype="none"/>
</styles>
</skuid__page>

Lucas - can you make this break without using a custom formula function? I have a suspicion your problem is there - though I haven’t studied it enough to be 100% sure.

But thanks for reporting.

Hi Rob,

Yes, you are right, it is due to the formula function.

I managed to find a work around.

Thank you for taking a look.