Commit 0d0d088e authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Add console warnings if using invalid values or params in decision tree notices

parent d93d2d3b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -230,8 +230,8 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
        'notice' => [
            //    Parameter             Value                                                                                           Warning
            ['ideal_developer',    'A local agency that a core team member will help you pick',                                         'That\'s cool. We will try and find an appropriate company in your country.' . "\n\n" . $disclaimer],
            ['ideal_developer',    'A local freelancer that the core team will help you pick',                                     'That\'s cool. We will try and find someone appropriate in your country. Just be aware that a freelancer usually won\'t be able to offer the full reliability than an established agency can. It\'s a trade-off of service breadth/reliability vs. cost.' . "\n\n" . $disclaimer],
            ['ideal_developer',    'One of the Core Development Team members',                                                     'That\'s cool. The core team ensures work is done to high standards. Communication and terms vary depending on the core team member\'s preference.' . "\n\n" . 'You should expect to be charged around the same as a high-quality established UK/US agency, however quotes will vary depending on the core team member\'s own terms. If you need lower costs, or physical meetings, it may be best to choose a local agency or freelancer, especially if you are not based in a “Western” country.' . "\n\n" . 'There is no guarantee for availability of a core team member for any particular project because they may sometimes be very busy (especially with Composr development) or not be a good match. Sometimes they may have a waiting period as they have to clear back-logs. In such a case a team member will try and match you with a local developer.'],
            ['ideal_developer',    'A local freelancer that a core team member will help you pick (lower cost, more basic, less formal)',                                     'That\'s cool. We will try and find someone appropriate in your country. Just be aware that a freelancer usually won\'t be able to offer the full reliability than an established agency can. It\'s a trade-off of service breadth/reliability vs. cost.' . "\n\n" . $disclaimer],
            ['ideal_developer',    'A Composr Core Development Team member',                                                     'That\'s cool. The core team ensures work is done to high standards. Communication and terms vary depending on the core team member\'s preference.' . "\n\n" . 'You should expect to be charged around the same as a high-quality established UK/US agency, however quotes will vary depending on the core team member\'s own terms. If you need lower costs, or physical meetings, it may be best to choose a local agency or freelancer, especially if you are not based in a “Western” country.' . "\n\n" . 'There is no guarantee for availability of a core team member for any particular project because they may sometimes be very busy (especially with Composr development) or not be a good match. Sometimes they may have a waiting period as they have to clear back-logs. In such a case a team member will try and match you with a local developer.'],
        ],
        'previous' => 'paid',
        'form_method' => 'POST',
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ Each question details has:
 - comcode_prepend and comcode_append

Other features
 - Actually 'inform'/'notice'/'warn' can take a 'next'-style array, in which case the messages are shown using JavaScript upon option selection
 - Actually 'inform'/'notice'/'warn' can take a 'next'-style array, in which case the messages are shown using JavaScript upon option selection.
  - In this case, the browser console will give a warning if you provide a value that does not exist, or an error if you provide an element (parameter) name that does not exist.
*/

/**
+11 −0
Original line number Diff line number Diff line
@@ -660,10 +660,18 @@
    $cms.functions.decisionTreeRender = function decisionTreeRender(parameter, value, notice, noticeTitle) {
        value = strVal(value);
        var els = document.getElementById('main-form').elements[parameter];
        if (els === undefined) {
            $util.fatal($util.format('$cms.functions.decisionTreeRender(): Could not find element {1} on form.', [parameter]));
            return;
        }
        if (els.length === undefined) {
            els = [els];
        }
        var foundValue = false;
        $util.toArray(els).forEach(function (el) {
            if ((el.value === value) || ((el.type === 'checkbox') && !el.checked && ('' === value))) {
                foundValue = true;
            }
            el.addEventListener('click', function () {
                var selected = false;
                if (el.type === 'checkbox') {
@@ -676,6 +684,9 @@
                }
            });
        });
        if (!foundValue) {
            $util.warn($util.format('$cms.functions.decisionTreeRender(): Could not find a value of "{1}" on element {2}', [value, parameter]));
        }
    };

    function prepareMassSelectMarker(set, type, id, checked) {