Changeset 939 in genappalpha


Ignore:
Timestamp:
Jun 29, 2016, 6:00:05 AM (6 years ago)
Author:
ehb
Message:

html5: support for nested listbox repeaters

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • etc/perl/genapp_util.pl

    r937 r939  
    12071207                $error .= valid_name( "$f \"id\"", $x );
    12081208            }
     1209            # check for duplicate id's
     1210            {
     1211                my $ref_mod = {};
     1212                my $mod_info = start_json( $json, $ref_mod );
     1213               
     1214                my %ids;
     1215
     1216                do {
     1217                    if ( !$$mod_info{ 'fields:id' } ) {
     1218                        $error .= "Module $f has field without field id defined\n" if $$mod_info{ 'fields:type' } ne "info";
     1219                    } else {
     1220                        $error .= "Module $f has fields with duplicate id \"" . $$mod_info{ 'fields:id' } . "\"\n" if $ids{ $$mod_info{ 'fields:id' } }++;
     1221                    }
     1222                } while( $mod_info = next_json( $ref_mod, 'fields:id' ) );
     1223            }
    12091224            # check repeaters & repeats
    12101225            {
     
    12641279                            $error .= "Module $f field '$k' repeat on '$repeat{ $k }' : missing repeater\n";
    12651280                        }
    1266 #                        if ( $repeater{ $k } && $repeater{ $repeat{ $k } } =~ /(integer)/ )
    1267 #                        {
    1268 #                            $warn .= "Module $f field '$k' is a repeat on '$repeat{ $k }' which is a repeater of type '$repeater{ $repeat{ $k } }'. This structure is not currently supported for integer repeat types\n";
    1269 #                        }
    12701281                        if ( $repeat{ $k } eq $k )
    12711282                        {
     
    12781289                            if ( $depth && $me eq $k )
    12791290                            {
    1280                                 $error .= "Module $f field '$k' has  parent repeater which references '$k' as a repeater creating an infinite recursive loop of repeaters\n";
     1291                                $error .= "Module $f field '$k' has parent repeater which references '$k' as a repeater creating an infinite recursive loop of repeaters\n";
    12811292                                last;
    12821293                            }
  • etc/reserved_words

    r938 r939  
    4444import
    4545int
     46integer
    4647interface
    4748let
  • languages/html5/add/js/ga.min.js

    r937 r939  
    102102ga.repeat.change=function(a,b,c){var d,e=[],f="#"+b;d=$(f);var g,h="",n="",k,p,l;if(!(ga.repeat.data[a]&&ga.repeat.data[a].repeater&&ga.repeat.data[a].repeater[b]&&d.length))return!1;switch(ga.repeat.data[a].repeater[b].type){case "checkbox":d=d.prop("checked")?1:0;break;case "integer":case "listbox":d=d.val();break;default:return console.warn("ga.repeat.change( "+a+" , "+b+" ) type "+ga.repeat.data[a].repeater[b].type+" not supported"),!1}if(!c&&ga.repeat.data[a].repeater[b].value===d)return!1;g=
    103103ga.repeat.children(a,b);switch(ga.repeat.data[a].repeater[b].type){case "checkbox":if(d)for(k in g)l=b+"-"+k,h+=ga.repeat.data[a].repeat[k].htmlr.replace(/%%id%%/g,l).replace("%%label%%",""),n+=ga.repeat.data[a].repeat[k].evalr.replace(/%%id%%/g,l),ga.repeat.data[a].repeater[k]&&(ga.repeat.data[a].repeater[l]||(ga.repeat.data[a].repeater[l]=jQuery.extend({},ga.repeat.data[a].repeater[k])),e.push(l),ga.repeat.data[a].repeater[l].value&&delete ga.repeat.data[a].repeater[l].value);break;case "integer":for(p=
    104 1;p<=d;++p)for(k in g)l=b+"-"+k+"-"+(p-1),h+=ga.repeat.data[a].repeat[k].htmlr.replace(/%%id%%/g,l).replace("%%label%%","["+p+"]"),n+=ga.repeat.data[a].repeat[k].evalr.replace(/%%id%%/g,l),ga.repeat.data[a].repeater[k]&&(ga.repeat.data[a].repeater[l]||(ga.repeat.data[a].repeater[l]=jQuery.extend({},ga.repeat.data[a].repeater[k])),e.push(l),ga.repeat.data[a].repeater[l].value&&delete ga.repeat.data[a].repeater[l].value);break;case "listbox":p=b+"-"+d;g=ga.repeat.children(a,p);for(k in g)l=p+"-"+k,
    105 h+=ga.repeat.data[a].repeat[k].htmlr.replace(/%%id%%/g,l).replace("%%label%%",""),n+=ga.repeat.data[a].repeat[k].evalr.replace(/%%id%%/g,l),ga.repeat.data[a].repeater[k]&&(ga.repeat.data[a].repeater[l]||(ga.repeat.data[a].repeater[l]=jQuery.extend({},ga.repeat.data[a].repeater[k])),e.push(l),ga.repeat.data[a].repeater[l].value&&delete ga.repeat.data[a].repeater[l].value);break;default:return console.warn("ga.repeat.change( "+a+" , "+b+" ) type "+ga.repeat.data[a].repeater[b].type+" not supported"),
    106 !1}!/^<tr>/.test(h)&&/<\/tr>$/.test(h)&&(h="<tr>"+h);$(f+"-repeater").html(h);eval(n);ga.repeat.data[a].repeater[b].value=d;for(k=0;k<e.length;++k)ga.repeat.change(a,e[k],c);$("#global_data").data("_pull_json#"+b)&&ga.pull.doPull("#"+b);resetHoverHelp()};ga.hide=function(a,b){ga.hide.data=ga.hide.data||{};ga.hide.data[a]=ga.hide.data[a]||{};ga.hide.data[a][b]=ga.hide.data[a][b]||{};ga.hide.data[a][b].active=1};ga.hide.data={};
     1041;p<=d;++p)for(k in g)l=b+"-"+k+"-"+(p-1),h+=ga.repeat.data[a].repeat[k].htmlr.replace(/%%id%%/g,l).replace("%%label%%","["+p+"]"),n+=ga.repeat.data[a].repeat[k].evalr.replace(/%%id%%/g,l),ga.repeat.data[a].repeater[k]&&(ga.repeat.data[a].repeater[l]||(ga.repeat.data[a].repeater[l]=jQuery.extend({},ga.repeat.data[a].repeater[k])),e.push(l),ga.repeat.data[a].repeater[l].value&&delete ga.repeat.data[a].repeater[l].value);break;case "listbox":g=b.replace(/-[0-9]+$/,"").replace(/^(.*)-([A-ZA-z0-9_]*)$/,
     105"$2")+"-"+d;p=b+"-"+d;g=ga.repeat.children(a,g);for(k in g)l=p+"-"+k,h+=ga.repeat.data[a].repeat[k].htmlr.replace(/%%id%%/g,l).replace("%%label%%",""),n+=ga.repeat.data[a].repeat[k].evalr.replace(/%%id%%/g,l),ga.repeat.data[a].repeater[k]&&(ga.repeat.data[a].repeater[l]||(ga.repeat.data[a].repeater[l]=jQuery.extend({},ga.repeat.data[a].repeater[k])),e.push(l),ga.repeat.data[a].repeater[l].value&&delete ga.repeat.data[a].repeater[l].value);break;default:return console.warn("ga.repeat.change( "+a+" , "+
     106b+" ) type "+ga.repeat.data[a].repeater[b].type+" not supported"),!1}!/^<tr>/.test(h)&&/<\/tr>$/.test(h)&&(h="<tr>"+h);$(f+"-repeater").html(h);eval(n);ga.repeat.data[a].repeater[b].value=d;for(k=0;k<e.length;++k)ga.repeat.change(a,e[k],c);$("#global_data").data("_pull_json#"+b)&&ga.pull.doPull("#"+b);resetHoverHelp()};ga.hide=function(a,b){ga.hide.data=ga.hide.data||{};ga.hide.data[a]=ga.hide.data[a]||{};ga.hide.data[a][b]=ga.hide.data[a][b]||{};ga.hide.data[a][b].active=1};ga.hide.data={};
    107107ga.hide.update=function(a,b){var c;if(ga.hide.data[a]&&ga.hide.data[a][b])if(ga.hide.data[a][b].hides){if($(b).prop("checked"))for(c in ga.hide.data[a][b].hides)$(c+"-itd").html(" "),$(c).hide();else for(c in ga.hide.data[a][b].hides)$(c+"-itd").html(ga.hide.data[a][b].hides[c]),$(c).show();setHoverHelp()}else console.log("ga.hide.update( "+a+" , "+b+" ) error, no hides attached to this hider");else console.log("ga.hide.update( "+a+" , "+b+" ) error, hider has not been defined")};
    108108ga.hide.add=function(a,b,c){ga.hide.data=ga.hide.data||{};ga.hide.data[a]=ga.hide.data[a]||{};ga.hide.data[a][c]=ga.hide.data[a][c]||{};ga.hide.data[a][c].hides=ga.hide.data[a][c].hides||{};ga.hide.data[a][c].hides[b]=$(b+"-itd").html()};ga.directives=function(a,b){ga.directives.data=ga.directives.data||{};ga.directives.data[a]=b};ga.hideifnot=function(a,b){ga.directives.data&&ga.directives.data[b]&&!/^(off|false|0$)/.test(ga.directives.data[b].toLowerCase())||$(a).hide()};ga.data={};
  • languages/html5/base.php

    r937 r939  
    22header('Content-type: application/json');
    33# setup php session
     4__~debug:basemylog{error_log( "startup __application__ __menu:id__ __menu:modules:id__\n", 3, "/tmp/mylog" );}
    45session_start();
    56if (!isset($_SESSION['count'])) {
     
    678679    {
    679680        $a = preg_split( "/-/", $v );
    680         __~debug:basemylog{error_log( "preg_split of $v:\n" . json_encode( $a, JSON_PRETTY_PRINT ), 3, "/tmp/mylog" );}
     681        __~debug:basemylog{error_log( "preg_split of $v:\n" . json_encode( $a, JSON_PRETTY_PRINT ) . "\n", 3, "/tmp/mylog" );}
    681682        if ( !isset( $_REQUEST[ $a[ 0 ] ] ) || !is_array( $_REQUEST[ $a[ 0 ] ] ) ) {
    682683            $_REQUEST[ $a[ 0 ] ] = [];
     
    694695    }
    695696
    696 __~debug:basemylog{    error_log( "request ready to jsonize\n" . print_r( $_REQUEST, true ) . "\n", 3, "/tmp/mylog" );}
     697    __~debug:basemylog{error_log( "request ready to jsonize\n" . print_r( $_REQUEST, true ) . "\n", 3, "/tmp/mylog" );}
     698    __~debug:basemylog{error_log( "request in json" . json_encode( $_REQUEST, JSON_PRETTY_PRINT ) . "\n", 3, "/tmp/mylog" );}
    697699    $json = json_encode( $_REQUEST );
    698700    $json = str_replace( "'", "_", $json );
  • languages/html5/js/repeat.js

    r937 r939  
    174174    add_html = "",
    175175    add_eval = "",
     176    tid,
    176177    i,
    177178    j,
     
    272273    case "listbox" :
    273274       
     275        tid = id.replace( /-[0-9]+$/, "" ).replace( /^(.*)-([A-ZA-z0-9_]*)$/, "$2" ) + "-" + val;
     276
    274277        j = id + "-" + val;
    275278
    276         children = ga.repeat.children( mod, j );
    277         __~debug:repeat{ for ( i in children ) { console.log( "ga.repeat.change( " + mod + " , " + id + " ) select child " + i );} }
     279        __~debug:repeat{console.log( "ga.repeat.change listbox, j is " + j + " val is " + val + " tid " + tid );}
     280        children = ga.repeat.children( mod, tid );
     281        __~debug:repeat{for ( i in children ) { console.log( "ga.repeat.change( " + mod + " , " + id + " ) select child " + i );} }
    278282
    279283        for ( i in children ) {
Note: See TracChangeset for help on using the changeset viewer.